source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/GatewayPolicyEngineTransformationEjb/src/java/gov/hhs/fha/nhinc/gateway/policyenginetransformation/AdhocQueryTransformHelper.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: 5.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
7
8import gov.hhs.fha.nhinc.common.eventcommon.AdhocQueryRequestEventType;
9import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
10import gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;
11import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.ActionHelper;
12import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.AttributeHelper;
13import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.CommunityHelper;
14import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.Constants;
15import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.InboundOutboundChecker;
16import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
17import gov.hhs.fha.nhinc.util.format.PatientIdFormatUtil;
18import java.util.List;
19import oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryRequest;
20import oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1;
21import oasis.names.tc.xacml._2_0.context.schema.os.ActionType;
22import oasis.names.tc.xacml._2_0.context.schema.os.AttributeType;
23import oasis.names.tc.xacml._2_0.context.schema.os.AttributeValueType;
24import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
25import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
26import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
27
28/**
29 *
30 * @author rayj
31 */
32public class AdhocQueryTransformHelper {
33
34 private static final String ActionValue = "DocumentQueryIn";
35 private static final String PatientAssigningAuthorityAttributeId = Constants.AssigningAuthorityAttributeId;
36 private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
37
38 public static CheckPolicyRequestType transformAdhocQueryToCheckPolicy(AdhocQueryRequestEventType event) {
39 CheckPolicyRequestType result = null;
40 if (InboundOutboundChecker.IsInbound(event.getDirection())) {
41 result = transformAdhocQueryInboundToCheckPolicy(event);
42 }
43 if (InboundOutboundChecker.IsOutbound(event.getDirection())) {
44 result = transformAdhocQueryOutboundToCheckPolicy(event);
45 }
46 return result;
47 }
48
49 private static CheckPolicyRequestType transformAdhocQueryToCheckPolicyBase(AdhocQueryRequestEventType event) {
50 CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
51
52 AdhocQueryRequest docQuery = event.getMessage().getAdhocQueryRequest();
53
54 RequestType request = new RequestType();
55
56 request.setAction(ActionHelper.actionFactory(ActionValue));
57
58 ResourceType resource = new ResourceType();
59 resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, extractPatientIdentifierAssigningAuthority(docQuery)));
60 resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, extractPatientIdentifierId(docQuery)));
61 request.getResource().add(resource);
62
63 SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity() , event.getMessage().getAssertion());
64 request.getSubject().add(subject);
65
66 genericPolicyRequest.setRequest(request);
67 return genericPolicyRequest;
68 }
69
70 private static CheckPolicyRequestType transformAdhocQueryInboundToCheckPolicy(AdhocQueryRequestEventType event) {
71 return transformAdhocQueryToCheckPolicyBase(event);
72 }
73 private static CheckPolicyRequestType transformAdhocQueryOutboundToCheckPolicy(AdhocQueryRequestEventType event) {
74 CheckPolicyRequestType checkPolicy = transformAdhocQueryToCheckPolicyBase(event);
75 checkPolicy.getRequest().getResource().get(0).getAttribute().add(AttributeHelper.attributeFactory(Constants.HomeCommunityAttributeId, Constants.DataTypeString, CommunityHelper.extractCommunityId(event.getReceivingHomeCommunity())));
76 return checkPolicy;
77 }
78
79 public static String extractPatientIdentifierId(AdhocQueryRequest docQuery) {
80 return PatientIdFormatUtil.parsePatientId(extractPatientIdentifier(docQuery));
81 }
82
83 public static String extractPatientIdentifierAssigningAuthority(AdhocQueryRequest docQuery) {
84 return PatientIdFormatUtil.parseCommunityId(extractPatientIdentifier(docQuery));
85 }
86
87 private static String extractPatientIdentifier(AdhocQueryRequest docQuery) {
88 String patientIdentifier = null;
89
90 if ((docQuery != null) && (docQuery.getAdhocQuery() != null)) {
91 List<SlotType1> slots = docQuery.getAdhocQuery().getSlot();
92 for (SlotType1 slot : slots) {
93 if ((slot.getName() != null) && (slot.getName().contentEquals("$XDSDocumentEntryPatientId"))) {
94 if (slot.getValueList() != null) {
95 if (slot.getValueList().getValue().size() == 1) {
96 patientIdentifier = slot.getValueList().getValue().get(0);
97 }
98 }
99 }
100 }
101 }
102 return patientIdentifier;
103 }
104}
Note: See TracBrowser for help on using the repository browser.