[507] | 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.eventcommon.SubjectAddedEventType;
|
---|
| 8 | import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
|
---|
| 9 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
|
---|
| 10 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
|
---|
| 11 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
|
---|
| 12 | import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
|
---|
| 13 | import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
|
---|
| 14 | import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
|
---|
| 15 | import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
|
---|
| 16 | import org.hl7.v3.II;
|
---|
| 17 | import org.hl7.v3.PRPAIN201301UV;
|
---|
| 18 | import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01Subject1;
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | *
|
---|
| 22 | * @author rayj
|
---|
| 23 | */
|
---|
| 24 | public class SubjectAddedTransformHelper {
|
---|
| 25 |
|
---|
| 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 transformSubjectAddedToCheckPolicy(SubjectAddedEventType event) {
|
---|
| 31 | return transformSubjectAddedInToCheckPolicy(event);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public static CheckPolicyRequestType transformSubjectAddedInToCheckPolicy(SubjectAddedEventType event) {
|
---|
| 35 | CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
|
---|
| 36 | PRPAIN201301UV subjectAdded = event.getMessage().getPRPAIN201301UV();
|
---|
| 37 | RequestType request = new RequestType();
|
---|
| 38 | request.setAction(ActionHelper.actionFactory(ActionValue));
|
---|
| 39 |
|
---|
| 40 | SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
|
---|
| 41 | request.getSubject().add(subject);
|
---|
| 42 |
|
---|
| 43 | II ii = extractPatientIdentifier(subjectAdded);
|
---|
| 44 | if (ii != null) {
|
---|
| 45 | ResourceType resource = new ResourceType();
|
---|
| 46 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot() ));
|
---|
| 47 | resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, ii.getExtension()));
|
---|
| 48 | request.getResource().add(resource);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | genericPolicyRequest.setRequest(request);
|
---|
| 52 | return genericPolicyRequest;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | private static II extractPatientIdentifier(PRPAIN201301UV message) {
|
---|
| 56 | II ii = null;
|
---|
| 57 |
|
---|
| 58 | if ((message != null) && (message.getControlActProcess() != null)) {
|
---|
| 59 | if (message.getControlActProcess().getSubject().size() >= 1) {
|
---|
| 60 | PRPAIN201301UVMFMIMT700701UV01Subject1 subject;
|
---|
| 61 | subject = message.getControlActProcess().getSubject().get(0);
|
---|
| 62 | //todo: check each sub-class for null
|
---|
| 63 | ii = subject.getRegistrationEvent().getSubject1().getPatient().getId().get(0);
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | return ii;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|