source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/GatewayPolicyEngineTransformationEjb/src/java/gov/hhs/fha/nhinc/gateway/policyenginetransformation/SubjectAddedTransformHelper.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 3.1 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
6
7import gov.hhs.fha.nhinc.common.eventcommon.SubjectAddedEventType;
8import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
9import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
10import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
11import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
12import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
13import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
14import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
15import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
16import org.hl7.v3.II;
17import org.hl7.v3.PRPAIN201301UV;
18import org.hl7.v3.PRPAIN201301UVMFMIMT700701UV01Subject1;
19
20/**
21 *
22 * @author rayj
23 */
24public 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}
Note: See TracBrowser for help on using the repository browser.