1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 | package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
|
---|
6 |
|
---|
7 | import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
8 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectReidentificationEventType;
|
---|
9 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectReidentificationMessageType;
|
---|
10 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
|
---|
11 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
|
---|
12 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
|
---|
13 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.InboundOutboundChecker;
|
---|
14 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
|
---|
15 | import javax.xml.bind.JAXBElement;
|
---|
16 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
17 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
18 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
19 | import org.hl7.v3.II;
|
---|
20 | import org.hl7.v3.PRPAIN201309UV;
|
---|
21 | import org.hl7.v3.PRPAMT201307UVParameterList;
|
---|
22 | import org.hl7.v3.PRPAMT201307UVPatientIdentifier;
|
---|
23 | import org.hl7.v3.PRPAMT201307UVQueryByParameter;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | *
|
---|
27 | * @author svalluripalli
|
---|
28 | */
|
---|
29 | public class SubjectReidentificationTransformHelper {
|
---|
30 |
|
---|
31 | private static final String ActionInValue = "SubjectDiscoveryReidentificationIn";
|
---|
32 | private static final String ActionOutValue = "SubjectDiscoveryReidentificationOut";
|
---|
33 | private static final String PatientAssigningAuthorityAttributeId = Constants.AssigningAuthorityAttributeId;
|
---|
34 | private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
|
---|
35 |
|
---|
36 | public static CheckPolicyRequestType transformSubjectReidentificationToCheckPolicy(SubjectReidentificationEventType event) {
|
---|
37 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
38 | SubjectReidentificationMessageType message = event.getMessage();
|
---|
39 | PRPAIN201309UV subjectReidentification = message.getPRPAIN201309UV();
|
---|
40 | RequestType request = new RequestType();
|
---|
41 | if (event.getDirection() != null) {
|
---|
42 | System.out.println("event.getDirection() is " + event.getDirection());
|
---|
43 | }
|
---|
44 | if (InboundOutboundChecker.IsInbound(event.getDirection())) {
|
---|
45 | request.setAction(ActionHelper.actionFactory(ActionInValue));
|
---|
46 | }
|
---|
47 | if (InboundOutboundChecker.IsOutbound(event.getDirection())) {
|
---|
48 | request.setAction(ActionHelper.actionFactory(ActionOutValue));
|
---|
49 | }
|
---|
50 | System.out.println("Action is >>>" + request.getAction().getAttribute().get(0).getAttributeId() + "<<<");
|
---|
51 | SubjectType subject = SubjectHelper.subjectFactoryReident(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
|
---|
52 | request.getSubject().add(subject);
|
---|
53 | II ii = extractPatientIdentifier(subjectReidentification);
|
---|
54 | if (ii != null) {
|
---|
55 | ResourceType resource = new ResourceType();
|
---|
56 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot()));
|
---|
57 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, ii.getExtension()));
|
---|
58 | request.getResource().add(resource);
|
---|
59 | }
|
---|
60 | genericPolicyRequest.setRequest(request);
|
---|
61 | return genericPolicyRequest;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Extract a Patient from 201309
|
---|
66 | * @param message
|
---|
67 | * @return II (PatientId root and extension)
|
---|
68 | */
|
---|
69 | private static II extractPatientIdentifier(PRPAIN201309UV message) {
|
---|
70 | II ii = null;
|
---|
71 | PRPAMT201307UVQueryByParameter queryByParameter = null;
|
---|
72 | PRPAMT201307UVParameterList parameterList = null;
|
---|
73 | PRPAMT201307UVPatientIdentifier patientIdentifier = null;
|
---|
74 | if ((message != null) && (message.getControlActProcess() != null)) {
|
---|
75 | JAXBElement<PRPAMT201307UVQueryByParameter> queryByParamterElement = message.getControlActProcess().getQueryByParameter();
|
---|
76 | if (null != queryByParamterElement) {
|
---|
77 | queryByParameter = queryByParamterElement.getValue();
|
---|
78 | if (null != queryByParameter) {
|
---|
79 | parameterList = queryByParameter.getParameterList();
|
---|
80 | if (null != parameterList) {
|
---|
81 | patientIdentifier = (parameterList.getPatientIdentifier() != null) ? parameterList.getPatientIdentifier().get(0) : null;
|
---|
82 | if (null != patientIdentifier) {
|
---|
83 | if (null != patientIdentifier.getValue() && patientIdentifier.getValue().size() >= 1) {
|
---|
84 | ii = patientIdentifier.getValue().get(0);
|
---|
85 | System.out.println(">>>>> patientIdentifier " + ii.getExtension() + " " + ii.getRoot());
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 | return ii;
|
---|
93 | }
|
---|
94 | }
|
---|