From: Bostjan D. <bos...@ma...> - 2003-07-09 13:15:07
|
Waldron, Terry wrote: > Hi, > I'm trying to get information from the PID segment. I'm obviously doing something wrong, but I'm not sure what. > This is the code snippet I'm using. > > // Get some patient information from the PID segment > PID pid = (PID)in.get("PID"); > String pname = pid.getPatientName().toString(); > //Write the patient name to a log file > try { > Log.getInstance().log("patient name: " + pname); > } catch (LogException le) { > System.err.println("Warning: can't write outbound message to log file"); > } > > What shows in the log is: 9-Jul-2003 8:37:21 AM patient name: [Lca.uhn.hl7v2.model.v24.datatype.XPN;@143c8b3 > This looks like type information and a pointer to an address. Am I referencing this wrong? If so how should I be doing this? Patient name in PID is a complex HL7 structure. It's An XPN (eXtended Patient Name). Getting the name is not that easy. Following is a simple code snippet: PID pid = (PID)in.get("PID"); XPN name = pid.getPatientName(0); String pname = name.getGivenName().getValue(); pname += " " + name.getMiddleInitialOrName().getValue(); pname += " " + name.getFamilyLastName().getFamilyName().getValue(); Mind that for each basic element you must use getValue() and not toString(). Also, XPN is not your average "name + surname". It can be much more complex (a lot of (mostly optional) fields, a person might have more than one name...). |