[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.gateway.aggregator;
|
---|
| 6 |
|
---|
| 7 | import com.services.nhinc.schema.auditmessage.AuditMessageType;
|
---|
| 8 | import com.services.nhinc.schema.auditmessage.FindAuditEventsResponseType;
|
---|
| 9 | import gov.hhs.fha.nhinc.common.connectionmanager.dao.AssigningAuthorityHomeCommunityMappingDAO;
|
---|
| 10 | import gov.hhs.fha.nhinc.common.nhinccommon.QualifiedSubjectIdentifierType;
|
---|
| 11 | import gov.hhs.fha.nhinc.nhinccomponentaggregator.NhincComponentAggregatorPortType;
|
---|
| 12 | import javax.ejb.Stateless;
|
---|
| 13 | import javax.jws.WebService;
|
---|
| 14 |
|
---|
| 15 | import gov.hhs.fha.nhinc.gateway.aggregator.document.DocQueryAggregator;
|
---|
| 16 | import gov.hhs.fha.nhinc.gateway.aggregator.document.DocRetrieveAggregator;
|
---|
| 17 | import gov.hhs.fha.nhinc.nhinclib.NullChecker;
|
---|
| 18 | import java.util.HashMap;
|
---|
| 19 | import java.util.List;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | *
|
---|
| 23 | * @author westbergl
|
---|
| 24 | */
|
---|
| 25 | @WebService(serviceName = "NhincComponentAggregator",
|
---|
| 26 | portName = "NhincComponentAggregatorPort",
|
---|
| 27 | endpointInterface = "gov.hhs.fha.nhinc.nhinccomponentaggregator.NhincComponentAggregatorPortType",
|
---|
| 28 | targetNamespace = "urn:gov:hhs:fha:nhinc:nhinccomponentaggregator",
|
---|
| 29 | wsdlLocation = "META-INF/wsdl/NhincComponentAggregator/NhincComponentAggregator.wsdl")
|
---|
| 30 | @Stateless
|
---|
| 31 | public class NhincComponentAggregator implements NhincComponentAggregatorPortType
|
---|
| 32 | {
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * This method starts a transaction for doc query messages. It will record
|
---|
| 36 | * the systems where messages will be sent as part of this transaction and
|
---|
| 37 | * then will return a unique transaction ID that will be associated with
|
---|
| 38 | * all messages in this transaction.
|
---|
| 39 | *
|
---|
| 40 | * @param startTransactionDocQueryRequest The Patient ID, and AssigningAuthority pairs
|
---|
| 41 | * for each NHIN gateway that will be receiving
|
---|
| 42 | * a request message.
|
---|
| 43 | * @return The assigned transaction ID.
|
---|
| 44 | */
|
---|
| 45 | public StartTransactionDocQueryResponseType startTransactionDocQuery(StartTransactionDocQueryRequestType startTransactionDocQueryRequest)
|
---|
| 46 | {
|
---|
| 47 | StartTransactionDocQueryResponseType oResponse = new StartTransactionDocQueryResponseType();
|
---|
| 48 | String sTransactionId = "";
|
---|
| 49 |
|
---|
| 50 | // Cycle through the list of assigning authorities and get the corresponding
|
---|
| 51 | // home community IDs so that we can use them later.
|
---|
| 52 | //--------------------------------------------------------------------------
|
---|
| 53 | HashMap<String,String> hAssignAuthToHomeCommMap = new HashMap<String, String>();
|
---|
| 54 | if ((startTransactionDocQueryRequest != null) &&
|
---|
| 55 | (startTransactionDocQueryRequest.getQualifiedPatientIdentifiers() != null) &&
|
---|
| 56 | (startTransactionDocQueryRequest.getQualifiedPatientIdentifiers().getQualifiedSubjectIdentifier() != null) &&
|
---|
| 57 | (startTransactionDocQueryRequest.getQualifiedPatientIdentifiers().getQualifiedSubjectIdentifier().size() > 0))
|
---|
| 58 | {
|
---|
| 59 | AssigningAuthorityHomeCommunityMappingDAO mappingDao = new AssigningAuthorityHomeCommunityMappingDAO();
|
---|
| 60 |
|
---|
| 61 | List<QualifiedSubjectIdentifierType> olQualSubjId = startTransactionDocQueryRequest.getQualifiedPatientIdentifiers().getQualifiedSubjectIdentifier();
|
---|
| 62 | for (QualifiedSubjectIdentifierType oQualSubjId : olQualSubjId)
|
---|
| 63 | {
|
---|
| 64 | if ((oQualSubjId.getAssigningAuthorityIdentifier() != null) &&
|
---|
| 65 | (oQualSubjId.getAssigningAuthorityIdentifier().trim().length() > 0) &&
|
---|
| 66 | (!hAssignAuthToHomeCommMap.containsKey(oQualSubjId.getAssigningAuthorityIdentifier().trim())))
|
---|
| 67 | {
|
---|
| 68 | String sHomeCommunityId = mappingDao.getHomeCommunityId(oQualSubjId.getAssigningAuthorityIdentifier().trim());
|
---|
| 69 | if ((sHomeCommunityId != null) &&
|
---|
| 70 | (sHomeCommunityId.trim().length() > 0))
|
---|
| 71 | {
|
---|
| 72 | hAssignAuthToHomeCommMap.put(oQualSubjId.getAssigningAuthorityIdentifier().trim(), sHomeCommunityId);
|
---|
| 73 | }
|
---|
| 74 | } // if ((oQualSubjId.getAssigningAuthorityIdentifier() != null) &&
|
---|
| 75 | } // for (QualifiedSubjectIdentifierType oQualSubjId : olQualSubjId)
|
---|
| 76 | } // if ((startTransactionDocQueryRequest != null) &&
|
---|
| 77 |
|
---|
| 78 | DocQueryAggregator oAggregator = new DocQueryAggregator();
|
---|
| 79 | sTransactionId = oAggregator.startTransaction(startTransactionDocQueryRequest, hAssignAuthToHomeCommMap);
|
---|
| 80 |
|
---|
| 81 | oResponse.setTransactionId(sTransactionId);
|
---|
| 82 |
|
---|
| 83 | return oResponse;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /**
|
---|
| 87 | * This method is called to log the response from an NHIN gateway for a
|
---|
| 88 | * specific doc query transaction. It will save the response and wait for the
|
---|
| 89 | * caller to request an aggregated set of responses.
|
---|
| 90 | *
|
---|
| 91 | * @param setResponseMsgDocQueryRequest The response that was received and is to be logged
|
---|
| 92 | * awaiting for aggregation.
|
---|
| 93 | * @return The status of the call. 'Success' or 'Failure'.
|
---|
| 94 | */
|
---|
| 95 | public SetResponseMsgDocQueryResponseType setResponseMsgDocQuery(SetResponseMsgDocQueryRequestType setResponseMsgDocQueryRequest)
|
---|
| 96 | {
|
---|
| 97 | SetResponseMsgDocQueryResponseType oResponse = new SetResponseMsgDocQueryResponseType();
|
---|
| 98 | DocQueryAggregator oAggregator = new DocQueryAggregator();
|
---|
| 99 | String sStatus = oAggregator.setResponseMsg(setResponseMsgDocQueryRequest);
|
---|
| 100 | oResponse.setStatus(sStatus);
|
---|
| 101 | return oResponse;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | /**
|
---|
| 105 | * This method returns either a status if it is still waiting for results
|
---|
| 106 | * to come in, or the set of aggregated results. If the caller passes in
|
---|
| 107 | * false for the "timed out" parameter, it will only return the results
|
---|
| 108 | * when all of the expected responses have been recieved. If they have not
|
---|
| 109 | * all been received, then it will return a status of "Pending" with no
|
---|
| 110 | * reesults. When all are received, it will send a status of "Complete"
|
---|
| 111 | * along with the aggregated results. If timedOut is set to true, then
|
---|
| 112 | * it will pass back the set of aggregated results that was received and
|
---|
| 113 | * it will place error information in the aggregated results for the ones
|
---|
| 114 | * that it did not receive. It will also send back a status of "Incomplete"
|
---|
| 115 | * with the results. If timedOut is set to true, but everything had been
|
---|
| 116 | * received, then it will send back a status of "Complete" with the
|
---|
| 117 | * aggregated results.
|
---|
| 118 | *
|
---|
| 119 | * @param getAggResultsDocQueryRequest Tells whether we are in a timed out
|
---|
| 120 | * state or not.
|
---|
| 121 | * @return Returns results if all responses have been received or if
|
---|
| 122 | * timedOut is set to true. Returns status only if we are not
|
---|
| 123 | * timedOut and if not all expected results have been received.
|
---|
| 124 | */
|
---|
| 125 | public GetAggResultsDocQueryResponseType getAggResultsDocQuery(GetAggResultsDocQueryRequestType getAggResultsDocQueryRequest)
|
---|
| 126 | {
|
---|
| 127 | GetAggResultsDocQueryResponseType oResponse = new GetAggResultsDocQueryResponseType();
|
---|
| 128 | DocQueryAggregator oAggregator = new DocQueryAggregator();
|
---|
| 129 | oResponse = oAggregator.getAggResults(getAggResultsDocQueryRequest);
|
---|
| 130 | return oResponse;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * This method starts a transaction for doc retrieve messages. It will record
|
---|
| 135 | * the systems where messages will be sent as part of this transaction and
|
---|
| 136 | * then will return a unique transaction ID that will be associated with
|
---|
| 137 | * all messages in this transaction.
|
---|
| 138 | *
|
---|
| 139 | * @param startTransactionDocRetrieveRequest The Home community ID, Repository ID,
|
---|
| 140 | * and DocumentId for each document
|
---|
| 141 | * that will be requested from an
|
---|
| 142 | * NHIN gateway.
|
---|
| 143 | * @return The assigned transaction ID.
|
---|
| 144 | */
|
---|
| 145 | public StartTransactionDocRetrieveResponseType startTransactionDocRetrieve(StartTransactionDocRetrieveRequestType startTransactionDocRetrieveRequest)
|
---|
| 146 | {
|
---|
| 147 | StartTransactionDocRetrieveResponseType oResponse = new StartTransactionDocRetrieveResponseType();
|
---|
| 148 | String sTransactionId = "";
|
---|
| 149 |
|
---|
| 150 | DocRetrieveAggregator oAggregator = new DocRetrieveAggregator();
|
---|
| 151 | sTransactionId = oAggregator.startTransaction(startTransactionDocRetrieveRequest);
|
---|
| 152 |
|
---|
| 153 | oResponse.setTransactionId(sTransactionId);
|
---|
| 154 |
|
---|
| 155 | return oResponse;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * This method is called to log the response from an NHIN gateway for a
|
---|
| 160 | * specific doc retrieve transaction. It will save the response and wait for the
|
---|
| 161 | * caller to request an aggregated set of responses.
|
---|
| 162 | *
|
---|
| 163 | * @param setResponseMsgDocRetrieveRequest The response that was received and is to be logged
|
---|
| 164 | * awaiting for aggregation along with the identification
|
---|
| 165 | * information for this message that was given when the transaction
|
---|
| 166 | * was started.
|
---|
| 167 | * @return The status of the call. 'Success' or 'Failure'.
|
---|
| 168 | */
|
---|
| 169 | public SetResponseMsgDocRetrieveResponseType setResponseMsgDocRetrieve(SetResponseMsgDocRetrieveRequestType setResponseMsgDocRetrieveRequest)
|
---|
| 170 | {
|
---|
| 171 | SetResponseMsgDocRetrieveResponseType oResponse = new SetResponseMsgDocRetrieveResponseType();
|
---|
| 172 | DocRetrieveAggregator oAggregator = new DocRetrieveAggregator();
|
---|
| 173 | String sStatus = oAggregator.setResponseMsg(setResponseMsgDocRetrieveRequest);
|
---|
| 174 | oResponse.setStatus(sStatus);
|
---|
| 175 | return oResponse;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | /**
|
---|
| 179 | * This method returns either a status if it is still waiting for results
|
---|
| 180 | * to come in, or the set of aggregated results. If the caller passes in
|
---|
| 181 | * false for the "timed out" parameter, it will only return the results
|
---|
| 182 | * when all of the expected responses have been recieved. If they have not
|
---|
| 183 | * all been received, then it will return a status of "Pending" with no
|
---|
| 184 | * reesults. When all are received, it will send a status of "Complete"
|
---|
| 185 | * along with the aggregated results. If timedOut is set to true, then
|
---|
| 186 | * it will pass back the set of aggregated results that was received and
|
---|
| 187 | * it will place error information in the aggregated results for the ones
|
---|
| 188 | * that it did not receive. It will also send back a status of "Incomplete"
|
---|
| 189 | * with the results. If timedOut is set to true, but everything had been
|
---|
| 190 | * received, then it will send back a status of "Complete" with the
|
---|
| 191 | * aggregated results.
|
---|
| 192 | *
|
---|
| 193 | * @param getAggResultsDocRetrieveRequest Tells whether we are in a timed out
|
---|
| 194 | * state or not.
|
---|
| 195 | * @return Returns results if all responses have been received or if
|
---|
| 196 | * timedOut is set to true. Returns status only if we are not
|
---|
| 197 | * timedOut and if not all expected results have been received.
|
---|
| 198 | */
|
---|
| 199 | public GetAggResultsDocRetrieveResponseType getAggResultsDocRetrieve(GetAggResultsDocRetrieveRequestType getAggResultsDocRetrieveRequest)
|
---|
| 200 | {
|
---|
| 201 | GetAggResultsDocRetrieveResponseType oResponse = new GetAggResultsDocRetrieveResponseType();
|
---|
| 202 | DocRetrieveAggregator oAggregator = new DocRetrieveAggregator();
|
---|
| 203 | oResponse = oAggregator.getAggResults(getAggResultsDocRetrieveRequest);
|
---|
| 204 | return oResponse;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | public FindAuditEventsResponseType getAggResultsAuditQuery(FindAuditEventsResponseAggregationType getAggResultsAuditQueryRequest) {
|
---|
| 208 | FindAuditEventsResponseType response = null;
|
---|
| 209 |
|
---|
| 210 | // if we have an aggregate, then use that as the basis.
|
---|
| 211 | //------------------------------------------------------
|
---|
| 212 | if ((getAggResultsAuditQueryRequest != null) &&
|
---|
| 213 | (getAggResultsAuditQueryRequest.getAggregate() != null) &&
|
---|
| 214 | (NullChecker.isNotNullish(getAggResultsAuditQueryRequest.getAggregate().getFindAuditEventsReturn()))) {
|
---|
| 215 | response = getAggResultsAuditQueryRequest.getAggregate();
|
---|
| 216 | if (getAggResultsAuditQueryRequest.getNew() != null &&
|
---|
| 217 | NullChecker.isNotNullish(getAggResultsAuditQueryRequest.getNew().getFindAuditEventsReturn())) {
|
---|
| 218 | for (AuditMessageType msg : getAggResultsAuditQueryRequest.getNew().getFindAuditEventsReturn()) {
|
---|
| 219 | response.getFindAuditEventsReturn().add(msg);
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
| 223 | // If the aggregate is empty, then use the new as the basis...
|
---|
| 224 | //--------------------------------------------------------------
|
---|
| 225 | else if ((getAggResultsAuditQueryRequest != null) &&
|
---|
| 226 | NullChecker.isNotNullish(getAggResultsAuditQueryRequest.getNew().getFindAuditEventsReturn())) {
|
---|
| 227 | response = getAggResultsAuditQueryRequest.getNew();
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | return response;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | }
|
---|