Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Using Create Segment Functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Create Segment Functions

    Hi.

    I'm trying to write a transfomer script to modify the CON segments in a message, deleting all those except a specific Type, and adding an additional copy with modifications. This is all working fairly well except that when I try to create the new segment, it is inserted to the end of the message, instead of following the current CON segment that I am iterating over.

    ---------------------------------------------------------
    My Source Message:
    ---------------------------------------------------------
    MSH|^~\&|EPIC|IFH|NYCLIX|NYCLIX|20080415132906|704 888|ADT^A31|139|D|2.5|||
    EVN|A31|200804151329|||704888^PIASCIK^JONAH^TEST^^ ^^^IUH^^^^^MHHC|
    PID|||1241204^^^^EPI||ZZ TEST^PARIS^HILTON^^MS.^||19850823|F|||TWIN TOWERS LOS ANGELES COUNTY DETENTION CENTER^^LOS ANGELES^CA^00000^^^^||(123)456-7890^^7|(000)000-0000^^8|DEAF/MUTE|||156234|999-99-9999|||WHITE||||||||N
    PD1||||199^ZZTEST^MD^^^^||||||||||
    ROL||||199^ZZTEST^MD^^^^|20070717|||
    CON|1|CLINICAL UNK|face sheet/ insurance card/notification 10/02/07||||||||||||
    CON|2|CLINICAL UNK|face sheets/ insurance card notification 10/02/07||||||||||||
    CON|3|CONSENT|RHIO CONSENT FORM||||||||100002||20080415||
    NK1|1|King^Larry^^^^|Friend||(000)000-0000||1|||||||||||||||||||||||||||
    PV1|||^^^^^^^^|||||||||||||||5|||||||||||||||||||| ||||||||||||
    PV2||||||||||||||||||||||N|||||||||||||||||||||||| |||

    ---------------------------------------------------------
    My transmform:
    ---------------------------------------------------------
    var count = 0;
    var setID = 1;

    for each (con in msg..CON)
    {
    // Find a RHIO Consent - Type 'CONSENT'
    if (con['CON.2']['CON.2.1'].toString() == "CONSENT")
    {
    // Set first CON segment for Disclosure
    msg['CON'][count]['CON.1']['CON.1.1'] = setID.toString();
    msg['CON'][count]['CON.2']['CON.2.1'] = "001";
    msg['CON'][count]['CON.5']['CON.5.1'] = "Disclosure Consent";
    count++;
    setID++;
    // Create a second CON segment for Access Consent
    createSegmentAfter('CON', msg['CON'][count-1])
    msg['CON'][count] = msg['CON'][count-1];
    msg['CON'][count]['CON.1']['CON.1.1'] = setID.toString();
    msg['CON'][count]['CON.2']['CON.2.1'] = "110";
    msg['CON'][count]['CON.5']['CON.5.1'] = "Access Consent";
    count++;
    setID++;
    }
    else
    {
    delete msg['CON'][count];
    };
    }

    ---------------------------------------------------------
    My Result Message
    ---------------------------------------------------------
    MSH|^~\&|EPIC|IFH|NYCLIX|NYCLIX|20080415132906|704 888|ADT^A31|139|D|2.5|||
    EVN|A31|200804151329|||704888^PIASCIK^JONAH^TEST^^ ^^^IUH^^^^^MHHC|
    PID|||1241204^^^^EPI||ZZ TEST^PARIS^HILTON^^MS.^||19850823|F|||TWIN TOWERS LOS ANGELES COUNTY DETENTION CENTER^^LOS ANGELES^CA^00000^^^^||(123)456-7890^^7|(000)000-0000^^8|DEAF/MUTE|||156234|999-99-9999|||WHITE||||||||N
    PD1||||199^ZZTEST^MD^^^^||||||||||
    ROL||||199^ZZTEST^MD^^^^|20070717|||
    CON|1|001|RHIO CONSENT FORM||Disclosure Consent||||||100002||20080415||
    NK1|1|King^Larry^^^^|Friend||(000)000-0000||1|||||||||||||||||||||||||||
    PV1|||^^^^^^^^|||||||||||||||5|||||||||||||||||||| ||||||||||||
    PV2||||||||||||||||||||||N|||||||||||||||||||||||| |||
    CON|2|110|RHIO CONSENT FORM||Access Consent||||||100002||20080415||

    ---------------------------------------------------------

    Any ideas/recommendations/solutions?

    Thanks in advance!

    Jonah Piascik
    The Institute for Family Health
    [email protected]
    212.404.7697
Working...
X