source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/GatewayPolicyEngineTransformationEjb/src/java/gov/hhs/fha/nhinc/gateway/policyenginetransformation/SubjectRevisedTransformHelper.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 */
5
6package gov.hhs.fha.nhinc.gateway.policyenginetransformation;
7import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
8import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevisedEventType;
9import gov.hhs.fha.nhinc.common.eventcommon.SubjectRevisedMessageType;
10import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
11import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
12import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
13import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
14import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
15import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
16import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
17import org.hl7.v3.II;
18import org.hl7.v3.PRPAIN201302UV;
19import org.hl7.v3.PRPAIN201302UVMFMIMT700701UV01Subject1;
20
21/**
22 *
23 * @author svalluripalli
24 */
25public 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}
Note: See TracBrowser for help on using the repository browser.