Skip to content

How to get all components of field using Terser #137

@madhub

Description

@madhub

Is there way to get all components of field using Terser , either as List or as single string

For example for patient TEST^^PATIENT^P
I am looking for API to return TEST^^PATIENT^P
String completePatientName = terser.get("/.PID(0)-5(0)"); // should returnall components field . Currently it returns 1st component

OR

I am looking for API to return list of values "Test","","PATIENT","P" when I call some API on terser
List<String> patientComponents = terser.get("/.PID(0)-5(0)"); // should returnall components field including empty components

// complete example 
pubic void terserParserTest()  {


	String myMsg = "MSH|^~\\&|LABGL1||DMCRES||19951002180700||ORU^R01|LABGL1199510021807427|P|2.4||||||x~y|\r"
				+ "PID|||T12345~T2~T3||TEST^^PATIENT^P||19601002|M||||||||||123456\r"
				+ "PV1|||NER|||||||GSU||||||||E||||||||||||||||||||||||||19951002174900|19951006\r"
				+ "OBR|1||09527539021001920|1001920^BLOOD GASES, ARTERIAL^^^ABG|||19951002180200|||||||19951002180300||||1793559||0952753902||19951002180700||350|F||^^^^^RT\r"
				+ "OBX||NM|1001910^PATIENT TEMPERATURE, ARTERIAL^^^TEMP CORR|0001|37.0~37.1~37.2||||||F|||19951002180700||42\r"
				+ "OBX||TX|1001912^FIO2, ARTERIAL^^^FIO2 art|0001|*|%||A|||F|||19951002180700||42\r";

		PipeParser parser = new PipeParser();
		try {
			Message message = parser.parse(myMsg);

			Terser terser = new Terser(message);
                        // Currently it returns 1st component not all components
			var completePatientName = terser.get("/.PID(0)-5(0)");

		} catch (HL7Exception e) {
			throw new RuntimeException(e);
		}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions