source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Gateway/GatewayPolicyEngineTransformationEjb/src/java/gov/hhs/fha/nhinc/gateway/policyenginetransformation/SubscribeTransformHelper.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: 4.4 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.nhinccommonadapter.CheckPolicyRequestType;
8import gov.hhs.fha.nhinc.common.eventcommon.SubscribeEventType;
9import gov.hhs.fha.nhinc.common.eventcommon.SubscribeMessageType;
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.InboundOutboundChecker;
14import gov.hhs.fha.nhinc.gateway.policyenginetransformation.Helpers.SubjectHelper;
15import gov.hhs.fha.nhinc.nhinclib.NullChecker;
16import java.util.List;
17import javax.xml.bind.JAXBElement;
18import oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryRequest;
19import oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType;
20import oasis.names.tc.xacml._2_0.context.schema.os.RequestType;
21import oasis.names.tc.xacml._2_0.context.schema.os.ResourceType;
22import oasis.names.tc.xacml._2_0.context.schema.os.SubjectType;
23import org.oasis_open.docs.wsn.b_2.Subscribe;
24import org.w3c.dom.Element;
25
26/**
27 *
28 * @author svalluripalli
29 */
30public class SubscribeTransformHelper {
31
32 private static final String ActionInValue = "HIEMSubscriptionRequestIn";
33 private static final String ActionOutValue = "HIEMSubscriptionRequestOut";
34 private static final String PatientAssigningAuthorityAttributeId = Constants.AssigningAuthorityAttributeId;
35 private static final String PatientIdAttributeId = Constants.ResourceIdAttributeId;
36
37 public static CheckPolicyRequestType transformSubscribeToCheckPolicy(SubscribeEventType event) {
38 CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
39 SubscribeMessageType message = event.getMessage();
40 RequestType request = new RequestType();
41 if (InboundOutboundChecker.IsInbound(event.getDirection())) {
42 request.setAction(ActionHelper.actionFactory(ActionInValue));
43 }
44 if (InboundOutboundChecker.IsOutbound(event.getDirection())) {
45 request.setAction(ActionHelper.actionFactory(ActionOutValue));
46 }
47
48 SubjectType subject = SubjectHelper.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
49 request.getSubject().add(subject);
50
51 AdhocQueryRequest adhocReq = new AdhocQueryRequest();
52 AdhocQueryType adhocQuery = new AdhocQueryType();
53 adhocQuery = getAdhocQuery(event.getMessage().getSubscribe());
54 adhocReq.setAdhocQuery(adhocQuery);
55 String patId = AdhocQueryTransformHelper.extractPatientIdentifierId(adhocReq);
56 String assignAuth = AdhocQueryTransformHelper.extractPatientIdentifierAssigningAuthority(adhocReq);
57
58 ResourceType resource = new ResourceType();
59
60 if (NullChecker.isNotNullish(assignAuth)) {
61 resource.getAttribute().add(AttributeHelper.attributeFactory(PatientAssigningAuthorityAttributeId, Constants.DataTypeString, assignAuth));
62 }
63
64 if (NullChecker.isNotNullish(patId)) {
65 resource.getAttribute().add(AttributeHelper.attributeFactory(PatientIdAttributeId, Constants.DataTypeString, patId));
66 }
67
68 request.getResource().add(resource);
69
70 genericPolicyRequest.setRequest(request);
71 return genericPolicyRequest;
72 }
73
74 public static AdhocQueryType getAdhocQuery(Subscribe nhinSubscribe) {
75 AdhocQueryType adhocQuery = null;
76 List<Object> any = nhinSubscribe.getAny();
77
78
79 for (Object anyItem : any) {
80 if (anyItem instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType) {
81 adhocQuery = (AdhocQueryType) anyItem;
82 }
83 if (anyItem instanceof Element) {
84 Element element = (Element) anyItem;
85
86 Object o = (JAXBElement<oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType>) nhinSubscribe.getAny();
87
88 // Object o = (JAXBElement<oasis.names.tc.ebxml_regrep.xsd.rim._3.AdhocQueryType>) anyItem;
89 }
90 if (anyItem instanceof JAXBElement) {
91 if (((JAXBElement) anyItem).getValue() instanceof AdhocQueryType) {
92 adhocQuery = (AdhocQueryType) ((JAXBElement) anyItem).getValue();
93 }
94 }
95 }
96 return adhocQuery;
97 }
98}
Note: See TracBrowser for help on using the repository browser.