PART A:
USING JAVASCRIPT SPLIT
to extract OT Booking Number (Procedure Booking Number)
Assume there is a hypothetical patient planning for a surgical procedure.
Patient Information
Patient Name: XX, XX XXX
HKID: TM1234567
Date of Birth: 18 June 1946
Sex: F
Next of Kin: YYY, YY YYYYY
Next of Kin Relationship: Husband
Ward: Medical B8C
Hospital Number: HN14092XX0N
Date of Hospital Admission: 05 May 2014
Surgical Procedure Information
Procedure Booked:
1. FIrst Surgical Procedure String
2. Second Surgical Procedure String
3. 3rd Surgical Procedure String
Theatre booked: CATHLAB
OT Booking Number: OTB10005662
Booking Magnitude: Intermediate
Nature: Elective
Surgical Diagnosis:
1. First Diagnosis String
2. Second Diagnosis String
3. Third Diagnosis String
Booked Surgeon:
AAAAAA, AAAAA AAAAA (Dr.)
BBBB, BBBBB BBBB (Dr.)
The HL7 message (v2.3.1) of the above patient:
MSH|^~\&|EDI|HAHO|PMS|PWH|20140505101637||ADT^A01|20140505101537599755|P|2.3.1|||AL|AL|HKG|ASCII|ENG
PID|1||TM1234567^^^^HKID||XX^XX XXX||19460618|F||||||||||||||||||||
NK1|1|YYY, YY YYYYY|H
PV1|1|P|MED^B8C||||||||||||||||HN14092XX0N|||||||||||||||||||||||||20140505094200
PR1|1||^[1] FIrst Surgical Procedure String [2] Second Surgical Procedure Sting [3] 3rd Surgical Procedure Sting|THEATRE_CODE:CATHLAB,APPTNO:OTB100056625,BOOK_MAGNITUDE:Intermediate|20100811000000|EL||||||||1|^[1] First Diagnosis String [2] Second Diagnosis String [3] Third Diagnosis String
Please noted that:
1. the PR1.4.1 string
=
|THEATRE_CODE:CATHLAB,APPTNO:OTB100056625,BOOK_MAGNITUDE:Intermediate|
2. The Procedure booking number 'OTB100056625' is inside the PR1.4.1 string.
To extract the Procedure booking number, we can use Mirth Connect's JavaScript Transformer. There are different methods to perform string manipulation using JavaScript. Methods include substring, split or regular expression.
JavaScript Code using Split to extract procedure booking number:
// use split to find OTB No and booking magnitude
var full_PR14= msg['PR1']['PR1.4']['PR1.4.1'].toString();
var PR14_split=new java.lang.String(full_PR14).replace(",",":").split(":");
var theatre_code= 'Booking Theatre: ' + PR14_split[1];
var OTB_No= 'OT Booking No: ' + PR14_split[3];
var booking_Magnitude= 'Booking Magnitude: ' + PR14_split[5];
Reference:
Please refer to excellent article by Mr Scott Downe on
"how to split on 2 characters"
http://scottdowne.wordpress.com/2010/07/13/javascript-array-split-on-multiple-characters)
Basically I am using Downe's technique to split the whole string presented in PR1.4
on character ':' and character '," :
i.e.
this whole string:
THEATRE_CODE:CATHLAB,APPTNO:OTB100056625,BOOK_MAGNITUDE:Intermediate
is spitted into 6 parts by splitting at ':' and ',':
Part 0 -- THEATRE_CODE
Part 1 -- CATHLAB
Part 2 -- APPTNO
Part 3 -- OTB100056625
Part 4 -- BOOK_MAGNITUDE
Part 5 -- Intermediate
And then I reassign the part 3 as the Procedure Booking Number 'OTB_No'.
PART B:
USING JAVASCRIPT SUBSTRING
to extract Date of Booking
Please noted that:
1. the PR1.5.1 string
=
|20100811000000|
2. It is the Date of Booking in YYYYMMDD format
To convert the Date of Booking to DD/MM/YYYY format, we can use JavaScript substring function.
JavaScript Code using Substring to convert Date of Booking format:
// use substring to convert date of Booking:
var original_date= msg['PR1']['PR1.5']['PR1.5.1'].toString();
var BOOKING_DATE = original_date.substring(6,8) + '/' + original_date.substring(4,6) + '/' + original_date.substring(0,4);
var full_PR14= msg['PR1']['PR1.4']['PR1.4.1'].toString();
var PR14_split=new java.lang.String(full_PR14).replace(",",":").split(":");
var theatre_code= 'Booking Theatre: ' + PR14_split[1];
var OTB_No= 'OT Booking No: ' + PR14_split[3];
var booking_Magnitude= 'Booking Magnitude: ' + PR14_split[5];
// REMOVE open bracket [ from original procedure string
var full_PR13= msg['PR1']['PR1.3']['PR1.3.2'].toString();
full_PR13 = new java.lang.String(full_PR13).replace("["," ");
// push all missing data to the procedure string
var refromatted_PR13 = '[1]' + nature + ' ' + 'Booking Date:' + ' ' + BOOKING_DATE +'[2]' + OTB_No + ';' + ' ' + booking_Magnitude + '.' + ' ' + '[3]' + full_PR13;
msg['PR1']['PR1.3']['PR1.3.2'] = refromatted_PR13;
OUTPUT TRANSFORMED HL7 MESSAGE:
MSH|^~\&|EDI|HAHO|PMS|PWH|20140505101637||ADT^A01|20140505101537599755|P|2.3.1|||AL|AL|HKG|ASCII|ENG
PID|1||TM1234567^^^^HKID||XX^XX XXX||19460618|F||||||||||||||||||||
NK1|1|YYY, YY YYYYY|H
PV1|1|P|MED^B8C||||||||||||||||HN14092140N|||||||||||||||||||||||||20140505094200
PR1|1||^[1]ELECTIVE Booking Date: 11/08/2010[2]OT Booking No: OTB100056625; Booking Magnitude: Intermediate. [3] 1] FIrst Surgical Procedure String 2] Second Surgical Procedure Sting 3] 3rd Surgical Procedure Sting|THEATRE_CODE:CATHLAB,APPTNO:OTB100056625,BOOK_MAGNITUDE:Intermediate|20100811000000|ELECTIVE||||||||1|^[1] First Diagnosis String [2] Second Diagnosis String [3] Third Diagnosis String [4] Fourth Diagnosis String [5] Fifth Diagnosis String [6] Sixth Diagnosis String [7] Seventh Diagnosis String [8] Eighth Diagnosis String [9] Ninth Diagnosis String
ROL|1|LI||^AAAAAA, AAAAA AAAAA (Dr.)
ROL|2|LI||^BBBB, BBBBB BBBB (Dr.)
Please noted that the PR1.3.2 becomes
[1]ELECTIVE Booking Date: 11/08/2010[2]OT Booking No: OTB100056625; Booking Magnitude: Intermediate. [3] 1] FIrst Surgical Procedure String 2] Second Surgical Procedure Sting 3] 3rd Surgical Procedure Sting
Innovian will treat this as 3 procedure strings
|1]ELECTIVE Booking Date: 11/08/2010
[2]OT Booking No: OTB100056625; Booking Magnitude: Intermediate.
[3] 1] FIrst Surgical Procedure String 2] Second Surgical Procedure Sting 3] 3rd Surgical Procedure Sting
PART C:
USING JAVASCRIPT
to reassign the following missing data to the procedure string PR1.3.2
--Nature of Surgery, elective or emergency
--Date of Booking
--OT Booking Numeber
--Booking Magnitude
PLEASE NOTED THAT the original PR1.3.2 contains the following procedure string
[1] FIrst Surgical Procedure String [2] Second Surgical Procedure Sting [3] 3rd Surgical Procedure Sting
Final JavaScript Code in Mirth Connect:
// Nature of booking elective or emergency
var codeMap = {
'EL': 'ELECTIVE',
'EM': 'EMERGENCY',
};
for each (PR1 in msg.PR1)
PR1['PR1.6']['PR1.6.1'] = codeMap[PR1['PR1.6']['PR1.6.1'].toString()] || '';
var nature = msg['PR1']['PR1.6']['PR1.6.1'].toString();
// Convert date of booking format
var original_date= msg['PR1']['PR1.5']['PR1.5.1'].toString();
var BOOKING_DATE = original_date.substring(6,8) + '/' + original_date.substring(4,6) + '/' + original_date.substring(0,4);
// extract OT Booking number and magnitude
The output at Innovian will be:
Reference 2:
The HL7 message in XML format of the above patient:
<HL7Message>
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<MSH.3.1>EDI</MSH.3.1>
</MSH.3>
<MSH.4>
<MSH.4.1>HAHO</MSH.4.1>
</MSH.4>
<MSH.5>
<MSH.5.1>PMS</MSH.5.1>
</MSH.5>
<MSH.6>
<MSH.6.1>PWH</MSH.6.1>
</MSH.6>
<MSH.7>
<MSH.7.1>20140505101637</MSH.7.1>
</MSH.7>
<MSH.8/>
<MSH.9>
<MSH.9.1>ADT</MSH.9.1>
<MSH.9.2>A01</MSH.9.2>
</MSH.9>
<MSH.10>
<MSH.10.1>20140505101537599755</MSH.10.1>
</MSH.10>
<MSH.11>
<MSH.11.1>P</MSH.11.1>
</MSH.11>
<MSH.12>
<MSH.12.1>2.3.1</MSH.12.1>
</MSH.12>
<MSH.13/>
<MSH.14/>
<MSH.15>
<MSH.15.1>AL</MSH.15.1>
</MSH.15>
<MSH.16>
<MSH.16.1>AL</MSH.16.1>
</MSH.16>
<MSH.17>
<MSH.17.1>HKG</MSH.17.1>
</MSH.17>
<MSH.18>
<MSH.18.1>ASCII</MSH.18.1>
</MSH.18>
<MSH.19>
<MSH.19.1>ENG</MSH.19.1>
</MSH.19>
</MSH>
<PID>
<PID.1>
<PID.1.1>1</PID.1.1>
</PID.1>
<PID.2/>
<PID.3>
<PID.3.1>TM1234567</PID.3.1>
<PID.3.2/>
<PID.3.3/>
<PID.3.4/>
<PID.3.5>HKID</PID.3.5>
</PID.3>
<PID.4/>
<PID.5>
<PID.5.1>XX</PID.5.1>
<PID.5.2>XX XXX</PID.5.2>
</PID.5>
<PID.6/>
<PID.7>
<PID.7.1>19460618</PID.7.1>
</PID.7>
<PID.8>
<PID.8.1>F</PID.8.1>
</PID.8>
<PID.9/>
<PID.10/>
<PID.11/>
<PID.12/>
<PID.13/>
<PID.14/>
<PID.15/>
<PID.16/>
<PID.17/>
<PID.18/>
<PID.19/>
<PID.20/>
<PID.21/>
<PID.22/>
<PID.23/>
<PID.24/>
<PID.25/>
<PID.26/>
<PID.27/>
<PID.28/>
</PID>
<NK1>
<NK1.1>
<NK1.1.1>1</NK1.1.1>
</NK1.1>
<NK1.2>
<NK1.2.1>YYY, YY YYYYY</NK1.2.1>
</NK1.2>
<NK1.3>
<NK1.3.1>H</NK1.3.1>
</NK1.3>
</NK1>
<PV1>
<PV1.1>
<PV1.1.1>1</PV1.1.1>
</PV1.1>
<PV1.2>
<PV1.2.1>P</PV1.2.1>
</PV1.2>
<PV1.3>
<PV1.3.1>MED</PV1.3.1>
<PV1.3.2>B8C</PV1.3.2>
</PV1.3>
<PV1.4/>
<PV1.5/>
<PV1.6/>
<PV1.7/>
<PV1.8/>
<PV1.9/>
<PV1.10/>
<PV1.11/>
<PV1.12/>
<PV1.13/>
<PV1.14/>
<PV1.15/>
<PV1.16/>
<PV1.17/>
<PV1.18/>
<PV1.19>
<PV1.19.1>HN14092XX0N</PV1.19.1>
</PV1.19>
<PV1.20/>
<PV1.21/>
<PV1.22/>
<PV1.23/>
<PV1.24/>
<PV1.25/>
<PV1.26/>
<PV1.27/>
<PV1.28/>
<PV1.29/>
<PV1.30/>
<PV1.31/>
<PV1.32/>
<PV1.33/>
<PV1.34/>
<PV1.35/>
<PV1.36/>
<PV1.37/>
<PV1.38/>
<PV1.39/>
<PV1.40/>
<PV1.41/>
<PV1.42/>
<PV1.43/>
<PV1.44>
<PV1.44.1>20140505094200</PV1.44.1>
</PV1.44>
</PV1>
<PR1>
<PR1.1>
<PR1.1.1>1</PR1.1.1>
</PR1.1>
<PR1.2/>
<PR1.3>
<PR1.3.1/>
<PR1.3.2>[1] FIrst Surgical Procedure String [2] Second Surgical Procedure Sting [3] 3rd Surgical Procedure Sting</PR1.3.2>
</PR1.3>
<PR1.4>
<PR1.4.1>THEATRE_CODE:CATHLAB,APPTNO:OTB100056625,BOOK_MAGNITUDE:Intermediate</PR1.4.1>
</PR1.4>
<PR1.5>
<PR1.5.1>20100811000000</PR1.5.1>
</PR1.5>
<PR1.6>
<PR1.6.1>EL</PR1.6.1>
</PR1.6>
<PR1.7/>
<PR1.8/>
<PR1.9/>
<PR1.10/>
<PR1.11/>
<PR1.12/>
<PR1.13/>
<PR1.14>
<PR1.14.1>1</PR1.14.1>
</PR1.14>
<PR1.15>
<PR1.15.1/>
<PR1.15.2>[1] First Diagnosis String [2] Second Diagnosis String [3] Third Diagnosis String</PR1.15.2>
</PR1.15>
</PR1>
<ROL>
<ROL.1>
<ROL.1.1>1</ROL.1.1>
</ROL.1>
<ROL.2>
<ROL.2.1>LI</ROL.2.1>
</ROL.2>
<ROL.3/>
<ROL.4>
<ROL.4.1/>
<ROL.4.2>AAAAAA, AAAAA AAAAA (Dr.)</ROL.4.2>
</ROL.4>
</ROL>
<ROL>
<ROL.1>
<ROL.1.1>2</ROL.1.1>
</ROL.1>
<ROL.2>
<ROL.2.1>LI</ROL.2.1>
</ROL.2>
<ROL.3/>
<ROL.4>
<ROL.4.1/>
<ROL.4.2>BBBB, BBBBB BBBB (Dr.)</ROL.4.2>
</ROL.4>
</ROL>
</HL7Message>