Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get all components of field using Terser #137

Open
madhub opened this issue Jan 3, 2025 · 0 comments
Open

How to get all components of field using Terser #137

madhub opened this issue Jan 3, 2025 · 0 comments

Comments

@madhub
Copy link

madhub commented Jan 3, 2025

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);
		}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant