File tree 2 files changed +22
-1
lines changed
main/java/io/github/linuxforhealth/hl7
test/java/io/github/linuxforhealth 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,9 @@ private static Message getHl7Message(String data) {
185
185
output .append (line );
186
186
} else {
187
187
int firstDash = line .indexOf ("-" );
188
- output .append (line .substring (0 , firstDash + 5 ));
188
+ // Added fail-safe check if the content after "-" is less than 5 characters
189
+ int lastContentIndex = Math .min (firstDash + 5 , line .length ());
190
+ output .append (line .substring (0 , lastContentIndex ));
189
191
}
190
192
output .append ("\n " );
191
193
}
Original file line number Diff line number Diff line change @@ -324,6 +324,25 @@ void testCodingSystems() throws FHIRException {
324
324
assertThat (coding .getSystem ()).isEqualTo ("http://terminology.hl7.org/CodeSystem/v2-0163" );
325
325
}
326
326
327
+ @ Test
328
+ void test_nte_split_print_structure_on_dash (){
329
+ String hl7message = "MSH|^~\\ &|Lab|Lab|GeneralHosp|MySys|202408160605-1000||ORU^R01|218374717|P|2.3|\n " +
330
+ "PID|1||||||||123|\n " +
331
+ "ORC|RE||123|\n " +
332
+ "OBR|1||123|456||||||||||||||||||202408160605-1000|||F|||||\n " +
333
+ "OBX|1|NM|1894^Non-HDL Cholesterol, calc^43396-1^1894||180|mg/dL|<130 optimal|H|||F|||202408160605-1000|12D0620420^General's Hospital|%AUTO^%AUTO^2|\n " +
334
+ "NTE|1|#9151E| |\n " +
335
+ "NTE|2|#9151E|LDL and Non-HDL Cholesterol goals based on level of risk:|\n " +
336
+ "NTE|3|#9151E| |\n " +
337
+ "NTE|4|#9151E| LDL NON-HDL|\n " +
338
+ "NTE|5|#9151E| ------------------------|\n " +
339
+ "SPM|1|YF123321||123456^Specimen (specimen)^SCT|||||||||||||202408180502-1000|202408180531-1000|" ;
340
+
341
+ Bundle b = ftv .convertToBundle (hl7message , OPTIONS , null );
342
+
343
+ assertThat (b .getType ()).isEqualTo (BundleType .COLLECTION );
344
+ }
345
+
327
346
private void verifyResult (String json , BundleType expectedBundleType ) {
328
347
verifyResult (json , expectedBundleType , true );
329
348
}
You can’t perform that action at this time.
0 commit comments