protected MCCIIN000002UV01 sendToNhin( PRPAIN201306UV02 respMsg, AssertionType assertion, NhinTargetCommunitiesType targets) { MCCIIN000002UV01 resp = new MCCIIN000002UV01(); NhinTargetSystemType targetSystem = new NhinTargetSystemType(); CMUrlInfos urlInfoList = null; if (targets != null) { urlInfoList = getTargets(targets); } if (urlInfoList != null && NullChecker.isNotNullish(urlInfoList.getUrlInfo()) && urlInfoList.getUrlInfo().get(0) != null && NullChecker.isNotNullish(urlInfoList.getUrlInfo().get(0).getUrl())) { targetSystem.setUrl(urlInfoList.getUrlInfo().get(0).getUrl()); PassthruPatientDiscoveryDeferredRespProxyObjectFactory patientDiscoveryFactory = new PassthruPatientDiscoveryDeferredRespProxyObjectFactory(); PassthruPatientDiscoveryDeferredRespProxy proxy = patientDiscoveryFactory.getPassthruPatientDiscoveryDeferredRespProxy(); resp = proxy.proxyProcessPatientDiscoveryAsyncResp(respMsg, assertion, targetSystem); } return resp; }
public MCCIIN000002UV01 createAck( PIXConsumerPRPAIN201301UVRequestType request, String ackMsgText) { MCCIIN000002UV01 ack = new MCCIIN000002UV01(); II msgId = new II(); String senderOID = null; String receiverOID = null; if (request != null && request.getPRPAIN201301UV02() != null) { // Extract the message id if (request.getPRPAIN201301UV02().getId() != null) { msgId = request.getPRPAIN201301UV02().getId(); } // Set the sender OID to the receiver OID from the original message if (NullChecker.isNotNullish(request.getPRPAIN201301UV02().getReceiver()) && request.getPRPAIN201301UV02().getReceiver().get(0) != null && request.getPRPAIN201301UV02().getReceiver().get(0).getDevice() != null && NullChecker.isNotNullish( request.getPRPAIN201301UV02().getReceiver().get(0).getDevice().getId()) && request.getPRPAIN201301UV02().getReceiver().get(0).getDevice().getId().get(0) != null && NullChecker.isNotNullish( request .getPRPAIN201301UV02() .getReceiver() .get(0) .getDevice() .getId() .get(0) .getRoot())) { senderOID = request.getPRPAIN201301UV02().getReceiver().get(0).getDevice().getId().get(0).getRoot(); } // Set the receiver OID to the sender OID from the original message if (request.getPRPAIN201301UV02().getSender() != null && request.getPRPAIN201301UV02().getSender().getDevice() != null && NullChecker.isNotNullish(request.getPRPAIN201301UV02().getSender().getDevice().getId()) && request.getPRPAIN201301UV02().getSender().getDevice().getId().get(0) != null && NullChecker.isNotNullish( request.getPRPAIN201301UV02().getSender().getDevice().getId().get(0).getRoot())) { receiverOID = request.getPRPAIN201301UV02().getSender().getDevice().getId().get(0).getRoot(); } // Create the ack message ack = HL7AckTransforms.createAckMessage( null, msgId, HL7AckTransforms.ACK_TYPE_CODE_ACCEPT, ackMsgText, senderOID, receiverOID); } return ack; }
public static CheckPolicyRequestType transformSubscribeToCheckPolicy(SubscribeEventType event) { CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType(); RequestType request = new RequestType(); if (InboundOutboundChecker.isInbound(event.getDirection())) { request.setAction(ActionHelper.actionFactory(ActionInValue)); } if (InboundOutboundChecker.isOutbound(event.getDirection())) { request.setAction(ActionHelper.actionFactory(ActionOutValue)); } SubjectHelper subjHelp = new SubjectHelper(); SubjectType subject = subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion()); request.getSubject().add(subject); AdhocQueryRequest adhocReq = new AdhocQueryRequest(); AdhocQueryType adhocQuery = null; adhocQuery = getAdhocQuery(event.getMessage().getSubscribe()); adhocReq.setAdhocQuery(adhocQuery); String patId = AdhocQueryTransformHelper.extractPatientIdentifierId(adhocReq); String assignAuth = AdhocQueryTransformHelper.extractPatientIdentifierAssigningAuthority(adhocReq); ResourceType resource = new ResourceType(); AttributeHelper attrHelper = new AttributeHelper(); if (NullChecker.isNotNullish(assignAuth)) { resource .getAttribute() .add( attrHelper.attributeFactory( PatientAssigningAuthorityAttributeId, Constants.DataTypeString, assignAuth)); } if (NullChecker.isNotNullish(patId)) { String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(patId); LOG.debug("transformSubscribeToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId); resource .getAttribute() .add( attrHelper.attributeFactory( PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId)); } setTopic(event, resource); request.getResource().add(resource); AssertionHelper assertHelp = new AssertionHelper(); assertHelp.appendAssertionDataToRequest(request, event.getMessage().getAssertion()); genericPolicyRequest.setRequest(request); genericPolicyRequest.setAssertion(event.getMessage().getAssertion()); return genericPolicyRequest; }
@Override public int hashCode() { int hashCode = 0; if (NullChecker.isNotNullish(id)) { hashCode = id.hashCode(); if (NullChecker.isNotNullish(organizationId)) { hashCode += organizationId.hashCode(); } } return hashCode; }
private boolean equals(Identifier a, Identifier b) { if ((NullChecker.isNullish(a.getId())) || (a.getOrganizationId() == null) || (NullChecker.isNullish(b.getId())) || (b.getOrganizationId() == null)) { return false; } return a.getId().contentEquals(b.getId()) && a.getOrganizationId().contentEquals(b.getOrganizationId()); }
public void sendAlertMessage(EDXLDistribution body, AssertionType assertion) { log.debug("Begin sendAlertMessage"); String url = null; AdminDistributionHelper helper = getHelper(); String target = helper.getLocalCommunityId(); url = helper.getUrl(target, NhincConstants.ADAPTER_ADMIN_DIST_SECURED_SERVICE_NAME); if (NullChecker.isNotNullish(url)) { AdapterAdministrativeDistributionSecuredPortType port = getPort(url, assertion); RespondingGatewaySendAlertMessageSecuredType message = new RespondingGatewaySendAlertMessageSecuredType(); message.setEDXLDistribution(body); SamlTokenCreator tokenCreator = new SamlTokenCreator(); Map requestContext = tokenCreator.CreateRequestContext(assertion, url, NhincConstants.ADMIN_DIST_ACTION); WebServiceProxyHelper oHelper = new WebServiceProxyHelper(); oHelper.initializePort((javax.xml.ws.BindingProvider) port, url); try { getWebServiceProxyHelper() .invokePort( port, AdapterAdministrativeDistributionSecuredPortType.class, "sendAlertMessage", message); } catch (Exception ex) { log.error("Unable to send message: " + ex.getMessage()); } } }
private boolean checkPolicy(Notify notify, AssertionType assertion) { log.debug("In NhinHiemNotifyWebServiceProxy.checkPolicy"); boolean policyIsValid = false; NotifyEventType policyCheckReq = new NotifyEventType(); policyCheckReq.setDirection(NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION); gov.hhs.fha.nhinc.common.eventcommon.NotifyMessageType request = new gov.hhs.fha.nhinc.common.eventcommon.NotifyMessageType(); request.setAssertion(assertion); request.setNotify(notify); policyCheckReq.setMessage(request); PolicyEngineChecker policyChecker = new PolicyEngineChecker(); CheckPolicyRequestType policyReq = policyChecker.checkPolicyNotify(policyCheckReq); policyReq.setAssertion(assertion); PolicyEngineProxyObjectFactory policyEngFactory = new PolicyEngineProxyObjectFactory(); PolicyEngineProxy policyProxy = policyEngFactory.getPolicyEngineProxy(); CheckPolicyResponseType policyResp = policyProxy.checkPolicy(policyReq, assertion); if (policyResp.getResponse() != null && NullChecker.isNotNullish(policyResp.getResponse().getResult()) && policyResp.getResponse().getResult().get(0).getDecision() == DecisionType.PERMIT) { policyIsValid = true; } log.debug("Finished NhinHiemNotifyWebServiceProxy.checkPolicy - valid: " + policyIsValid); return policyIsValid; }
private static void setTopic(SubscribeEventType event, ResourceType resource) { String topic = null; try { LOG.debug("######## BEGIN TOPIC EXTRACTION ########"); JAXBElement<TopicExpressionType> jbElement = (JAXBElement<TopicExpressionType>) event.getMessage().getSubscribe().getFilter().getAny().get(0); TopicExpressionType topicExpression = jbElement.getValue(); topic = (String) topicExpression.getContent().get(0); LOG.debug("Topic extracted: " + topic); } catch (Throwable t) { LOG.error("Error extracting the topic: " + t.getMessage(), t); } if (NullChecker.isNotNullish(topic)) { if (LOG.isDebugEnabled()) { LOG.debug( "Adding topic (" + topic + ") as attribute (" + ATTRIBUTE_ID_TOPIC + ") and type: " + Constants.DataTypeString); } AttributeHelper attrHelper = new AttributeHelper(); resource .getAttribute() .add(attrHelper.attributeFactory(ATTRIBUTE_ID_TOPIC, Constants.DataTypeString, topic)); } }
public PRPAIN201310UV02 pixConsumerPRPAIN201309UV( PRPAIN201309UV02 request, AssertionType assertion, NhinTargetSystemType target) { String url = null; PRPAIN201310UV02 resp = new PRPAIN201310UV02(); // Get the URL to the Nhin Subject Discovery Service url = getUrl(target); if (NullChecker.isNotNullish(url)) { PIXConsumerPortType port = getPort(url); SamlTokenCreator tokenCreator = new SamlTokenCreator(); Map requestContext = tokenCreator.CreateRequestContext( assertion, url, NhincConstants.SUBJECT_DISCOVERY_ACTION); ((BindingProvider) port).getRequestContext().putAll(requestContext); resp = port.pixConsumerPRPAIN201309UV(request); } else { log.error( "The URL for service: " + NhincConstants.SUBJECT_DISCOVERY_SERVICE_NAME + " is null"); } return resp; }
/** * 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; }
private AdapterSubscriptionManagerPortType getPort(NhinTargetSystemType target) { String serviceName = NhincConstants.HIEM_UNSUBSCRIBE_ADAPTER_SERVICE_NAME; String url = getUrl(target, serviceName); AdapterSubscriptionManagerPortType port = null; if (NullChecker.isNotNullish(url)) { port = getPort(url); } return port; }
public PRPAIN201310UV02 createFault201310( PIXConsumerPRPAIN201309UVRequestType request, String ackMsgText) { PRPAIN201310UV02 result = new PRPAIN201310UV02(); String senderOID = null; String receiverOID = null; if (request != null && request.getPRPAIN201309UV02() != null) { // Set the sender OID to the receiver OID from the original message if (NullChecker.isNotNullish(request.getPRPAIN201309UV02().getReceiver()) && request.getPRPAIN201309UV02().getReceiver().get(0) != null && request.getPRPAIN201309UV02().getReceiver().get(0).getDevice() != null && NullChecker.isNotNullish( request.getPRPAIN201309UV02().getReceiver().get(0).getDevice().getId()) && request.getPRPAIN201309UV02().getReceiver().get(0).getDevice().getId().get(0) != null && NullChecker.isNotNullish( request .getPRPAIN201309UV02() .getReceiver() .get(0) .getDevice() .getId() .get(0) .getRoot())) { senderOID = request.getPRPAIN201309UV02().getReceiver().get(0).getDevice().getId().get(0).getRoot(); } // Set the receiver OID to the sender OID from the original message if (request.getPRPAIN201309UV02().getSender() != null && request.getPRPAIN201309UV02().getSender().getDevice() != null && NullChecker.isNotNullish(request.getPRPAIN201309UV02().getSender().getDevice().getId()) && request.getPRPAIN201309UV02().getSender().getDevice().getId().get(0) != null && NullChecker.isNotNullish( request.getPRPAIN201309UV02().getSender().getDevice().getId().get(0).getRoot())) { receiverOID = request.getPRPAIN201309UV02().getSender().getDevice().getId().get(0).getRoot(); } // Create the 201310 message result = HL7PRPA201310Transforms.createFaultPRPA201310(senderOID, receiverOID); } return result; }
protected boolean hasNhinTargetHomeCommunityId( RespondingGatewayProvideAndRegisterDocumentSetSecuredRequestType request) { if (request != null && request.getNhinTargetCommunities() != null && NullChecker.isNotNullish(request.getNhinTargetCommunities().getNhinTargetCommunity()) && request.getNhinTargetCommunities().getNhinTargetCommunity().get(0) != null && request.getNhinTargetCommunities().getNhinTargetCommunity().get(0).getHomeCommunity() != null && NullChecker.isNotNullish( request .getNhinTargetCommunities() .getNhinTargetCommunity() .get(0) .getHomeCommunity() .getHomeCommunityId())) { return true; } return false; }
public MCCIIN000002UV01 processPatientDiscoveryAsyncResp( PRPAIN201306UV02 request, AssertionType assertion, NhinTargetCommunitiesType target) { LOG.debug( "Begin EntityPatientDiscoveryDeferredResponseProxyWebServiceSecuredImpl.processPatientDiscoveryAsyncResp(...)"); MCCIIN000002UV01 response = new MCCIIN000002UV01(); String serviceName = NhincConstants.PATIENT_DISCOVERY_ENTITY_SECURED_ASYNC_RESP_SERVICE_NAME; try { LOG.debug("Before target system URL look up."); String url = oProxyHelper.getUrlLocalHomeCommunity(serviceName); if (LOG.isDebugEnabled()) { LOG.debug( "After target system URL look up. URL for service: " + serviceName + " is: " + url); } if (NullChecker.isNotNullish(url)) { RespondingGatewayPRPAIN201306UV02SecuredRequestType securedRequest = new RespondingGatewayPRPAIN201306UV02SecuredRequestType(); if (request != null) { securedRequest.setNhinTargetCommunities(target); securedRequest.setPRPAIN201306UV02(request); } ServicePortDescriptor<EntityPatientDiscoverySecuredAsyncRespPortType> portDescriptor = new EntityPatientDiscoverySecuredAsyncRespServicePortDescriptor(); CONNECTClient<EntityPatientDiscoverySecuredAsyncRespPortType> client = CONNECTClientFactory.getInstance() .getCONNECTClientSecured(portDescriptor, url, assertion); response = (MCCIIN000002UV01) client.invokePort( EntityPatientDiscoverySecuredAsyncRespPortType.class, "processPatientDiscoveryAsyncResp", securedRequest); } else { LOG.error("Failed to call the web service (" + serviceName + "). The URL is null."); } } catch (Exception ex) { LOG.error( "Error: Failed to retrieve url for service: " + serviceName + " for local home community"); LOG.error(ex.getMessage(), ex); } LOG.debug( "End EntityPatientDiscoveryDeferredResponseProxyWebServiceSecuredImpl.processPatientDiscoveryAsyncResp(...)"); return response; }
public static List<String> parseFormattedParameter( String paramFormattedString, List<String> resultCollection) { if (resultCollection == null) { resultCollection = new ArrayList<String>(); } if ((NullChecker.isNotNullish(paramFormattedString)) && (resultCollection != null)) { if (paramFormattedString.startsWith("(")) { String working = paramFormattedString.substring(1); int endIndex = working.indexOf(")"); if (endIndex != -1) { working = working.substring(0, endIndex); } String[] multiValueString = working.split(","); if (multiValueString != null) { for (int i = 0; i < multiValueString.length; i++) { String singleValue = multiValueString[i]; if (singleValue != null) { singleValue = singleValue.trim(); } if (singleValue.startsWith("'")) { singleValue = singleValue.substring(1); } if (singleValue.endsWith("'")) { int endTickIndex = singleValue.indexOf("'"); if (endTickIndex != -1) { singleValue = singleValue.substring(0, endTickIndex); } } resultCollection.add(singleValue); if (log.isDebugEnabled()) { log.debug("Added single value: " + singleValue + " to query parameters"); } } } } else { resultCollection.add(paramFormattedString); if (log.isDebugEnabled()) { log.debug( "No wrapper on status - adding status: " + paramFormattedString + " to query parameters"); } } } return resultCollection; }
private String getUrl(NhinTargetSystemType target, String serviceName) { String url = null; try { url = ConnectionManagerCache.getEndpontURLFromNhinTarget(target, serviceName); } catch (ConnectionManagerException ex) { log.warn( "exception occurred accessing url from connection manager (getEndpontURLFromNhinTarget)", ex); } if (NullChecker.isNullish(url)) { try { url = ConnectionManagerCache.getLocalEndpointURLByServiceName(serviceName); } catch (ConnectionManagerException ex) { log.warn( "exception occurred accessing url from connection manager (getLocalEndpointURLByServiceName)", ex); } } return url; }
public static String buildDocumentClassCodeItem(List<String> documentClassCodeList) { String buffer = ""; if ((documentClassCodeList != null) && (documentClassCodeList.size() > 0)) { buffer = "("; for (String documentClassCode : documentClassCodeList) { documentClassCode = documentClassCode.trim(); if (NullChecker.isNotNullish(buffer)) { buffer = buffer + "'" + documentClassCode + "'" + ","; } } if (buffer.endsWith(",")) { buffer = buffer.substring(0, buffer.length() - 1); } buffer = buffer + ")"; } if (buffer.contentEquals("()")) { buffer = ""; } return buffer; }
public Element subscribe( Element subscribeElement, AssertionType assertion, NhinTargetSystemType target) throws Exception { Element responseElement = null; String url = getWebServiceProxyHelper() .getAdapterEndPointFromConnectionManager( NhincConstants.HIEM_SUBSCRIBE_ADAPTER_SERVICE_NAME); if (NullChecker.isNotNullish(url)) { WsntSubscribeMarshaller subscribeMarshaller = new WsntSubscribeMarshaller(); Subscribe subscribe = subscribeMarshaller.unmarshalUnsubscribeRequest(subscribeElement); SubscribeRequestType adapterSubcribeRequest = new SubscribeRequestType(); adapterSubcribeRequest.setSubscribe(subscribe); adapterSubcribeRequest.setAssertion(assertion); ServicePortDescriptor<AdapterNotificationProducerPortType> portDescriptor = new HiemSubscribeAdapterServicePortDescriptor(); CONNECTClient<AdapterNotificationProducerPortType> client = getCONNECTClientUnsecured(portDescriptor, url, assertion); SubscribeResponse response = (SubscribeResponse) client.invokePort(AdapterNotificationProducerPortType.class, "subscribe", subscribe); SubscribeResponseMarshaller subscribeResponseMarshaller = new SubscribeResponseMarshaller(); responseElement = subscribeResponseMarshaller.marshal(response); } else { LOG.error( "Failed to call the web service (" + NhincConstants.HIEM_SUBSCRIBE_ADAPTER_SERVICE_NAME + "). The URL is null."); } return responseElement; }
private int getTimeoutFromConfig() { int timeout = 0; try { String sValue = PropertyAccessor.getInstance().getProperty(CONFIG_KEY_TIMEOUT); if (NullChecker.isNotNullish(sValue)) { timeout = Integer.parseInt(sValue); } } catch (PropertyAccessException ex) { LOG.warn( "Error occurred reading property value from config file (" + CONFIG_KEY_TIMEOUT + "). Exception: " + ex.toString()); } catch (NumberFormatException nfe) { LOG.warn( "Error occurred converting property value: " + CONFIG_KEY_TIMEOUT + ". Exception: " + nfe.toString()); } return timeout; }
private List<QualifiedSubjectIdentifierType> determineTargets(CMUrlInfos targets) { List<QualifiedSubjectIdentifierType> correlations = null; RetrievePatientCorrelationsRequestType request = new RetrievePatientCorrelationsRequestType(); request.setQualifiedPatientIdentifier(patientIdentifier); if ((targets != null) && (NullChecker.isNotNullish(targets.getUrlInfo()))) { for (CMUrlInfo targetCommunity : targets.getUrlInfo()) { request.getTargetHomeCommunity().add(targetCommunity.getHcid()); } } PatientCorrelationFacadeProxy patientCorrFacadeProxy = new PatientCorrelationFacadeProxyObjectFactory().getPatientCorrelationFacadeProxy(); RetrievePatientCorrelationsResponseType response = patientCorrFacadeProxy.retrievePatientCorrelations(request); if (response != null) { correlations = response.getQualifiedPatientIdentifier(); if (correlations != null) { for (QualifiedSubjectIdentifierType correlation : correlations) {} } } return correlations; }
/** * Fetch all the matching patients from all the community and all assigning authorities on a known * id. * * @param Patient * @return Patient */ public List<Patient> findPatients(Patient patient) { log.debug("PatientDAO.findAllPatients() - Begin"); Session session = null; List<Patient> patientsList = new ArrayList<Patient>(); try { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.openSession(); log.info("Reading Records..."); // NHIN required query parameters String gender = patient.getGender(); Timestamp dateOfBirth = patient.getDateOfBirth(); String firstName = patient.getPersonnames().get(0).getFirstName(); String lastName = patient.getPersonnames().get(0).getLastName(); // NHIN optional query parameters String ssn = patient.getSsn(); String prefix = patient.getPersonnames().get(0).getPrefix(); String middleName = patient.getPersonnames().get(0).getMiddleName(); String suffix = patient.getPersonnames().get(0).getSuffix(); Address address = new Address(); if (patient.getAddresses() != null && patient.getAddresses().size() > 0) { address = patient.getAddresses().get(0); } Phonenumber phonenumber = new Phonenumber(); if (patient.getPhonenumbers() != null && patient.getPhonenumbers().size() > 0) { phonenumber = patient.getPhonenumbers().get(0); } // Build the select with query criteria StringBuffer sqlSelect = new StringBuffer( "SELECT DISTINCT p.patientId, p.dateOfBirth, p.gender, p.ssn, i.id, i.organizationid"); sqlSelect.append(" FROM patientdb.patient p"); sqlSelect.append(" INNER JOIN patientdb.identifier i ON p.patientId = i.patientId"); sqlSelect.append(" INNER JOIN patientdb.personname n ON p.patientId = n.patientId"); if (address.getAddressId() != null) { sqlSelect.append(" INNER JOIN patientdb.address a ON p.patientId = a.patientId"); } if (phonenumber.getPhonenumberId() != null) { sqlSelect.append(" INNER JOIN patientdb.phonenumber h ON p.patientId = h.patientId"); } StringBuffer criteriaString = new StringBuffer(""); if (NullChecker.isNotNullish(gender)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" p.gender = ?"); } if (dateOfBirth != null) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" p.dateOfBirth = ?"); } if (NullChecker.isNotNullish(firstName)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" n.firstname = ?"); } if (NullChecker.isNotNullish(lastName)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" n.lastname = ?"); } if (NullChecker.isNotNullish(ssn)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" p.ssn = ?"); } if (NullChecker.isNotNullish(prefix)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" n.prefix = ?"); } if (NullChecker.isNotNullish(middleName)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" n.middleName = ?"); } if (NullChecker.isNotNullish(suffix)) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" n.suffix = ?"); } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getStreet1())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" a.street1 = ?"); } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getStreet2())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" a.street2 = ?"); } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getCity())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" a.city = ?"); } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getState())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" a.state = ?"); } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getPostal())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" a.postal = ?"); } if (phonenumber.getPhonenumberId() != null && NullChecker.isNotNullish(phonenumber.getValue())) { if (criteriaString.length() > 0) { criteriaString.append(" AND"); } else { criteriaString.append(" WHERE"); } criteriaString.append(" h.value = ?"); } sqlSelect.append(criteriaString); sqlSelect.append(" ORDER BY i.id, i.organizationid"); Query sqlQuery = session .createSQLQuery(sqlSelect.toString()) .addScalar("patientId", Hibernate.LONG) .addScalar("dateOfBirth", Hibernate.TIMESTAMP) .addScalar("gender", Hibernate.STRING) .addScalar("ssn", Hibernate.STRING) .addScalar("id", Hibernate.STRING) .addScalar("organizationid", Hibernate.STRING); int iParam = 0; if (NullChecker.isNotNullish(gender)) { sqlQuery.setString(iParam, gender); iParam++; } if (dateOfBirth != null) { sqlQuery.setTimestamp(iParam, dateOfBirth); iParam++; } if (NullChecker.isNotNullish(firstName)) { sqlQuery.setString(iParam, firstName); iParam++; } if (NullChecker.isNotNullish(lastName)) { sqlQuery.setString(iParam, lastName); iParam++; } if (NullChecker.isNotNullish(ssn)) { sqlQuery.setString(iParam, ssn); iParam++; } if (NullChecker.isNotNullish(prefix)) { sqlQuery.setString(iParam, prefix); iParam++; } if (NullChecker.isNotNullish(middleName)) { sqlQuery.setString(iParam, middleName); iParam++; } if (NullChecker.isNotNullish(suffix)) { sqlQuery.setString(iParam, suffix); iParam++; } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getStreet1())) { sqlQuery.setString(iParam, address.getStreet1()); iParam++; } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getStreet2())) { sqlQuery.setString(iParam, address.getStreet2()); iParam++; } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getCity())) { sqlQuery.setString(iParam, address.getCity()); iParam++; } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getState())) { sqlQuery.setString(iParam, address.getState()); iParam++; } if (address.getAddressId() != null && NullChecker.isNotNullish(address.getPostal())) { sqlQuery.setString(iParam, address.getPostal()); iParam++; } if (phonenumber.getPhonenumberId() != null && NullChecker.isNotNullish(phonenumber.getValue())) { sqlQuery.setString(iParam, phonenumber.getValue()); iParam++; } log.debug("Final SQL Query is " + sqlQuery.getQueryString()); List<Object[]> result = sqlQuery.list(); if (result != null && result.size() > 0) { Long[] patientIdArray = new Long[result.size()]; Timestamp[] dateOfBirthArray = new Timestamp[result.size()]; String[] genderArray = new String[result.size()]; String[] ssnArray = new String[result.size()]; String[] idArray = new String[result.size()]; String[] organizationIdArray = new String[result.size()]; int counter = 0; for (Object[] row : result) { patientIdArray[counter] = (Long) row[0]; dateOfBirthArray[counter] = (Timestamp) row[1]; genderArray[counter] = row[2].toString(); ssnArray[counter] = row[3].toString(); idArray[counter] = row[4].toString(); organizationIdArray[counter] = row[5].toString(); counter++; } for (int i = 0; i < patientIdArray.length; i++) { Patient patientData = new Patient(); patientData.setPatientId(patientIdArray[i]); patientData.setDateOfBirth(dateOfBirthArray[i]); patientData.setGender(genderArray[i]); patientData.setSsn(ssnArray[i]); Identifier identifierData = new Identifier(); identifierData.getPatient().setPatientId(patientIdArray[i]); identifierData.setId(idArray[i]); identifierData.setOrganizationId(organizationIdArray[i]); patientData.getIdentifiers().add(identifierData); // Populate demographic data patientData.setAddresses( AddressDAO.getAddressDAOInstance().findPatientAddresses(patientIdArray[i])); patientData.setPersonnames( PersonnameDAO.getPersonnameDAOInstance().findPatientPersonnames(patientIdArray[i])); patientData.setPhonenumbers( PhonenumberDAO.getPhonenumberDAOInstance() .findPatientPhonenumbers(patientIdArray[i])); patientsList.add(patientData); } } } catch (Exception e) { log.error("Exception during read occured due to : " + e.getMessage(), e); } finally { // Flush and close session if (session != null) { session.flush(); session.close(); } } log.debug("PatientDAO.findPatients() - End"); return patientsList; }
public org.hl7.v3.PRPAIN201306UV02 proxyPRPAIN201305UV( org.hl7.v3.PRPAIN201305UV02 body, WebServiceContext context) { PRPAIN201306UV02 response = null; ProxyPRPAIN201305UVProxyRequestType request = new ProxyPRPAIN201305UVProxyRequestType(); request.setPRPAIN201305UV02(body); request.setAssertion(SamlTokenExtractor.GetAssertion(context)); String homeCommunityId = null; if (body != null && NullChecker.isNotNullish(body.getReceiver()) && body.getReceiver().get(0) != null && body.getReceiver().get(0).getDevice() != null && body.getReceiver().get(0).getDevice().getAsAgent() != null && body.getReceiver().get(0).getDevice().getAsAgent().getValue() != null && body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() != null && body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() != null && NullChecker.isNotNullish( body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId()) && body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) != null && NullChecker.isNotNullish( body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot())) { homeCommunityId = body.getReceiver() .get(0) .getDevice() .getAsAgent() .getValue() .getRepresentedOrganization() .getValue() .getId() .get(0) .getRoot(); } else { homeCommunityId = SamlTokenExtractorHelper.getHomeCommunityId(); } if (NullChecker.isNotNullish(homeCommunityId)) { NhincProxyPatientDiscovery service = new NhincProxyPatientDiscovery(); NhincProxyPatientDiscoveryPortType port = service.getNhincProxyPatientDiscoveryPort(); ((javax.xml.ws.BindingProvider) port) .getRequestContext() .put( javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SamlTokenExtractorHelper.getEndpointURL(homeCommunityId, SERVICE_NAME)); response = port.proxyPRPAIN201305UV(request); } else { response = null; } return response; }
public LogEventRequestType transformNhinNotifyRequestToAuditMessage( LogNhinNotifyRequestType message) { LogEventRequestType response = new LogEventRequestType(); AuditMessageType auditMsg = new AuditMessageType(); LOG.info("******************************************************************"); LOG.info("Entering transformNhinNotifyRequestToAuditMessage() method."); LOG.info("******************************************************************"); if (message == null || message.getDirection() == null || message.getInterface() == null) { LOG.error( "DocumentQueryTransforms.transformDocQueryReq2AuditMsg() has insufficient data to log a message audfit"); return null; } String _interface = message.getInterface(); String direction = message.getDirection(); response.setDirection(direction); response.setInterface(_interface); AssertionType assertion = null; UserType userInfo = null; // Extract Assertion and UserInfo from Message.Assertion if (message != null && message.getMessage() != null && message.getMessage().getAssertion() != null) { assertion = message.getMessage().getAssertion(); if (assertion.getUserInfo() != null) { userInfo = message.getMessage().getAssertion().getUserInfo(); } } // Create EventIdentification CodedValueType eventID = null; eventID = AuditDataTransformHelper.createCodedValue( AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_NOT, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_NOTIFY, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_NOT, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_NOTIFY, null); auditMsg.setEventIdentification( AuditDataTransformHelper.createEventIdentification( AuditDataTransformConstants.EVENT_ACTION_CODE_CREATE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID, null)); // Create Active Participant Section boolean isSender = AuditDataTransformHelper.isSender(_interface, direction); boolean isRecipient = isSender ? false : true; if (userInfo != null) { ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantForHuman(userInfo); auditMsg.getActiveParticipant().add(participant); } ActiveParticipant source = AuditDataTransformHelper.createActiveParticipantSource(isSender, null); auditMsg.getActiveParticipant().add(source); ActiveParticipant destination = AuditDataTransformHelper.createActiveParticipantDestination( assertion.getSamlAuthnStatement(), isRecipient); auditMsg.getActiveParticipant().add(destination); /* Assign AuditSourceIdentification */ String patientId = ""; if (message != null && NullChecker.isNotNullish(message.getMessage().getAssertion().getUniquePatientId()) && NullChecker.isNotNullish( message.getMessage().getAssertion().getUniquePatientId().get(0))) { patientId = message.getMessage().getAssertion().getUniquePatientId().get(0); } String communityId = ""; String communityName = ""; if (userInfo != null && userInfo.getOrg() != null) { if (userInfo.getOrg().getHomeCommunityId() != null) { communityId = userInfo.getOrg().getHomeCommunityId(); } if (userInfo.getOrg().getName() != null) { communityName = userInfo.getOrg().getName(); } } AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName, null); auditMsg.getAuditSourceIdentification().add(auditSource); /* Assign ParticipationObjectIdentification */ /** Create a ParticipantObjectIdentification entry for Patient */ ParticipantObjectIdentificationType partObjId = null; if ((patientId != null) && (!patientId.isEmpty())) { CodedValueType partObjectIdType = AuditDataTransformHelper.getPatientParticipantRoleIdCodedValue(); // Participant Object Identification Entry $1 Patient partObjId = AuditDataTransformHelper.createParticipantObjectIdentification( AuditDataTransformConstants.PARTICIPANT_OBJECT_TYPE_CODE_PERSON, AuditDataTransformConstants.PARTICIPANT_OBJECT_TYPE_CODE_ROLE_PATIENT, partObjectIdType, patientId, null); auditMsg.getParticipantObjectIdentification().add(partObjId); } // TODO: Illegal piggybacking of message in ParticipantObjectIdentification.ObjectQuery boolean addDone = true; if (partObjId == null) { partObjId = new ParticipantObjectIdentificationType(); addDone = false; } // Fill in the message field with the contents of the event message try { JAXBContextHandler oHandler = new JAXBContextHandler(); JAXBContext jc = oHandler.getJAXBContext( org.oasis_open.docs.wsn.b_2.ObjectFactory.class, ihe.iti.xds_b._2007.ObjectFactory.class); Marshaller marshaller = jc.createMarshaller(); ByteArrayOutputStream baOutStrm = new ByteArrayOutputStream(); baOutStrm.reset(); if (message != null) { marshaller.marshal(message.getMessage().getNotify(), baOutStrm); } LOG.debug("Done marshalling the message."); partObjId.setParticipantObjectQuery(baOutStrm.toByteArray()); } catch (Exception e) { e.printStackTrace(); LOG.error("EXCEPTION when marshalling Nhin Notify Request : " + e); throw new RuntimeException(); } if (!addDone) { auditMsg.getParticipantObjectIdentification().add(partObjId); } response.setAuditMessage(auditMsg); LOG.info("******************************************************************"); LOG.info("Exiting transformNhinNotifyRequestToAuditMessage() method."); LOG.info("******************************************************************"); return response; }
private void isPropertyStringValid(String property) throws PropertyAccessException { if (NullChecker.isNullish(property)) { throw new PropertyAccessException("Invalid property name value: " + property); } }
public void notify( Element notifyElement, ReferenceParametersElements referenceParametersElements, AssertionType assertion, NhinTargetSystemType target) { String url = null; log.debug( "Notify element received in NhinHiemNotifyWebServiceProxy: " + XmlUtility.serializeElementIgnoreFaults(notifyElement)); if (target != null) { try { url = ConnectionManagerCache.getEndpontURLFromNhinTarget( target, NhincConstants.HIEM_NOTIFY_SERVICE_NAME); } catch (ConnectionManagerException ex) { log.error( "Error: Failed to retrieve url for service: " + NhincConstants.HIEM_NOTIFY_SERVICE_NAME); log.error(ex.getMessage()); } } else { log.error("Target system passed into the proxy is null"); } try { if (NullChecker.isNotNullish(url)) { NotificationConsumer port = getPort(url); log.debug("unmarshaling notify message"); WsntSubscribeMarshaller notifyMarshaller = new WsntSubscribeMarshaller(); Notify notify = notifyMarshaller.unmarshalNotifyRequest(notifyElement); // Element reMarshalled = notifyMarshaller.marshalNotifyRequest(notify); // log.debug("REMARSHALLED: " + // XmlUtility.serializeElementIgnoreFaults(reMarshalled)); // Policy check log.debug("Calling checkPolicy"); if (checkPolicy(notify, assertion)) { log.debug("attaching reference parameter headers"); SoapUtil soapUtil = new SoapUtil(); soapUtil.attachReferenceParameterElements( (WSBindingProvider) port, referenceParametersElements); auditInputMessage(notify, assertion); log.debug("Calling token creator"); SamlTokenCreator tokenCreator = new SamlTokenCreator(); Map requestContext = tokenCreator.CreateRequestContext(assertion, url, NhincConstants.SUBSCRIBE_ACTION); ((BindingProvider) port).getRequestContext().putAll(requestContext); try { log.debug("Calling notification consumer port in NhinHiemWebServiceProxy."); port.notify(notify); } catch (Exception ex) { log.error("Error occurred while trying to invoke notify", ex); } ((Closeable) port).close(); } else { log.error("Failed policy check on send NHIN notify message"); } } else { log.error("The URL for service: " + NhincConstants.HIEM_NOTIFY_SERVICE_NAME + " is null"); } } catch (Throwable t) { // TODO: Figure out what to do with the exception log.error("Error sending notify to remote gateway: " + t.getMessage(), t); } }
public LogEventRequestType transformEntityNotifyResponseToGenericAudit( LogEntityNotifyResponseType message) { LogEventRequestType response = new LogEventRequestType(); AuditMessageType auditMsg = new AuditMessageType(); LOG.info("******************************************************************"); LOG.info("Entering transformEntityNotifyResponseToGenericAudit() method."); LOG.info("******************************************************************"); if (message == null || message.getDirection() == null || message.getInterface() == null) { LOG.error( "DocumentQueryTransforms.transformDocQueryReq2AuditMsg() has insufficient data to log a message audfit"); return null; } String _interface = message.getInterface(); String direction = message.getDirection(); response.setDirection(direction); response.setInterface(_interface); AssertionType assertion = null; UserType userInfo = null; // Extract Assertion and UserInfo from Message.Assertion if (message != null && message.getMessage() != null && message.getMessage().getAssertion() != null) { assertion = message.getMessage().getAssertion(); if (assertion.getUserInfo() != null) { userInfo = message.getMessage().getAssertion().getUserInfo(); } } // Create EventIdentification CodedValueType eventID = null; eventID = AuditDataTransformHelper.createCodedValue( AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_NOT, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_NOTIFY, AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_NOT, AuditDataTransformConstants.EVENT_ID_DISPLAY_NAME_NOTIFY, null); auditMsg.setEventIdentification( AuditDataTransformHelper.createEventIdentification( AuditDataTransformConstants.EVENT_ACTION_CODE_CREATE, AuditDataTransformConstants.EVENT_OUTCOME_INDICATOR_SUCCESS, eventID, null)); // Create Active Participant Section boolean isSender = AuditDataTransformHelper.isSender(_interface, direction); boolean isRecipient = isSender ? false : true; if (userInfo != null) { ActiveParticipant participant = AuditDataTransformHelper.createActiveParticipantForHuman(userInfo); auditMsg.getActiveParticipant().add(participant); } ActiveParticipant source = AuditDataTransformHelper.createActiveParticipantSource(isSender, null); auditMsg.getActiveParticipant().add(source); ActiveParticipant destination = AuditDataTransformHelper.createActiveParticipantDestination( assertion.getSamlAuthnStatement(), isRecipient); auditMsg.getActiveParticipant().add(destination); /* Assign AuditSourceIdentification */ String patientId = ""; if (message != null && NullChecker.isNotNullish(message.getMessage().getAssertion().getUniquePatientId()) && NullChecker.isNotNullish( message.getMessage().getAssertion().getUniquePatientId().get(0))) { patientId = message.getMessage().getAssertion().getUniquePatientId().get(0); } String communityId = ""; String communityName = ""; if (userInfo != null && userInfo.getOrg() != null) { if (userInfo.getOrg().getHomeCommunityId() != null) { communityId = userInfo.getOrg().getHomeCommunityId(); } if (userInfo.getOrg().getName() != null) { communityName = userInfo.getOrg().getName(); } } AuditSourceIdentificationType auditSource = AuditDataTransformHelper.createAuditSourceIdentification(communityId, communityName, null); auditMsg.getAuditSourceIdentification().add(auditSource); /* Assign ParticipationObjectIdentification */ /** Create a ParticipantObjectIdentification entry for Patient */ ParticipantObjectIdentificationType partObjId = null; if ((patientId != null) && (!patientId.isEmpty())) { CodedValueType partObjectIdType = AuditDataTransformHelper.getPatientParticipantRoleIdCodedValue(); // Participant Object Identification Entry $1 Patient partObjId = AuditDataTransformHelper.createParticipantObjectIdentification( AuditDataTransformConstants.PARTICIPANT_OBJECT_TYPE_CODE_PERSON, AuditDataTransformConstants.PARTICIPANT_OBJECT_TYPE_CODE_ROLE_PATIENT, partObjectIdType, patientId, null); auditMsg.getParticipantObjectIdentification().add(partObjId); } // TODO: Illegal piggybacking of message in ParticipantObjectIdentification.ObjectQuery if (partObjId == null) { partObjId = new ParticipantObjectIdentificationType(); } response.setAuditMessage(auditMsg); LOG.info("******************************************************************"); LOG.info("Exiting transformEntityNotifyResponseToGenericAudit() method."); LOG.info("******************************************************************"); return response; }
public PRPAIN201306UV02 PRPAIN201305UV( PRPAIN201305UV02 body, AssertionType assertion, NhinTargetSystemType target) { String url = null; PRPAIN201306UV02 response = new PRPAIN201306UV02(); ProxyPRPAIN201305UVProxyRequestType proxyRequest = new ProxyPRPAIN201305UVProxyRequestType(); try { if (body != null) { proxyRequest.setPRPAIN201305UV02(body); proxyRequest.setAssertion(assertion); proxyRequest.setNhinTargetSystem(target); log.debug("Before target system URL look up."); url = oProxyHelper.getUrlLocalHomeCommunity( NhincConstants.NHINC_PASSTHRU_PATIENT_DISCOVERY_SERVICE_NAME); log.debug( "After target system URL look up. URL for service: " + NhincConstants.NHINC_PASSTHRU_PATIENT_DISCOVERY_SERVICE_NAME + " is: " + url); if (NullChecker.isNotNullish(url)) { NhincProxyPatientDiscoveryPortType port = getPort( url, NhincConstants.PATIENT_DISCOVERY_ACTION, WS_ADDRESSING_ACTION, assertion); response = (PRPAIN201306UV02) oProxyHelper.invokePort( port, NhincProxyPatientDiscoveryPortType.class, "proxyPRPAIN201305UV", proxyRequest); } else { log.error( "Failed to call the web service (" + NhincConstants.NHINC_PASSTHRU_PATIENT_DISCOVERY_SERVICE_NAME + "). The URL is null."); } } else { log.error( "Failed to call the web service (" + NhincConstants.NHINC_PASSTHRU_PATIENT_DISCOVERY_SERVICE_NAME + "). The input parameter is null."); } } catch (Exception e) { log.error( "Failed to call the web service (" + NhincConstants.NHINC_PASSTHRU_PATIENT_DISCOVERY_SERVICE_NAME + "). An unexpected exception occurred. " + "Exception: " + e.getMessage(), e); response = new HL7PRPA201306Transforms() .createPRPA201306ForErrors( proxyRequest.getPRPAIN201305UV02(), NhincConstants.PATIENT_DISCOVERY_ANSWER_NOT_AVAIL_ERR_CODE); } return response; }