Mirth (NextGen) Connect Bits #2: Adding New Segments and Repeating Fields on an HL7 Message
Posted On August 13, 2020
The code below is one way to add new segments. I prefer to create a tmp object and set up the static segments in the Outbound template of the transformer. I then use the code below to add new segments.
var newOBR = <OBR/>;
newOBR['OBR.1']['OBR.1.1'] = i; // index
newOBR['OBR.2']['OBR.2.1'] = '202008131000'; // order no
newOBR['OBR.3']['OBR.3.1'] = '202008141000'; // filler no
newOBR['OBR.4']['OBR.4.1'] = 'CBC';
newOBR['OBR.4']['OBR.4.2'] = 'Complete Blood Count';
tmp.appendChild(newOBR);
To add repeating fields, I use the code below. Here I have an array of diagnosis objects. I want to add them in the FT1.19 as repeating fields.
var icd10CodesArray = [{'code': 'J12.8', 'name': 'Other viral pneumonia'}, {'code' : 'R06.0', 'name' : 'Dyspnoea'}];
var newFT1 = <FT1/>;
newFT1['FT1.1']['FT1.1.1'] = 1; // Set ID
newFT1['FT1.2']['FT1.2.1'] = 'T00001ID'; // Transaction ID
newFT1['FT1.3']['FT1.3.1'] = 'BATCH200813'; // Transaction Batch ID
newFT1['FT1.4']['FT1.4.1'] = DateUtil.formatDate('yyyyMMdd', new Date()); // Transaction Date
newFT1['FT1.5']['FT1.5.1'] = DateUtil.formatDate('yyyyMMdd', new Date()); // Transaction Posting Date
newFT1['FT1.6']['FT1.6.1'] = 1; // Transaction Type
newFT1['FT1.10']['FT1.10.1'] = 1; // Transaction Qty
newFT1['FT1.14']['FT1.14.1'] = 'POLICY123'; // Insurance Plan ID
newFT1['FT1.15']['FT1.15.1'] = ''; // Insurance Amnt
newFT1['FT1.16']['FT1.16.1'] = 'FACILITY123'; // Assigned Patient Loc
// Create child fields for FT1.19 for list of ICD codes
for(var x = 0; x < icd10CodesArray.length; x++) {
var childFT1 = <FT1.19/>;
childFT1['FT1.19.1'] = icd10CodesArray[x]['code']; // Dx Code
childFT1['FT1.19.2'] = icd10CodesArray[x]['name']; // Dx Name
childFT1['FT1.19.3'] = 'I10'; // Coding System
newFT1['FT1.19'] += childFT1;
}
tmp.appendChild(newFT1);
For the FT1, repeating delimiter which is “~” will show up in the FT1.19 field like the sample below.
FT1|1|T00001ID|BATCH200813|20200813|20200813|1||||1||||POLICY123||FACILITY123|||J12.8^Other viral pneumonia^I10~R06.0^Dyspnoea^I10
For more Mirth Connect related blog posts, check out the Mirth (NextGen) Bits tag or Health IT page. Feel free to leave a comment or feedback.