source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/PatientCorrelationEJB/src/java/gov/hhs/fha/nhinc/patientcorrelationservice/parsers/PRPAIN201301UV/PRPAIN201301UVParser.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 4.3 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package gov.hhs.fha.nhinc.patientcorrelationservice.parsers.PRPAIN201301UV;
7
8import java.util.List;
9import org.apache.commons.logging.Log;
10import org.apache.commons.logging.LogFactory;
11import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01ControlActProcess;
12import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01RegistrationEvent;
13import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01Subject1;
14import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01Subject2;
15import org.hl7.v3.PRPAMT201301UVPatient;
16
17/**
18 *
19 * @author svalluripalli
20 */
21public class PRPAIN201301UVParser {
22 private static Log log = LogFactory.getLog(PRPAIN201301UVParser.class);
23
24 /**
25 * This method gets the patientPerson from HL7V3 message of type PRPAIN201301UV
26 * @param message of type PRPAIN201301UV
27 * @return PRPAMT201301UVPerson
28 */
29 public static PRPAMT201301UVPatient ParseHL7PatientPersonFrom201301Message(org.hl7.v3.PRPAIN201301UV message) {
30 //assume one subject for now
31 PRPAMT201301UVPatient patient = ParseHL7PatientFromMessage(message);
32 //PRPAMT201301UVPerson patientPerson = ParseHL7PatientPersonFromHL7Patient(patient);
33 return patient;
34 }
35
36 /**
37 * This method returns patientPerson extracted from PRPAMT201301UVPatient using JAXB Element
38 * @param patient of type PRPAMT201301UVPatient
39 * @return PRPAMT201301UVPerson
40 */
41// public static PRPAMT201301UVPerson ParseHL7PatientPersonFromHL7Patient(PRPAMT201301UVPatient patient) {
42// JAXBElement<PRPAMT201301UVPerson> patientPersonElement = patient.getPatientPerson();
43// PRPAMT201301UVPerson patientPerson = patientPerson = patientPersonElement.getValue();
44// return patientPerson;
45// }
46
47 /**
48 * This method extracts Patient of type HL7V3 PRPAMT201301UVPatient from HL7V3 PRPAIN201301UV
49 * @param message of type PRPAIN201301UV
50 * @return PRPAMT201301UVPatient
51 */
52 public static PRPAMT201301UVPatient ParseHL7PatientFromMessage(org.hl7.v3.PRPAIN201301UV message) {
53 PRPAMT201301UVPatient patient = null;
54 log.info("in ExtractPatient");
55
56 PRPAIN201301UVMFMIMT700701UV01Subject1 subject = ParseSubjectFromMessage(message);
57 if (subject == null) {
58 return null;
59 }
60 PRPAIN201301UVMFMIMT700701UV01RegistrationEvent registrationevent = subject.getRegistrationEvent();
61 if (registrationevent == null) {
62 log.info("registrationevent is null - no patient");
63 return null;
64 }
65 //HL7Parser.PrintId(registrationevent.getTypeId(), "registrationevent");
66
67 PRPAIN201301UVMFMIMT700701UV01Subject2 subject1 = registrationevent.getSubject1();
68 if (subject1 == null) {
69 log.info("subject1 is null - no patient");
70 return null;
71 }
72 //HL7Parser.PrintId(subject1.getTypeId(), "subject1");
73
74 patient = subject1.getPatient();
75 if (patient == null) {
76 log.info("patient is null - no patient");
77 return null;
78 }
79 //HL7Parser.PrintId(patient.getId(), "patient");
80
81 log.info("done with ExtractPatient");
82 return patient;
83 }
84
85 public static PRPAIN201301UVMFMIMT700701UV01Subject1 ParseSubjectFromMessage(org.hl7.v3.PRPAIN201301UV message) {
86 //assume one subject for now
87
88 if (message == null) {
89 log.info("message is null - no patient");
90 return null;
91 }
92 PRPAIN201301UVMFMIMT700701UV01ControlActProcess controlActProcess = message.getControlActProcess();
93 if (controlActProcess == null) {
94 log.info("controlActProcess is null - no patient");
95 return null;
96 }
97 //HL7Parser.PrintId(controlActProcess.getId(), "controlActProcess");
98
99 List<PRPAIN201301UVMFMIMT700701UV01Subject1> subjects = controlActProcess.getSubject();
100 if ((subjects == null) || (subjects.size() == 0)) {
101 log.info("subjects is blank/null - no patient");
102 return null;
103 }
104
105 //for now, assume we only need one subject, this will need to be modified later
106 PRPAIN201301UVMFMIMT700701UV01Subject1 subject = subjects.get(0);
107 //HL7Parser.PrintId(subject.getTypeId(), "subject");
108
109 return subject;
110 }
111}
Note: See TracBrowser for help on using the repository browser.