From 8c1bd1a3c6f866619a14fd9803e1276eafc4dae3 Mon Sep 17 00:00:00 2001 From: Evtimiy Mihaylov Date: Wed, 4 Jan 2023 17:37:07 +0200 Subject: [PATCH] chore(segments): support for custom z-segments added --- lib/hl7.js | 3 ++- test/testfiles/ADTA01.adm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/hl7.js b/lib/hl7.js index 4eb7be4..591e0e0 100755 --- a/lib/hl7.js +++ b/lib/hl7.js @@ -82,7 +82,8 @@ var hl7Lib = {}; }; function validSegmentType(segmentname, ID, logger){ - if (validSegmentsName.indexOf(segmentname) < 0){ + // Custom segments can be added with Z prefix (ZPR, ZAR) that are not part of the HL7 specs + if (!segmentname[0] || (segmentname[0] !== 'Z' && validSegmentsName.indexOf(segmentname) < 0)){ if (typeof logger === 'object' && typeof logger.error === 'function'){ logger.error('Unkown segmentType (' + ID + '): ' + segmentname); } diff --git a/test/testfiles/ADTA01.adm b/test/testfiles/ADTA01.adm index b973d78..0aa5660 100644 --- a/test/testfiles/ADTA01.adm +++ b/test/testfiles/ADTA01.adm @@ -2,4 +2,5 @@ MSH|^~\&|EPICADT|DH|LABADT|DH|201301011226||ADT^A01|HL7MSG00001|P|2.3.1| EVN|A01|201301011223|| PID|||MRN12345^5^M11||APPLESEED^JOHN^A^III||19710101|M||C|1 CATALYZE STREET^^MADISON^WI^53005-1020|GL|(414)379-1212|(414)271-3434||S||MRN12345001^2^M10|123456789|987654^NC| NK1|1|APPLESEED^BARBARA^J|WIFE||||||NK^NEXT OF KIN -PV1|1|I|2000^2012^01||||004777^GOOD^SIDNEY^J.|||SUR||||ADM|A0| \ No newline at end of file +PV1|1|I|2000^2012^01||||004777^GOOD^SIDNEY^J.|||SUR||||ADM|A0| +ZPR|CARDIO|D123^^EMC \ No newline at end of file