[507] | 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.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
| 8 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevisedEventType;
|
---|
| 9 | import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevisedMessageType;
|
---|
| 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.SubjectHelper;
|
---|
| 14 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
| 15 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
| 16 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
| 17 | import org.hl7.v3.II;
|
---|
| 18 | import org.hl7.v3.PRPAIN201302UV;
|
---|
| 19 | import org.hl7.v3.PRPAIN201302UVMFMIMT700701UV01Subject1;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | *
|
---|
| 23 | * @author svalluripalli
|
---|
| 24 | */
|
---|
| 25 | public class SubjectRevisedTransformHelper {
|
---|
| 26 | private static final String ActionValue = "SubjectDiscoveryIn";
|
---|
| 27 | private static final String PatientAssigningAuthorityAttributeId = Constants.AssigningAuthorityAttributeId;
|
---|
| 28 | private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
|
---|
| 29 |
|
---|
| 30 | public static CheckPolicyRequestType transformSubjectRevisedToCheckPolicy(SubjectRevisedEventType event) {
|
---|
| 31 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
| 32 | SubjectRevisedMessageType message = event.getMessage();
|
---|
| 33 | PRPAIN201302UV subjectRevised = message.getPRPAIN201302UV();
|
---|
| 34 | RequestType request = new RequestType();
|
---|
| 35 | request.setAction(ActionHelper.actionFactory(ActionValue));
|
---|
| 36 | SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
|
---|
| 37 | request.getSubject().add(subject);
|
---|
| 38 | II ii = extractPatientIdentifier(subjectRevised);
|
---|
| 39 | if (ii != null) {
|
---|
| 40 | ResourceType resource = new ResourceType();
|
---|
| 41 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot() ));
|
---|
| 42 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, ii.getExtension()));
|
---|
| 43 | request.getResource().add(resource);
|
---|
| 44 | }
|
---|
| 45 | genericPolicyRequest.setRequest(request);
|
---|
| 46 | return genericPolicyRequest;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | private static II extractPatientIdentifier(PRPAIN201302UV message) {
|
---|
| 50 | II ii = null;
|
---|
| 51 |
|
---|
| 52 | if ((message != null) && (message.getControlActProcess() != null)) {
|
---|
| 53 | if (message.getControlActProcess().getSubject().size() >= 1) {
|
---|
| 54 | PRPAIN201302UVMFMIMT700701UV01Subject1 subject;
|
---|
| 55 | subject = message.getControlActProcess().getSubject().get(0);
|
---|
| 56 | //todo: check each sub-class for null
|
---|
| 57 | ii = subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0);
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | return ii;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|