protected MCCIIN000002UV01 addPatientDiscoveryAsyncReq( RespondingGatewayPRPAIN201305UV02RequestType request) { MCCIIN000002UV01 ack = new MCCIIN000002UV01(); // "process" the request and send a response out to the Nhin. PatientDiscovery201305Processor msgProcessor = new PatientDiscovery201305Processor(); PRPAIN201306UV02 resp = msgProcessor.process201305(request.getPRPAIN201305UV02(), request.getAssertion()); // Generate a new response assertion AsyncMessageProcessHelper asyncProcess = createAsyncProcesser(); AssertionType newAssertion = asyncProcess.copyAssertionTypeObject(request.getAssertion()); // Original request message id is now set as the relates to id newAssertion.getRelatesToList().add(request.getAssertion().getMessageId()); // Generate a new unique response assertion Message ID newAssertion.setMessageId(AsyncMessageIdCreator.generateMessageId()); // Set user info homeCommunity String homeCommunityId = HomeCommunityMap.getLocalHomeCommunityId(); HomeCommunityType homeCommunityType = new HomeCommunityType(); homeCommunityType.setHomeCommunityId(homeCommunityId); homeCommunityType.setName(homeCommunityId); newAssertion.setHomeCommunity(homeCommunityType); if (newAssertion.getUserInfo() != null && newAssertion.getUserInfo().getOrg() != null) { newAssertion.getUserInfo().getOrg().setHomeCommunityId(homeCommunityId); newAssertion.getUserInfo().getOrg().setName(homeCommunityId); } ack = sendToNhin(resp, newAssertion, request.getNhinTargetCommunities()); return ack; }
/** * This calls the unsecured web service for this method. * * @param body The message to be sent to the web service. * @param assertion The assertion information to go with the message. * @return The response from the web service. * @throws PatientDiscoveryException */ @AdapterDelegationEvent( beforeBuilder = PRPAIN201305UV02EventDescriptionBuilder.class, afterReturningBuilder = PRPAIN201306UV02EventDescriptionBuilder.class, serviceType = "Patient Discovery", version = "1.0") public PRPAIN201306UV02 respondingGatewayPRPAIN201305UV02( PRPAIN201305UV02 body, AssertionType assertion) throws PatientDiscoveryException { String url = null; PRPAIN201306UV02 response = new PRPAIN201306UV02(); String sServiceName = NhincConstants.PATIENT_DISCOVERY_ADAPTER_SERVICE_NAME; try { if (body != null) { LOG.debug("Before target system URL look up."); url = oProxyHelper.getAdapterEndPointFromConnectionManager(sServiceName); LOG.debug( "After target system URL look up. URL for service: " + sServiceName + " is: " + url); if (NullChecker.isNotNullish(url)) { RespondingGatewayPRPAIN201305UV02RequestType request = new RespondingGatewayPRPAIN201305UV02RequestType(); request.setAssertion(assertion); request.setPRPAIN201305UV02(body); request.setNhinTargetCommunities(null); ServicePortDescriptor<AdapterPatientDiscoveryPortType> portDescriptor = new AdapterPatientDiscoveryServicePortDescriptor(); CONNECTClient<AdapterPatientDiscoveryPortType> client = CONNECTClientFactory.getInstance() .getCONNECTClientUnsecured(portDescriptor, url, assertion); response = (PRPAIN201306UV02) client.invokePort( AdapterPatientDiscoveryPortType.class, "respondingGatewayPRPAIN201305UV02", request); } else { throw new PatientDiscoveryException( "Failed to call the adapter web service (" + sServiceName + "). The URL is null."); } } else { throw new PatientDiscoveryException( "Failed to call the web service (" + sServiceName + "). The input parameter is null."); } } catch (Exception e) { LOG.error( "Failed to call the web service (" + sServiceName + "). An unexpected exception occurred. " + "Exception: " + e.getMessage(), e); throw new PatientDiscoveryException(e.fillInStackTrace()); } return response; }
public org.hl7.v3.MCCIIN000002UV01 processPatientDiscoveryAsyncReq( org.hl7.v3.RespondingGatewayPRPAIN201305UV02RequestType processPatientDiscoveryAsyncReqAsyncRequest) { return new AdapterPatientDiscoveryDeferredRequestImpl() .processPatientDiscoveryAsyncReq( processPatientDiscoveryAsyncReqAsyncRequest.getPRPAIN201305UV02(), processPatientDiscoveryAsyncReqAsyncRequest.getAssertion(), context); }
protected RequestType getRequestType(RespondingGatewayPRPAIN201305UV02RequestType event) { addDebugLog("Begin -- PatientDiscoveryPolicyTransformHelper.getRequestType()"); RequestType request = new RequestType(); setSubjectToRequestType(event, request); ResourceType resource = null; AttributeHelper attrHelper = new AttributeHelper(); II ii = extractPatientIdentifier(event.getPRPAIN201305UV02()); if (ii != null) { resource = new ResourceType(); resource .getAttribute() .add( attrHelper.attributeFactory( PatientAssigningAuthorityAttributeId, Constants.DataTypeString, ii.getRoot())); String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(ii.getExtension()); log.debug("transformSubjectAddedInToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId); resource .getAttribute() .add( attrHelper.attributeFactory( PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId)); request.getResource().add(resource); } request.getResource().add(resource); addDebugLog("End -- PatientDiscoveryPolicyTransformHelper.getRequestType()"); return request; }
protected void setSubjectToRequestType( RespondingGatewayPRPAIN201305UV02RequestType event, RequestType request) { // change to get the info from the receiver node HomeCommunityType receiverHomeCommunity = getReceiverHomeCommunityFrom201305(event); SubjectType subject = new SubjectHelper().subjectFactory(receiverHomeCommunity, event.getAssertion()); request.getSubject().add(subject); }
private HomeCommunityType getReceiverHomeCommunityFrom201305( RespondingGatewayPRPAIN201305UV02RequestType event) { HomeCommunityType receiverHomeCommunity = new HomeCommunityType(); if (event != null && event.getPRPAIN201305UV02().getReceiver() != null && !event.getPRPAIN201305UV02().getReceiver().isEmpty() && event.getPRPAIN201305UV02().getReceiver().get(0) != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice() != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getId() != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getId().get(0) != null && NullChecker.isNotNullish( event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getId() .get(0) .getRoot())) { receiverHomeCommunity.setHomeCommunityId( event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getId().get(0).getRoot()); } return receiverHomeCommunity; }
public MCCIIN000002UV01 addPatientDiscoveryAsyncReq( PRPAIN201305UV02 request, AssertionType assertion, NhinTargetCommunitiesType targets) { MCCIIN000002UV01 resp = new MCCIIN000002UV01(); RespondingGatewayPRPAIN201305UV02RequestType unsecureRequest = new RespondingGatewayPRPAIN201305UV02RequestType(); unsecureRequest.setAssertion(assertion); unsecureRequest.setNhinTargetCommunities(targets); unsecureRequest.setPRPAIN201305UV02(request); // Audit the incoming Nhin 201305 Message PatientDiscoveryAuditLogger auditLogger = new PatientDiscoveryAuditLogger(); AcknowledgementType ack = auditLogger.auditEntityDeferred201305( unsecureRequest, unsecureRequest.getAssertion(), NhincConstants.AUDIT_LOG_INBOUND_DIRECTION, NhincConstants.AUDIT_LOG_RESPONSE_PROCESS); // ASYNCMSG PROCESSING - RSPPROCESS AsyncMessageProcessHelper asyncProcess = createAsyncProcesser(); String messageId = assertion.getMessageId(); boolean bIsQueueOk = asyncProcess.processMessageStatus(messageId, AsyncMsgRecordDao.QUEUE_STATUS_RSPPROCESS); // check for valid queue entry if (bIsQueueOk) { resp = addPatientDiscoveryAsyncReq(unsecureRequest); asyncProcess.processAck( messageId, AsyncMsgRecordDao.QUEUE_STATUS_RSPSENTACK, AsyncMsgRecordDao.QUEUE_STATUS_RSPSENTERR, resp); } else { String ackMsg = "Deferred Patient Discovery response processing halted; deferred queue repository error encountered"; // Set the error acknowledgement status // fatal error with deferred queue repository resp = HL7AckTransforms.createAckErrorFrom201305(request, ackMsg); } // Audit the responding Acknowledgement Message ack = auditLogger.auditAck( resp, unsecureRequest.getAssertion(), NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION, NhincConstants.AUDIT_LOG_ENTITY_INTERFACE); return resp; }
protected HomeCommunityType getHomeCommunityFrom201305( RespondingGatewayPRPAIN201305UV02RequestType event) { HomeCommunityType senderHomeCommunity = new HomeCommunityType(); if (event != null && event.getPRPAIN201305UV02().getSender() != null && event.getPRPAIN201305UV02().getSender().getDevice() != null && event.getPRPAIN201305UV02().getSender().getDevice().getAsAgent() != null && event.getPRPAIN201305UV02().getSender().getDevice().getAsAgent().getValue() != null && event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() != null && event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() != null && NullChecker.isNotNullish( event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId()) && event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) != null && NullChecker.isNotNullish( event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot())) { senderHomeCommunity.setHomeCommunityId( event .getPRPAIN201305UV02() .getSender() .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot()); } return senderHomeCommunity; }
/** * Transform method to create a CheckPolicyRequest object from a 201305 request * * @param request * @return CheckPolicyRequestType */ public CheckPolicyRequestType transformPatientDiscoveryEntityToCheckPolicy( RespondingGatewayPRPAIN201305UV02RequestType event) { addDebugLog( "Begin -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()"); CheckPolicyRequestType checkPolicyRequest = null; if (event == null) { addErrorLog("Request is null."); return checkPolicyRequest; } else { checkPolicyRequest = new CheckPolicyRequestType(); } PRPAIN201305UV02 patDiscReq = event.getPRPAIN201305UV02(); // RequestType request = getRequestType(patDiscReq, event.getAssertion()); RequestType request = new RequestType(); SubjectHelper subjHelp = new SubjectHelper(); // SubjectType subject = subjHelp.subjectFactory(event.getAssertion().getHomeCommunity(), // event.getAssertion()); SubjectType subject = new SubjectType(); subject.setSubjectCategory(SubjectHelper.SubjectCategory); log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding subject"); request.getSubject().add(subject); II qualifiedPatientIdentifier = extractPatientIdentifier(patDiscReq); if (qualifiedPatientIdentifier != null) { ResourceType resource = new ResourceType(); AttributeHelper attrHelper = new AttributeHelper(); resource .getAttribute() .add( attrHelper.attributeFactory( PatientAssigningAuthorityAttributeId, Constants.DataTypeString, qualifiedPatientIdentifier.getRoot())); String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(qualifiedPatientIdentifier.getExtension()); log.debug( "transformPatientDiscoveryNhincToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId); resource .getAttribute() .add( attrHelper.attributeFactory( PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId)); HomeCommunityType homeCommunityId = null; if (event != null && event.getPRPAIN201305UV02() != null && NullChecker.isNotNullish(event.getPRPAIN201305UV02().getReceiver()) && event.getPRPAIN201305UV02().getReceiver().get(0) != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice() != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent() != null && event.getPRPAIN201305UV02().getReceiver().get(0).getDevice().getAsAgent().getValue() != null && event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() != null && event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() != null && NullChecker.isNotNullish( event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId()) && event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) != null && NullChecker.isNotNullish( event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot())) { homeCommunityId = new HomeCommunityType(); homeCommunityId.setHomeCommunityId( event .getPRPAIN201305UV02() .getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot()); } resource .getAttribute() .add( attrHelper.attributeFactory( Constants.HomeCommunityAttributeId, Constants.DataTypeString, subjHelp.determineSendingHomeCommunityId(homeCommunityId, event.getAssertion()))); request.getResource().add(resource); } log.debug("transformPatientDiscoveryNhincToCheckPolicy - adding assertion data"); AssertionHelper assertHelp = new AssertionHelper(); assertHelp.appendAssertionDataToRequest(request, event.getAssertion()); request.setAction(ActionHelper.actionFactory(ActionOutValue)); checkPolicyRequest.setRequest(request); checkPolicyRequest.setAssertion(event.getAssertion()); addDebugLog( "End -- PatientDiscoveryPolicyTransformHelper.transformPatientDiscoveryEntityToCheckPolicy()"); return checkPolicyRequest; }