HL7 Parsing–My Own Parser

In my previous post, i showed how to use HAPI for parsing HL7 File. But for my current assignment , i am not able to go further on HAPI. Here is my requirement

1. I need to parse Patient lab result ORU^R01 Message type
2. Here is the structure of the message

MSH
PID
ORC
IN1
IN2...IN4
DG1....DG4
OBR (N times, under each OBR, there can be N number of OBXs)
----> OBX1....OBXn
----------NTEs(Some time OBX may also contain NTEs
NTE(Some times, OBR may not have OBX, but they have NTEs

3. And here is the challenge, upfront i will not know how many DG, OBR and under each OBR, how many OBXs are present in the result file. So without any looping mechanism, we cannot parse the file and convert into human readable text.
4. I tried with lot with HAPI to achieve the desired result, but no luck. May be because of the following reasons
            a) HAPI Does not have much examples to show the power of the parser of each Message type
            b) I do not have time to read their API and form the example Smile

            c) Finally HAPI does not have ability to parse the multiple OBR and OBX


So i decided to drop HAPI and started my own parser. I have been working in Health care industry for more than 14 years, so understanding the terminology/domain is not a problem for me. Writing our own parser is fun for me, because i have the done the same thing in VB6 successfully.  But this time with java. Here is the detail code.

package hl7.parse;

import java.util.HashMap;
import java.util.Map;

public class MyParser {

String message;
private Long totalLines = (long) 0;
private Long MSHCount = (long) 0;
private Long PIDCount = (long) 0;
private Long ORCCount = (long) 0;
private Long totalDGs = (long) 0;
private Long OBRCounter = (long) 0;
private Long OBXCounter = (long) 0;
private String MSH;
private String PID;
private String ORC;
private Map<String, String> element = new HashMap<String, String>();
private String currentOBR;

public Long getTotalDGs() {
return totalDGs;
}

public Long getTotalOBRs() {
return OBRCounter;
}

public Long getORCCount() {
return ORCCount;
}

public String getORC() {
return ORC;
}

public String getMSH() {
return MSH;
}

public String getPID() {
return PID;
}

public Long getPIDCount() {
return PIDCount;
}

public Long getMSHCount() {
return MSHCount;
}

public Long getTotalLines() {
return totalLines;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public MyParser(String message) {
this.message = message;
}

public String getValue(String key) {
return element.get(key);
}

public void parseIt() {
String delimiter = "\\r";
String[] temp;
temp = message.split(delimiter);
for (int i = 0; i < temp.length; i++) {
// Store the lines if developer wants it
element.put("Segment-" + i, temp[i]);
parseSegment(temp[i]);
totalLines++;
}

// Write the final one
// Store the total OBX Count -- OBR[1]OBX-count
if (this.currentOBR != null) {
String key = "OBR[" + OBRCounter + "]" + "OBX-count";
element.put(key, String.valueOf(OBXCounter));

}
}

private void parseSegment(String line) {
String segment;
segment = line.substring(0, 3);
if (segment.equalsIgnoreCase("MSH"))
parseMSH(line);

if (segment.equalsIgnoreCase("PID"))
parsePID(line);

if (segment.equalsIgnoreCase("ORC"))
parseORC(line);

if (segment.equalsIgnoreCase("DG1") || segment.equalsIgnoreCase("DG2")
|| segment.equalsIgnoreCase("DG3")
|| segment.equalsIgnoreCase("DG4"))
parseDGs(line);

if (segment.equalsIgnoreCase("OBR"))
parseOBRs(line);

if (segment.equalsIgnoreCase("OBX"))
parseOBXs(line);

}

private void parseDGs(String line) {

String delimiter = "\\|";
String[] temp;
temp = line.split(delimiter);
totalDGs++;
element.put("DG-" + totalDGs, line);
element.put("DG-" + totalDGs + "-count", String.valueOf(temp.length));
for (int i = 0; i < temp.length; i++) {
element.put("DG[" + totalDGs + "]-" + i, temp[i]);
}

}

private void parseOBRs(String line) {

String delimiter = "\\|";
String[] temp;
temp = line.split(delimiter);

// Store the total OBX Count -- OBR[1]OBX-count
if (this.currentOBR != null) {
String key = "OBR[" + OBRCounter + "]" + "OBX-count";
element.put(key, String.valueOf(OBXCounter));
}
OBRCounter++;
element.put("OBR[" + OBRCounter + "]", line);
element.put("OBR[" + OBRCounter + "]" + "-count",
String.valueOf(temp.length));
this.currentOBR = "OBR[" + OBRCounter + "]";
// Reset the OBX counter
OBXCounter = (long) 0;
for (int i = 0; i < temp.length; i++) {
element.put("OBR[" + OBRCounter + "]-" + i, temp[i]);
if (i == 4 || i == 16) //
{
parseSubComponent(temp[i], "OBR[" + OBRCounter + "]-" + i);
}
}

}

private void parseOBXs(String line) {

// Here we need to carefull, OBX are under OBR, so we need to attach to
// the correct OBR
String delimiter = "\\|";
String[] temp;
String key;
temp = line.split(delimiter);
OBXCounter++;
key = this.currentOBR + "OBX[" + OBXCounter + "]";
// Very first thing is, We need to Print the OBX Line under OBR as
// OBR[1]OBX[1]
element.put(key, line);
// OBR[1]OBX[1]-count
element.put(key + "-count", String.valueOf(temp.length));
// OBR[1]OBX[1]-1, // OBR[1]OBX[1]-2,etc
for (int i = 0; i < temp.length; i++) {
element.put(key + "-" + i, temp[i]);
}
}

private void parseMSH(String line) {

String delimiter = "\\|";
String[] temp;
temp = line.split(delimiter);
this.MSH = line;
for (int i = 0; i < temp.length; i++) {
element.put("MSH-" + i, temp[i]);
MSHCount++;
}

}

private void parseORC(String line) {

String delimiter = "\\|";
String[] temp;
temp = line.split(delimiter);
this.ORC = line;
for (int i = 0; i < temp.length; i++) {
element.put("ORC-" + i, temp[i]);
if (i == 12 || i == 17 || i == 18) //
{
parseSubComponent(temp[i], "ORC-" + i);
}
ORCCount++;
}

}

private void parsePID(String line) {

String delimiter = "\\|";
String[] temp;
temp = line.split(delimiter);
this.PID = line;
for (int i = 0; i < temp.length; i++) {

element.put("PID-" + i, temp[i]);
if (i == 5 || i == 11) // Let us parse patient Name
{
parseSubComponent(temp[i], "PID-" + i);
}
PIDCount++;
}

}

private void parseSubComponent(String line, String mapKey) {

String delimiter = "\\^";
String[] temp;
temp = line.split(delimiter);
int j;
for (int i = 0; i < temp.length; i++) {
j = i + 1;
element.put(mapKey + "-" + j, temp[i]);
}

}

}





public void onParse() {
String element;
String value;
String hl7Message = getStringFromInputStream("c:\\temp\\example1.hl7");
System.out.println("HL7 Content is " + hl7Message);
myParser = new MyParser(hl7Message);
myParser.parseIt();

element = "Receiving Facility";
value = myParser.getValue("MSH-5");
System.out.println(element + " : " + value);

element = "Patient No";
value = myParser.getValue("PID-2");
System.out.println(element + " : " + value);

element = "Lab Accession Number";
value = myParser.getValue("PID-4");
System.out.println(element + " : " + value);

element = "Patient Last Name";
value = myParser.getValue("PID-5-1");
System.out.println(element + " : " + value);

element = "Patient First Name";
value = myParser.getValue("PID-5-2");
System.out.println(element + " : " + value);

element = "Patient Middle Name";
value = myParser.getValue("PID-5-3");
System.out.println(element + " : " + value);

element = "Patient DOB";
value = myParser.getValue("PID-7");
System.out.println(element + " : " + value);

element = "Patient Sex";
value = myParser.getValue("PID-8");
System.out.println(element + " : " + value);

element = "Provider NPI";
value = myParser.getValue("ORC-12-1");
System.out.println(element + " : " + value);

element = "Provider Last Name";
value = myParser.getValue("ORC-12-2");
System.out.println(element + " : " + value);

element = "Provider First Name";
value = myParser.getValue("ORC-12-3");
System.out.println(element + " : " + value);

element = "Provider Initial";
value = myParser.getValue("ORC-12-5");
System.out.println(element + " : " + value);

element = "Account No";
value = myParser.getValue("ORC-17-1");
System.out.println(element + " : " + value);

element = "Account Name";
value = myParser.getValue("ORC-17-2");
System.out.println(element + " : " + value);

element = "Account Address";
value = myParser.getValue("ORC-18-1");
System.out.println(element + " : " + value);

element = "Account City";
value = myParser.getValue("ORC-18-2");
System.out.println(element + " : " + value);

element = "Account State";
value = myParser.getValue("ORC-18-3");
System.out.println(element + " : " + value);

element = "Account Zip";
value = myParser.getValue("ORC-18-4");
System.out.println(element + " : " + value);

element = "Account Phone";
value = myParser.getValue("ORC-18-5");
System.out.println(element + " : " + value);

System.out
.println("*********************************ALL ABOUT MSH ***********************");
// Let us print the MSH Values
for (int i = 0; i < myParser.getMSHCount(); i++) {
System.out.println("MSH-" + i + ": "
+ myParser.getValue("MSH-" + i));
}

// Ofcouse If you want to you get particular value also as follows
System.out.println("Please give me MSH[3] "
+ myParser.getValue("MSH-3"));

// Ofcourse You can also print MSH String
System.out.println("Please give me MSH Line..." + myParser.getMSH());

System.out
.println("*********************************ALL ABOUT PID ***********************");
// Ofcouse If you want to you get particular value also as follows
System.out.println("Please give me PID[3] "
+ myParser.getValue("PID-3"));

// Ofcourse You can also print PID String
System.out.println("Please give me PID Line..." + myParser.getPID());

// Component 1 [ST] family name (last name)
// Component 2 [ST] given name (first name)
// Component 3 [ST] middle initial or name
// Component 4 [ST] suffix (jr, sr, etc)
// Component 5 [ST] prefix (Mr, Mrs, Dr etc)
// Component 6 [ST] degree (MD, PHD etc)
// Component 7 [ID] name type code

// Ofcouse You can print Patient Last Name as follows
System.out.println("Please give me Patient Last Name "
+ myParser.getValue("PID-5-1"));

// Ofcouse You can print Patient First Name as follows
System.out.println("Please give me Patient First Name "
+ myParser.getValue("PID-5-2"));

// Ofcouse You can print Patient Address as follows
System.out.println("Please give me Patient Address "
+ myParser.getValue("PID-11-1"));

// Ofcouse You can print Patient Address as follows
System.out.println("Please give me Patient City "
+ myParser.getValue("PID-11-2"));

// Ofcouse You can print Patient Address as follows
System.out.println("Please give me Patient State "
+ myParser.getValue("PID-11-3"));

// Ofcouse You can print Patient Address as follows
System.out.println("Please give me Patient Zip "
+ myParser.getValue("PID-11-4"));

// Let us print the PID Values
for (int i = 0; i < myParser.getPIDCount(); i++) {
System.out.println("PID-" + i + ": "
+ myParser.getValue("PID-" + i));
}

System.out
.println("*********************************ALL ABOUT ORC***********************");
// Let us print the ORC Values
for (int i = 0; i < myParser.getORCCount(); i++) {
System.out.println("ORC-" + i + ": "
+ myParser.getValue("ORC-" + i));
}
// Ofcouse If you want to you get particular value also as follows
System.out.println("Please give me ORC[2] "
+ myParser.getValue("ORC-2"));

// Ofcourse You can also print ORC String
System.out.println("Please give me ORC Line..." + myParser.getORC());

System.out
.println("*********************************ALL ABOUT DG***********************");
// Total Number of DGs
System.out.println("Please give me Total DGs " + myParser.getTotalDGs());
// Let us print the DGs
for (int i = 1; i <= myParser.getTotalDGs(); i++) {
System.out.println("DG-" + i + ": " + myParser.getValue("DG-" + i));
}

for (int i = 1; i <= myParser.getTotalDGs(); i++) {
int total = Integer.parseInt(myParser
.getValue("DG-" + i + "-count"));
for (int j = 1; j < total; j++) {
System.out.println("DG[" + i + "]-" + j + " : "
+ myParser.getValue("DG[" + i + "]-" + j));
}

}

System.out
.println("*********************************ALL ABOUT OBR***********************");
// Total Number of OBRs
System.out.println("Please give me Total OBR " + myParser.getTotalOBRs());
// Let us print the OBRs
String key;
for (int i = 1; i <= myParser.getTotalOBRs(); i++) {
key = "OBR[" + i + "]";
System.out.println(key + " : " + myParser.getValue(key));
// We can also retieve the total elements in each OBR
System.out.println("Total Elements in " + key + " is "
+ myParser.getValue(key + "-count"));
}

for (int i = 1; i <= myParser.getTotalOBRs(); i++) {
key = "OBR[" + i + "]-count";
int total = Integer.parseInt(myParser.getValue(key));
for (int j = 1; j < total; j++) {
key = "OBR[" + i + "]-" + j;
System.out.println(key + " : " + myParser.getValue(key));
}

}

System.out
.println("*********************************ALL ABOUT OBX***********************");

key = "OBR[1]OBX-count";
// For given OBR, You can find how many OBXs are there as follows
System.out.println("Please give me Total OBXs in OBR[1] "
+ myParser.getValue(key));

key = "OBR[2]OBX-count";
System.out.println("Please give me Total OBXs in OBR[2] "
+ myParser.getValue(key));

key = "OBR[1]OBX[1]";
// You can also Print the OBX Line in each OBR as follows
System.out.println("Please give me OBX[1] in OBR[1] " + myParser.getValue(key));
key = "OBR[1]OBX-count";
int total = Integer.parseInt(myParser.getValue(key));

// You can also Print all OBXs in OBR[1]
for (int i = 1; i <= total; i++) {
key = "OBR[1]OBX[" + i + "]";
System.out.println("OBR[1]OBX[" + i + "] => " + myParser.getValue(key));
}

// Dont know how many OBRs and how many OBXs in each OBRs, no problem,
// we can put them in the loop
for (int i = 1; i <= myParser.getTotalOBRs(); i++) {
key = "OBR[" + i + "]";
System.out.println(key + " : " + myParser.getValue(key));
key = key + "OBX-count";
total = Integer.parseInt(myParser.getValue(key));
for (int j = 1; j <= total; j++) {
key = "OBR[" + i + "]" + "OBX[" + j + "]";
System.out.println("----->" + key + " : " + myParser.getValue(key));
}
}
}

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

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

String line;
try {
br = new BufferedReader(new FileReader(fileName));
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();

}

Sample HL7 File


MSH|^~\&|mas|MY XXXX LAB|mas|100|201303201430||ORU^R01||P|2.3|
PID|1|K2TE154871|^^^MRN~^^^CID~^^^ACCN|234567892|K2^TEST^||19640512|M|||^^FL^|||||U|||||||0||
ORC|1|000133423|||CM||||201206132103|PHH|201206141230|^^^^     ^^^^^|||||261^XXXX CARE CENTER|31231 IN.STATE ROAD 17 SUITE 102^LAUDERHILL^NY^22313^95455848444|3|PHH|
IN1|1|09102|MCARE|MEDICARE PART B|PO BOX 44117^^JACKSONVILLE^FL^322310018||8664549007||MEDICARE PART B|||||||K2^TEST^|01|00000000|^^NY^||||||||||||||||||||||||||||T|
DG1|1|ICD|319|UNSPECIFIED MENTAL RETARDATION|||||||||||||BUIR154337^000039106|
DG2|1|ICD|30490|UNSPECIFIED DRUG DEPENDENCE, UNSPECIFIED USE|||||||||||||HOJA159610^000039110|
OBR|1|234567892||22014^K2S|||201211151512|201211151514||||||201211151512||^^^^     ^^^^^||A|GENERAL CHEMISTRY||||||X|
OBX|1|TX|22014^K2S|  ^A^A|X||-||||X||9|201211150000||...||
OBR|2|234567892||2521S^K2S|||201211151512|201211181214|||A|||201211151512||^^^^     ^^^^^||D|DRUGS||||||F|
OBX|1|TX|2521S^K2S|  ^A^A|NEGATIVE|CUTOFF 20 ng/ml|-||||F||9|201211181214||MAM||
OBR|3|234567892||4814^GABA|||201211151512|201212061207|||A|||201211151512||^^^^     ^^^^^||D|DRUGS||||||C|
OBX|1|TX|4814^GABA|  ^D^D|X||-||||X||9|201212060949||RBJ|MERCY^^^^^^|
NTE|1|LD|     A THERAPEUTIC RANGE FOR GABAPENTIN HAS NOT BEEN ESTABLISHED. THE RANGE OF|
NTE|2|LD|     THE ASSAY IS 0.75 TO 40.00 ug/mL.REPORTABLE RESULT BELOW THIS RANGE IS|
NTE|3|LD|     <0.75 ug/mL AND ABOVE THIS RANGE IS >40.0 ug/ml.|
OBR|4|234567892||9632^GABA|||201211151512|201211191214|||A|||201211151512||^^^^     ^^^^^||A|GENERAL CHEMISTRY||||||X|
OBX|1|TX|9632^GABA|  ^A^A|X|ng/ml|NEGATIVE-|*|||X||9|201211191214||MAM||



Here is the output

Receiving Facility : 100
Patient No : K2TE154871
Lab Accession Number : 234567892
Patient Last Name : K2
Patient First Name : TEST
Patient Middle Name : null
Patient DOB : 19640512
Patient Sex : M
Provider NPI :
Provider Last Name :
Provider First Name :
Provider Initial :
Account No : 261
Account Name : XXXX CARE CENTER
Account Address : 31231 IN.STATE ROAD 17 SUITE 102
Account City : LAUDERHILL
Account State : NY
Account Zip : 22313
Account Phone : 95455848444
*********************************ALL ABOUT MSH ***********************
MSH-0: MSH
MSH-1: ^~\&
MSH-2: mas
MSH-3: MY XXXX LAB
MSH-4: mas
MSH-5: 100
MSH-6: 201303201430
MSH-7:
MSH-8: ORU^R01
MSH-9:
MSH-10: P
MSH-11: 2.3
Please give me MSH[3] MY XXXX LAB
Please give me MSH Line...MSH|^~\&|mas|MY XXXX LAB|mas|100|201303201430||ORU^R01||P|2.3|
*********************************ALL ABOUT PID ***********************
Please give me PID[3] ^^^MRN~^^^CID~^^^ACCN
Please give me PID Line...PID|1|K2TE154871|^^^MRN~^^^CID~^^^ACCN|234567892|K2^TEST^||19640512|M|||^^FL^|||||U|||||||0||
Please give me Patient Last Name K2
Please give me Patient First Name TEST
Please give me Patient Address
Please give me Patient City
Please give me Patient State FL
Please give me Patient Zip null
PID-0: PID
PID-1: 1
PID-2: K2TE154871
PID-3: ^^^MRN~^^^CID~^^^ACCN
PID-4: 234567892
PID-5: K2^TEST^
PID-6:
PID-7: 19640512
PID-8: M
PID-9:
PID-10:
PID-11: ^^FL^
PID-12:
PID-13:
PID-14:
PID-15:
PID-16: U
PID-17:
PID-18:
PID-19:
PID-20:
PID-21:
PID-22:
PID-23: 0
*********************************ALL ABOUT ORC***********************
ORC-0: ORC
ORC-1: 1
ORC-2: 000133423
ORC-3:
ORC-4:
ORC-5: CM
ORC-6:
ORC-7:
ORC-8:
ORC-9: 201206132103
ORC-10: PHH
ORC-11: 201206141230
ORC-12: ^^^^ ^^^^^
ORC-13:
ORC-14:
ORC-15:
ORC-16:
ORC-17: 261^XXXX CARE CENTER
ORC-18: 31231 IN.STATE ROAD 17 SUITE 102^LAUDERHILL^NY^22313^95455848444
ORC-19: 3
ORC-20: PHH
Please give me ORC[2] 000133423
Please give me ORC Line...ORC|1|000133423|||CM||||201206132103|PHH|201206141230|^^^^ ^^^^^|||||261^XXXX CARE CENTER|31231 IN.STATE ROAD 17 SUITE 102^LAUDERHILL^NY^22313^95455848444|3|PHH|
*********************************ALL ABOUT DG***********************
Please give me Total DGs 2
DG-1: DG1|1|ICD|319|UNSPECIFIED MENTAL RETARDATION|||||||||||||BUIR154337^000039106|
DG-2: DG1|1|ICD|30490|UNSPECIFIED DRUG DEPENDENCE, UNSPECIFIED USE|||||||||||||HOJA159610^000039110|
DG[1]-1 : 1
DG[1]-2 : ICD
DG[1]-3 : 319
DG[1]-4 : UNSPECIFIED MENTAL RETARDATION
DG[1]-5 :
DG[1]-6 :
DG[1]-7 :
DG[1]-8 :
DG[1]-9 :
DG[1]-10 :
DG[1]-11 :
DG[1]-12 :
DG[1]-13 :
DG[1]-14 :
DG[1]-15 :
DG[1]-16 :
DG[1]-17 : BUIR154337^000039106
DG[2]-1 : 1
DG[2]-2 : ICD
DG[2]-3 : 30490
DG[2]-4 : UNSPECIFIED DRUG DEPENDENCE, UNSPECIFIED USE
DG[2]-5 :
DG[2]-6 :
DG[2]-7 :
DG[2]-8 :
DG[2]-9 :
DG[2]-10 :
DG[2]-11 :
DG[2]-12 :
DG[2]-13 :
DG[2]-14 :
DG[2]-15 :
DG[2]-16 :
DG[2]-17 : HOJA159610^000039110
*********************************ALL ABOUT OBR***********************
Please give me Total OBR 4
OBR[1] : OBR|1|234567892||22014^K2S|||201211151512|201211151514||||||201211151512||^^^^ ^^^^^||A|GENERAL CHEMISTRY||||||X|
Total Elements in OBR[1] is 26
OBR[2] : OBR|2|234567892||2521S^K2S|||201211151512|201211181214|||A|||201211151512||^^^^ ^^^^^||D|DRUGS||||||F|
Total Elements in OBR[2] is 26
OBR[3] : OBR|3|234567892||4814^GABA|||201211151512|201212061207|||A|||201211151512||^^^^ ^^^^^||D|DRUGS||||||C|
Total Elements in OBR[3] is 26
OBR[4] : OBR|4|234567892||9632^GABA|||201211151512|201211191214|||A|||201211151512||^^^^ ^^^^^||A|GENERAL CHEMISTRY||||||X|
Total Elements in OBR[4] is 26
OBR[1]-1 : 1
OBR[1]-2 : 234567892
OBR[1]-3 :
OBR[1]-4 : 22014^K2S
OBR[1]-5 :
OBR[1]-6 :
OBR[1]-7 : 201211151512
OBR[1]-8 : 201211151514
OBR[1]-9 :
OBR[1]-10 :
OBR[1]-11 :
OBR[1]-12 :
OBR[1]-13 :
OBR[1]-14 : 201211151512
OBR[1]-15 :
OBR[1]-16 : ^^^^ ^^^^^
OBR[1]-17 :
OBR[1]-18 : A
OBR[1]-19 : GENERAL CHEMISTRY
OBR[1]-20 :
OBR[1]-21 :
OBR[1]-22 :
OBR[1]-23 :
OBR[1]-24 :
OBR[1]-25 : X
OBR[2]-1 : 2
OBR[2]-2 : 234567892
OBR[2]-3 :
OBR[2]-4 : 2521S^K2S
OBR[2]-5 :
OBR[2]-6 :
OBR[2]-7 : 201211151512
OBR[2]-8 : 201211181214
OBR[2]-9 :
OBR[2]-10 :
OBR[2]-11 : A
OBR[2]-12 :
OBR[2]-13 :
OBR[2]-14 : 201211151512
OBR[2]-15 :
OBR[2]-16 : ^^^^ ^^^^^
OBR[2]-17 :
OBR[2]-18 : D
OBR[2]-19 : DRUGS
OBR[2]-20 :
OBR[2]-21 :
OBR[2]-22 :
OBR[2]-23 :
OBR[2]-24 :
OBR[2]-25 : F
OBR[3]-1 : 3
OBR[3]-2 : 234567892
OBR[3]-3 :
OBR[3]-4 : 4814^GABA
OBR[3]-5 :
OBR[3]-6 :
OBR[3]-7 : 201211151512
OBR[3]-8 : 201212061207
OBR[3]-9 :
OBR[3]-10 :
OBR[3]-11 : A
OBR[3]-12 :
OBR[3]-13 :
OBR[3]-14 : 201211151512
OBR[3]-15 :
OBR[3]-16 : ^^^^ ^^^^^
OBR[3]-17 :
OBR[3]-18 : D
OBR[3]-19 : DRUGS
OBR[3]-20 :
OBR[3]-21 :
OBR[3]-22 :
OBR[3]-23 :
OBR[3]-24 :
OBR[3]-25 : C
OBR[4]-1 : 4
OBR[4]-2 : 234567892
OBR[4]-3 :
OBR[4]-4 : 9632^GABA
OBR[4]-5 :
OBR[4]-6 :
OBR[4]-7 : 201211151512
OBR[4]-8 : 201211191214
OBR[4]-9 :
OBR[4]-10 :
OBR[4]-11 : A
OBR[4]-12 :
OBR[4]-13 :
OBR[4]-14 : 201211151512
OBR[4]-15 :
OBR[4]-16 : ^^^^ ^^^^^
OBR[4]-17 :
OBR[4]-18 : A
OBR[4]-19 : GENERAL CHEMISTRY
OBR[4]-20 :
OBR[4]-21 :
OBR[4]-22 :
OBR[4]-23 :
OBR[4]-24 :
OBR[4]-25 : X
*********************************ALL ABOUT OBX***********************
Please give me Total OBXs in OBR[1] 1
Please give me Total OBXs in OBR[2] 1
Please give me OBX[1] in OBR[1] OBX|1|TX|22014^K2S| ^A^A|X||-||||X||9|201211150000||...||
OBR[1]OBX[1] => OBX|1|TX|22014^K2S| ^A^A|X||-||||X||9|201211150000||...||
OBR[1] : OBR|1|234567892||22014^K2S|||201211151512|201211151514||||||201211151512||^^^^ ^^^^^||A|GENERAL CHEMISTRY||||||X|
----->OBR[1]OBX[1] : OBX|1|TX|22014^K2S| ^A^A|X||-||||X||9|201211150000||...||
OBR[2] : OBR|2|234567892||2521S^K2S|||201211151512|201211181214|||A|||201211151512||^^^^ ^^^^^||D|DRUGS||||||F|
----->OBR[2]OBX[1] : OBX|1|TX|2521S^K2S| ^A^A|NEGATIVE|CUTOFF 20 ng/ml|-||||F||9|201211181214||MAM||
OBR[3] : OBR|3|234567892||4814^GABA|||201211151512|201212061207|||A|||201211151512||^^^^ ^^^^^||D|DRUGS||||||C|
----->OBR[3]OBX[1] : OBX|1|TX|4814^GABA| ^D^D|X||-||||X||9|201212060949||RBJ|MERCY^^^^^^|
OBR[4] : OBR|4|234567892||9632^GABA|||201211151512|201211191214|||A|||201211151512||^^^^ ^^^^^||A|GENERAL CHEMISTRY||||||X|
----->OBR[4]OBX[1] : OBX|1|TX|9632^GABA| ^A^A|X|ng/ml|NEGATIVE-|*|||X||9|201211191214||MAM||