1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 |
|
---|
6 | package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
|
---|
7 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
|
---|
8 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
|
---|
9 | import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
10 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevokedEventType;
|
---|
11 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevokedMessageType;
|
---|
12 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
|
---|
13 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
|
---|
14 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
15 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
16 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
17 | import org.hl7.v3.II;
|
---|
18 | import org.hl7.v3.PRPAIN201303UV;
|
---|
19 | import org.hl7.v3.PRPAIN201303UVMFMIMT700701UV01Subject1;
|
---|
20 | /**
|
---|
21 | *
|
---|
22 | * @author svalluripalli
|
---|
23 | */
|
---|
24 | public class SubjectRevokedTransformHelper {
|
---|
25 | private static final String ActionValue = "SubjectRevokedIn";
|
---|
26 | private static final String PatientAssigningAuthorityAttributeId = Constants.AssigningAuthorityAttributeId;
|
---|
27 | private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
|
---|
28 |
|
---|
29 | public static CheckPolicyRequestType transformSubjectRevokedToCheckPolicy(SubjectRevokedEventType event) {
|
---|
30 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
31 | SubjectRevokedMessageType message = event.getMessage();
|
---|
32 | PRPAIN201303UV subjectRevoked = message.getPRPAIN201303UV();
|
---|
33 | RequestType request = new RequestType();
|
---|
34 | request.setAction(ActionHelper.actionFactory(ActionValue));
|
---|
35 | SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
|
---|
36 | request.getSubject().add(subject);
|
---|
37 | II ii = extractPatientIdentifier(subjectRevoked);
|
---|
38 | if (ii != null) {
|
---|
39 | ResourceType resource = new ResourceType();
|
---|
40 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot() ));
|
---|
41 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, ii.getExtension()));
|
---|
42 | request.getResource().add(resource);
|
---|
43 | }
|
---|
44 | genericPolicyRequest.setRequest(request);
|
---|
45 | return genericPolicyRequest;
|
---|
46 | }
|
---|
47 |
|
---|
48 | private static II extractPatientIdentifier(PRPAIN201303UV message) {
|
---|
49 | II ii = null;
|
---|
50 |
|
---|
51 | if ((message != null) && (message.getControlActProcess() != null)) {
|
---|
52 | if (message.getControlActProcess().getSubject().size() >= 1) {
|
---|
53 | PRPAIN201303UVMFMIMT700701UV01Subject1 subject;
|
---|
54 | subject = message.getControlActProcess().getSubject().get(0);
|
---|
55 | //todo: check each sub-class for null
|
---|
56 | ii = subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0);
|
---|
57 | }
|
---|
58 | }
|
---|
59 | return ii;
|
---|
60 | }
|
---|
61 | }
|
---|