LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources
Apache License 2.0
89 stars 36 forks source link

StringIndexOutOfBoundsException is thrown while converting NTE segments with additional dash #512

Open quake1997 opened 1 year ago

quake1997 commented 1 year ago

Describe the bug

When hl7 msg contains NTE segments with additional dash (-), StringIndexOutOfBoundsException exception is thrown while calling HL7ToFHIRConverter::convert. Issue related to changes implemented within https://github.com/LinuxForHealth/hl7v2-fhir-converter/pull/305/files#diff-c5d8954d3bc36408229772e082eb4fc36125a89c9e858fa22ec36aaa27c3c493R170

To Reproduce

@Test
void shouldCreateBundleResource() {
   HL7ToFHIRConverter ftv = new HL7ToFHIRConverter();
   String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r"
                + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r"
                + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r"
                + "OBR|1|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||58410-2^CBC panel - Blood by Automated count^LN||||||||||||\r"
                + "NTE|1|L|Test Range:\r"
                + "NTE|2|L|Test1 and Test: 10 - 12\r"
                + "DG1|1||A013^Paratyphoid fever C^I10C|||A|||||||||1\r";

     assertNotNull(ftv.convert(hl7message));
 }

Expected behavior FHIR bundle resource is created correctly