Requirement Constraints

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 2 August 2013

HL7 Parsing

Posted on 22:59 by Unknown

I was working in parsing the HL7 ORU Message using HAPI. Found an interesting article by here by Ignacio Suay. Thanks mate for simple and quick example

Based on that, here is my example, But still finding a way to extract OBR, OBX and NTE Segments.

package com.product.HL7;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;
import ca.uhn.hl7v2.util.Terser;
import ca.uhn.hl7v2.validation.impl.NoValidation;

import com.product.domain.LabResults;

public class ParseFile {

static final Logger LOG = LoggerFactory.getLogger(ParseFile.class);
private String HL7Message;
private List<HL7Data> MSH = new ArrayList<HL7Data>();
private List<HL7Data> orderInfo = new ArrayList<HL7Data>();
private ParsingEvent parseingEvent;

public List<HL7Data> getOrderInfo() {
return orderInfo;
}

public void setOrderInfo(List<HL7Data> orderInfo) {
this.orderInfo = orderInfo;
}

public ParseFile(ParsingEvent parseingEvent) {
this.parseingEvent = parseingEvent;
}

public String getHL7Message() {
return HL7Message;
}

public List<HL7Data> getMSH() {
return MSH;
}

public void setMSH(List<HL7Data> mSH) {
MSH = mSH;
}

public void setHL7Message(String hL7Message) {
HL7Message = hL7Message;
}

public void parseMessage() throws HL7Exception {

String element;
String value;
HapiContext context = new DefaultHapiContext();
context.setValidationContext(new NoValidation());
PipeParser pipeParser = context.getPipeParser();
/* pipeParser.setValidationContext(new NoValidation()); */
Message message = pipeParser.parse(HL7Message);
Terser terser = new Terser(message);

LabResults labResults = new LabResults();

element = "Receiving Facility";
value = terser.get("/.MSH-6");
LOG.debug(element + " : " + value);
labResults.setDocAccountNo(value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Date";
value = terser.get("/.MSH-7");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient No";
value = terser.get("/.PID-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Lab Accession Number";
value = terser.get("/.PID-4");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Last Name";
value = terser.get("/.PID-5-1");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient First Name";
value = terser.get("/.PID-5-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Middle Name";
value = terser.get("/.PID-5-3");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient DOB";
value = terser.get("/.PID-7");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Sex";
value = terser.get("/.PID-8");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Address";
value = terser.get("/.PID-11-1");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient City";
value = terser.get("/.PID-11-2");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient State";
value = terser.get("/.PID-11-3");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Zip";
value = terser.get("/.PID-11-4");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Phone";
value = terser.get("/.PID-13");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Maritial Status";
value = terser.get("/.PID-16");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient EHR Number";
value = terser.get("/.PID-18");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient SS";
value = terser.get("/.PID-19");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Care Number";
value = terser.get("/.PID-20");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Caid Number";
value = terser.get("/.PID-21");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

element = "Patient Age";
value = terser.get("/.PID-23");
LOG.debug(element + " : " + value);
MSH.add(new HL7Data(element, value));
value = null;
element = null;

/*********************** Order Informaton ************************************/

element = "Lab Accession Number";
value = terser.get("/.ORC-2");
LOG.debug(element + " : " + value);
orderInfo.add(new HL7Data(element, value));
value = null;
element = null;

parseingEvent.parsingCompleted();

}
}

Some important note.
1. Hapi always expect \r at the end of the each segment. So if you have manually append the character at the end of the each segment Smile as i did in my example

	// convert InputStream to String
private static String getStringFromInputStream(InputStream is) {

BufferedReader br = null;
StringBuilder sb = new StringBuilder();

String line;
try {

br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
sb.append(line + "\r");
}

} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

return sb.toString();

}


2. HAPI will also validate the Message while parsing. If you want to avoid that, see my example above.

3. But i don’t think so my job is going to easy to fetch OBR and OBX and NTE segments using HAPI. I am trying with that, latest will post if i am able to complete.

Sample File
MSH|^~\&|mas|My LAB|mas|3535|201305280003||ORU^R01||P|2.3|
PID|1|PAT393929|^^^MRN~^^^CID~^^^ACCN|000035100|MOOAFEFERE^SCOOPDSTT^||19690608|M|||^^FL^|||||U|||||||43|y|
ORC|1|000035100|||CM||||201302271648|PAH|201302271700|^^^^     ^^^^^|||||355^MY HOUSE|0011 NW 10 STR^MYCITY^NY^11111^111-371-1111|3|PAH|
OBR|1|000035100||BATH SALTS^BATH SALTS|||20130131----|201302271651||||||201302271648||^^^^     ^^^^^||D|DRUGS||||||F|
OBX|1|TX|BATH SALTS^BATH SALTS|  ^D^[|NEGATIVE||-||||F||7|201302271651||PAH||

Email ThisBlogThis!Share to XShare to Facebook
Posted in EMR Labs Stuff, Today Tech Stuff | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • ZK Example for inline Editing with Add New and Delete
    I am quite impressed on this demo from ZK . But adding new record and delete existing record is missing as part of typical CRUD. So i thoug...
  • EDI 5010 Documentation 837 Professional - Loop 2010BB Payer Name
    2010BB Payer Name          In this loop, all the information will be taken from Insurance master screen. Take a look of our sample screen...
  • EDI 5010 Documentation–837 - BHT - Beginning of Hierarchical Transaction
    BHT – Beginning of Hierarchical Transaction Loop Seg ID Segment Name Format Length Ref# Req Value   BHT Beginning of Hier...
  • Hibernate Validator Example 2
    In this example, we will see some more validation constraints such as @email, @past, @length, etc. And also we will also define custom error...
  • ZK Passing Parameter between two files using MVVM–Part 1
    Overview This is the first series of articles about Passing parameter between two zul files using MVVM Design pattern .This article will fo...
  • MVVM Command annotation and Notify change example
    Here is an example, how to pass parameter on a zul through MVVM Command binding annotation. ZK URL http://books.zkoss.org/wiki/ZK%20Develo...
  • History of Present Illness
    HPI - One of the main component of Clinical History. What is an HPI ? The history of present illness (HPI) is a chronological description...
  • Patient Demographics
    Patient browse (search) is the key element for any EMR / PMS Software. In my past 15 years experience, i involved more than 5 times in desig...
  • ViewModel Class Java Annotation @Init, @NotifyChange, @Command
    In following sections we'll list all syntaxes that can be used in implementing a ViewModel and applying ZK bind annotation. The ZK binde...
  • Good Website Design Links
    Form Design Label Placement in Forms International Address Fields in Web Forms 40 Eye-Catching Registration Pages blog-comment-form-...

Categories

  • Billing Process
  • C Workbook
  • C++ Workbook
  • Eclipse Tips
  • EDI 5010
  • EMR Appointment Features
  • EMR Labs Stuff
  • EMR PMS Links
  • EMR Use cases
  • EMR Vital Sign
  • Good Website Design
  • Hibernate Criteria Queries
  • Hibernate Introduction
  • Hibernate Introduction Setup
  • Hibernate Mapping
  • Hibernate POC
  • Hibernate Validator
  • Hibernate–Java Environment setup
  • HPI
  • Java
  • Maven
  • MU Certification
  • NPI
  • PQRS
  • Practice Management System
  • Spring Security
  • Tech Links
  • Today Tech Stuff
  • zk
  • ZK Hibernate
  • ZK 5 Databinding
  • ZK Application
  • ZK Calling Another ZUL
  • ZK CheckBox
  • ZK CreateComponents
  • ZK CSS
  • ZK extended Components
  • ZK Foreach
  • ZK Forum Posts
  • ZK Framework
  • ZK Hibernate Setup
  • ZK ID Space
  • ZK Include
  • ZK Installation
  • ZK iReport
  • ZK Layout
  • ZK Listitem Pagination
  • ZK Message Box
  • ZK MVC
  • ZK MVC Combox Box
  • ZK MVC CRUD Examples
  • ZK MVC Listbox
  • ZK MVVM
  • ZK MVVM Combo
  • ZK MVVM CRUD
  • ZK MVVM ListBox
  • ZK Spring
  • ZK TextBox

Blog Archive

  • ▼  2013 (105)
    • ►  December (3)
    • ►  September (7)
    • ▼  August (13)
      • HL7 Parsing–My Own Parser
      • ZK Dropupload example
      • Hibernate Custom validator to validate Multiple em...
      • ZK List box inline Editing with Add New and Delete...
      • ZK Example for inline Editing with Add New and Delete
      • Patient Demographics and Patient cases
      • How to get Current Date and Time and store in the ...
      • Maintaining Patient Insurance
      • EDI Transactions
      • Health care Coding system
      • ZK upload PDF to server and show in the screen us...
      • ZK Quick InputBox
      • HL7 Parsing
    • ►  July (1)
    • ►  June (11)
    • ►  May (3)
    • ►  April (14)
    • ►  March (19)
    • ►  February (21)
    • ►  January (13)
  • ►  2012 (177)
    • ►  December (1)
    • ►  November (13)
    • ►  October (19)
    • ►  September (24)
    • ►  August (26)
    • ►  July (6)
    • ►  June (37)
    • ►  May (30)
    • ►  April (16)
    • ►  March (1)
    • ►  January (4)
  • ►  2011 (5)
    • ►  December (1)
    • ►  November (1)
    • ►  July (1)
    • ►  June (1)
    • ►  April (1)
  • ►  2010 (1)
    • ►  September (1)
Powered by Blogger.

About Me

Unknown
View my complete profile