Dossia Application Programming Interface
From Dossia Wiki
Introduction
Welcome to the Dossia Application Programming Interface (API). Using the Dossia API, Personal Health Applications (PHAs) can securely read an individual's health record, add new records, provide annotations, upload images and perform other operations to maintain a person's lifelong health record. Dossia's API provides an open interface for it's ecosystem partners to build innovative personal health applications that are focused on the needs of the healthcare consumer.
Terminology
- A Record pertains to an individual Dossia participant, or user.
- A record is composed of a set Documents.
- Documents can be stored hierarchically in a tree structure by specifying a parent document.
- Dossia uses oAuth as its authentication protocol for all API operations.
- The Dossia API utilizes a Representational State Transfer (REST) style of software architecture.
- A Share is created when a user grants access to an application.
- Shares are based on a collection of Roles.
- A Role will grant read/write access to specific Document types.
Authentication
- All API calls are authenticated with OAuth. Further information about the Dossia authentication process and OAuth implementation can be found in the Dossia OAuth Developer Guide.
- When establishing OAuth authentication the user will always be asked to authenticate with their username and password if they are not already logged in and will be asked to confirm a share/access agreement.
- A user can revoke access to a share from the Dossia web site.
General Design
- The Dossia API conforms to the design principles of Representational State Transfer.
- Dossia currently supports XML, JPEG, PNG and PDF formats in API calls.
- Data for REST calls should be set in the HTTP body along with matching MIME content type in HTTP headers.
- Currently supported MIME content types:
- application/xml
- application/pdf
- image/jpeg
- image/gif
- image/bmp
- image/png
HTTP Status Codes
The Dossia API returns appropriate HTTP status codes for every request:
- 200 OK: Success
- 304 Not Modified: There was no new data to return.
- 400 Bad Request: Your request failed.
- 401 Not Authorized: Authentication credentials, or the credentials provided are not valid.
- 403 Forbidden: We understand your request, but are refusing to fulfill it. An accompanying error message should explain why.
- 404 Not Found: Either an invalid URI has been requested or the resource in question does not exist.
- 405 Method Not Allowed: A request is initiated with an incorrect HTTP method than that specified in the documentation.
- 500 Internal Server Error
- 502 Bad Gateway: Returned if Dossia API is down or being upgraded.
- 503 Service Unavailable: Dossia's servers are up, but are overloaded with requests. Try again later.
Encoding
- The Dossia API supports UTF-8 encoding.
API Usage Guidelines
In order to keep the Dossia API running smoothly, please adhere to the following guidelines:
- If your application does not keep local state, request only the first page of information that you need, and load additional pages only when triggered by user interaction. Use the page parameter.
- If your application keeps a local archive that persists between sessions, please request documents in batches of 50. Save it locally and avoid requesting it again. Please then behave as above, making use of the query xml inclusions/fromdate to request only documents you haven't seen before
Registering Your Application
Before using the Dossia API, you must:
Dossia API URL Endpoints
The following URL endpoints are available from Dossia for development, staging and production environments.
Development
https://dev-api.dossia.org/dossia-restful-api/services/v2.0
Staging
https://staging-api.dossia.org/dossia-restful-api/services/v2.0
Production
https://api.dossia.org/dossia-restful-api/services/v2.0
Shares and Roles
Dossia embraces the ability to share medical data between individuals and applications. Sharing of data is role-based. Shares may have different roles. Each document type will have an associated role that may be applied. The combination of these roles across document types defines a share type. To prevent user complexity we have predefined a number of share types. Each Personal Health Application will be assigned a share type.
General Guidelines
Dossia offers a number of ways to access and create data. The following guidelines are helpful in understanding the general operation of the API.
- Documents may be requested individually or part of a group. It should be noted that non-XML documents (e.g. binary documents) cannot be downloaded as part of a group, and must be downloaded individually.
- XML Data loaded into a participant's record will be validated against known Dossia XML schemas. Please see our Dossia Schema Documentation for more information. Please note that Dossia has provisioned for versioning of the API and our schemas so care should be taken with namespaces.
- All non-XML data must be attached to an XML document. Non-XML data has to be attached to an XML document by using the Related Documents function when initially uploading the document. This ensures that each non-XML document has meaning. For example, if an API client uploads a scanned image of an immunizaion, the API client should also place a XML document of type Immunization in the participant's record and relate the two documents using the Related Documents function.
- Relationships between documents are validated as to which document types can be related to other documents. As an example we wouldn't allow an image to be attached to an Encounter document, however we would allow an image to be attached to a Diagnosis. (Not Implemented) Today, the rules for document relationships are not enforced by the API, however they will be in a future release and documented here.
- All XML documents, whether being sent or received will be wrapped in an XML Container document.
- When receiving related documents as part of the container non-XML documents will be referred to within a NonXmlDocument document type.
- Dossia never deletes documents and the API does not expose a method for deleting documents. A document can be annotated or supressed but never deleted.
- When updating documents we do not remove the documents, we simply version it. The replacement document must be of the same type otherwise an error will occur.
- Document hierarchies are based upon the most recent version of documents rather than version of the document itself. This allows us to have a consistent way of maintaining relationships between documents.
- All API calls to obtain a participant's medical documents use a Record ID. The Record ID will always be the first record returned when making a request for available records.
- Most of our API call results can be modified by specifying query parameters in the request URL. See the Parameters section for more information.
TimeZone in API documents
In future releases(Dossia 3.0),timezones will be taken into consideration when displaying records entered through the API.Namely the Dossia user will be able to control the timezone that a record is displayed in.The following rules will apply to documents submitted through the API.
- When no time is included in the document,record will be displayed with only date.If editable,time cannot be added to this record.
- When time and no timezone is included in the document,record will be displayed with date and time and no timezone. If editable,no timezone will be selected and can be added.
- Sorting precedence will be in the following order : Date only;Date plus time only,Date plus time plus timezone.
- User will have a choice to either display in the timezone it was entered with,or to display in a selected timezone.Only records that have entered a timezone will be converted for display when user elects to.
- API will accept all timezones valid or invalid as part of the document.But only US timezones excluding Arizona will be available for display on the Dossia record.Other timezones will be made available in future releases.
Document IDs and Document Hierarchy
When a new document is created, the Dossia API returns a Document ID for that document. When updating a document using the replace function, Dossia will version the existing document with a new Document ID rather than replace it. It should be noted that the updated document will keep the original Document ID. An application can request a previous version of a document by making use of the versions function in the API.
Dossia allows the creation of a tree hierarchy of documents. When uploading a document, an application can specify the parent Document ID to attach to the document. Trees can also be formed when adding new documents using the payload functionality within the container. See the container section for more details.
For ease of use, hierarchies are based upon Document IDs, and not the individual documents. This gives everyone the benefit of not having to worry about what happens when a document is updated, and the associated effect on the hierarchy. By keeping the hierarchy at this level, the API by default will always brings back the latest version a document. Older versions can be brought back using the Versions API call.
As an example. Document A1 is created. Document B1 is created with A1 being its parent. We now update document B1 with B2. When requesting A1s children the API will bring back B2 and not B1. Likewise, if A1 is updated to A2, when requesting children of A2 the API would return B2.
Container
The Container is the core document used in all methods within the API. Each API call will specify its usage. The Container is useful for sending and requesting multiple documents. In particular, it is extremely useful for obtaining documents stored hierarchically. With one API call, an application can obtain all XML documents related to a parent document. This functionality can also be combined with obtaining a collection of documents by type. As an example, an application can request a collection of Encounter documents with their related documents attached in the result payload. In the case of an Encounter document this is especially useful as the encounter document in itself does not provide many details, but its related Diagnosis and Procedure documents do.
At the root level the Container has a collection of documents. Each document consists of a payload section (which contains the actual XML content), followed by a collection of related documents. Each related document has a document section, which will have its own payload / related documents forming a tree hierarchy.
- When uploading a collection of documents in the container, the API wraps the whole collection as a transaction. If one document fails all will fail.
- When updating documents the related documents section should not be used at all. If a related documents section is found the request will produce a validation failure. Also, only one document can be updated at a time.
API Operations
Document Creation
New XML Document
Upon successful validation this function created new documents for the individual specified by record-id.
| Http Method | POST |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/records/{record-id}/documents |
| Input | Container, recursive use of document and payload elements allowed |
| Output | Container, with document payload of Result records |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V2.0, V3.0 |
Sample Input Document
<?xml version="1.0" encoding="UTF-8"?>
<ns1:container xmlns:ns1="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<ns1:document>
<ns1:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="Medical"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</ns1:payload>
<ns1:relatedDocuments>
<ns1:document>
<ns1:payload>
<phr:Allergy xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="Medication"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/allergy.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:AllergenCode System="ICD" MinorVersion=""
MajorVersion="">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:AllergenCode>
<phr:Reaction System="ICD" MinorVersion=""
MajorVersion="">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:Reaction>
</phr:Allergy>
</ns1:payload>
</ns1:document>
<ns1:document>
<ns1:payload>
<phr:FamilyHistory xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sequence="1"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/familyHistory.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:Code System="ICD" MinorVersion="0" MajorVersion="9">
<phr:Code>123</phr:Code>
</phr:Code>
<phr:Status>Active</phr:Status>
<phr:Sensitive>false</phr:Sensitive>
<phr:FamilyMember>Fathers-Father</phr:FamilyMember>
<phr:AgeOfOnset>45</phr:AgeOfOnset>
<phr:AgeOfResolution>55</phr:AgeOfResolution>
</phr:FamilyHistory>
</ns1:payload>
<ns1:relatedDocuments>
<ns1:document>
<ns1:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode System="CPT" MinorVersion=""
MajorVersion="">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</ns1:payload>
</ns1:document>
</ns1:relatedDocuments>
</ns1:document>
</ns1:relatedDocuments>
</ns1:document>
<ns1:document>
<ns1:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="Medical"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of MA</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>2009-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32421110</phr:EncounterId>
</phr:Encounter>
</ns1:payload>
</ns1:document>
</ns1:container>
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU" version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7" version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk" version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK" version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmDC6dp-E7Kz0" version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/"; //Dossia API call.
String httpMethod = "POST";
String contentType = "application/xml";//Content type of the document
/*Initialize with the Dossia OAuth URL end-points*/
String requestUrl = "https://dev-api.dossia.org/authserver/request_token";//Dossia end-point
to get Request token.
String authorizeUrl = "https://dev-api.dossia.org/authserver/authorize";//Dossia end-point
to get authorization.
String accessUrl = "https://dev-api.dossia.org/authserver/access_token";//Dossia end-point
to get Access token.
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively.*/
String consumerKey = "ConsumerKey";//Consumer key, that is registered in Dossia server.
String consumerSecret = "demoConsumerSecret__";//Consumer key, that is registered in Dossia server.
String callbackUrl = "";
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret.*/
String accessToken = "a0b5439c0fe99f60109a30b52384910c"; //Get access token from Dossia OAuth server.
String tokenSecret = "01ba84e0be29d25b679d2d9548c735ed";//Get token secret from Dossia OAuth server.
InputStream is=new FileInputStream("createDocument.xml");//Read content from file to create document.
/*Create the accessor object and assign the tokens.*/
OAuthServiceProvider provider = new OAuthServiceProvider(requestUrl, authorizeUrl, accessUrl);
OAuthConsumer consumer = new OAuthConsumer(callbackUrl, consumerKey, consumerSecret, provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.tokenSecret = tokenSecret;
accessor.accessToken = accessToken;
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method.*/
OAuthMessage request = new OAuthMessage(httpMethod, call, new ArrayList<OAuth.Parameter>(),is);
request.getHeaders().add(new OAuth.Parameter(HttpMessage.CONTENT_TYPE,contentType));
Object accepted = accessor.consumer.getProperty(OAuthConsumer.ACCEPT_ENCODING);
if (accepted != null) {
request.getHeaders().add(new OAuth.Parameter(HttpMessage.ACCEPT_ENCODING, accepted.toString()));
}
request.addRequiredParameters(accessor);
Object ps = accessor.consumer.getProperty(OAuthClient.PARAMETER_STYLE);
ParameterStyle style = (ps == null) ? ParameterStyle.BODY
: Enum.valueOf(ParameterStyle.class, ps.toString());
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make the Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
#region oAuth end-point representation values, and some of the Ids
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret.*/
//For understanding this is hard coded as constants.
public static class OauthConst
{
public const string OATH_CONSUMERKEY = "ConsumerKey";
public const string OATH_CONSUMER_SECRET = "demoConsumerSecret__";
public const string Token = "2839b1f312f557b1f2cee7ea98d48d51";
public const string TokenSecret = "9088e4864b297d14133ecbee03c66f4b";
public const string Method_POST = "POST";
public const string Method_GET = "GET";
public const string DOSSIA_API_URL = "https://dev-api.dossia.org/dossia-restful-api/services/v2.0/";
public const string API_VERSIONID = "1";
public const string API_DOCUMENTTYPE = "encounter";
}
#endregion
#region Parameters
string apiPostUrl, responseText, sNormalizedUrl, outParameters, sNonce, sTimeStamp,
signature = string.Empty;
Stream requestStream;
HttpWebResponse response;
#endregion
//Read xml data from file. Here xml file is loaded from physical location.
byte[] xmlInputStream = File.ReadAllBytes(@"CreateNewDoc.xml");
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/";
#region Uri Instantiated and oAuth Library Instance Instantiated
//URI Instance Instantiated.
Uri uri = new Uri(apiPostUrl);
//OAuthBase - BaseLibrary Instance Instantiated.
OAuthBase oAuth = new OAuthBase();
sNonce = oAuth.GenerateNonce(); //Calling GenerateNonce BaseLibrary Method
sTimeStamp = oAuth.GenerateTimeStamp();//Calling GenerateNonce BaseLibrary Method
#endregion
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token, OauthConst.TokenSecret,
OauthConst.Method_POST, sTimeStamp, sNonce,AuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
#region Add oAuth QueryString Parameters
//Use the constructed URI and append with the QueryString Parameter Values.
StringBuilder sStringb = new StringBuilder(uri.ToString());
sStringb.AppendFormat("?oauth_consumer_key={0}&", OauthConst.OATH_CONSUMERKEY);
sStringb.AppendFormat("oauth_nonce={0}&", sNonce);
sStringb.AppendFormat("oauth_timestamp={0}&", sTimeStamp);
sStringb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
if (string.IsNullOrEmpty(OauthConst.Token) == false)
sStringb.AppendFormat("oauth_token={0}&", OauthConst.Token);
sStringb.AppendFormat("oauth_version={0}&", "1.0");
sStringb.AppendFormat("oauth_signature={0}", signature);
#endregion
//Fire HTTP_WEB_REQUEST
WebRequest request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xmlInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(xmlInputStream, 0, xmlInputStream.Length);
}
requestStream.Close(); // Close the Stream object.
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT.
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
string message = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
//Initialize dossia client
require_once 'lib/Dossia_Client.php';
$dossia = new Dossia_Client();
/*Initialize with the Dossia OAuth URL end-points*/
$dossia->service_path = 'https://dev-api.dossia.org/dossia-restful-api/services/v2.0/'; //Dossia
api end-point.
$dossia->request_token_url = "https://dev-api.dossia.org/authserver/request_token"; //Dossia
end-point to get Request token.
$dossia->authorize_token_url= "https://dev-api.dossia.org/authserver/authorize"; //Dossia
end-point to get authorization.
$dossia->access_token_url = "https://dev-api.dossia.org/authserver/access_token"; //Dossia
end-point to get Access token.
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively.*/
$dossia->customer_key = "ConsumerKey"; //Consumer key,that is registered in Dossia server.
$dossia->customer_secret = "demoConsumerSecret__"; //Consumer key,that is registered in Dossia server.
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret.*/
$dossia->get_tokens();
/* Get the input XML data for the document creation */
$input_data = file_get_contents('create_xml_doc.xml');
$api_service = "records/" . $dossia->record_id . "/documents/";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
/* Initialize the CURL Request */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
New Binary Document
Creating a binary document is a two step process.
- 1. Create a new XML document of type binary (Binary.xsd). This call is a simillar to creating a new XML document.
- 2. Send binary conent through http request body by triggering the /binary call on that document id generated for above call.
| Http Method | POST |
|---|---|
| Content-type | application/pdf or image/jpeg or image/bmp or image/gif |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/binary |
| Input | Binary conent in request body with conent length and content type in headers. These header values should match the ones that are sent in binary xml document. |
| Output | Http Return code 200 if successful |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V2.0, V3.0 |
Step 1 - Sample Binary XML Input document
<?xml version="1.0" encoding="UTF-8"?>
<ns1:container xmlns:ns1="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<ns1:document>
<ns1:payload>
<phr:BinaryData xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ProfessionallySourced="false"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/binaryData.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:Comments>My Broken leg</phr:Comments>
<phr:MimeType>image/jpeg</phr:MimeType>
<phr:Length>10483</phr:Length>
</phr:BinaryData>
</ns1:payload>
</ns1:document>
</ns1:container>
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmM3oQ6vLodCN"
version="0" />
</api:container>
Step 2 - Call to records/{recordId}/documents/{documentId}/binary with file content in request body and with content type as "image/jpeg" for above sample.
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/"; //Dossia API call.
String httpMethod = "POST";
String contentType = "application/xml";//Content type of the document
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” DossiaAPI call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("createBinDoc.xml");//Read content from file to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
//Step1: Creating XML document.
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
String documentId = getDocumentId(new String(response.readBodyAsString()));//Getting document id
from the reponse text.
//Step2: Creating Bin document.
call = call + documentId + "/binary";
is = new FileInputStream("createJPEG.jpg");//Read content from file to create binary document.
contentType = "image/jpeg"; //Set content type of binary document.
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
client = new OAuthClient(new HttpClient3());
response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Read xml data from file
byte[] xmlInputStream = File.ReadAllBytes(@"CreateBinDoc.xml");
//Parameters Declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
StringBuilder sStringb = null;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
#region STEP 1 - Creating XML document.
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,AuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xmlInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(xmlInputStream, 0, xmlInputStream.Length);
}
requestStream.Close();// Close the Stream object.
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
#endregion
#region STEP 2 - Creating Bin document.
///STEP 2 - Begins here...
if (string.IsNullOrEmpty(responseText.Trim()) == false)
{
//Create XMlDocumnet out of Response Text
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseText);
string docId;
docId = xmlDoc.GetElementsByTagName("api:container")[0].ChildNodes[0].Attributes["id"].Value;
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/"
+ docId + "/binary";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,AuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
//Get the JPEG file bytes.
byte[] jpegFileInputStream = File.ReadAllBytes(@"DossiaAPI_ServerError.jpg");
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "image/jpeg";
request.ContentLength = jpegFileInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(jpegFileInputStream, 0, jpegFileInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
}
#endregion
PHP Sample Code:
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$upload_file = 'test.jpg';
$content_type = 'image/jpef';
/*Step 1 Create a new XML document of type binary (Binary.xsd). This call is a simillar to creating
a new XML document */
/* Get the input XML data for the document creation */
$input_data = file_get_contents('create_bin_doc.xml');
$api_service = "records/" . $dossia->record_id . "/documents/";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
/* Initialize the CURL Request */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/*Step 2 Send binary conent through http request body by triggering the /binary call on that
document id generated for Step 1 */
/*Get document ID from the output of the above call*/
preg_match('/<api:document id="(.+)" /', $result, $matches);
$doc_id = array_pop($matches);
/*Intialize the API call*/
$api_service = 'records/' . $dossia->record_id . '/documents/'.$doc_id.'/binary';
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$params = file_get_contents($upload_file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $content_type",
"Content-Length:" . strlen($params), "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 180);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$binary_output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
echo $binary_output;
?>
New Application Document with label
API gives a provision to create and store application documents and label (tag) them with this call.
| Http Method | POST |
|---|---|
| Content-type | any valid conent type |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/key/{keyId}/label/{labelId} |
| Input | Binary conent in request body with content length and content type in headers. |
| Output | Http Return code 200 if successful |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V2.0, V3.0 |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmCK29K4UeKaM"
version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/key/{keyId}/label/{labelId}";//Dossia
API call.
String httpMethod = "POST";
String contentType = "image/jpeg";//Content type of the document
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("createAppDocWithLabel.jpeg");//Read content from file to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
/Get the JPEG file bytes.
byte[] jpegFileInputStream = File.ReadAllBytes(@"DossiaAPI_ServerError.jpg");
//Parameters Declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}
/apps/documents/key/{key_id}/label/{label_id};
uri = new URI(apiPostUrl)
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp, sNonce,OAuthBase.SignatureTypes.HMACSHA1, out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "image/jpeg";
request.ContentLength = jpegFileInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(jpegFileInputStream, 0, jpegFileInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request POSTING failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
$key_id = 'key123';
$label_id = 'label123';
/*Initialize the input data*/
$upload_file = 'test.jpg';
$content_type = 'image/jpef';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/apps/documents/key/" . $key_id . "/label/" . $label_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$params = file_get_contents($upload_file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $content_type",
"Content-Length:" . strlen($params), "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 180);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
New Application Document
API gives a provision to create and store documents related to PHA's at Dossia's end through this call.
| Http Method | POST |
|---|---|
| Content-type | any valid conent type |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/key/{keyId} |
| Input | Binary conent in request body with conent length and content type in headers. |
| Output | Http Return code 200 if successful |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V2.0, V3.0 |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmCK29K4UeKaM"
version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/key/{keyId}";//Dossia
API call.
String httpMethod = "POST";
String contentType = "application/jpeg";//Content type of the document
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("createAppDoc.jpeg");//Read content from file to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Get the JPEG file bytes.
byte[] jpegFileInputStream = File.ReadAllBytes(@"DossiaAPI_ServerError.jpg");
//Parameters Declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/apps/documents/key/{keyId}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "image/jpeg";
request.ContentLength = jpegFileInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(jpegFileInputStream, 0, jpegFileInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request POSTING failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$key_id = '12abc45';
$upload_file = 'test.jpg';
$content_type = 'image/jpef';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/apps/documents/key/" . $key_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$params = file_get_contents($upload_file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $content_type",
"Content-Length:" . strlen($params), "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 180);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Relating existing documents as parent and child documents
| Http Method | POST | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{parentDocumentId}/rels/related/{childDocId} | |
| Input | NONE | |
| Output | NONE | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/rels/related/{childDocId}";
//Dossia API call.
String httpMethod = "POST";
String contentType = "application/xml";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is = new ByteArrayInputStream("".getBytes());//Set no content as input is not required for this call.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code
/Read xml data from file
byte[] xmlInputStream = File.ReadAllBytes(@"RelatingADocToParentDoc.xml");
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}
/documents/{parentDocument_id}/rels/related;
uri = new URI(apiPostUrl)
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
WebRequest request = HttpWebRequest.Create(apiPostUrl);
request.Method = "POST";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
string message = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$parent_doc_id = '12abc45';
$ child_doc_id = ‘we434rr’;
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $parent_doc_id . "/rels/related/".$child_doc_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST", $dossia->service_path . $api_service, array());
$data_req->sign_request($dossia->sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
/* Print the output */
echo $output;
?>
Relating a Document to a Parent Document
| Http Method | POST | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{parentDocumentId}/rels/related | |
| Input | Container, recursive use of document and Payload elements. | |
| Output | Container, with document payload of Result records | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Input document
<?xml version="1.0" encoding="UTF-8"?>
<ns1:container xmlns:ns1="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<ns1:document>
<ns1:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode System="CPT" MinorVersion=""
MajorVersion="">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</ns1:payload>
</ns1:document>
</ns1:container>
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/rels/related";
//Dossia API call.
String httpMethod = "POST";
String contentType = "application/xml";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("relateDocToParentDoc.xml");//Read content from file
to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}
/documents/{parentDocumentId}/rels/related;
uri = new URI(apiPostUrl)
//Read xml data from file
byte[] xmlInputStream = File.ReadAllBytes(@"RelatingADocToParentDoc.xml");
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
WebRequest request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xmlInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(xmlInputStream, 0, xmlInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
string message = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$parent_doc_id = '12abc45';
$input_data = file_get_contents('relate_xml_doc.xml);
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $parent_doc_id . "/rels/related";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method)$sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Replacing a Document with Another Document
| Http Method | POST | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/replace | |
| Input | Container, single use of document element. relateddocuments element not allowed. | |
| Output | Container, with document payload containing a Result records | |
| Http Return Codes | 200, 400, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Input Document
<?xml version="1.0" encoding="UTF-8"?>
<ns1:container xmlns:ns1="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<ns1:document>
<ns1:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis JR II</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215159</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode System="CPT" MinorVersion=""
MajorVersion="">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</ns1:payload>
</ns1:document>
</ns1:container>
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="1" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/replace";//Dossia
API call.
String httpMethod = "POST";
String contentType = "application/xml";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("replaceDocument.xml");//Read content from file to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Read xml data from file
byte[] xmlInputStream = File.ReadAllBytes(@"ReplacingDoc.xml");
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/{document-id}/replace";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
WebRequest request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xmlInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(xmlInputStream, 0, xmlInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
string message = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
$input_data = file_get_contents('replace_xml_doc.xml);
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id . "/replace";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Replacing an Application document with another document
Application documents could be replaced only by passing document id that got created as a part of application document creation.
| Http Method | POST | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key-id}/replace | |
| Input | Binary stream as a part of request body and content-type information set in request headers | |
| Output | Container, with document payload containing document with document id | |
| Http Return Codes | 200, 400, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="123"
version="1" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key-id}/replace";
//Dossia API call.
String httpMethod = "POST";
String contentType = "application/bmp";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is=new FileInputStream("replaceAppDoc.bmp");//Read content from file to create document.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared.
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Get the JPEG file bytes.
byte[] jpegFileInputStream = File.ReadAllBytes(@"InputImage.jpeg");
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/apps/documents/key/{key-id}/replace";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_POST, sTimeStamp,
sNonce,OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "POST";
request.ContentType = "image/jpeg";
request.ContentLength = jpegFileInputStream.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(jpegFileInputStream, 0, jpegFileInputStream.Length);
}
requestStream.Close();
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$key_id = '123';
$binary_file = 'test_replace.jpg';
$content_type = 'image/jpeg';
/*Initialize API call */
$api_service = 'records/'.$dossia->record_id.'/apps/documents/key/'.$key_id.'/replace';
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$params = file_get_contents($binary_file);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $content_type",
"Content-Length:" . strlen($params), "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 180);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Document Suppression
This call is used to suppress a document.
| Http Method | DELETE | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id} | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call="{dossia-api-endpoint}/records/{record-id}/documents/{document-id}";//DossiaAPI call.
String httpMethod = "DELETE";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}/ documents/{document_id};
uri = new uri(apiPostUrl)
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.method = = “DELETE”
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$doc_id = '12abc45';
/*Initialize API call */
$api_service = "records/".$dossia->record_id."/documents/”.$doc_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "DELETE", $dossia->service_path . $api_service, array());
$data_req->sign_request($dossia->sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
UnSuppress a document
This call is used to unsuppress a document.
| Http Method | POST | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/unsuppress | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record_id}/apps/documents/{document_id}/unsuppress";
//Dossia API call.
String httpMethod = "POST";
String contentType = "application/xml";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
InputStream is = new ByteArrayInputStream("".getBytes());//Set no content as input is not required for this call.
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Creating OAuthMessage object and ParameterStyle object to pass to the invoke method
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(request, style);//Make Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}/apps/documents/{document_id}/unsuppress";
uri = new uri(apiPostUrl)
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(url, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = “POST”;
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$doc_id = '12abc45';
/*Initialize API call */
$api_service = 'records/'.$dossia->record_id.'/documents/'.$doc_id.'/unsuppress';
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "POST", $dossia->service_path . $api_service, array());
$data_req->sign_request($dossia->sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $file_type", "Content-Length:" . strlen($params), "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 180);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Application Document Deletion
Use this method to delete an existing application document.
| Http Method | DELETE | |
|---|---|---|
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key-id} | |
| Output | Http Return code 200 | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call="{dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key-id}";//DossiaAPI call.
String httpMethod = "DELETE";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/apps/documents/key/{key-id}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$key_id = '123';
/*Initialize API call */
$api_service = "records/".$dossia->record_id."/apps/documents/key/".$key_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "DELETE",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieval of Documents
Parameters
When retrieving documents the behavior can be modified by adding query parameters to the URL.
- offset - Specifies the offset into the collection of results to start sending documents back
- limit - Specifies the maximum number of documents to return
- modfied_since - filter results by only sending documents modified since date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- modified_before - filter results by only send documents modified before date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- hd_start_date_since - filter results by only documents whose health data started since date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- hd_start_date_before - filter results by only documents whose health data started before date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- hd_end_date_since - filter results by only documents whose health data end date is since date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- hd_end_date_before - filter results by only documents whose health data end date is before date. Accepted formats are MMddyyyy/MMddyyyyhh:mm/MMddyyyyhh:mm:ss:SS
- related_documents - return a documents hierarchy of documents
- expand_codes_short - requests the server to append the short description of a code where able
- expand_codes_long - requests the server to append the long description of a code where able
- ids_only - requests the return Document IDs rather than the full XML document
- meta - requests the return Document to contain metadata
- includeFilter - filter to specify documents to include in search. Currently supports filtering by Coding System and Codes. Codes are optional. Format is: codingSystem1:code1,code2,|codingSystem2,code1,code2
- excludeFilter - filter to specify documents to exclude from search. Currently supports filtering by Coding System and Codes. Unlike includeFilter, excludeFilter does not allow multiple coding system to be passed. Include and Exclude filters may not be used together. Codes are optional. Format is: codingSystem1:code1,code2
Available Records
This function is intended to assist with user shares. If a Dossia participant has access to other users they will be listed here.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records | |
| Output | Container, with document payload of Participant records with first containing the record of the caller. | |
| Allowed Params | offset , limit, ids_only | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns="http://www.dossia.org/v2.0/xml/phr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmJSzykB9xH3L">
<api:payload>
<Participant type="Primary">
<FullName>Lovina L Torres</FullName>
<FirstName>Lovina</FirstName>
<MiddleName>L</MiddleName>
<LastName>Torres</LastName>
<Gender>Male</Gender>
<Address>
<StreetAddress1>842 OKLAHOMA CITY ct</StreetAddress1>
<StreetAddress2>unit 977</StreetAddress2>
<City>PENN YAN</City>
<State>NY</State>
<PostalCode>14527</PostalCode>
</Address>
<Contact type="Email">lovina.torres@gmail.org</Contact>
</Participant>
</api:payload>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/"; //Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize API call */
$api_service = "records/";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: OAuth " . implode(",",
$data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
Retrieving a Record
This function will return a participant record for an individual specified by record-id.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id} | |
| Output | Container, with document payload of a Participant record | |
| Allowed Params | NONE | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns="http://www.dossia.org/v2.0/xml/phr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmJSzykB9xH3L">
<api:payload>
<Participant type="Primary">
<FullName>Lovina L Torres</FullName>
<FirstName>Lovina</FirstName>
<MiddleName>L</MiddleName>
<LastName>Torres</LastName>
<Gender>Male</Gender>
<Address>
<StreetAddress1>842 OKLAHOMA CITY ct</StreetAddress1>
<StreetAddress2>unit 977</StreetAddress2>
<City>PENN YAN</City>
<State>NY</State>
<PostalCode>14527</PostalCode>
</Address>
<Contact type="Email">lovina.torres@gmail.org</Contact>
</Participant>
</api:payload>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}"; //Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Getting the reponse text.
C# Sample Code:
//Parameters declared
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
WebRequest request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: OAuth " . implode(",",
$data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving Root Level Documents Within a Record
Often applications start obtaining information at the root level and navigate the tree hierarchy in subsequent calls to the API. This call provides an ability to initiate tree navigation. Initially it returns only documents with no parents. However, if the Related Documents parameter is applied this call will return all documents in the hierarchy.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/ | |
| Output | container with only root level documents | |
| Allowed Params | offset , limit, modfied_since, modified_before, related_documents, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), ids_only, hd_start_date_since, hd_start_date_before, hd_end_date_since, hd_end_date_before | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output (offset=1 and limit=1)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmO9_QAsaRRCn"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" class="Medical"
ProfessionallySourced="true"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
</api:container>
Sample Output (ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmMsG9-t87qT5"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmO9_QAsaRRCn"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmGhmcypoBCUd"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmC28qQBv8pvv"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmC0gOH7R5uca"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmJS8YbHYfgSY"
version="2" />
<api:document id="t0FhmOk46GXiarC9VkEcmBT_k-XR8zNP"
version="1" />
<api:document id="t0FhmOk46GXiarC9VkEcmH4jBspU-gjB"
version="0" />
</api:container>
Sample Output (related_documents=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0">
<api:payload>
<phr:Allergy xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/allergy.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:AllergenCode MajorVersion="" MinorVersion=""
System="ICD">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:AllergenCode>
<phr:Reaction MajorVersion="" MinorVersion="" System="ICD">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:Reaction>
</phr:Allergy>
</api:payload>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:payload>
<phr:FamilyHistory xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" sequence="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/familyHistory.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:Code MajorVersion="9" MinorVersion="0" System="ICD">
<phr:Code>123</phr:Code>
</phr:Code>
<phr:Status>Active</phr:Status>
<phr:Sensitive>false</phr:Sensitive>
<phr:FamilyMember>Fathers-Father</phr:FamilyMember>
<phr:AgeOfOnset>45</phr:AgeOfOnset>
<phr:AgeOfResolution>55</phr:AgeOfResolution>
</phr:FamilyHistory>
</api:payload>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0">
<api:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode MajorVersion="" MinorVersion=""
System="CPT">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</api:payload>
</api:document>
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
</api:container>
Sample Output (related_document=y and ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0" />
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/"; //Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Getting the reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: OAuth " . implode(",",
$data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving Document Summary Counts
It is often useful to know in advance how many documents by type a may have in their record. For example, a client application may need to know how many Medications a participant has in his/her record. This call will provide a summary of that information.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/summary_count | |
| Output | Container, with document payload of Summary records | |
| Allowed Params | NONE | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:summary xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/summary.xsd">
<api:document count="1" type="BinaryData">
<api:documentversion count="1"
uri="http://www.dossia.org/v2.0/xml/phr/Binarydata" />
</api:document>
<api:document count="14" type="Allergy">
<api:documentversion count="14"
uri="http://www.dossia.org/v2.0/xml/phr/Allergy" />
</api:document>
<api:document count="7" type="Diagnosis">
<api:documentversion count="7"
uri="http://indivo.org/xml/phr/diagnosis.xsd" />
</api:document>
<api:document count="1" type="FamilyHistory">
<api:documentversion count="1"
uri="http://www.dossia.org/v2.0/xml/phr/FamilyHistory" />
</api:document>
<api:document count="2" type="Encounter">
<api:documentversion count="2"
uri="http://www.dossia.org/v2.0/xml/phr/Encounter" />
</api:document>
<api:document count="2" type="Immunization">
<api:documentversion count="2"
uri="http://www.dossia.org/v2.0/xml/phr/Immunization" />
</api:document>
</api:summary>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/summary_count/"; //Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/documents/summary_count/";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/summary_count";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: OAuth " . implode(",",
$data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Document using a Document ID
This call will return the document specified by the document-id. As noted in the Allowed Params section you can specify related_documents which will also recursively bring back any child documents.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id} | |
| Output | Container, with document payload | |
| Allowed Params | related_documents,ids_only, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), meta | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
</api:container>
Sample Output (related_documents=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0">
<api:payload>
<phr:Allergy xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/allergy.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:AllergenCode MajorVersion="" MinorVersion=""
System="ICD">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:AllergenCode>
<phr:Reaction MajorVersion="" MinorVersion="" System="ICD">
<phr:Code>code</phr:Code>
<phr:ShortDescription>AllergenCode</phr:ShortDescription>
</phr:Reaction>
</phr:Allergy>
</api:payload>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:payload>
<phr:FamilyHistory xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" sequence="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/familyHistory.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:Code MajorVersion="9" MinorVersion="0" System="ICD">
<phr:Code>123</phr:Code>
</phr:Code>
<phr:Status>Active</phr:Status>
<phr:Sensitive>false</phr:Sensitive>
<phr:FamilyMember>Fathers-Father</phr:FamilyMember>
<phr:AgeOfOnset>45</phr:AgeOfOnset>
<phr:AgeOfResolution>55</phr:AgeOfResolution>
</phr:FamilyHistory>
</api:payload>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0">
<api:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode MajorVersion="" MinorVersion=""
System="CPT">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</api:payload>
</api:document>
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
</api:container>
Sample Output (related_documents=y and ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0" />
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/";//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/{document-id}/";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Binary Document
Binary documents can be retrieved by the Document ID of a relative binary XML document. This call does not return the Container XML. Some binary document types take advantage of optimization features such as content negotiation, gzip compression, caching headers, as well as streaming capabilities. The document returned by this API call is the direct binary data stream.
| Http Method | GET | |
|---|---|---|
| Content-type | Conent type of the out document will be content content type in binary xml document. | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/binary | |
| Output | Binary document as a part of output stream. | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/binary";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
response.getBodyAsStream();//Write binary stream into a file.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
//Apply necessary DocumentID here..[t0FhmOk46GXiarC9VkEcmHF8o1Df72pm]
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/{document-id}/binary";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] outputData = encoding.GetBytes(responseText);
string contentType = response.contentType;
//Custom Action for the recieved binary output here.
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id . "/binary";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Metadata
This call will return the meta data for document specified by the document-id.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/meta | |
| Output | Container, with document payload of Meta data records | |
| Allowed Params | related_documents | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
type="http://www.dossia.org/v2.0/xml/phr/Encounter" version="0">
<api:metadata>
<api:creationDate>2009-07-22 16:14:11.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:class>Medical</api:class>
<api:classification>Claims Medical</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
<api:parentId>t0FhmOk46GsdfjsdflkjsdfkljsdB2CU</api:parentId>
</api:metadata>
</api:document>
</api:container>
Sample Output (related_documents=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
type="http://www.dossia.org/v2.0/xml/phr/Encounter" version="0">
<api:metadata>
<api:creationDate>2009-07-22 16:14:11.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:class>Medical</api:class>
<api:classification>Claims Medical</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
type="http://www.dossia.org/v2.0/xml/phr/Allergy" version="0">
<api:metadata>
<api:creationDate>2009-07-22 16:14:11.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:class>Medication</api:class>
<api:classification>PHR</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
type="http://www.dossia.org/v2.0/xml/phr/FamilyHistory" version="0">
<api:metadata>
<api:creationDate>2009-07-22 16:14:11.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:class>Medication</api:class>
<api:classification>Claims Medical</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
type="http://www.dossia.org/v2.0/xml/phr/Immunization" version="0">
<api:metadata>
<api:creationDate>2009-07-22 16:14:11.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:class>Medication</api:class>
<api:classification>PHR</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
</api:document>
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/meta"; //Dossia
API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted..Apply necessary DOCUMENTID in place of ‘OauthConst.API_DOCUMENTID’
apiPostUrl = OauthConst.DOSSIA_API_URL + "/records/{record-id}/documents/{document-id}/meta";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id . "/meta";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Metadata for all root level documents
This call will return the meta data of all available application documents.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/meta | |
| Output | Container, with document payload of Meta data of documents | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAGSrJEJMOXg" type="Participant" version="1">
<api:metadata>
<api:creationDate>2009-08-18</api:creationDate>
<api:professionallySourced>false</api:professionallySourced>
<api:createdParticipant>ConsumerDemo</api:createdParticipant>
<api:schemaType>http://www.dossia.org/v2.0/xml/phr/Participant</api:schemaType>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmNLHuARM0Bbr" type="Participant" version="0">
<api:metadata>
<api:creationDate>2009-08-14</api:creationDate>
<api:professionallySourced>false</api:professionallySourced>
<api:createdParticipant>ConsumerDemo</api:createdParticipant>
<api:schemaType>http://www.dossia.org/v2.0/xml/phr/Participant</api:schemaType>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmNuS1PlzZR9n" type="Participant" version="0">
<api:metadata>
<api:creationDate>2009-08-14</api:creationDate>
<api:professionallySourced>false</api:professionallySourced>
<api:createdParticipant>ConsumerDemo</api:createdParticipant>
<api:schemaType>http://www.dossia.org/v2.0/xml/phr/Participant</api:schemaType>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmOkCdK7Kg6cO" type="Participant" version="0">
<api:metadata>
<api:creationDate>2009-08-14</api:creationDate>
<api:professionallySourced>false</api:professionallySourced>
<api:createdParticipant>ConsumerDemo</api:createdParticipant>
<api:schemaType>http://www.dossia.org/v2.0/xml/phr/Participant</api:schemaType>
</api:metadata>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/meta"; //Dossia
API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}/documents/meta";
uri = new Uri(apiPostUrl);
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/meta";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET", $dossia->service_path . $api_service, array());
$data_req->sign_request($dossia->sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Metadata for Application documents
This call will return the meta data of all available application documents.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/meta | |
| Output | Container, with document payload of Meta data records | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmHoU0GUIKexJ">
<api:metadata>
<api:creationDate>2009-07-01</api:creationDate>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmMWbTJyefTR8">
<api:metadata>
<api:creationDate>2009-06-29</api:creationDate>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmHsI7Fm0xklV">
<api:metadata>
<api:creationDate>2009-07-09</api:creationDate>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmEYovbmfofbM">
<api:metadata>
<api:creationDate>2009-06-29</api:creationDate>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmD2luQCZTVcy">
<api:metadata>
<api:creationDate>2009-07-09</api:creationDate>
</api:metadata>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/meta"; //Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/apps/documents/meta";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize API call */
$api_service = "records/".$dossia->record_id."/apps/documents/meta";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Versions
This call will return all of the versions of a document specified by the document-id.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/versions | |
| Output | Container, with document version information | |
| Allowed Params | offset , limit, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), ids_only | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
type="http://www.dossia.org/v2.0/xml/phr/Immunization" version="0">
<api:metadata>
<api:creationDate>2009-07-23 10:30:53.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:classification>PHR</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
type="http://www.dossia.org/v2.0/xml/phr/Immunization" version="1">
<api:metadata>
<api:creationDate>2009-07-23 10:31:41.0</api:creationDate>
<api:professionallySourced>true</api:professionallySourced>
<api:startDate>1999-05-26</api:startDate>
<api:classification>PHR</api:classification>
<api:createdParticipant>TESTDSDATA SOURCE</api:createdParticipant>
</api:metadata>
</api:document>
</api:container>
Sample Output (ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="1" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/versions";//Dossia
API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/documents/{document-id}/versions";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id . "/versions";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Specific Document Version
This call will return a specific version of the document specified by the document-id.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{document-id}/versions/{version-id} | |
| Output | Container, with document payload of a particular document version | |
| Allowed Params | expand_codes_short(Not Implemented), expand_codes_long(Not Implemented) | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output (Retrieving version zero document)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="0">
<api:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215156</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode MajorVersion="" MinorVersion=""
System="CPT">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</api:payload>
</api:document>
</api:container>
Sample Output (version 1 document)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmP3TyXJ9OdeQ"
version="1">
<api:payload>
<phr:Immunization xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/immunization.xsd">
<phr:Origin Classification="PHR">
<phr:Organization>
<phr:OrganizationName>Dossia</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Provider>
<phr:Individual>
<phr:FullName>Dr Samuel Geddis JR</phr:FullName>
<phr:ProviderIdentifier Type="NPI">
<phr:Identifier>1215157</phr:Identifier>
</phr:ProviderIdentifier>
<phr:Organization>
<phr:OrganizationName>Harvard Vanguard Medicals</phr:OrganizationName>
</phr:Organization>
</phr:Individual>
</phr:Provider>
<phr:Date Type="Actual">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:VaccineCode MajorVersion="" MinorVersion=""
System="CPT">
<phr:Code>code</phr:Code>
<phr:ShortDescription>Immunization</phr:ShortDescription>
</phr:VaccineCode>
<phr:Site>Left Arm</phr:Site>
</phr:Immunization>
</api:payload>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/versions/{version-id}";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/documents/{document-id}/versions/{version-id}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request GET failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_id = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
$version = '0';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/" . $document_id . "/versions/" . $version;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving parent document
This call will return immediate parent document to the supplied document id.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/{documentId}/parent | |
| Output | Container, with document payload of parent document | |
| Allowed Params | related_documents, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), ids_only, meta | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/{document-id}/parent"; //Dossia
API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record_id}/documents/ {document_id}/parent";
uri = new Uri(apiPostUrl);
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
request.Method =”GET”;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$doc_id = '12abc45';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/$doc_id/parent";
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET", $dossia->service_path . $api_service, array());
$data_req->sign_request($dossia->sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', "Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Collection of Documents by Type
This call will return a collection of document by a document type. As noted in Allowed Params section you may specify related_documents which will also recursively bring back any child documents.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/document_type/{document_type} | |
| Output | Container, with document payload of a Participant record | |
| Allowed Params | offset , limit, modfied_since, modified_before, related_documents, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), ids_only, hd_start_date_since, hd_start_date_before, hd_end_date_since, hd_end_date_before, meta | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output (for retrieving Encounters)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmDC6dp-E7Kz0"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of MA</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>2009-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32421110</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
</api:container>
Sample Output (related_documents=y and ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0" />
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmDC6dp-E7Kz0"
version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/document_type/{document-type}";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/documents/document_type/{document-type}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_type = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/document_type/" . $document_type;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Collection of Documents by Type and Class
This call will return a collection of document by a document type and class. As noted in Allowed Params section you may specify related_documents which will also recursively bring back any child documents.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/documents/document_type/{document_type}/class/{class} | |
| Output | Container, with document payload of a Participant record | |
| Allowed Params | offset , limit, modfied_since, modified_before, related_documents, expand_codes_short(Not Implemented), expand_codes_long(Not Implemented), ids_only, hd_start_date_since, hd_start_date_before, hd_end_date_since, hd_end_date_before | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Sample Output (for retrieving Encounters)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of Arkansas</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>1999-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32432432</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmDC6dp-E7Kz0"
version="0">
<api:payload>
<phr:Encounter xmlns:phr="http://www.dossia.org/v2.0/xml/phr"
ProfessionallySourced="true" class="Medical"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/xml/phr http://www.dossia.org/v2.0/xml/phr/encounter.xsd">
<phr:Origin Classification="Claims Medical">
<phr:Organization>
<phr:OrganizationName>Blue Cross/Blue Shield of MA</phr:OrganizationName>
</phr:Organization>
</phr:Origin>
<phr:Date Type="Approximate">
<phr:StartDate>2009-05-26</phr:StartDate>
</phr:Date>
<phr:EncounterId>BCBSAR-32421110</phr:EncounterId>
</phr:Encounter>
</api:payload>
</api:document>
</api:container>
Sample Output (related_documents=y and ids_only=y)
<?xml version="1.0" encoding="UTF-8"?>
<api:container xmlns:api="http://www.dossia.org/v2.0/api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd">
<api:document id="t0FhmOk46GXiarC9VkEcmAnOfhT6B2UU"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDen6k3mouU7"
version="0" />
<api:document id="t0FhmOk46GXiarC9VkEcmCt2IWqdAJQk"
version="0">
<api:relatedDocuments>
<api:document id="t0FhmOk46GXiarC9VkEcmDOOQL5qgTyK"
version="0" />
</api:relatedDocuments>
</api:document>
</api:relatedDocuments>
</api:document>
<api:document id="t0FhmOk46GXiarC9VkEcmDC6dp-E7Kz0"
version="0" />
</api:container>
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/documents/document_type/{document-type}";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
System.out.println(new String(response.readBodyAsString()));//Get reponse text.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/documents/document_type/{document-type}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$document_type = 't0FhmOk46GXiarC9VkEcmAjmvrMF_vvO';
/*Initialize API call */
$api_service = "records/" . $dossia->record_id . "/documents/document_type/" . $document_type;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Application document by label id
This call will return a application binary document related to label id.This call would get the content-type of the document on fly from the label id and record id passed and sends back the binary content of that application document through response.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/label/{label_id} | |
| Output | Http status code 200 with application document as a binary stream | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/label/{label-id}";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
response.getBodyAsStream();//Write binary stream into a file.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/" + OauthConst.API_RECORDID
+ "/apps/documents/label/" + OauthConst.API_LABELID;
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
request.Method = "GET";
request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$label_id = 'a133mk';
/*Initialize API call */
$api_service = "records/".$dossia->record_id."/apps/documents/label/".$label_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Retrieving a Application document by key id
This call will return a application binary document related to document id.This call would get the content-type of the document on fly from the document id and record id passed and sends back the binary content of that application document through response.
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key_id} | |
| Output | Http status code 200 with application document as a binary stream | |
| Http Return Codes | 200, 401, 404 | |
| API Version Compatibility | V2.0, V3.0 | |
Java Sample Code:
String call = "{dossia-api-endpoint}/records/{record-id}/apps/documents/key/{key-id}";
//Dossia API call.
String httpMethod = "GET";
/*Initialize with the Dossia OAuth URL end-points as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in Java sample code snippet of “New XML Document” Dossia API call.*/
/*Create the accessor object and assign the tokens as shown in Java sample code snippet of
“New XML Document” Dossia API call.*/
OAuthClient client = new OAuthClient(new HttpClient3());
OAuthMessage response = client.invoke(accessor, httpMethod, call, new ArrayList<Map.Entry>());//Make
Dossia API call
response.getBodyAsStream();//Write binary stream into a file.
C# Sample Code:
//Parameters declared
Uri uri = null;
OAuthBase oAuth = null;
WebRequest request = null;
string Errormessage = string.Empty;
/* Use Region ‘Parameters’ as explained in ‘New XML Document’ Call */
/* Use Region ‘oAuth end-point representation values, and some of the Ids’
as explained in ‘New XML Document’ Call */
//Prepare the URL to be posted
//Replace with the correct id in place of t0FhmOk46GXiarC9VkEcmDlbaRfef5ZB
apiPostUrl = OauthConst.DOSSIA_API_URL + "records/{record-id}/apps/documents/key/{key-id}";
/* Use Region ‘Uri Instantiated and oAuth Library Instance Instantiated’
as explained in ‘New XML Document’ Call */
//Calling GenerateSignature BaseLibrary Method
signature = oAuth.GenerateSignature(uri, OauthConst.OATH_CONSUMERKEY,
OauthConst.OATH_CONSUMER_SECRET, OauthConst.Token,
OauthConst.TokenSecret, OauthConst.Method_GET, sTimeStamp,
sNonce, OAuthBase.SignatureTypes.HMACSHA1,
out sNormalizedUrl, out outParameters);
signature = HttpUtility.UrlEncode(signature); //HTML Enocoding
/* Use Region ‘Add oAuth QueryString Parameters’
as explained in ‘New XML Document’ Call */
//Fire HTTP_WEB_REQUEST
request = HttpWebRequest.Create(sStringb.ToString());
//request.Method = "GET";
//request.ContentType = "application/xml";
request.Timeout = 600000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{ //SUCCESSFULL CALL
using (Stream stream = response.GetResponseStream())
{
//READ the OUT PUT OF THE CALL
StreamReader reader = new StreamReader(stream);
responseText = reader.ReadToEnd(); //responseText holds OUTPUT
//Custom Action for the recieved xml output here.
//As sample: the recieved XML output is written Console.
//Console.WriteLine(responseText);
}
}
else
{
//Error Occured - Form the Error Message Based on the returned 'StatusCode'
Errormessage = String.Format("Http Request failed. Received HTTP Status Code: {0}",
response.StatusCode);
}
PHP Sample Code:
<?php
/*Initialize dossia client as shown in PHP sample code snippet of “New XML Document” DossiaAPI call.*/
/*Initialize with the Dossia OAuth URL end-points as shown in PHP sample code snippet of
“New XML Document” Dossia API call.*/
/*Initialize the key and secret with Dossia supplied key and Dossia generated secret respectively
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Get the tokens from Dossia OAuth server and initialize the access token and token secret
as shown in PHP sample code snippet of “New XML Document” Dossia API call.*/
/*Initialize the record ID for document creation */
$dossia->record_id = 't0FhmOk46GXiarC9VkEcmN7loEfGSQRR';
/*Initialize the input data*/
$key_id = '123';
/*Initialize API call */
$api_service = "records/".$dossia->record_id."/apps/documents/key/".$key_id;
$test_token = new OAuthConsumer($dossia->token, $dossia->token_secret);
$sig_method = $dossia->hmac_method;
if ($dossia->user_sig_method) $sig_method = $dossia->sig_methods[$dossia->user_sig_method];
$data_req = OAuthRequest::from_consumer_and_token($dossia->the_consumer, $test_token, "GET",
$dossia->service_path . $api_service, array());
$data_req->sign_request($sig_method, $dossia->the_consumer, $test_token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml',
"Authorization: OAuth " . implode(",", $data_req->get_parameters())));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
curl_close($ch);
/* Print the output */
echo $output;
?>
Application and Participant Synchronization facility (Available in Dossia 3.0)
This is a facility to help applications keep Participant Dossia records in unison with third party applications who cache data locally. We provide the ability to store a last sync date at application and participant level, however it is the calling applications responsibility to maintain these. We provide two levels of call to assist in identifying modifications to a participant medical record :-
- At application level we provide a call to list participants that have had modifications to their record.
- At participant level to identify which records have been modified.
This information can come back as either RSS or ATOM feeds.
As these calls are used in conjunction with OAuth it is important to note that the application consumer key will be used as the access token, and shared secret as the token secret.
Usage Guide
- Obtain Server Date.
- Identify participants with new or modified data (populate the modified_before parameter with the server date).
- For each participant
- Identify which records have changed (populate the modified_before parameter with the server date).
- Synchronize.
- Set the Participant Sync Date with the server date.
Parameters
When retrieving feed data the behavior can be modified by adding query parameters to the URL.
- offset - Specifies the offset into the collection of results to start sending documents back
- limit - Specifies the maximum number of documents to return
- modfied_since - filter results by only sending documents modified since date. Format is xml DateTime
- modified_before - filter results by only send documents modified before date. Format is xml DateTime
- include_self - If set participant searches will also identify data that the calling application has added
Format
- RSS - Specifies that RSS2.0 format should be returned
- ATOM - Specifies that ATOM2.0 format should be returned
Dossia Server Date
This should be called at the start of the synchronization process and the returned date should be used in subsequent queries / updates.
| Http Method | GET |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/feed/server_date |
| Input | n/a |
| Output | <Date>xsd:dateTime</Date> |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V3.0 |
Sample Output Document
<Date>2010-08-06T15:31:27.000-04:00</Date>
Application Sync Date
Simply lets an application store and retrieve a date
Setting Application Sync Date
| Http Method | POST |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/feed/sync_date |
| Input | <Date>xsd:dateTime</Date> |
| Output | n/a |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V3.0 |
Sample Input Document
<Date>2010-08-06T15:31:27.000-04:00</Date>
Getting Application Sync Date
| Http Method | GET |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/feed/sync_date |
| Input | n/a |
| Output | <Date>xsd:dateTime</Date> |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V3.0 |
Sample Output Document
<Date>2010-08-06T15:31:27.000-04:00</Date>
Participant Sync Date
Lets an application store and retrieve a date for the participant. This date will automatically be used (unless overridden) as a basis for finding any new participant data in subsequent queries
Setting Participant Sync Date
| Http Method | POST |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/feed/{recordId}sync_date |
| Input | <Date>xsd:dateTime</Date> |
| Output | n/a |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V3.0 |
Sample Input Document
<Date>2010-08-06T15:31:27.000-04:00</Date>
Getting Participant Sync Date
| Http Method | GET |
|---|---|
| Content-type | application/xml |
| URI | {dossia-api-endpoint}/feed/{recordId}/sync_date |
| Input | n/a |
| Output | <Date>xsd:dateTime</Date> |
| Http Return Codes | 200, 400, 401, 404 |
| API Version Compatibility | V3.0 |
Sample Output Document
<Date>2010-08-06T15:31:27.000-04:00</Date>
Identifying Participants with modified records
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/feed/{formatType} | |
| Allowed Params | offset , limit, modfied_since, modified_before | |
| Input | n/a | |
| Output | RSS2.0 or Atom | |
| Http Return Codes | 200, 400, 401, 404 | |
| API Version Compatibility | V3.0 | |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Dossia Participant Detail Synchronization Feed</title>
<link rel="alternate" href="http://www.dossia.org/feed/ATOM" />
<subtitle>Dossia Participant ID's of Participants that have had data changes.</subtitle>
<entry>
<title>ModifiedRecords</title>
<author>
<name>Dossia API</name>
</author>
<id>qO7k9WDv3VSDPEwSmZ3kLX21gtdUuINa</id>
<updated>2010-08-02T20:20:28Z</updated>
<published>2010-08-02T20:20:28Z</published>
<content type="text/xml">
<LastSyncDates xmlns="">
<InsertDate>2010-07-23T11:24:48.000-04:00</InsertDate>
<DeleteDate>2010-07-19T16:18:23.000-04:00</DeleteDate>
<OtherDate>2010-07-23T11:07:08.000-04:00</OtherDate>
</LastSyncDates>
</content>
<dc:creator>Dossia API</dc:creator>
<dc:date>2010-08-02T20:20:28Z</dc:date>
</entry>
<entry>
<title>ModifiedRecords</title>
<author>
<name>Dossia API</name>
</author>
<id>qO7k9WDv3VSDPEwSmZ3kLVy-imBeX2xr</id>
<updated>2010-08-02T20:20:28Z</updated>
<published>2010-08-02T20:20:28Z</published>
<content type="text/xml">
<LastSyncDates xmlns="">
<InsertDate>2010-07-19T17:53:27.000-04:00</InsertDate>
</LastSyncDates>
</content>
<dc:creator>Dossia API</dc:creator>
<dc:date>2010-08-02T20:20:28Z</dc:date>
</entry>
......
</feed>
Identifying New or Modified Participant Medical Records
This call will identifies new or modified participant medical records. The Participant Sync date is used for the start date (if it's setup), however the since_date parameter can be used to override that date. The format type should be either RSS or ATOM.
Identifying New or Modified Participant Medical Records
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/feed/{recordId}/{formatType} | |
| Allowed Params | offset , limit, modfied_since, modified_before, include_self | |
| Input | n/a | |
| Output | RSS2.0 or Atom | |
| Http Return Codes | 200, 400, 401, 404 | |
| API Version Compatibility | V3.0 | |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Dossia Participant Detail Synchronization Feed</title>
<link rel="alternate" href="http://www.dossia.org/qO7k9WDv3VSDPEwSmZ3kLX21gtdUuINa/feed/ATOM" />
<subtitle>Dossia Participant lists ID's of documents that have changed.</subtitle>
<entry>
<title>WRITE</title>
<author>
<name>SIMON FRENCH</name>
</author>
<updated>2010-07-23T04:00:00Z</updated>
<published>2010-07-23T04:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLeSjaaWWkNwj</content>
<dc:creator>SIMON FRENCH</dc:creator>
<dc:date>2010-07-23T04:00:00Z</dc:date>
</entry>
<entry>
<title>WRITE</title>
<author>
<name>Vanguard DATA SOURCE</name>
</author>
<updated>2010-05-20T04:00:00Z</updated>
<published>2010-05-20T04:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLfzz_PuRLsyX</content>
<dc:creator>Vanguard DATA SOURCE</dc:creator>
<dc:date>2010-05-20T04:00:00Z</dc:date>
</entry>
<entry>
<title>RELATE</title>
<author>
<name>Vanguard DATA SOURCE</name>
</author>
<updated>2010-04-09T04:00:00Z</updated>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLWsEW1CZiwKv</content>
<dc:creator>Vanguard DATA SOURCE</dc:creator>
</entry>
<entry>
<title>SUPPRESS</title>
<author>
<name>SIMON FRENCH</name>
</author>
<updated>2010-02-24T05:00:00Z</updated>
<published>2010-02-24T05:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLfLyX7j8ORBW</content>
<dc:creator>SIMON FRENCH</dc:creator>
<dc:date>2010-02-24T05:00:00Z</dc:date>
</entry>
</feed>
...........
Identifying New or Modified Participant Medical Records by Document Type
| Http Method | GET | |
|---|---|---|
| Content-type | application/xml | |
| URI | {dossia-api-endpoint}/feed/{recordId}/documentType/{document_type}/{formatType} | |
| Allowed Params | offset , limit, modfied_since, modified_before, include_self | |
| Input | n/a | |
| Output | RSS2.0 or Atom | |
| Http Return Codes | 200, 400, 401, 404 | |
| API Version Compatibility | V3.0 | |
Sample Output Document
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Dossia Participant Detail Synchronization Feed</title>
<link rel="alternate" href="http://www.dossia.org/qO7k9WDv3VSDPEwSmZ3kLX21gtdUuINa/feed/ATOM" />
<subtitle>Dossia Participant lists ID's of documents that have changed.</subtitle>
<entry>
<title>WRITE</title>
<author>
<name>SIMON FRENCH</name>
</author>
<updated>2010-07-23T04:00:00Z</updated>
<published>2010-07-23T04:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLeSjaaWWkNwj</content>
<dc:creator>SIMON FRENCH</dc:creator>
<dc:date>2010-07-23T04:00:00Z</dc:date>
</entry>
<entry>
<title>WRITE</title>
<author>
<name>Vanguard DATA SOURCE</name>
</author>
<updated>2010-05-20T04:00:00Z</updated>
<published>2010-05-20T04:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLfzz_PuRLsyX</content>
<dc:creator>Vanguard DATA SOURCE</dc:creator>
<dc:date>2010-05-20T04:00:00Z</dc:date>
</entry>
<entry>
<title>RELATE</title>
<author>
<name>Vanguard DATA SOURCE</name>
</author>
<updated>2010-04-09T04:00:00Z</updated>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLWsEW1CZiwKv</content>
<dc:creator>Vanguard DATA SOURCE</dc:creator>
</entry>
<entry>
<title>SUPPRESS</title>
<author>
<name>SIMON FRENCH</name>
</author>
<updated>2010-02-24T05:00:00Z</updated>
<published>2010-02-24T05:00:00Z</published>
<content type="text">qO7k9WDv3VSDPEwSmZ3kLfLyX7j8ORBW</content>
<dc:creator>SIMON FRENCH</dc:creator>
<dc:date>2010-02-24T05:00:00Z</dc:date>
</entry>
</feed>
...........
Data Element Definitions
| Element | Description | Notes | Required/Optional |
|---|---|---|---|
| Container | |||
| Document | Document holds payload of actual medical document (or) holds related documents (or) metadata related to documents. | Used in both input as well as output API calls. | |
| Document | |||
| Metadata | This holds metadata information related to a document (Used only in Output API Calls) | Used only in output API calls. | |
| Payload | This holds the medical documents i.e encounter, allergy etc., | Used in input as well as output API calls. | |
| relatedDocuments | This holds related documents to a parent document. | Used in input as well as output API calls. Used only when a parent document exist. | |
| Metadata | |||
| creationDate | Creation date of the document | | |
| professionallySourced | Flag that indicates whether the document is professionally sourced document. | | |
| startDate | start date indicates startdate of medical document type. | Refer Dossia Schemas for more information. | |
| endDate | end date indicates end date of medical document type . | Refer Dossia Schemas for more information. | |
| class | Indicates classification of the medical document type | Please refer to Dossia schemas for each indivual type class. | |
| classification | Indicates classification of source of data | Please refer to Dossia schemas for each indivual type classification. | |
| RelatedDocuments | |||
| document | this indicates the related document to parent document | True if the Allergen is negated with treatment. If unknown then False. | |
Document Type
| Element |
|---|
| Actor |
| Allergy |
| Annotation |
| Appointment |
| BinaryData |
| ClinicalReport |
| ClinicalTopic |
| Dental |
| Encounter |
| Equipment |
| FamilyHistory |
| Immunization |
| Insurance |
| LabTest |
| Measurement |
| Medication |
| MedicationFulfillment |
| MedicationCompliance |
| Micro |
| Participant |
| Problem |
| Procedure |
