Sidebar

How do I find the number of subfields in an HL7 message, then modify them?

0 votes
594 views
asked Jul 8, 2015 by jon-t-6024 (560 points)
I have the following FT1 segment, and I need to modify the subfields of FT1-19.  How do I find the subfields, then modify them individually?

FT1|1||020910MSASC1V|201002010000^201002010000|201002110000||27447F|||1|3400000|3400000||||24.24|||715.16~123.22~~|170||||||50~~

1 Answer

0 votes
 
Best answer

Normally, source.getCount() would be used to find the number of fields, but it currently does not work on subfields.  The solution, then, is to use a split() on the field.  

The following solution will modify the FT1-19 subfields to add "I9" to FT1-19.3 for each diagnosis value.

 

var ft119Count = source.getNode('FT1-19').split('~').length;

for (var x=1; x <= ft119Count; x++) {

    message.setNode('FT1-19[' + x + '].3', 'I9');
}
answered Jul 8, 2015 by jon-t-6024 (560 points)
...