Adding my 2 cents...
I stuck with the Java Object-Oriented way (I like compile-time checks and my
IDE's auto-completion), and wrote conversion methods to our classes for
Segments and Data Types. I end up having a Message method for each unique ADT
message, but they are all VERY short. All the REALLY hard work is in the
Segment and Data Type conversion methods, which are shared by all messages.
public static Transition convert(ADT_A01 source, Endpoint config) {
Transition transition = convertTransition(source.getPID(),
source.getPD1(), source.getEVN(), source.getPV1(), source.getPV2(),
source.getNK1(0),
source.getNK1(1),
config);
for(int nkIndex = 0; nkIndex < source.getNK1Reps(); ++nkIndex) {
}
transition.setStatus(Status.Admitted);
return transition;
}
public static Transition convert(ADT_A03 source, Endpoint config) {
Transition transition = convertTransition(source.getPID(),
source.getPD1(), source.getEVN(), source.getPV1(), source.getPV2(),
source.getNK1(0),
source.getNK1(1),
config);
transition.setStatus(Status.Discharged);
return transition;
}
public static Transition convert(ADT_A06 source, Endpoint config) {
Transition transition = convertTransition(source.getPID(),
source.getPD1(), source.getEVN(), source.getPV1(), source.getPV2(),
source.getNK1(0),
source.getNK1(1),
config);
if(source.getDG1Reps() > 0) {
transition.setFirstDiagnosis(convert(source.getDG1(0), config));
if(source.getDG1Reps() > 1) {
transition.setSecondDiagnosis(convert(source.getDG1(1), config));
}
}
transition.setStatus(Status.Discharged);
transition.setDischargedToCareOf("Hospital");
return transition;
}
private static Transition convertTransition(PID pid, PD1 pd1, EVN evn, PV1 pv1,
PV2 pv2, NK1 nk1Primary, NK1 nk1Secondary, Endpoint config) {
Transition transition = convert(pd1, config);
transition.setPatient(convert(pid, config));
convert(evn, transition, config);
convert(pv1, transition, config);
convert(pv2, transition, config);
convert(convert(nk1Primary, config), transition, 0, config);
convert(convert(nk1Secondary, config), transition, 1, config);
return transition;
}
Converters for ORM and ORU are uglier, though. The Java data types for HAPI's
HL7 groups all have the message name in the type (ORU_R01_PATIENT_RESULT and
ORU_R01_OBSERVATION, for example), so those can't really be abstracted out very
well, even though the messages are very similar. Still, even though they are
much longer than the ADT messages, I'm pretty hapi ;-) with my architecture,
and I don't have any complex third party code generators to worry about.
----
Jake
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel