[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | package gov.hhs.fha.nhinc.adaptermpi;
|
---|
| 7 |
|
---|
| 8 | import gov.hhs.fha.nhinc.adaptercomponentmpi.*;
|
---|
| 9 | import org.apache.commons.logging.Log;
|
---|
| 10 | import org.apache.commons.logging.LogFactory;
|
---|
| 11 | import org.hl7.v3.PIXConsumerPRPAIN201305UVRequestType;
|
---|
| 12 | import org.hl7.v3.PRPAIN201306UV;
|
---|
| 13 | import gov.hhs.fha.nhinc.properties.PropertyAccessor;
|
---|
| 14 | import gov.hhs.fha.nhinc.connectmgr.ConnectionManagerCache;
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | *
|
---|
| 19 | * @author Jon Hoppesch
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | public class AdapterMpiQuery {
|
---|
| 23 | private static Log log = LogFactory.getLog(AdapterMpiQuery.class);
|
---|
| 24 |
|
---|
| 25 | private static final String GATEWAY_PROPERTY_FILE = "gateway";
|
---|
| 26 | private static final String HOME_COMMUNITY_ID_PROPERTY = "localHomeCommunityId";
|
---|
| 27 | private static final String SERVICE_NAME_ADAPTER_COMPONENT_MPI_SERVICE = "adaptercomponentmpiservice";
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * Send the patient query request to the actual MPI that is implemented
|
---|
| 31 | *
|
---|
| 32 | * @param
|
---|
| 33 | * @return
|
---|
| 34 | */
|
---|
| 35 | public static PRPAIN201306UV query(PIXConsumerPRPAIN201305UVRequestType findCandidatesRequest) {
|
---|
| 36 | log.debug("Entering AdapterMpiQuery.query method...");
|
---|
| 37 | PRPAIN201306UV queryResponse = null;
|
---|
| 38 | AdapterComponentMpiService mpiService = new AdapterComponentMpiService ();
|
---|
| 39 | AdapterComponentMpiPortType mpiPort = mpiService.getAdapterComponentMpiPort();
|
---|
| 40 |
|
---|
| 41 | // Get the Home community ID for this box...
|
---|
| 42 | //------------------------------------------
|
---|
| 43 | String sHomeCommunityId = "";
|
---|
| 44 | String sEndpointURL = "";
|
---|
| 45 | try {
|
---|
| 46 | sHomeCommunityId = PropertyAccessor.getProperty(GATEWAY_PROPERTY_FILE, HOME_COMMUNITY_ID_PROPERTY);
|
---|
| 47 | }
|
---|
| 48 | catch (Exception e) {
|
---|
| 49 | log.error("Failed to read " + HOME_COMMUNITY_ID_PROPERTY +
|
---|
| 50 | " property from the " + GATEWAY_PROPERTY_FILE + ".properties file. Error: " +
|
---|
| 51 | e.getMessage(), e);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | if ((sHomeCommunityId != null) && (sHomeCommunityId.length() > 0)) {
|
---|
| 55 | try {
|
---|
| 56 | sEndpointURL = ConnectionManagerCache.getEndpointURLByServiceName(sHomeCommunityId, SERVICE_NAME_ADAPTER_COMPONENT_MPI_SERVICE);
|
---|
| 57 | }
|
---|
| 58 | catch (Exception e) {
|
---|
| 59 | log.error("Failed to retrieve endpoint URL for service:" + SERVICE_NAME_ADAPTER_COMPONENT_MPI_SERVICE +
|
---|
| 60 | " from connection manager. Error: " + e.getMessage(), e);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | if ((sEndpointURL != null) &&
|
---|
| 65 | (sEndpointURL.length() > 0)) {
|
---|
| 66 | ((javax.xml.ws.BindingProvider) mpiPort).getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, sEndpointURL);
|
---|
| 67 | }
|
---|
| 68 | else {
|
---|
| 69 | // Just a way to cover ourselves for the time being... - assume port 8080
|
---|
| 70 | //-------------------------------------------------------------------------
|
---|
| 71 | ((javax.xml.ws.BindingProvider) mpiPort).getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/NhinConnect/AdapterComponentMpiService");
|
---|
| 72 |
|
---|
| 73 | log.warn("Did not find endpoint URL for service: " + SERVICE_NAME_ADAPTER_COMPONENT_MPI_SERVICE + " and " +
|
---|
| 74 | "Home Community: " + sHomeCommunityId + ". Using default URL: " +
|
---|
| 75 | "'http://localhost:8080/NhinConnect/AdapterComponentMpiService'");
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | if (findCandidatesRequest.getPRPAIN201305UV() != null) {
|
---|
| 79 | queryResponse = mpiPort.findCandidates(findCandidatesRequest.getPRPAIN201305UV());
|
---|
| 80 | }
|
---|
| 81 | else {
|
---|
| 82 | queryResponse = null;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | log.debug("Exiting AdapterMpiQuery.query method...");
|
---|
| 86 | return queryResponse;
|
---|
| 87 | }
|
---|
| 88 | }
|
---|