FHIR – POST data to Remote Server

In the previous blog, we have demonstrated how to GET the FHIR data from  the remote server. This blog post will be a continuation of the previous post, so the Mirth version that I will be using for this will be 3.4.2

As I previously said, latest version of Mirth 3.5 has FHIR listening and sending capability In-built in it. If you want to have a sophisticated FHIR sending and listening capability the best way is to choose 3.5 verison of Mirth.

We have got the data from the remote FHIR server. Now how do we update the data? to the remote server?

For this we are creating a new channel FHIR – Sender :

  1. Configure a new destination in the FHIR – Fetcher channel with the same listening port number of FHIR-Sender channel’s HTTP listener
  2. the content-type will be text/plain. And in the template provide the channel map variable ${getResponse}. We have used this same variable in the
  3. The listener of new channel FHIR-Sender will be a HTTP listener with a port number same as specified in the outbound channel of FHIR – Fetcher.
  4. To test, if the new channel is receiving the same data sent by the previous channel do a quick test in source transformer of the new channel by using the below code: logger.info(“Inside 2nd Channel : “+connectorMessage.getRawData());
  5. Note: connectorMessage is an important and very useful object in Mirth Javascript. This is supposed to fetch raw data, response data, transformed data and processed data efficiently from source to destination or from one channel to another.
  6. In the outbound message template provide the following XML template <Observation xmlns=”http://hl7.org/fhir”><Observation xmlns=”http://hl7.org/fhir”>   <id value=”66b0787a-b0c6-4f58-bf6b-ff5f7129658e”/>   <meta>      <versionId value=”2″/>      <lastUpdated value=”2017-05-26T11:54:50.782-04:00″/>      <profile value=”http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation”/>      <profile value=”http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-SocialHistory”/>      <tag>         <system value=”https://smarthealthit.org/tags”/>         <code value=”synthea-5-2017″/>      </tag>   </meta>   <status value=”final”/>   <category>      <coding>         <system value=”http://hl7.org/fhir/observation-category”/>         <code value=”social-history”/>      </coding>   </category>   <category>      <coding>         <system value=”http://ncimeta.nci.nih.gov”/>         <code value=”C2004062″/>      </coding>   </category>   <code>      <coding>         <system value=”http://loinc.org”/>         <code value=”76690-7″/>         <display value=”Sexual orientation”/>      </coding> <text value=”VibinChander-Test-1″/>   </code>   <subject>      <reference value=”Patient/73f8dd15-e42f-48c4-a6b2-98f2253fb8ef”/>   </subject>   <context>      <reference value=”Encounter/b74c4ab6-e9bb-4c5b-a805-8e65e1880278″/>   </context>   <effectiveDateTime value=”2008-06-05T06:59:12-04:00″/>   <issued value=”2008-06-05T06:59:12-04:00″/>   <valueQuantity>      <value value=”0″/>      <unit value=”{nominal}”/>      <system value=”http://unitsofmeasure.org/”/>      <code value=”{nominal}”/>   </valueQuantity></Observation>
  7.  The uhn FHIR server takes updating of data only in the form of XML rather than JSON. So basically we are fetching the JSON from the first channel then we have to transform the JSON to XML in another channel then send the updated XML from the new channel  to hit the remote FHIR server.
  8. Here, I’m skipping the conversion part from JSON to XML and hard-coding the XML part as it is. In the above XML I have modified only one tag <text value=”VibinChander-Test-1″/> if you modify the other tags on this you may get error in updating the status of FHIR because the API  is constructed to validate the contents of FHIR as well.
  9. After Deployment in the sender channel’s response you can find this tag “Observation/66b0787a-b0c6-4f58-bf6b-ff5f7129658e/_history/10” this URL is accessible in the publicly which will provide you the updated status.
  10. The sender type of the new channel has to be PUT not POST and the corresponding URL for that will be https://fhirtest.uhn.ca/baseDstu3/Observation/66b0787a-b0c6-4f58-bf6b-ff5f7129658e?_format=xml&_pretty=true
  11. you will find the updated data you have made in this URL https://fhirtest.uhn.ca/baseDstu3/Observation/66b0787a-b0c6-4f58-bf6b-ff5f7129658e/_history/10

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: