1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 | package gov.hhs.fha.nhinc.patientcorrelationservice.parsers.PRPAIN201309UV;
|
---|
6 |
|
---|
7 | import gov.hhs.fha.nhinc.patientcorrelation.model.CorrelatedIdentifiers;
|
---|
8 | import java.util.ArrayList;
|
---|
9 | import java.util.List;
|
---|
10 | import javax.xml.bind.JAXBElement;
|
---|
11 | import org.apache.commons.logging.Log;
|
---|
12 | import org.apache.commons.logging.LogFactory;
|
---|
13 | import org.hl7.v3.CS;
|
---|
14 | import org.hl7.v3.II;
|
---|
15 | import org.hl7.v3.MCCIMT000300UV01Acknowledgement;
|
---|
16 | import org.hl7.v3.MFMIMT700711UV01QueryAck;
|
---|
17 | import org.hl7.v3.PRPAIN201309UV;
|
---|
18 | import org.hl7.v3.PRPAIN201309UVQUQIMT021001UV01ControlActProcess;
|
---|
19 | import org.hl7.v3.PRPAIN201310UV;
|
---|
20 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01ControlActProcess;
|
---|
21 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01RegistrationEvent;
|
---|
22 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01Subject1;
|
---|
23 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01Subject2;
|
---|
24 | import org.hl7.v3.PRPAMT201304UVPatient;
|
---|
25 | import org.hl7.v3.PRPAMT201304UVPerson;
|
---|
26 | import org.hl7.v3.PRPAMT201307UVDataSource;
|
---|
27 | import org.hl7.v3.PRPAMT201307UVParameterList;
|
---|
28 | import org.hl7.v3.PRPAMT201307UVPatientIdentifier;
|
---|
29 | import org.hl7.v3.PRPAMT201307UVQueryByParameter;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | *
|
---|
33 | * @author svalluripalli
|
---|
34 | */
|
---|
35 | public class PRPAIN201309UVParser {
|
---|
36 |
|
---|
37 | private static Log log = LogFactory.getLog(PRPAIN201309UVParser.class);
|
---|
38 | private static String CODE = "CA";
|
---|
39 | private static String CNTRL_MODCODE = "EVN";
|
---|
40 | private static String CNTRL_CODE = "PRPA_TE201310UV";
|
---|
41 | private static String CNTRL_SUBJ_TYPECODE = "SUBJ";
|
---|
42 | private static String STATUS_CD = "active";
|
---|
43 | private static String CNTRL_SUBJ_EVENT_SUBJ_CLASS_CODE = "PAT";
|
---|
44 | private static String PATIENTPERSON_CLASSCODE = "PSN";
|
---|
45 | //private static String DETERMINER_CODE = "INSTANCE";
|
---|
46 | private static String QUERY_RESPONSE = "OK";
|
---|
47 |
|
---|
48 | private static CS getCS(String value) {
|
---|
49 | CS cs = new CS();
|
---|
50 | cs.setCode(value);
|
---|
51 | return cs;
|
---|
52 | }
|
---|
53 |
|
---|
54 | public static PRPAMT201307UVParameterList parseHL7ParameterListFrom201309Message(PRPAIN201309UV message) {
|
---|
55 | if (message == null) {
|
---|
56 | return null;
|
---|
57 | }
|
---|
58 | PRPAIN201309UVQUQIMT021001UV01ControlActProcess ctrlAccess = message.getControlActProcess();
|
---|
59 | if (ctrlAccess == null) {
|
---|
60 | return null;
|
---|
61 | }
|
---|
62 | JAXBElement<PRPAMT201307UVQueryByParameter> queryByParameter = ctrlAccess.getQueryByParameter();
|
---|
63 | if (queryByParameter == null) {
|
---|
64 | return null;
|
---|
65 | }
|
---|
66 | PRPAMT201307UVParameterList parameterList = (queryByParameter.getValue() != null) ? queryByParameter.getValue().getParameterList() : null;
|
---|
67 | if (parameterList == null) {
|
---|
68 | return null;
|
---|
69 | }
|
---|
70 | return parameterList;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public static PRPAMT201307UVPatientIdentifier parseHL7PatientPersonFrom201309Message(PRPAIN201309UV message) {
|
---|
74 | log.debug("---- Begin PRPAIN201309UVParser.parseHL7PatientPersonFrom201309Message()----");
|
---|
75 | PRPAMT201307UVParameterList parameterList = parseHL7ParameterListFrom201309Message(message);
|
---|
76 | PRPAMT201307UVPatientIdentifier patientIdentifier = (parameterList.getPatientIdentifier() != null) ? parameterList.getPatientIdentifier().get(0) : null;
|
---|
77 | log.debug("---- End PRPAIN201309UVParser.parseHL7PatientPersonFrom201309Message()----");
|
---|
78 | return patientIdentifier;
|
---|
79 | }
|
---|
80 |
|
---|
81 | public static List<II> buildAssigningAuthorityInclusionFilterList(PRPAIN201309UV message) {
|
---|
82 | List<II> list = new ArrayList<II>();
|
---|
83 | PRPAMT201307UVParameterList parameterList = parseHL7ParameterListFrom201309Message(message);
|
---|
84 | List<PRPAMT201307UVDataSource> dataSourceList;
|
---|
85 | if (parameterList != null) {
|
---|
86 | dataSourceList = parameterList.getDataSource();
|
---|
87 | for (PRPAMT201307UVDataSource dataSource : dataSourceList) {
|
---|
88 | for (II dataSourceValue : dataSource.getValue()) {
|
---|
89 | list.add(dataSourceValue);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | }
|
---|
93 | return list;
|
---|
94 | }
|
---|
95 |
|
---|
96 | public static PRPAMT201307UVQueryByParameter ExtractQueryId(PRPAIN201309UV message) {
|
---|
97 | PRPAMT201307UVQueryByParameter queryByParameter = null;
|
---|
98 | if (message.getControlActProcess() != null) {
|
---|
99 | JAXBElement<PRPAMT201307UVQueryByParameter> queryByParamterElement = message.getControlActProcess().getQueryByParameter();
|
---|
100 | if (queryByParamterElement != null) {
|
---|
101 | queryByParameter = queryByParamterElement.getValue();
|
---|
102 | }
|
---|
103 | }
|
---|
104 | return queryByParameter;
|
---|
105 | }
|
---|
106 | }
|
---|