Hi everyone,
I think I painted myself into a mental corner.
Goal is to achieve a canonical dataformat to log my HL7 messages.
I would like to accomodate various HL7 versions/event types where I need
different terser expressions like
/PATIENT_RESULT/PATIENT/PV1-19-1 or
/RESPONSE/PATIENT/VISIT/PV1-19-1 for PV1-19.
These expressions are dependent on version, event type, etc.
In my route the expressions work ok, however I have lots of choice/when
decisions which breaks easily. So I thought about putting that logic into a
bean.
That works great with @Terser language annotations. However those expressions
are fixed. I would have loved to use terser expressions in the bean. Like so:
if (versionId.equalsIgnoreCase("2.2")) {
headers.put(„dob", terser("/PATIENT_RESULT/PATIENT/PID-7-1"));
headers.put(„surname",
terser("/PATIENT_RESULT/PATIENT/PID-5-1"));
headers.put(„name", terser("/PATIENT_RESULT/PATIENT/PID-5-2"));
headers.put("pid", terser("/PATIENT_RESULT/PATIENT/PID-3-1"));
headers.put(„caseno",
terser("/PATIENT_RESULT/PATIENT/PV1-19-1"));
} else if (versionId.equalsIgnoreCase("2.3")) {
headers.put(„dob", terser("/RESPONSE/PATIENT/PID-7-1"));
headers.put(„surname", terser("/RESPONSE/PATIENT/PID-5-1"));
headers.put(„name", terser("/RESPONSE/PATIENT/PID-5-2"));
headers.put("pid", terser("/RESPONSE/PATIENT/PID-3-1"));
headers.put(„caseno",
terser("/RESPONSE/PATIENT/VISIT/PV1-19-1"));
Is this possible? Or are there other approaches I am currently missing?
I created a sample in https://github.com/twalzer/tersertest that kinda works.
But not like sketched above. Any hints?
Cheers, Thomas.