Integrating – AWS EC2 (MySQL) to Mirth Engine

For this post. I have purchased a personal EC2 instance in AWS environment (a free tier for one year). Specifically an Amazon-AMI Image AWS instance with Fedora Operating System.

In the remote EC2 system, MySQL is deployed and a database is created as test. Once the DB is created in the EC2 instance, you have to create a table with some sample patient demographics information.

How to Access AWS remote server?

AWS_putty_access_1

Open the putty client and put the AWS amazon hostname in the Host Name or IP adress text box. Else you can put the elastic IP of your AWS instance there. It doesn’t always need to be a complete hostname.

  1. Then select SSH on the left side window of the putty and select on Auth. 
  2. Once you selected Auth on the right window pane click on the Browse button and select the private key you have downloaded from the amazon.
  3. This private key will be a .ppk file. This PPK file will be necessary to establish the SSH connectivity between your putty client and the AWS system.

Put_Private_Key_For_Access

  1. Once this is done click on the Open button on the bottom.
  2. Once you open you will be prompted to enter the username. If you purchased a Linux Ubuntu System the default user name will be ubuntu.
  3. If you have purchased a different system (say here I have purchased the Amazon AMI system). For the Amazon AMI system you need the password as ec2-user. 
  4. you can install MySQL linux distribution based the version you use. For Amazon AMI linux it uses the Fedora System. For Fedora use this command to install the MySQL. Before executing the below command do the command sudo yum update once.
dnf install mysql-community-server

For the Debian Ubuntu distribution use the below command for the MySQL installation

  • sudo apt-get update
  • sudo apt-get install mysql-server

Once installation is done. Log into your MySQL database on the AWS linux box. You can do this by typing the below command in the putty client box.

mysql -u root -p

Once it is done, you will enter into mysql> type show databases; initially you will not have a new database been created at your end. you have to create a new database for yourself. use the below command and create a new database.

create database test;

This will create a new database. Now we have to use this database and create the tables in it. Use the below command to use this database;

use test;

Here, test is the database name that i’m creating in the box. you can have the name of your choice. Then create a table with the following fields as provided in the screen shot below.

Mysql_Table_Structutre

  1. Once you have created it, log on to your AWS web console. And open the port in the security groups on the web console.
  2. Click on Edit button after selecting the security group and then add the port 3306 on TCP.
  3. Only when we do this the inbound socket of your remote system will open, then only your local Mirth system can establish the communication to the system in AWS environment.

In case if you install any application server like the Apache or Tomcat you would initially want to open the specific ports which are specified in the httpd.conf or catalina.conf files. We want to go to the security group on the AWS console and then open enable those inbound ports, then only your (IP+Port) combination will work in the browser, this IP+Port combination is technically referred as Socket.

Create a channel in your local Mirth Connect. make the source to the javascript reader and keep the polling frequency of your interest to fetch the data from the DB. In the source connector area provide the following code.

var dbConn;
// AWS Mysql Credentials
var mySqlDriver = “com.mysql.jdbc.Driver”;
// 54.175.172.38 – Server IP
// 3306 – Mysql Default Port number
// test – Database in Remote server
var mySqlConnectionTemplate = “jdbc:mysql://54.175.172.38:3306/test”;
var mySqlUserName = “root”;

// Create Parent Tag <PatientDemographics>
var patientDemographicsXml = new XML(‘<PatientDemographics></PatientDemographics>’);
// Create Parent for individual patient information <IndividualPatientInformation>
var individualPatientInfoXml = new XML(‘<IndividualPatientInformation></IndividualPatientInformation>’);

try {
// MySQL connection Template
dbConn = DatabaseConnectionFactory.createDatabaseConnection(mySqlDriver, mySqlConnectionTemplate, mySqlUserName, );
// Select statement
// patient_information – is the table name
result = dbConn.executeCachedQuery(“select * from patient_information“);

// Loop through the resultset value
while (result.next()) {
individualPatientInfoXml[‘PatientId’] = result.getInt(“pid”);
individualPatientInfoXml[‘PatientFirstName’] = result.getString(“patient_first_name”);
individualPatientInfoXml[‘PatientLastName’] = result.getString(“patient_last_name”);
individualPatientInfoXml[‘PatientMiddleName’] = result.getString(“patient_middle_ name”);
individualPatientInfoXml[‘PatientSuffixName’] = result.getString(“patient_suffix_name”);
individualPatientInfoXml[‘PatientDateOfBirth’] = result.getString(“patient_date_of_birth”);
individualPatientInfoXml[‘PatientGender’] = result.getString(“patient_gender”);
individualPatientInfoXml[‘PatientAge’] = result.getInt(“patient_age”);
individualPatientInfoXml[‘PatientAddress1’] = result.getString(“patient_address_1”);
individualPatientInfoXml[‘PatientAddress2’] = result.getString(“patient_address_2”);
individualPatientInfoXml[‘PatientEmailAddress’] = result.getString(“patient_emailAddress”);
individualPatientInfoXml[‘PatientTelecomNumber’] = result.getString(“patient_telecom_number”);
individualPatientInfoXml[‘PatientRace’] = result.getString(“patient_race”);
individualPatientInfoXml[‘PatientEthincity’] = result.getString(“patient_ethincity”);
individualPatientInfoXml[‘PatientMaritalStatus’] = result.getString(“patient_maritalstatus”);
individualPatientInfoXml[‘PatientLanguage’] = result.getString(“patient_language”);
individualPatientInfoXml[‘PatientCountry’] = result.getString(“patient_country”);
individualPatientInfoXml[‘PatientState’] = result.getString(“patient_state”);
individualPatientInfoXml[‘PatientCity’] = result.getString(“patient_city”);
individualPatientInfoXml[‘PatientZipCode’] = result.getString(“patient_zipcode”);
individualPatientInfoXml[‘PatientSSN’] = result.getString(“patient_ssn”);
individualPatientInfoXml[‘PatientDriverLicense’] = result.getString(“patient_driver_license”);

patientDemographicsXml[‘PatientDemographics’] += individualPatientInfoXml;

individualPatientInfoXml = new XML(‘<IndividualPatientInformation></IndividualPatientInformation>’);
}

msg = patientDemographicsXml;

return msg;

} finally {
if (dbConn) {
dbConn.close();
}
}

Once the connector code is created then you will be able to fetch all the data which are available in the database as a batch, instead of single row entries. You will be able to accumulate all the data from the database on each row as shown below:

Mysql_data_from_table

These data will be accumulated inside mirth as a XML data created in batch and the output of your mirth data will be as shown below:

<PatientDemographics>
<IndividualPatientInformation>
<PatientId>3301</PatientId>
<PatientFirstName>Jennifer</PatientFirstName>
<PatientLastName>Jaquline</PatientLastName>
<PatientMiddleName>Fernandez</PatientMiddleName>
<PatientSuffixName>III</PatientSuffixName>
<PatientDateOfBirth>1994-04-01</PatientDateOfBirth>
<PatientGender>F</PatientGender>
<PatientAge>23</PatientAge>
<PatientAddress1>No:8, washington, test drive</PatientAddress1>
<PatientAddress2>Oregan, detroit</PatientAddress2>
<PatientEmailAddress>jenn@test.com</PatientEmailAddress>
<PatientTelecomNumber>12356722</PatientTelecomNumber>
<PatientRace>2106-3</PatientRace>
<PatientEthincity>2131-5</PatientEthincity>
<PatientMaritalStatus>S</PatientMaritalStatus>
<PatientLanguage>EN</PatientLanguage>
<PatientCountry>US</PatientCountry>
<PatientState>GA</PatientState>
<PatientCity>oregan</PatientCity>
<PatientZipCode>55023</PatientZipCode>
<PatientSSN>123456789</PatientSSN>
<PatientDriverLicense>AXXW12345</PatientDriverLicense>
</IndividualPatientInformation>
<IndividualPatientInformation>
<PatientId>3302</PatientId>
<PatientFirstName>James</PatientFirstName>
<PatientLastName>Rupert</PatientLastName>
<PatientMiddleName>Jones</PatientMiddleName>
<PatientSuffixName>IV</PatientSuffixName>
<PatientDateOfBirth>1993-04-22</PatientDateOfBirth>
<PatientGender>M</PatientGender>
<PatientAge>24</PatientAge>
<PatientAddress1>4/12 Stevie Street, jj colony</PatientAddress1>
<PatientAddress2>Michigan, detroit</PatientAddress2>
<PatientEmailAddress>james@test.com</PatientEmailAddress>
<PatientTelecomNumber>12005678</PatientTelecomNumber>
<PatientRace>2028-9</PatientRace>
<PatientEthincity>2131-5</PatientEthincity>
<PatientMaritalStatus>M</PatientMaritalStatus>
<PatientLanguage>EN</PatientLanguage>
<PatientCountry>US</PatientCountry>
<PatientState>OR</PatientState>
<PatientCity>Oregan</PatientCity>
<PatientZipCode>44336</PatientZipCode>
<PatientSSN>987654321</PatientSSN>
<PatientDriverLicense>AXXE12309</PatientDriverLicense>
</IndividualPatientInformation>
</PatientDemographics>

Happy Integrations !!!!!

 

Advertisements

Parse responses in response tab

Imagine that we are sending certain data to external sources and we are getting response from those source. Now the received response has to be parsed inside the response tab.

APPROACH 1:

Imagine we are receiving an HTML response like this as provided below:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″/>
<title>401 – Unauthorized: Access is denied due to invalid credentials.</title>
<style type=”text/css”>
<!–
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:”trebuchet MS”, Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
–>
</style>
</head>
<body>




401 – Unauthorized: Access is denied due to invalid credentials.


You do not have permission to view this directory or page using the credentials that you supplied.



</div>
</body>
</html>

We need to get the status that we are receiving on this and make business logic accordingly. For example,  here on this HTML response we are supposed to parse the status value 401, and if it is 401 then we need to perform actions accordingly.

This can be achieved by using external library called JSOUP that is used for parsing HTML via JAVA. download the jsoup jar library and then test it in the JAVA first using any version of eclipse. Find the JAVA code below:

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class TestHtml {
public void htmlDataReader() {
String htmlData =””; // your html string
Document doc = Jsoup.parse(htmlData);
Document doc = Jsoup.parse(htmlData);
Elements tds = doc.getElementsByTag(“h2”);
String text = tds.text();
System.out.println(“Data : “+ text.substring(0,3));
}
public static void main (String args[]) {
TestHtml val =  new TestHtml();
val.htmlDataReader();
}
}

Output : Data: 401

The corresponding Mirth code for the above JAVA code will be as follows:

importPackage(org.jsoup);
var doc = Jsoup.parse(msg);
var tds = doc.getElementsByTag(“h2”);
var text = tds.text();
var responseStatusValue = text.substring(0,3);
if(responseStatusValue==’401′){
logger.debug(“Data : “+ text.substring(0,3));
// Business logic below of your choice
}

APPROACH 2:

If we are going to parse the HTML data through mirth itself without using any external library, then it is little challenging because the tag <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”> is expected to come in HTML, but ex4 will not be considering this element as a XML tag. So mirth will not take this data as a XML and allow us to parse the message as normal XML.

Make your source listener as RAW instead of XML then only it will be consumed inside Mirth. In the pre-processor of the mirth write the following code:

var pattern = $gc(‘pattern’);
if (!pattern) {
pattern = java.util.regex.Pattern.compile(‘^(\\s*(<\\?xml.*\\?>)?\\s*(<!DOCTYPE[^\\[>]*(\\[\\s*(<![^>]*>\\s*)*\\])?[^>]*>)?\\s*)’);
$gc(‘pattern’, pattern);
}
var prolog = ”;
var matcher = pattern.matcher(message);
if (matcher.find()) {
prolog = matcher.group(1);
message = message.substring(0, matcher.start(1)) + message.substring(matcher.end(1));
}
$c(‘prolog’, prolog);
return message;

Inside the source transformer provide the following code. you can use ‘msg’ inside the source transformer since, those DOCTYPE! will be removed inside the pre-processor. Your pre-processor is the first place where your code reaches at first followed by other stages of mirth interface engine.

var responseData = msg[‘body’][‘div’][1][‘div’][‘fieldset’][‘h2’].toString();
var responseData = msg[‘body’][‘div’][1][‘div’][‘fieldset’][‘h2’].toString();
logger.debug(msg[‘body’][‘div’][1][‘div’][‘fieldset’][‘h2’].toString());
var responseDataStatus = responseData.substring(0,3);
if(responseDataStatus==’401′){
logger.debug(“RESPONSE DATA : “+responseDataStatus);
// Your business Logic
}

APPROACH 3:

You can also perform this activity in the summary of the channel. As shown in the picture below:

summary javascript

Click on the properties tab, and provide the following code. This code is basically the replace code that we will be using to remove the incoming namespace.

message.replace(‘<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>&#8217;,”);
return message;

Similar to the scripts tab, we should be using message here instead of msg. From 3.4 version mirth has made this javascript properties tab available in the summary of the channel, which will be executed at first instead of the pre-processor.

Inside transformer we can use the code that we have used for Approach 2 directly. it will work fine.

APPROACH 4:

If we want the same to be achieved in response tab, then we cannot use approach 2 or approach 3. In that case we can use the inbuilt function $(‘responseStatusLine’) which will contain the corresponding HTTP responses such as 500,401 or 200.

We can call this function directly and use it in response transformer as provided below:

if($(‘responseStatusLine’).contains(‘401’)){
//Your business logic goes here…
}

Remove Segments from CCDA

Aim :

Let us consider that you want to remove certain segments from the incoming CCDA message structure, which your end client thinks that it is not needed for them to receive. How can we remove those specific segments from all  the incoming CCDA files?

Pre-requisite :

  • MirthConnect : 3.4.1.8057 (latest version) — Any previous versions also OK

Channel setup :

  1. Create a New channel name it as your wish Here I have named CCDA Mofification
  2. Click on Set Data Types button set the source connector inbound to XML
  3. Outbound and Destination 1 to XML
     – that’s it the channel setup is done for it.

Source Transformer :

  • Go to the source transformer and right click to create a new step
  • Name the step as Remove segment
  • Select the drop-down of  the step that you have created and select Javascript

 

let us assume that we don’t require the Vital signs segment from the incoming CCDA, though Vital signs segment is very important, I’m just using this to show demo in a very clear and easier format.

Write the following code in the transformer area:

var messageLength = msg[‘component’][‘structuredBody’][‘component’].length();
for(itr=0;itr<messageLength;itr++)
{
if(msg[‘component’][‘structuredBody’][‘component’][itr][‘section’][‘templateId’][‘@root’]==”2.16.840.1.113883.10.20.22.2.4.1″)
{
logger.info(“incoming Message : “+msg);
var removedSeg = msg[‘component’][‘structuredBody’][‘component’][itr][‘section’];
channelMap.put(“removedSegment”,removedSeg);
delete msg[‘component’][‘structuredBody’][‘component’][itr][‘section’];
logger.info(“outgoing Message : “+msg);
}

}

Consider that you provide the following sample data into mirth.

<ClinicalDocument xmlns=”urn:hl7-org:v3″ xmlns:cda=”urn:hl7-org:v3″ xmlns:sdtc=”urn:hl7-org:sdtc” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<realmCode code=”US”/>
<typeId extension=”POCD_HD000040″ root=”2.16.840.1.113883.1.3″/>
<templateId root=”2.16.840.1.113883.10.20.22.1.1″/>

………………………………………….
………………………………………….
………………………………………….
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.14″/>
<id extension=”Functional Status” root=”2.201″/>
<code code=”47420-5″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”FUNCTIONAL STATUS”/>
<title>Functional Status</title>
<text>
<table>
<thead>
<tr>
<th>Functional Condition</th>
<th>Effective Dates</th>
<th>Condition Status</th>
</tr>
</thead>
<tbody>
<tr>
<td/>
<td>null</td>
<td>completed</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.68″/>
<id root=”87347b49-c2ce-4e3e-9bf4-8fe09e9332db”/>
<code code=”” codeSystem=”2.16.840.1.113883.6.96″ displayName=”completed” xsi:type=”CE”/>
<statusCode code=”completed”/>
<effectiveTime>
<low value=”null”/>
<high value=”null”/>
</effectiveTime>
<value code=”” codeSystem=”2.16.840.1.113883.6.96″ displayName=”” xsi:type=”CD”/>
</observation>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.3.1″/>
<code code=”30954-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”RESULTS”/>
<title>Results</title>
<text>
<table>
<thead>
<tr>
<th>Test name</th>
<th>Date</th>
<th>Lab Name</th>
<th>Measure</th>
<th>Units</th>
<th>Reference Range</th>
<th>Lab Value</th>
</tr>
</thead>
<tbody>
<tr>
<td/>
<td>20141015</td>
<td>
<name>Century Hospital</name>
<name>Century Hospital</name>
<name>Century Hospital</name>
<name>Century Hospital</name>
</td>
<td>10^3/ul</td>
<td>10^3/ul</td>
<td> – </td>
<td>220.00</td>
</tr>
</tbody>
</table>
</text>
<entry>
<organizer classCode=”BATTERY” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.1″/>
<id root=”e673e7ec-effc-445c-8d4d-b723ad8327aa”/>
<code code=”43789009″ codeSystem=”2.16.840.1.113883.6.96″ codeSystemName=”SNOMED-CT” displayName=”CBC WO Differential” xsi:type=”CE”/>
<statusCode code=”completed”/>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.2″/>
<id root=”c6a6491d-c11e-425a-ac72-028cb6624783″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20141015″/>
<value unit=”10^3/ul” value=”220.00″ xsi:type=””/>
<author>
<time value=””/>
<assignedAuthor>
<id root=”c6a6491d-c11e-425a-ac72-028cb6624783″/>
<representedOrganization>
<name>&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;</name>
</representedOrganization>
</assignedAuthor>
</author>
<referenceRange>
<observationRange>
<value xsi:type=””>
<low unit=”” value=””/>
<high unit=”” value=””/>
</value>
</observationRange>
</referenceRange>
</observation>
</component>
</organizer>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.17″/>
<id extension=”SocialHistory” root=”17eae709-d72c-4b04-a75e-03facbe243d9″/>
<code code=”29762-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Social history”/>
<title>Social History</title>
<text>
<table>
<thead>
<tr>
<th>Description</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Current every day smoker</td>
<td>20141120</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.78″/>
<id extension=”12345″ root=”2.16.840.1.113883.19″/>
<code code=”ASSERTION” codeSystem=”2.16.840.1.113883.5.4″/>
<statusCode code=”completed”/>
<effectiveTime>
<low value=”20141120″/>
<high value=”null”/>
</effectiveTime>
<value code=”449868002″ codeSystem=”2.16.840.1.113883.6.96″ displayName=”Current every day smoker” xsi:type=”CD”/>
</observation>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.4.1″/>
<id extension=”VitalSigns” root=”17eae709-d72c-4b04-a75e-03facbe243d9″/>
<code code=”8716-3″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Vital signs”/>
<title>Vital Signs</title>
<text>
<table>
<thead>
<tr>
<th>Date / Time</th>
<th>Height</th>
<th>Weight</th>
<th>BMI</th>
<th>BP</th>
</tr>
</thead>
<tbody>
<tr>
<td>20140923</td>
<td>190 in</td>
<td>200 lbs</td>
<td>3.89 NI</td>
<td>220/120</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<organizer classCode=”CLUSTER” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.26″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”46680005″ codeSystem=”2.16.840.1.113883.6.96″ codeSystemName=”SNOMED-CT” displayName=”Vital signs”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”8302-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Height”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”in” value=”190″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”3132″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Weight”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”lbs” value=”200″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”39151″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Body Mass Index”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”3.89″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”220″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”120″ xsi:type=””/>
</observation>
</component>
</organizer>
</entry>
</section>
</component>
</structuredBody>
</component>
</ClinicalDocument>

Note : This is a sample data taken from an online open source. You can just google it to find any simple open source CCDA files.

You will get an output like this as follows :

<ClinicalDocument xmlns=”urn:hl7-org:v3″ xmlns:cda=”urn:hl7-org:v3″ xmlns:sdtc=”urn:hl7-org:sdtc” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
<realmCode code=”US”/>
<typeId extension=”POCD_HD000040″ root=”2.16.840.1.113883.1.3″/>
<templateId root=”2.16.840.1.113883.10.20.22.1.1″/>

………………………………………….
………………………………………….
………………………………………….

<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.14″/>
<id extension=”Functional Status” root=”2.201″/>
<code code=”47420-5″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”FUNCTIONAL STATUS”/>
<title>Functional Status</title>
<text>
<table>
<thead>
<tr>
<th>Functional Condition</th>
<th>Effective Dates</th>
<th>Condition Status</th>
</tr>
</thead>
<tbody>
<tr>
<td/>
<td>null</td>
<td>completed</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.68″/>
<id root=”87347b49-c2ce-4e3e-9bf4-8fe09e9332db”/>
<code code=”” codeSystem=”2.16.840.1.113883.6.96″ displayName=”completed” xsi:type=”CE”/>
<statusCode code=”completed”/>
<effectiveTime>
<low value=”null”/>
<high value=”null”/>
</effectiveTime>
<value code=”” codeSystem=”2.16.840.1.113883.6.96″ displayName=”” xsi:type=”CD”/>
</observation>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.3.1″/>
<code code=”30954-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”RESULTS”/>
<title>Results</title>
<text>
<table>
<thead>
<tr>
<th>Test name</th>
<th>Date</th>
<th>Lab Name</th>
<th>Measure</th>
<th>Units</th>
<th>Reference Range</th>
<th>Lab Value</th>
</tr>
</thead>
<tbody>
<tr>
<td/>
<td>20141015</td>
<td>
<name>Century Hospital</name>
<name>Century Hospital</name>
<name>Century Hospital</name>
<name>Century Hospital</name>
</td>
<td>10^3/ul</td>
<td>10^3/ul</td>
<td> – </td>
<td>220.00</td>
</tr>
</tbody>
</table>
</text>
<entry>
<organizer classCode=”BATTERY” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.1″/>
<id root=”e673e7ec-effc-445c-8d4d-b723ad8327aa”/>
<code code=”43789009″ codeSystem=”2.16.840.1.113883.6.96″ codeSystemName=”SNOMED-CT” displayName=”CBC WO Differential” xsi:type=”CE”/>
<statusCode code=”completed”/>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.2″/>
<id root=”c6a6491d-c11e-425a-ac72-028cb6624783″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20141015″/>
<value unit=”10^3/ul” value=”220.00″ xsi:type=””/>
<author>
<time value=””/>
<assignedAuthor>
<id root=”c6a6491d-c11e-425a-ac72-028cb6624783″/>
<representedOrganization>
<name>&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;&lt;name xmlns=”urn:hl7-org:v3″&gt;Century Hospital&lt;/name&gt;</name>
</representedOrganization>
</assignedAuthor>
</author>
<referenceRange>
<observationRange>
<value xsi:type=””>
<low unit=”” value=””/>
<high unit=”” value=””/>
</value>
</observationRange>
</referenceRange>
</observation>
</component>
</organizer>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.17″/>
<id extension=”SocialHistory” root=”17eae709-d72c-4b04-a75e-03facbe243d9″/>
<code code=”29762-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Social history”/>
<title>Social History</title>
<text>
<table>
<thead>
<tr>
<th>Description</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Current every day smoker</td>
<td>20141120</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.78″/>
<id extension=”12345″ root=”2.16.840.1.113883.19″/>
<code code=”ASSERTION” codeSystem=”2.16.840.1.113883.5.4″/>
<statusCode code=”completed”/>
<effectiveTime>
<low value=”20141120″/>
<high value=”null”/>
</effectiveTime>
<value code=”449868002″ codeSystem=”2.16.840.1.113883.6.96″ displayName=”Current every day smoker” xsi:type=”CD”/>
</observation>
</entry>
</section>
</component>
<component>
<section>
<templateId root=”2.16.840.1.113883.10.20.22.2.4.1″/>
<id extension=”VitalSigns” root=”17eae709-d72c-4b04-a75e-03facbe243d9″/>
<code code=”8716-3″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Vital signs”/>
<title>Vital Signs</title>
<text>
<table>
<thead>
<tr>
<th>Date / Time</th>
<th>Height</th>
<th>Weight</th>
<th>BMI</th>
<th>BP</th>
</tr>
</thead>
<tbody>
<tr>
<td>20140923</td>
<td>190 in</td>
<td>200 lbs</td>
<td>3.89 NI</td>
<td>220/120</td>
</tr>
</tbody>
</table>
</text>
<entry typeCode=”DRIV”>
<organizer classCode=”CLUSTER” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.26″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”46680005″ codeSystem=”2.16.840.1.113883.6.96″ codeSystemName=”SNOMED-CT” displayName=”Vital signs”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”8302-2″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Height”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”in” value=”190″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”3132″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Weight”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”lbs” value=”200″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”39151″ codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=”Body Mass Index”/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”3.89″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”220″ xsi:type=””/>
</observation>
</component>
<component>
<observation classCode=”OBS” moodCode=”EVN”>
<templateId root=”2.16.840.1.113883.10.20.22.4.27″/>
<id root=”14c09c70-b5b1-470d-9fa4-c5a1e0562681″/>
<code code=”” codeSystem=”2.16.840.1.113883.6.1″ codeSystemName=”LOINC” displayName=””/>
<statusCode code=”completed”/>
<effectiveTime value=”20140923″/>
<value unit=”NI” value=”120″ xsi:type=””/>
</observation>
</component>
</organizer>
</entry>
</section>
</component>
</structuredBody>
</component>
</ClinicalDocument>

This is a generalized code, that will remove the vital signs status for any incoming CCDA files. You can just change the template ID of the above provided code and remove any data that you want to remove to achieve this.

 

 

 

Blog at WordPress.com.

Up ↑