Difference between revisions of "API Method PatientDirectMessageSend"

From Updox API
Jump to: navigation, search
(Request)
 
(2 intermediate revisions by one user not shown)
Line 12: Line 12:
 
| align="top" | Java || <div class="mw-collapsible mw-collapsed" style="width:65px">
 
| align="top" | Java || <div class="mw-collapsible mw-collapsed" style="width:65px">
 
<div class="mw-collapsible-content" style="width:810px">
 
<div class="mw-collapsible-content" style="width:810px">
{{Talk To Updox - Core - Java|DirectSimpleSend|DirectSimpleSend}}
+
{{Talk To Updox - Core - Java|PatientDirectMessageSend|PatientDirectMessageSend}}
 
    
 
    
 
{{Json PatientDirectMessageSend Block - Java}}
 
{{Json PatientDirectMessageSend Block - Java}}
Line 18: Line 18:
 
{{Base_Code_for_Consuming_API_Using_Java}}
 
{{Base_Code_for_Consuming_API_Using_Java}}
 
|}
 
|}
 
  
 
== Sample Request and Response ==
 
== Sample Request and Response ==
Line 26: Line 25:
 
  {
 
  {
 
     "to": "dublin@direct.updoxqa.com",
 
     "to": "dublin@direct.updoxqa.com",
     "subject": "Test subject",
+
     "subject": "Test Subjec",
 
     "textMessage": "Test message body",
 
     "textMessage": "Test message body",
    "attachments": [
 
        {
 
            "params": {
 
                "patientDemographics": {
 
                    "emailAddress]": "",
 
                    "gender]": "F",
 
                    "dateOfBirth]": "1990-10-10",
 
                    "lastName]": "Doe",
 
                    "middleName]": "",
 
                    "firstName]": "Jane",
 
                    "patientId]": "100030"
 
                }
 
            },
 
            "content": "CgoKCgoKCgoKCgoKCgoKCgoKCgoKVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg",
 
            "mimeType": "text/plain",
 
            "fileName": "test.txt"
 
        }
 
    ],
 
 
     "patientDemographics": {
 
     "patientDemographics": {
 
         "patientId": "100030",
 
         "patientId": "100030",
Line 58: Line 39:
 
         "applicationId": "updox",
 
         "applicationId": "updox",
 
         "applicationPassword": "password",
 
         "applicationPassword": "password",
         "accountId": "605",
+
         "accountId": "updox_acct",
         "userId": "605"
+
         "userId": "updox_user"
 
     }
 
     }
}
+
}
  
 
==== Response ====
 
==== Response ====
  
 
  {
 
  {
    successful: true
+
    "successful": true,
    responseMessage: "OK"
+
    "responseMessage": "OK",
    responseCode: 2000
+
    "responseCode": 2000,
    recipient: "contact:227683"
+
    "recipient": "contact:227735",
    name: "dublin@direct.updoxqa.com"
+
    "name": "dublin@direct.updoxqa.com",
    directAddress: "dublin@direct.updoxqa.com"
+
    "directAddress": "dublin@direct.updoxqa.com",
    reason: null
+
    "reason": null,
    messageId: 249599
+
    "messageId": 252274,
    patientDirectAddress: "ptacct+227685@direct.updoxqa.com"
+
    "patientDirectAddress": "ptacct+227734@direct.updoxqa.com"
 
  }
 
  }
 
 
== Error Codes ==
 
== Error Codes ==
 
In addition to the [[General Error Set]], this method may return:   
 
In addition to the [[General Error Set]], this method may return:   

Latest revision as of 17:41, 3 December 2013

An outbound direct message method which sends a message from the supplied patient to the supplied direct address. If the "from" field is not provided the patient ID in the form "patient:{patient ID}", then the patientDemographics object must be passed in to define the patient sending the message.

Contents

Fields

Please refer to the Interactive API for a list of the fields for this method.

Code Samples

Language Source Code Examples
C#
Java


   public void TalkToUpdox() throws Exception {
       String uri = "https://updoxqa.com/io/PatientDirectMessageSend";
       ObjectMapper mapper = new ObjectMapper();
       Map<String,Object> messageData = BuildMessage();
       String jsonData = mapper.writeValueAsString(messageData);
       HttpResponse httpResponse = SendReceiveJSON(jsonData, uri);
       HttpEntity responseEntity = httpResponse.getEntity();
       String response = EntityUtils.toString(responseEntity);
       JsonNode actualObj = mapper.readTree(response);
 
       System.out.println(actualObj.get("responseCode"));
       System.out.println(actualObj.get("responseMessage"));
   }
 
   private Map<String,Object> BuildMessage() throws Exception
   {
       Map<String,Object> messageData = new HashMap();
       messageData.put("to","dublin@direct.updoxqa.com");
       messageData.put("subject","Test Subject");
       messageData.put("textMessage","Test message body");
       Map<String,String> patientDemographics = new HashMap();
       patientDemographics.put("patientId", "100030");
       patientDemographics.put("firstName", "Jane");
       patientDemographics.put("middleName", "");
       patientDemographics.put("lastName", "Doe");
       patientDemographics.put("dateOfBirth","1990-10-10");
       patientDemographics.put("gender","F");
       patientDemographics.put("emailAddress","");
       messageData.put("patientDemographics", patientDemographics);
       Map<String,String> authData = new HashMap();
       authData.put("applicationId", "updox");
       authData.put("applicationPassword", "password");
       authData.put("accountId", "updox_acct");
       authData.put("userId", "updox_user");
       messageData.put("auth", authData);
       return messageData;
   }
 
   private HttpResponse SendReceiveJSON(String jsonData, String uri) throws Exception {
       HttpClient httpClient = new DefaultHttpClient();
       HttpResponse response = null;
       StringEntity params = new StringEntity(jsonData);
       try {
           HttpPost request = new HttpPost(uri);
           request.addHeader("content-type", "application/json");
           request.setEntity(params);
           response = httpClient.execute(request);
       } catch (Exception ex) {
           // handle exception here
       } finally {
           httpClient.getConnectionManager().shutdown();
       }
       return response;
   }

Sample Request and Response

Request

{
   "to": "dublin@direct.updoxqa.com",
   "subject": "Test Subjec",
   "textMessage": "Test message body",
   "patientDemographics": {
       "patientId": "100030",
       "firstName": "Jane",
       "middleName": "",
       "lastName": "Doe",
       "dateOfBirth": "1990-10-10",
       "gender": "F",
       "emailAddress": ""
   },
   "auth": {
       "applicationId": "updox",
       "applicationPassword": "password",
       "accountId": "updox_acct",
       "userId": "updox_user"
   }
}

Response

{
   "successful": true,
   "responseMessage": "OK",
   "responseCode": 2000,
   "recipient": "contact:227735",
   "name": "dublin@direct.updoxqa.com",
   "directAddress": "dublin@direct.updoxqa.com",
   "reason": null,
   "messageId": 252274,
   "patientDirectAddress": "ptacct+227734@direct.updoxqa.com"
}

Error Codes

In addition to the General Error Set, this method may return:

4640: direct address error: invalid direct address
4641: direct address error: no direct address found for this user
4650: direct error: send failed
4651: direct error: send failed and/or invalid direct address
4652: direct error: either from or patientDemographics is required
Note that when a 4650 error code is returned, the "reason" field will contain a text description of the reason the message failed to send.