1 | package gov.hhs.fha.nhinc.cpp;
|
---|
2 |
|
---|
3 | import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType;
|
---|
4 | import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotificationMessageHolderType.Message;
|
---|
5 | import gov.hhs.fha.nhinc.common.subscriptionb2overridefordocuments.NotifyDocumentType;
|
---|
6 | import gov.hhs.fha.nhinc.entitynotificationconsumer.EntityNotificationConsumerPortType;
|
---|
7 | import gov.hhs.fha.nhinc.mpilib.MiniMpi;
|
---|
8 | import gov.hhs.fha.nhinc.mpilib.Patient;
|
---|
9 | import gov.hhs.fha.nhinc.mpilib.Patients;
|
---|
10 | import gov.hhs.fha.nhinc.properties.PropertyAccessException;
|
---|
11 | import gov.hhs.fha.nhinc.properties.PropertyAccessor;
|
---|
12 | import gov.hhs.fha.nhinc.repository.model.Document;
|
---|
13 | import gov.hhs.fha.nhinc.repository.model.DocumentQueryParams;
|
---|
14 | import gov.hhs.fha.nhinc.repository.service.DocumentService;
|
---|
15 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
|
---|
16 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType.DocumentRequest;
|
---|
17 | import java.util.List;
|
---|
18 | import java.util.UUID;
|
---|
19 | import javax.xml.bind.JAXBElement;
|
---|
20 | import javax.xml.ws.BindingProvider;
|
---|
21 | import oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryResponse;
|
---|
22 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType;
|
---|
23 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType;
|
---|
24 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType;
|
---|
25 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.InternationalStringType;
|
---|
26 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.LocalizedStringType;
|
---|
27 | import oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType;
|
---|
28 | import org.apache.commons.logging.Log;
|
---|
29 | import org.apache.commons.logging.LogFactory;
|
---|
30 | import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
|
---|
31 | import gov.hhs.fha.nhinc.common.nhinccommon.PersonNameType;
|
---|
32 | import gov.hhs.fha.nhinc.common.nhinccommon.UserType;
|
---|
33 | import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
|
---|
34 | import gov.hhs.fha.nhinc.common.nhinccommon.CeType;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | *
|
---|
38 | * @author svalluripalli
|
---|
39 | */
|
---|
40 | public class CPPOperations extends Thread {
|
---|
41 |
|
---|
42 | public static final String CPP_CLASS_CODE = "XNHIN-CONSENT";
|
---|
43 | private static Log log = LogFactory.getLog(CPPOperations.class);
|
---|
44 | private static String ADAPTER_PROPFILE_NAME = "adapter";
|
---|
45 | private static String ENTITY_NOTIFICATION_CONSUMER_ENDPOINT_URL = "EntityNotificationConsumerURL";
|
---|
46 | private static String ASSERTIONINFO_PROPFILE_NAME = "assertioninfo";
|
---|
47 | private static String DATE_OF_SIGNATURE = "SignDate";
|
---|
48 | private static String EXPIRATION_DATE = "ExpirationDate";
|
---|
49 | private static String FIRST_NAME = "UserFirstName";
|
---|
50 | private static String LAST_NAME = "UserLastName";
|
---|
51 | private static String USER_NAME = "UserName";
|
---|
52 | private static String ORG_NAME = "UserOrganization";
|
---|
53 | private static String USER_ROLE_CD = "UserRoleCode";
|
---|
54 | private static String USER_ROLE_CD_SYSTEM = "UserRoleCodeSystem";
|
---|
55 | private static String USER_ROLE_CD_SYSTEM_NAME = "UserRoleCodeSystemName";
|
---|
56 | private static String USER_ROLE_DISPLAY_NAME = "UserRoleDisplayName";
|
---|
57 | private static String PURPOSE_FOR_USE_ROLE_CD = "PurposeForUseRoleCode";
|
---|
58 | private static String PURPOSE_FOR_USE_CODE_SYSTEM = "PurposeForUseCodeSystem";
|
---|
59 | private static String PURPOSE_FOR_USE_CODE_SYSTEM_NAME = "PurposeForUseCodeSystemName";
|
---|
60 | private static String PURPOSE_FOR_USE_DISPLAY_NAME = "PurposeForUseDisplayName";
|
---|
61 | private static String CONTENT_REFERENCE = "ContentReference";
|
---|
62 | private static String CONTENT = "Content";
|
---|
63 | private static String SubscribeeCommunityList_PROPFILE_NAME = "SubscribeeCommunityList";
|
---|
64 | private static final String EBXML_RESPONSE_DOCID_IDENTIFICATION_SCHEME = "urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab";
|
---|
65 | private static final String EBXML_RESPONSE_PATIENTID_IDENTIFICATION_SCHEME = "urn:uuid:58a6f841-87b3-4a3e-92fd-a8ffeff98427";
|
---|
66 | private static final String EBXML_RESPONSE_DOCID_NAME = "XDSDocumentEntry.uniqueId";
|
---|
67 | private static final String EBXML_RESPONSE_PATIENTID_NAME = "XDSDocumentEntry.patientId";
|
---|
68 | private String patId;
|
---|
69 | private String orgId;
|
---|
70 | private String xacml;
|
---|
71 | private boolean finished = false;
|
---|
72 |
|
---|
73 | public boolean isFinished() {
|
---|
74 | return finished;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public void setFinished(boolean finished) {
|
---|
78 | this.finished = finished;
|
---|
79 | }
|
---|
80 |
|
---|
81 | public boolean isSendSuccessful() {
|
---|
82 | return sendSuccessful;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public void setSendSuccessful(boolean sendSuccessful) {
|
---|
86 | this.sendSuccessful = sendSuccessful;
|
---|
87 | }
|
---|
88 | private boolean sendSuccessful = false;
|
---|
89 |
|
---|
90 | public void init(String patientId, String organisationId, String xacmlDocument){
|
---|
91 | this.patId = patientId;
|
---|
92 | this.orgId = organisationId;
|
---|
93 | this.xacml = xacmlDocument;
|
---|
94 | }
|
---|
95 |
|
---|
96 | public void run() {
|
---|
97 | DocumentService docService = new DocumentService();
|
---|
98 |
|
---|
99 | log.debug("Saving CPP...");
|
---|
100 | log.debug("patId: " + patId);
|
---|
101 |
|
---|
102 | Document doc = retreiveCPP(patId, orgId);
|
---|
103 |
|
---|
104 | doc.setClassCode(CPP_CLASS_CODE);
|
---|
105 | doc.setRawData(xacml.getBytes());
|
---|
106 | doc.setPatientId(patId);
|
---|
107 | doc.setSourcePatientId(patId);
|
---|
108 | doc.setDocumentUniqueId(patId + '-' + CPP_CLASS_CODE);
|
---|
109 | doc.setDocumentTitle("Consumer Preferences Profile");
|
---|
110 |
|
---|
111 | log.debug("Calling save document");
|
---|
112 | docService.saveDocument(doc);
|
---|
113 | updateOptInNotifyDocument(patId, orgId, xacml, doc);
|
---|
114 | }
|
---|
115 |
|
---|
116 | public Document retreiveCPP(String patId, String orgId) {
|
---|
117 | log.debug("Check existing CPP document");
|
---|
118 | Document doc = new Document();
|
---|
119 | DocumentService docService = new DocumentService();
|
---|
120 | DocumentQueryParams params = new DocumentQueryParams();
|
---|
121 | java.util.LinkedList<String> cc = new java.util.LinkedList<String>();
|
---|
122 | java.util.List<Document> docs;
|
---|
123 |
|
---|
124 | cc.add(CPP_CLASS_CODE);
|
---|
125 |
|
---|
126 | params.setClassCodes(cc);
|
---|
127 | params.setPatientId(patId);
|
---|
128 | docs = docService.documentQuery(params);
|
---|
129 |
|
---|
130 | if (docs.size() == 1) {
|
---|
131 | log.debug("found cpp");
|
---|
132 | doc = docs.get(0);
|
---|
133 | }
|
---|
134 | return doc;
|
---|
135 | }
|
---|
136 |
|
---|
137 | /**
|
---|
138 | *
|
---|
139 | * @param patId
|
---|
140 | * @param orgId
|
---|
141 | * @param xacml
|
---|
142 | * @param doc
|
---|
143 | */
|
---|
144 | public void updateOptInNotifyDocument(String patId, String orgId, String xacml, gov.hhs.fha.nhinc.repository.model.Document doc) {
|
---|
145 | String ack = "";
|
---|
146 | ack = updateOptIn(patId, orgId, xacml);
|
---|
147 | log.info(ack);
|
---|
148 |
|
---|
149 | try { // Call Web Service Operation
|
---|
150 | gov.hhs.fha.nhinc.entitynotificationconsumer.EntityNotificationConsumerPortType port = getEntityNotificationConsumerWebservice();
|
---|
151 | gov.hhs.fha.nhinc.common.nhinccommonentity.NotifySubscribersOfDocumentRequestType notifySubscribersOfDocumentRequest = new gov.hhs.fha.nhinc.common.nhinccommonentity.NotifySubscribersOfDocumentRequestType();
|
---|
152 | DocumentRequest documentRequest = new DocumentRequest();
|
---|
153 | documentRequest.setDocumentUniqueId(doc.getDocumentUniqueId());
|
---|
154 | RetrieveDocumentSetRequestType retrieveDocumentSetRequestType = new RetrieveDocumentSetRequestType();
|
---|
155 | retrieveDocumentSetRequestType.getDocumentRequest().add(documentRequest);
|
---|
156 | Message message = new Message();
|
---|
157 | message.setRetrieveDocumentSetRequest(retrieveDocumentSetRequestType);
|
---|
158 | NotificationMessageHolderType notificationMessageHolderType = new NotificationMessageHolderType();
|
---|
159 | notificationMessageHolderType.setMessage(message);
|
---|
160 | NotifyDocumentType notifyDocumentType = new NotifyDocumentType();
|
---|
161 | notifyDocumentType.getNotificationMessage().add(notificationMessageHolderType);
|
---|
162 | notifySubscribersOfDocumentRequest.setNotify(notifyDocumentType);
|
---|
163 | RegistryObjectListType registryObjectListType = buildRegistryObjectList(patId, orgId, xacml, doc);
|
---|
164 | notifySubscribersOfDocumentRequest.setRegistryObjectList(registryObjectListType);
|
---|
165 | AssertionType assertion = buildAssertion(orgId);
|
---|
166 | notifySubscribersOfDocumentRequest.setAssertion(assertion);
|
---|
167 | gov.hhs.fha.nhinc.common.nhinccommon.AcknowledgementType result = port.notifySubscribersOfDocument(notifySubscribersOfDocumentRequest);
|
---|
168 | System.out.println("Result = " + result);
|
---|
169 | log.info(result.getMessage());
|
---|
170 | } catch (Exception ex) {
|
---|
171 | ex.printStackTrace();
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | private static RegistryObjectListType buildRegistryObjectList(String patId, String orgId, String xacml, gov.hhs.fha.nhinc.repository.model.Document doc){
|
---|
176 | AdhocQueryResponse oAdhocQueryResponse = new AdhocQueryResponse();
|
---|
177 | RegistryObjectListType oRegObjList = new RegistryObjectListType();
|
---|
178 | oasis.names.tc.ebxml_regrep.xsd.rim._3.ObjectFactory oRimObjectFactory = new oasis.names.tc.ebxml_regrep.xsd.rim._3.ObjectFactory();
|
---|
179 | oAdhocQueryResponse.setRegistryObjectList(oRegObjList);
|
---|
180 | List<JAXBElement<? extends IdentifiableType>> olRegObjs = oRegObjList.getIdentifiable();
|
---|
181 | ExternalIdentifierType oExtId = new ExternalIdentifierType();
|
---|
182 | ExternalIdentifierType oExtId1 = new ExternalIdentifierType();
|
---|
183 | ExtrinsicObjectType oExObj = new ExtrinsicObjectType();
|
---|
184 | JAXBElement<? extends IdentifiableType> oJAXBExtId = oRimObjectFactory.createExtrinsicObject(oExObj);
|
---|
185 | oExtId.setHome(orgId);
|
---|
186 | UUID oDocumentUUID = UUID.randomUUID();
|
---|
187 | String sDocumentUUID = "urn:uuid:" + oDocumentUUID.toString();
|
---|
188 | oExtId.setId(sDocumentUUID);
|
---|
189 | oExtId.setIdentificationScheme(EBXML_RESPONSE_DOCID_IDENTIFICATION_SCHEME);
|
---|
190 | oExtId.setName(CreateSingleValueInternationalStringType(EBXML_RESPONSE_DOCID_NAME));
|
---|
191 | oExtId1.setName(CreateSingleValueInternationalStringType(EBXML_RESPONSE_PATIENTID_NAME));
|
---|
192 | oExtId1.setHome(orgId);
|
---|
193 | UUID oDocumentUUID1 = UUID.randomUUID();
|
---|
194 | String sDocumentUUID1 = "urn:uuid:" + oDocumentUUID1.toString();
|
---|
195 | oExtId1.setId(sDocumentUUID1);
|
---|
196 | oExtId1.setIdentificationScheme(EBXML_RESPONSE_PATIENTID_IDENTIFICATION_SCHEME);
|
---|
197 | oExObj.getExternalIdentifier().add(oExtId1);
|
---|
198 | oExObj.getExternalIdentifier().add(oExtId);
|
---|
199 | olRegObjs.add(oJAXBExtId);
|
---|
200 | return oRegObjList;
|
---|
201 | }
|
---|
202 |
|
---|
203 | private static InternationalStringType CreateSingleValueInternationalStringType(String sLocStrValue)
|
---|
204 | {
|
---|
205 | log.debug("DocumentTransforms.CreateSingleValueInternationalStringType() -- Begin");
|
---|
206 | InternationalStringType oName = new InternationalStringType();
|
---|
207 | List<LocalizedStringType> olLocStr = oName.getLocalizedString();
|
---|
208 | LocalizedStringType oNameLocStr = new LocalizedStringType();
|
---|
209 | olLocStr.add(oNameLocStr);
|
---|
210 | oNameLocStr.setCharset("UTF-8");
|
---|
211 | oNameLocStr.setValue(sLocStrValue);
|
---|
212 | oNameLocStr.setLang("en-us");
|
---|
213 | log.debug("DocumentTransforms.CreateSingleValueInternationalStringType() -- End");
|
---|
214 | return oName;
|
---|
215 | }
|
---|
216 |
|
---|
217 | private static AssertionType buildAssertion(String gatewayOid){
|
---|
218 | log.debug("Begin - CPPOperations.buildAssertion() - ");
|
---|
219 | AssertionType assertion = new AssertionType();
|
---|
220 | String svalue = "";
|
---|
221 | try {
|
---|
222 | assertion.setHaveSignature(true);
|
---|
223 | assertion.setHaveWitnessSignature(true);
|
---|
224 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, DATE_OF_SIGNATURE);
|
---|
225 | if (svalue != null && svalue.length() > 0) {
|
---|
226 | assertion.setDateOfSignature(svalue.trim());
|
---|
227 | } else {
|
---|
228 | assertion.setDateOfSignature("");
|
---|
229 | }
|
---|
230 |
|
---|
231 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, EXPIRATION_DATE);
|
---|
232 | if (null != svalue && svalue.length() > 0) {
|
---|
233 | assertion.setExpirationDate(svalue.trim());
|
---|
234 | } else {
|
---|
235 | assertion.setExpirationDate("");
|
---|
236 | }
|
---|
237 | PersonNameType aPersonName = new PersonNameType();
|
---|
238 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, FIRST_NAME);
|
---|
239 | if(null != svalue && svalue.length() > 0){
|
---|
240 | aPersonName.setGivenName(svalue.trim());
|
---|
241 | } else {
|
---|
242 | aPersonName.setGivenName("");
|
---|
243 | }
|
---|
244 |
|
---|
245 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, LAST_NAME);
|
---|
246 | if(null != svalue && svalue.length() > 0){
|
---|
247 | aPersonName.setFamilyName(svalue.trim());
|
---|
248 | } else {
|
---|
249 | aPersonName.setFamilyName("");
|
---|
250 | }
|
---|
251 | UserType aUser = new UserType();
|
---|
252 | aUser.setPersonName(aPersonName);
|
---|
253 |
|
---|
254 | HomeCommunityType userHm = new HomeCommunityType();
|
---|
255 | svalue = PropertyAccessor.getProperty(SubscribeeCommunityList_PROPFILE_NAME, gatewayOid);
|
---|
256 | if (null != svalue && svalue.length() > 0) {
|
---|
257 | userHm.setName(svalue.trim());
|
---|
258 | } else {
|
---|
259 | userHm.setName("");
|
---|
260 | }
|
---|
261 | userHm.setHomeCommunityId(gatewayOid);
|
---|
262 | aUser.setOrg(userHm);
|
---|
263 | CeType userCe = new CeType();
|
---|
264 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, USER_ROLE_CD);
|
---|
265 | if(null!=svalue && svalue.length()>0){
|
---|
266 | userCe.setCode(svalue.trim());
|
---|
267 | } else {
|
---|
268 | userCe.setCode("");
|
---|
269 | }
|
---|
270 |
|
---|
271 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, USER_ROLE_CD_SYSTEM);
|
---|
272 | if(null!=svalue && svalue.length()>0){
|
---|
273 | userCe.setCodeSystem(svalue.trim());
|
---|
274 | } else {
|
---|
275 | userCe.setCodeSystem("");
|
---|
276 | }
|
---|
277 |
|
---|
278 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, USER_ROLE_CD_SYSTEM_NAME);
|
---|
279 | if(null!=svalue && svalue.length()>0){
|
---|
280 | userCe.setCodeSystemName(svalue.trim());
|
---|
281 | } else {
|
---|
282 | userCe.setCodeSystemName("");
|
---|
283 | }
|
---|
284 |
|
---|
285 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, USER_ROLE_DISPLAY_NAME);
|
---|
286 | if(null!=svalue && svalue.length()>0){
|
---|
287 | userCe.setDisplayName(svalue.trim());
|
---|
288 | } else {
|
---|
289 | userCe.setDisplayName("");
|
---|
290 | }
|
---|
291 | aUser.setRoleCoded(userCe);
|
---|
292 |
|
---|
293 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, USER_NAME);
|
---|
294 | if(null!=svalue && svalue.length()>0){
|
---|
295 | aUser.setUserName(svalue.trim());
|
---|
296 | } else {
|
---|
297 | aUser.setUserName("");
|
---|
298 | }
|
---|
299 | assertion.setUserInfo(aUser);
|
---|
300 |
|
---|
301 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, ORG_NAME);
|
---|
302 | HomeCommunityType hm = new HomeCommunityType();
|
---|
303 | if (null != svalue && svalue.length() > 0) {
|
---|
304 | hm.setName(svalue.trim());
|
---|
305 | } else {
|
---|
306 | hm.setName("");
|
---|
307 | }
|
---|
308 | assertion.setHomeCommunity(hm);
|
---|
309 |
|
---|
310 | CeType ce = new CeType();
|
---|
311 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, PURPOSE_FOR_USE_ROLE_CD);
|
---|
312 | if(null!=svalue && svalue.length()>0){
|
---|
313 | ce.setCode(svalue.trim());
|
---|
314 | } else {
|
---|
315 | ce.setCode("");
|
---|
316 | }
|
---|
317 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, PURPOSE_FOR_USE_CODE_SYSTEM);
|
---|
318 | if(null!=svalue && svalue.length()>0){
|
---|
319 | ce.setCodeSystem(svalue.trim());
|
---|
320 | } else {
|
---|
321 | ce.setCodeSystem("");
|
---|
322 | }
|
---|
323 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, PURPOSE_FOR_USE_CODE_SYSTEM_NAME);
|
---|
324 | if(null!=svalue && svalue.length()>0){
|
---|
325 | ce.setCodeSystemName(svalue.trim());
|
---|
326 | } else {
|
---|
327 | ce.setCodeSystemName("");
|
---|
328 | }
|
---|
329 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, PURPOSE_FOR_USE_DISPLAY_NAME);
|
---|
330 | if(null!=svalue && svalue.length()>0){
|
---|
331 | ce.setDisplayName(svalue.trim());
|
---|
332 | } else {
|
---|
333 | ce.setDisplayName("");
|
---|
334 | }
|
---|
335 | assertion.setPurposeOfDisclosureCoded(ce);
|
---|
336 |
|
---|
337 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, CONTENT_REFERENCE);
|
---|
338 | if(null!=svalue && svalue.length()>0){
|
---|
339 | assertion.setClaimFormRef(svalue.trim());
|
---|
340 | } else {
|
---|
341 | assertion.setClaimFormRef("");
|
---|
342 | }
|
---|
343 |
|
---|
344 | svalue = PropertyAccessor.getProperty(ASSERTIONINFO_PROPFILE_NAME, CONTENT);
|
---|
345 | svalue = svalue.trim();
|
---|
346 | if(null!=svalue && svalue.length()>0){
|
---|
347 | assertion.setClaimFormRaw(svalue.getBytes());
|
---|
348 | } else {
|
---|
349 | assertion.setClaimFormRaw("".getBytes());
|
---|
350 | }
|
---|
351 |
|
---|
352 | } catch (PropertyAccessException propExp) {
|
---|
353 | propExp.printStackTrace();
|
---|
354 | }
|
---|
355 | log.debug("End - CPPOperations.buildAssertion() - ");
|
---|
356 | return assertion;
|
---|
357 | }
|
---|
358 |
|
---|
359 | private EntityNotificationConsumerPortType getEntityNotificationConsumerWebservice() throws PropertyAccessException {
|
---|
360 | String endpointURL = PropertyAccessor.getProperty(ADAPTER_PROPFILE_NAME, ENTITY_NOTIFICATION_CONSUMER_ENDPOINT_URL);
|
---|
361 | log.info("EntitySubscriptionURL :" + endpointURL);
|
---|
362 | EntityNotificationConsumerPortType entitynotificationconsumerPort = null;
|
---|
363 | gov.hhs.fha.nhinc.entitynotificationconsumer.EntityNotificationConsumer service = new gov.hhs.fha.nhinc.entitynotificationconsumer.EntityNotificationConsumer();
|
---|
364 | entitynotificationconsumerPort = service.getEntityNotificationConsumerPortSoap11();
|
---|
365 | // Need to load in the correct UDDI endpoint URL address.
|
---|
366 | //--------------------------------------------------------
|
---|
367 | ((BindingProvider) entitynotificationconsumerPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
|
---|
368 | return entitynotificationconsumerPort;
|
---|
369 | }
|
---|
370 |
|
---|
371 | /**
|
---|
372 | *
|
---|
373 | * @param patId
|
---|
374 | * @param orgId
|
---|
375 | * @param xacml
|
---|
376 | * @return String
|
---|
377 | */
|
---|
378 | public String updateOptIn(String patId, String orgId, String xacml) {
|
---|
379 | log.debug("updateOptIn in MPI");
|
---|
380 | String ack = "";
|
---|
381 | org.w3c.dom.Document doc = CPPUtils.ByteArrayToDoc(xacml.getBytes());
|
---|
382 | boolean optInStatus = CPPUtils.isOptedIn(doc);
|
---|
383 | Patient searchParams = new Patient();
|
---|
384 | searchParams.getIdentifiers().add(patId, orgId);
|
---|
385 | //Search for patient
|
---|
386 | MiniMpi mpi = MiniMpi.GetMpiInstance();
|
---|
387 | Patients searchResults = mpi.Search(searchParams, false, true);
|
---|
388 | if (searchResults != null && searchResults.size() > 0) {
|
---|
389 | if (searchResults.size() > 1) {
|
---|
390 | return "More than one Patient found in MPI";
|
---|
391 | }
|
---|
392 | Patient patFound = searchResults.get(0);
|
---|
393 | if (optInStatus && patFound.isOptedIn()) {
|
---|
394 | return "Patient was already Opted In nothing to Update";
|
---|
395 | }
|
---|
396 |
|
---|
397 | if (!optInStatus && !patFound.isOptedIn()) {
|
---|
398 | return "Patient was already Opted Out nothing to Update";
|
---|
399 | }
|
---|
400 |
|
---|
401 | patFound.setOptedIn(optInStatus);
|
---|
402 | Patient updatedPatient = mpi.AddUpdate(patFound);
|
---|
403 |
|
---|
404 | if (updatedPatient != null && updatedPatient.getIdentifiers().get(0).getId() != null) {
|
---|
405 | ack = "Patient OptInOut Flag Updated Successfully";
|
---|
406 | } else {
|
---|
407 | ack = "Patient OptInOut Flag Not Updated";
|
---|
408 | }
|
---|
409 |
|
---|
410 | } else {
|
---|
411 | ack = "Patient Not Found in MPI";
|
---|
412 | }
|
---|
413 | return ack;
|
---|
414 | }
|
---|
415 | }
|
---|