Difference between revisions of "API Method AppointmentsSync"

From Updox API
Jump to: navigation, search
(Created page with " == Description == Method that allows the syncing of organization's appointments. == Behind the Scenes == System will parse list of contacts and attempt to find existing...")

Revision as of 20:08, 7 December 2015


Contents

Description

Method that allows the syncing of organization's appointments.


Behind the Scenes

System will parse list of contacts and attempt to find existing records based on the id passed in. If no match is found and old id value is supplied, will also do an additional check for that identifier prior to inserting a new record. If a match is not found, a new contact is created with whatever information is supplied.


Prerequisites

1 This API call requires Vendor-level credentials. The credentials should be populated into the applicationId and applicationPassword fields of the auth block:

 {
   ...
   "auth": {
     "applicationId": "vendorId",
     "applicationPassword": "vendorPassword",
     "accountId": "",
     "userId": ""
   }
 }
 
 

2 This API call requires a Practice/Account-level identifier. The identifier should be populated into the accountId field of the auth block:

 {
   ...
   "auth": {
     "applicationId": "vendorId",
     "applicationPassword": "vendorPassword",
     "accountId": "practiceId",
     "userId": ""
   }
 }



Code Samples

Language Source Code Examples
C#
 public void TalkToUpdox() {
   string json = new JavaScriptSerializer().Serialize(new {
     patients = new[] {
       new {
         id = 123, // not used and can be ignored
         chartNumber = 234,
         internalId = 345,
         firstName = "firstName",
         middleName = "middleName",
         lastName = "lastName",
         sex = "male",
         address1 = "address1",
         address2 = "address2",
         city = "Columbus",
         state = "OH",
         zip5 = "43017",
         dob = "2015-12-30",
         emailAddress = "valid@email.com",
         homePhone = "6141231234",
         workPhone = "6149879876",
         workExtension = "x112",
         mobileNumber = "6145675678",
         faxNumber = "6145435432",
         active = true,
         contactType = "patient",
         defaultProvider = "defaultProvider",
         maritalStatus = "married",
         primaryInsurance = new {
           companyName = "companyName1",
           phoneNumber = "6141231234",
           address1 = "address1",
           address2 = "address2",
           city = "Columbus",
           state = "OH",
           zip = "43017",
           policyNumber = "policyNumber",
           groupNumber = "groupNumber",
           planName = "planName",
           groupName = "groupName",
           effectiveDate = "2015-12-30",
           expirationDate = "2016-12-30",
           guarantorRelationship = "guarantorRelationship",
           guarantorName = "guarantorName",
           guarantorFirstName = "guarantorFirstName",
           guarantorMiddleName = "guarantorMiddleName",
           guarantorLastName = "guarantorLastName",
           guarantorDob = "1978-10-20",
           guarantorGender = "male",
           copayAmount = 50
         },
         secondaryInsurance = new {
           companyName = "companyName2",
           phoneNumber = "6141231234",
           address1 = "address1",
           address2 = "address2",
           city = "Columbus",
           state = "OH",
           zip = "43017",
           policyNumber = "policyNumber",
           groupNumber = "groupNumber",
           planName = "planName",
           groupName = "groupName",
           effectiveDate = "2015-12-30",
           expirationDate = "2016-12-30",
           guarantorRelationship = "guarantorRelationship",
           guarantorName = "guarantorName",
           guarantorFirstName = "guarantorFirstName",
           guarantorMiddleName = "guarantorMiddleName",
           guarantorLastName = "guarantorLastName",
           guarantorDob = "1978-10-20",
           guarantorGender = "female",
           copayAmount = 50
         }
       }
     },
     auth = new {
       applicationId = "vendorId",
       applicationPassword = "vendorPassword",
       accountId = "accountId",
       userId = ""
     }
   });
   string url = "https://updoxqa.com/io/syncAppointments";
   SendReceiveJSON(json, url);
 }
 
 private void SendReceiveJSON(string json, string url)
 {
   var httpWebRequest = WebRequest.Create(url);
   httpWebRequest.ContentType = "application/json";
   httpWebRequest.Method = "POST";
   using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
   {
     streamWriter.Write(json);
     streamWriter.Flush();
     streamWriter.Close();
     var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
     using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
     {
       var result = streamReader.ReadToEnd();
     }
   }
 }
Java


   public void TalkToUpdox() throws Exception {
       String uri = "https://updoxqa.com/io/syncAppointments";
       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> patient1 = new HashMap();
       patient1.put("id", 123);  // Currently not used and can be ignored
       patient1.put("chartNumber", 234);
       patient1.put("internalId", 345);
       patient1.put("firstName", "firstName");
       patient1.put("middleName", "middleName");
       patient1.put("lastName", "lastName");
       patient1.put("sex", "male");
       patient1.put("address1", "address1");
       patient1.put("address2", "address2");
       patient1.put("city", "Columbus");
       patient1.put("state", "OH");
       patient1.put("zip5", "43017");
       patient1.put("dob", "1978-10-30");
       patient1.put("emailAddress", "valid@email.com");
       patient1.put("homePhone", "6141231234");
       patient1.put("workPhone", "6149879876");
       patient1.put("workExtension", "x112");
       patient1.put("mobileNumber", "6144564567");
       patient1.put("faxNumber", "6149879532");
       patient1.put("active", true);
       patient1.put("contactType", "patient");
       patient1.put("defaultProvider", "defaultProvider");
       patient1.put("maritalStatus", "Marital Status");
 
       Map<String, Object> primaryInsurance = new HashMap();
       primaryInsurance.put("companyName", "companyName");
       primaryInsurance.put("phoneNumber", "phoneNumber");
       primaryInsurance.put("address1", "address1");
       primaryInsurance.put("address2", "address2");
       primaryInsurance.put("city", "city");
       primaryInsurance.put("state", "state");
       primaryInsurance.put("zip", "zip");
       primaryInsurance.put("policyNumber", "policyNumber");
       primaryInsurance.put("groupNumber", "groupNumber");
       primaryInsurance.put("planName", "planName");
       primaryInsurance.put("groupName", "groupName");
       primaryInsurance.put("effectiveDate", "effectiveDate");
       primaryInsurance.put("expirationDate", "expirationDate");
       primaryInsurance.put("guarantorRelationship", "guarantorRelationship");
       primaryInsurance.put("guarantorName", "guarantorName");
       primaryInsurance.put("guarantorFirstName", "guarantorFirstName");
       primaryInsurance.put("guarantorMiddleName", "guarantorMiddleName");
       primaryInsurance.put("guarantorLastName", "guarantorLastName");
       primaryInsurance.put("guarantorDob", "guarantorDob");
       primaryInsurance.put("guarantorGender", "guarantorGender");
       primaryInsurance.put("copayAmount", "copayAmount");
 
       patient1.put("primaryInsurance", primaryInsurance);
 
       Map<String, Object> secondaryInsurance = new HashMap();
       secondaryInsurance.put("companyName", "companyName");
       secondaryInsurance.put("phoneNumber", "phoneNumber");
       secondaryInsurance.put("address1", "address1");
       secondaryInsurance.put("address2", "address2");
       secondaryInsurance.put("city", "city");
       secondaryInsurance.put("state", "state");
       secondaryInsurance.put("zip", "zip");
       secondaryInsurance.put("policyNumber", "policyNumber");
       secondaryInsurance.put("groupNumber", "groupNumber");
       secondaryInsurance.put("planName", "planName");
       secondaryInsurance.put("groupName", "groupName");
       secondaryInsurance.put("effectiveDate", "effectiveDate");
       secondaryInsurance.put("expirationDate", "expirationDate");
       secondaryInsurance.put("guarantorRelationship", "guarantorRelationship");
       secondaryInsurance.put("guarantorName", "guarantorName");
       secondaryInsurance.put("guarantorFirstName", "guarantorFirstName");
       secondaryInsurance.put("guarantorMiddleName", "guarantorMiddleName");
       secondaryInsurance.put("guarantorLastName", "guarantorLastName");
       secondaryInsurance.put("guarantorDob", "guarantorDob");
       secondaryInsurance.put("guarantorGender", "guarantorGender");
       secondaryInsurance.put("copayAmount", "copayAmount");
 
       patient1.put("secondaryInsurance", secondaryInsurance);
   
       List<String> patients = new ArrayList<>();
       patients.add(patient1);
       
       Map<String, Object> messageData = new HashMap();
       messageData.put("patients", patients);
       
       Map<String,String> authData = new HashMap();
       authData.put("applicationId", "vendorId");
       authData.put("applicationPassword", "vendorPassword");
       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;
   }


Messages

Destination Address

 https://updoxqa.com/io/syncAppointments

Request JSON

   {
       "appointments": [
           {
               "locationId": "locationId",
               "cancelled": "true | false",
               "blocked": "true | false",
               "details": "details",
               "summary": "summary",
               "typeId": "typeId",
               "patientId": "patientId",
               "duration": "duration",
               "date": "date",
               "calendarId": "calendarId",
               "updoxId": "updoxId",
               "id": "id"
           }
       ],
       "auth": {
           "applicationId": "vendorId",
           "applicationPassword": "vendorPassword",
           "accountId": "accountId",
           "userId": ""
       }
   }

HTTP Response Status

 200 OK

Response JSON

  {
     "successful": true,
     "responseMessage": "OK",
     "responseCode": 2000,
     "statuses": [
         {
            "id": "id",
            "success": "true | false",
            "message": "message"
         }
     ]
   }


Error Codes

This method may return the General Error Set.