web stats
Append New segment in between two segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 11-21-2017, 02:52 AM
spsjagadeesh spsjagadeesh is offline
What's HL7?
Join Date: Nov 2017
Posts: 2
spsjagadeesh is on a distinguished road
Default Append New segment in between two segments


I am new to this mirth. I need to create a new hl7 from database query.

I have built some basic segments using segment. Now i need to insert new segment in between existing segments of template (I need to insert IN1 between PV1 and ORC in the below)

Below are the sample message and transformer i have used. But Transformer is not working as expected.

Template message

MSH|^~\&|wrewrwe|1100|TMP|TMP|Message Date||OML^O21|66F4FD61-7587-40E1-AB2B-2C5FECD8FFF3|D|2.5.1
PID|1||2A012070D7||INTERFACE^TEST||19881106|M|||AD DRESS1^^SCHENECTADY^NY^123459998|||||||123456

Transformer used

function in1SetSegmentDefaultValues(in1Cnt) {

// compilation of fields with activity in the database
var in1MsgID = in1Cnt;
var in1Parent = in1Cnt;
var in1CreateDate = in1Cnt;
var in1ID = in1Cnt;
var in1SetID = in1Cnt;
var in1PlanID = in1Cnt;
var in1CoID = in1Cnt;
var in1CoName = in1Cnt;
var in1Group = in1Cnt;
var in1PlanType = in1Cnt;
var in1LName = in1Cnt;
var in1FName = in1Cnt;
var in1RelToPat = in1Cnt;
var in1DOB = in1Cnt;
var in1InsAddr1 = in1Cnt;
var in1InsCity = in1Cnt;
var in1InsState = in1Cnt;
var in1InsZip = in1Cnt;
var in1TypeCode = in1Cnt;
var in1PolicyNumber = in1Cnt;
var in1CoverageType = in1Cnt;

// Add any field transformation logic here
var in1 =new XML("<IN1></IN1>");
// Set Default Values in HL7 Transaction
if (in1SetID) in1['IN1.1']['IN1.1.1'] = in1SetID;
if (in1PlanID) in1['IN1.3']['IN1.3.1'] = in1PlanID;
if (in1CoName) in1['IN1.4']['IN1.4.1'] = in1CoName;
if (in1InsAddr1) in1['IN1.5']['IN1.5.1'] = ""; // Ronnie indicated we don't store address. ?
if (in1Group) in1['IN1.8']['IN1.8.1'] = in1Group;
if (in1LName) in1['IN1.16']['IN1.16.1'] = in1LName;
if (in1FName) in1['IN1.16']['IN1.16.2'] = in1FName;
if (in1RelToPat) in1['IN1.17']['IN1.17.1'] = in1RelToPat;
if (in1DOB) in1['IN1.18']['IN1.18.1'] = in1DOB;
if (in1InsAddr1) in1['IN1.19']['IN1.19.1'] = in1InsAddr1;
if (in1InsCity) in1['IN1.19']['IN1.19.3'] = in1InsCity;
if (in1InsState) in1['IN1.19']['IN1.19.4'] = in1InsState;
if (in1InsZip) in1['IN1.19']['IN1.19.5'] = in1InsZip;
if (in1PolicyNumber) in1['IN1.36']['IN1.36.1'] = in1PolicyNumber;
if (in1CoverageType) in1['IN1.47']['IN1.47.1'] = in1CoverageType;

tmp.insertChildBefore(tmp.PV1, in1);
//tmp.insertChildBefore(child1, child2)
return (true);

function in1ReadTable() {

var rSet = 3;
var in1Cnt = 1;
while (rSet > 1) {

return true;

- Append child is working and it's appending In1 at the end
- But InsertChildBefore is not working
Reply With Quote

appendsegment, insertchildafter, segment

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 03:52 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation