Difference between revisions of "API Method PracticeCreate"

From Updox API
Jump to: navigation, search
 
(56 intermediate revisions by one user not shown)
Line 1: Line 1:
== Description ==
 
The following code samples describe the processes involved in adding a new practice.
 
  
  
  
 +
== Description ==
 +
The following code samples describe the processes involved in creating a practice - part of [[Account_Management|managing a Practice acount]].
 +
 
 +
 
 +
 
 +
 
 
==  Prerequisites ==
 
==  Prerequisites ==
# This API call requires [[Vendor credentialing|Vendor-level credentials]].  The credentials should be populated into the <code><span style="color:red">applicationId</span></code> and <code><span style="color:red">applicationPassword</span></code> fields of the <code><span style="color:red">auth</span></code> block.
 
 
  
 +
{{PreReq Vendor Credentials}}
  
 
== Code Samples ==
 
== Code Samples ==
=== Java ===
+
{| class="wikitable" style="width:900px; vertical-align:top; align:left"
  public void Test() throws Exception
+
! Language || Source Code Examples
  {
+
|-
    StringEntity params = new StringEntity("{ " +
+
| width="50px"| C# || <div class="mw-collapsible mw-collapsed" style="width:65px">
{{Json Practice Block - Java}}
+
<div class="mw-collapsible-content" style="width:810px">
{{Json Auth Block - Application - Java}}
+
 
    "}");
+
{{Core Method Header - CSharp}}
 
+
    String url = "{{Base url api|practiceCreate|practiceCreate}}";
+
    SendReceiveJSON(params, url);
+
  }
+
 
+
{{Base_Code_for_Consuming_API_Using_Java}}
+
 
+
=== C# ===
+
  public void Test()
+
  {
+
    string json = new JavaScriptSerializer().Serialize(new {
+
 
{{Json Practice Block - CSharp}}
 
{{Json Practice Block - CSharp}}
 
{{Json Auth Block - Application - CSharp}}
 
{{Json Auth Block - Application - CSharp}}
    });
+
{{Core Method Footer - CSharp|practiceCreate|practiceCreate}}
   
+
    string url = "{{Base url api|practiceCreate|practiceCreate}}";
+
    SendReceiveJSON(json, url);
+
  }
+
 
    
 
    
 
{{Base_Code_for_Consuming_API_Using_CSharp}}
 
{{Base_Code_for_Consuming_API_Using_CSharp}}
 +
</div>
 +
|-
 +
| align="top" | Java || <div class="mw-collapsible mw-collapsed" style="width:65px">
 +
<div class="mw-collapsible-content" style="width:810px">
 +
{{Talk To Updox - Core - Java|practiceCreate|practiceCreate}}
 +
 
 +
{{Json Practice Block - Java}}
 +
 
 +
{{Base_Code_for_Consuming_API_Using_Java}}
 +
|}
  
 
+
 
 
+
 
 +
 
 +
 
 
== Messages ==
 
== Messages ==
 +
=== Destination Address ===
 +
<div style="width:500px;">
 +
  {{Base url api|practiceCreate|practiceCreate}}
 +
</div>
 +
 
=== Request JSON ===
 
=== Request JSON ===
  {
+
<div style="width:500px;">
    "accountId": "NewPracticeId",
+
{{Json Request Practice}}
    "name": "NewPracticeName",
+
</div>
    ...
+
    "active": "true",
+
    "auth": {
+
        "applicationId": "vendorId",
+
        "applicationPassword": "vendorPassword"
+
    }
+
  }
+
  
 
=== HTTP Response Status ===
 
=== HTTP Response Status ===
 +
<div style="width:500px;">
 
   200 OK
 
   200 OK
 +
</div>
  
 
=== Response JSON ===
 
=== Response JSON ===
  {
+
<div style="width:500px;">
    "successful": true,
+
{{Json Response Practice}}
    "responseMessage": "OK",
+
</div>
    "responseCode": 2000,
+
    "accountId": "NewPracticeId",
+
    "action": "create"
+
  }
+
  
 
+
 
 
+
 
== Relevant Response Codes ==
+
 
In addition to the [[General Error Set]], this method may return the following values in the <code>responseCode</code> and <code>responseMessage</code> fields:
+
 
{|
+
== Relevant Response Codes ==  
! align="left"| <code>responseCode</code>
+
{{Relevant Response Codes Table Header}}
! align="left"| <code>responseMessage</code>
+
{{Response Code Table Row|4110}}
|-
+
{{Response Code Table Row|4130}}
|<code>4110</code>
+
{{Response Code Table Row|4140}}
|<code>no practice ID</code>
+
{{Response Code Table Row|4610}}
|-
+
{{Response Code Table Row|4620}}
|<code>4130</code>
+
{{Response Code Table Row|4630}}
|<code>account already exists</code>
+
|-
+
|<code>4140</code>
+
|<code>web address is already taken</code>
+
|-
+
|<code>4610</code>
+
|<code>direct address error: direct address is taken </code>
+
|-
+
|<code>4620</code>
+
|<code>direct address error: domain does not match the direct domain for this account</code>
+
|-
+
|<code>4630</code>
+
|<code>direct address error: account does not have a direct domain configured</code>
+
|-
+

Latest revision as of 10:14, 3 December 2013


Contents

Description

The following code samples describe the processes involved in creating a practice - part of managing a Practice acount.



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": ""
   }
 }

Code Samples

Language Source Code Examples
C#
 public void TalkToUpdox() {
   string json = new JavaScriptSerializer().Serialize(new {
     accountId = "NewPracticeId",  // required
     name = "Family Practice",  //required
     address1 = "94 N. High St",
     address2 = "Suite 100",
     city = "Dublin",
     state = "OH",
     postal = "43017",
     phone = "6147988170",
     fax = "6144074411",
     timeZone = "America/Chicago",
     websiteAddress = "practice_website",
     directDomain = "new_practice",
     directAddress = "practice_direct",
     active = "true",  //recommended, defaults to "false"
     auth = new {
       applicationId = "vendorId",
       applicationPassword = "vendorPassword",
       accountId = "",
       userId = ""
     }
   });
   string url = "https://updoxqa.com/io/practiceCreate";
   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/practiceCreate";
       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("accountId","NewPracticeId"); //required
       messageData.put("name","Family Practice"); //required
       messageData.put("address1", "94 N. High St");
       messageData.put("address2", "Suite 100");
       messageData.put("city", "Dublin");
       messageData.put("state", "OH");
       messageData.put("postal", "43017");
       messageData.put("phone", "6147988170");
       messageData.put("fax", "6144074411");
       messageData.put("directAddress", "practice_direct");
       messageData.put("directDomain", "new_practice");
       messageData.put("timeZone", "America/Chicago");
       messageData.put("websiteAddress", "practice_website");
       messageData.put("active","true"); //recommended, defaults to "false"
       
       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/practiceCreate

Request JSON

 {
   "accountId": "NewPracticeId",
   "name": "Family Practice",
   "address1": "94 N. High St",
   "address2": "Suite 100",
   "city": "Dublin",
   "state": "OH",
   "postal": "43017",
   "phone": "6147988170",
   "fax": "6144074411",
   "websiteAddress": "practice_website",
   "timeZone": "America/Chicago",
   "directDomain": "new_practice",
   "directAddress": "practice_direct",
   "active": "true",
   "auth": {
      "applicationId": "vendorId",
      "applicationPassword": "vendorPassword",
      "accountId": "",
      "userId": ""
   }
 }

HTTP Response Status

 200 OK

Response JSON

 {
   "successful": true,
   "responseMessage": "OK",
   "responseCode": 2000,
   "accountId": "NewPracticeId",
   "action": "create"
 }



Relevant Response Codes

In addition to the General Error Set, this method may return the following values in the responseCode and responseMessage fields:

responseCode responseMessage
4110 no practice ID
4130 account already exists
4140 web address is already taken
4610 direct address error: direct address is taken
4620 direct address error: domain does not match the direct domain for this account
4630 direct address error: account does not have a direct domain configured