source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Adapters/General/MpiEJB/src/java/gov/hhs/fha/nhinc/adaptercomponentmpi/PatientChecker.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 2.1 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package gov.hhs.fha.nhinc.adaptercomponentmpi;
6
7import gov.hhs.fha.nhinc.adaptercomponentmpi.hl7parsers.HL7Parser201305;
8import gov.hhs.fha.nhinc.adaptercomponentmpi.hl7parsers.HL7Parser201306;
9import gov.hhs.fha.nhinc.mpilib.*;
10import org.apache.commons.logging.Log;
11import org.apache.commons.logging.LogFactory;
12import org.hl7.v3.*;
13
14/**
15 *
16 * @author Jon Hoppesch
17 */
18public class PatientChecker {
19
20 private static Log log = LogFactory.getLog(PatientChecker.class);
21
22 public static PRPAIN201306UV FindPatient(PRPAIN201305UV query) {
23 log.debug("Entering PatientChecker.FindPatient method...");
24 PRPAIN201306UV result = null;
25
26 PRPAMT201306UVParameterList queryParams = HL7Parser201305.ExtractHL7QueryParamsFromMessage(query);
27
28 if (queryParams == null) {
29 log.error("no query parameters were supplied");
30 } else {
31 Patient sourcePatient = HL7Parser201305.ExtractMpiPatientFromQueryParams(queryParams);
32 log.info("perform patient lookup in mpi");
33
34 log.info("source patient check 1 [" + sourcePatient.getName().getLastName() + "]");
35 Patients searchResults = MpiDataAccess.LookupPatients(sourcePatient);
36 if (CommonChecks.isZeroSearchResult(searchResults)) {
37 log.info("patient not found in MPI");
38 result = null;
39 } else if (CommonChecks.isMultipleSearchResult(searchResults)) {
40 log.info("multiple patients found in MPI [searchResults.size()=" + searchResults.size() + "]");
41 result = null;
42 } else {
43 log.info("single patient found in MPI");
44 Patient searchResultPatient = searchResults.get(0);
45 log.info("Found patient " + searchResultPatient.getName().getFirstName() + " " + searchResultPatient.getName().getLastName());
46
47 result = HL7Parser201306.BuildMessageFromMpiPatient (searchResultPatient, query);
48 }
49 }
50
51 log.debug("Exiting PatientChecker.FindPatient method...");
52 return result;
53 }
54}
Note: See TracBrowser for help on using the repository browser.