public PatientArray mpiMatchSSN(string ssn) { PatientArray result = new PatientArray(); if (!SocSecNum.isValid(ssn)) { result.fault = new FaultTO("Invalid SSN"); } if (result.fault != null) { return(result); } try { PatientApi api = new PatientApi(); Site site = mySession.SiteTable.getSite("500"); Patient[] p = api.mpiMatch(site.Sources[0], ssn); addHomeData(p); result = new PatientArray(p); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }
internal string buildMatchSsnRequest(string ssn) { if (!SocSecNum.isValid(ssn)) { throw new Exception("Invalid SSN"); } PatientMatchesRequest hl7 = getBlankHl7Request(); hl7.VTQ.QueryName = MpiConstants.VQQ_QUERY_NAME_FUZZY; hl7.VTQ.SelectionCriteria = new ArrayList(2); hl7.VTQ.SelectionCriteria.Add( new SelectionCriterion(MpiConstants.FLD_SSN.FieldName, "EQ", ssn, "OR")); hl7.VTQ.SelectionCriteria.Add( new SelectionCriterion(MpiConstants.FLD_LASTNAME.FieldName, "EQ", "", "")); return(hl7.toMessage()); }
public PatientArray nptLookup( string SSN, string lastName, string firstName, string middleName, string nameSuffix, string DOB, string gender) { PatientArray result = new PatientArray(); if (String.IsNullOrEmpty(SSN)) { result.fault = new FaultTO("Must supply SSN"); } else if (!SocSecNum.isValid(SSN)) { result.fault = new FaultTO("Invalid SSN"); } if (result.fault != null) { return(result); } try { PatientApi api = new PatientApi(); Patient[] patients = api.nptMatch(SSN); result = new PatientArray(patients); } catch (Exception exc) { result.fault = new FaultTO(exc); } return(result); }
public Patient[] match(string target) { if (!SocSecNum.isValid(target)) { throw new NotImplementedException("non-SSN matches are currently not supported by CDW"); } SqlCommand cmd = new SqlCommand("SELECT * FROM SPatient.SPatient WHERE PatientSSN=@target;"); SqlParameter targetParam = new SqlParameter("@target", System.Data.SqlDbType.VarChar, 9); targetParam.Value = target; SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.SelectCommand = new SqlCommand(cmd.CommandText); adapter.SelectCommand.Parameters.Add(targetParam); IDataReader reader = (IDataReader)_cxn.query(adapter); IDictionary <string, Patient> patients = new Dictionary <string, Patient>(); //if (!reader..HasRows) //{ // return new Patient[0]; //} while (reader.Read()) { Patient p = new Patient(); p.LocalSiteId = (reader.GetInt16(reader.GetOrdinal("Sta3n"))).ToString(); p.LocalPid = reader.GetString(reader.GetOrdinal("PatientIEN")); p.Name = new PersonName(reader.GetString(reader.GetOrdinal("PatientName"))); if (!reader.IsDBNull(reader.GetOrdinal("PatientSSN"))) { p.SSN = new SocSecNum(reader.GetString(reader.GetOrdinal("PatientSSN"))); } if (!reader.IsDBNull(reader.GetOrdinal("Gender"))) { p.Gender = reader.GetString(reader.GetOrdinal("Gender")); } else { p.Gender = ""; } if (!reader.IsDBNull(reader.GetOrdinal("DateOfBirthText"))) { p.DOB = reader.GetString(reader.GetOrdinal("DateOfBirthText")); } if (!reader.IsDBNull(reader.GetOrdinal("PatientICN"))) { p.MpiPid = (reader.GetString(reader.GetOrdinal("PatientICN"))).ToString(); } else { // use SSN for patient ICN if (p.SSN == null || String.IsNullOrEmpty(p.SSN.toString())) { throw new MdoException(MdoExceptionCode.DATA_MISSING_REQUIRED, "Unable to process results for " + target + " - CDW record contains no ICN and no SSN"); } p.MpiPid = p.SSN.toString(); } p.Demographics = new Dictionary <string, DemographicSet>(); DemographicSet demogs = new DemographicSet(); demogs.PhoneNumbers = new List <PhoneNum>(); demogs.EmailAddresses = new List <EmailAddress>(); demogs.StreetAddresses = new List <Address>(); if (!reader.IsDBNull(reader.GetOrdinal("PhoneResidence"))) { demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("PhoneResidence")))); } if (!reader.IsDBNull(reader.GetOrdinal("PhoneWork"))) { demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("PhoneWork")))); } Address address = new Address(); if (!reader.IsDBNull(reader.GetOrdinal("StreetAddress1"))) { address.Street1 = reader.GetString(reader.GetOrdinal("StreetAddress1")); } if (!reader.IsDBNull(reader.GetOrdinal("StreetAddress2"))) { address.Street2 = reader.GetString(reader.GetOrdinal("StreetAddress2")); } if (!reader.IsDBNull(reader.GetOrdinal("StreetAddress3"))) { address.Street3 = reader.GetString(reader.GetOrdinal("StreetAddress3")); } if (!reader.IsDBNull(reader.GetOrdinal("City"))) { address.City = reader.GetString(reader.GetOrdinal("City")); } if (!reader.IsDBNull(reader.GetOrdinal("county"))) { address.County = reader.GetString(reader.GetOrdinal("county")); } if (!reader.IsDBNull(reader.GetOrdinal("State"))) { address.State = reader.GetString(reader.GetOrdinal("State")); } if (!reader.IsDBNull(reader.GetOrdinal("Zip"))) { address.Zipcode = reader.GetString(reader.GetOrdinal("Zip")); } demogs.StreetAddresses.Add(address); p.Demographics.Add(p.LocalSiteId, demogs); if (!patients.ContainsKey(p.MpiPid)) { p.SitePids = new System.Collections.Specialized.StringDictionary(); p.SitePids.Add(p.LocalSiteId, p.LocalPid); patients.Add(p.MpiPid, p); } else { if (!(patients[p.MpiPid].SitePids.ContainsKey(p.LocalSiteId))) { patients[p.MpiPid].SitePids.Add(p.LocalSiteId, p.LocalPid); } patients[p.MpiPid].Demographics.Add(p.LocalSiteId, p.Demographics[p.LocalSiteId]); } } // cleanup - need to set all temp ICNs back to null foreach (string key in patients.Keys) { if (!(patients[key].SSN == null) && !String.IsNullOrEmpty(patients[key].SSN.toString()) && !String.IsNullOrEmpty(patients[key].MpiPid) && String.Equals(patients[key].MpiPid, patients[key].SSN.toString())) { patients[key].MpiPid = null; } } Patient[] result = new Patient[patients.Count]; patients.Values.CopyTo(result, 0); return(result); }
private void setConfiguration(string facadeName) { setDefaults(); if (base.AllConfigs == null || base.AllConfigs.Count == 0) { return; // no config items present } if (!String.IsNullOrEmpty(facadeName) && base.AllConfigs.ContainsKey(facadeName)) { _facadeConfiguration = new FacadeConfiguration(base.AllConfigs[facadeName]); } if (base.AllConfigs.ContainsKey(MdwsConfigConstants.MDWS_CONFIG_SECTION)) { if (base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION].ContainsKey(MdwsConfigConstants.SESSIONS_LOG_LEVEL)) { try { _applicationSessionsLogLevel = (ApplicationSessionsLogLevel)Enum.Parse(typeof(ApplicationSessionsLogLevel), base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION][MdwsConfigConstants.SESSIONS_LOG_LEVEL]); } catch (Exception) { } } if (base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION].ContainsKey(MdwsConfigConstants.SESSIONS_LOGGING)) { Boolean.TryParse(base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION][MdwsConfigConstants.SESSIONS_LOGGING], out _applicationSessionsLogging); } TimeSpan.TryParse(getString(MdwsConfigConstants.TIMEOUT, base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION]), out _timeout); Boolean.TryParse(getString(MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION, base.AllConfigs[MdwsConfigConstants.MDWS_CONFIG_SECTION]), out _useConnectionPool); } if (base.AllConfigs.ContainsKey(MdwsConfigConstants.APP_PROXY_CONFIG_SECTION)) { string name = getString(MdwsConfigConstants.APP_PROXY_NAME, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); _appProxy.UserName = getString(MdwsConfigConstants.APP_PROXY_USERNAME, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); _appProxy.Pwd = getString(MdwsConfigConstants.APP_PROXY_PASSWORD, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); _appProxy.Uid = getString(MdwsConfigConstants.APP_PROXY_UID, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); string feduid = getString(MdwsConfigConstants.APP_PROXY_FEDUID, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); _appProxy.Phone = getString(MdwsConfigConstants.APP_PROXY_PHONE, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); string permission = getString(MdwsConfigConstants.APP_PROXY_PERMISSION, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); string siteId = getString(MdwsConfigConstants.APP_PROXY_SITE_ID, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); string siteName = getString(MdwsConfigConstants.APP_PROXY_SITE_NAME, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); _appProxy.PermissionString = getString(MdwsConfigConstants.APP_PROXY_CRED_TYPE, base.AllConfigs[MdwsConfigConstants.APP_PROXY_CONFIG_SECTION]); if (!String.IsNullOrEmpty(name)) { _appProxy.Name = new PersonName(name); } if (SocSecNum.isValid(feduid)) { _appProxy.SSN = new SocSecNum(feduid); } if (!String.IsNullOrEmpty(permission)) { _appProxy.PrimaryPermission = new gov.va.medora.mdo.dao.vista.MenuOption(permission); } if (!String.IsNullOrEmpty(siteId)) { _appProxy.LogonSiteId = new SiteId(siteId, siteName); } } }
/// <summary> /// Lookup a patient in the Medora Patient Index. This can be a stateless call (i.e. not currently required to login) /// </summary> /// <param name="SSN">Patient SSN (required)</param> /// <param name="lastName">Patient Last Name (optional)</param> /// <param name="firstName">Patient First Name (optional)</param> /// <param name="middleName">Patient Middle Name (optional)</param> /// <param name="nameSuffix">Patient Name Suffix (optional)</param> /// <param name="DOB">Patient Date Of Birth (optional)</param> /// <param name="gender">Patient Gender (not currently used for matching)</param> /// <returns>PatientArray of matches</returns> public PatientArray mpiLookup( string SSN, string lastName, string firstName, string middleName, string nameSuffix, string DOB, string gender) { PatientArray result = new PatientArray(); if (String.IsNullOrEmpty(SSN)) { result.fault = new FaultTO("Missing SSN"); } else if (!SocSecNum.isValid(SSN)) { result.fault = new FaultTO("Invalid SSN"); } // hard coded the cxn string since our MPI database should really be a service for everyone //else if (mySession == null || mySession.MdwsConfiguration == null || mySession.MdwsConfiguration.SqlConfiguration == null || // String.IsNullOrEmpty(mySession.MdwsConfiguration.SqlConfiguration.ConnectionString)) //{ // result.fault = new FaultTO("Your MDWS configuration does not contain a valid SQL connection string"); //} if (result.fault != null) { return(result); } Patient patient = new Patient(); patient.SSN = new SocSecNum(SSN); if (!String.IsNullOrEmpty(lastName) && !String.IsNullOrEmpty(firstName)) { patient.Name = new PersonName(); patient.Name.Lastname = lastName; patient.Name.Firstname = firstName; if (!String.IsNullOrEmpty(middleName)) { patient.Name.Firstname = firstName + " " + middleName; } patient.Name.Suffix = nameSuffix; } if (!String.IsNullOrEmpty(DOB)) { patient.DOB = DOB; } // SQL query doesn't care about gender so just ignore it for now //patient.Gender = gender; try { PatientApi api = new PatientApi(); Patient[] matches = null; Site site = mySession.SiteTable.getSite("500"); matches = api.mpiMatch(site.Sources[0], SSN); //if (patient.Name != null && !String.IsNullOrEmpty(patient.Name.LastNameFirst)) // match all patient info if present //{ // matches = api.mpiLookup(patient); //} //else // otherwise just match on SSN //{ // matches = api.mpiLookup(SSN); //} result = new PatientArray(matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }
public BoolTO getIdProofingStatus(string patientId, string patientName, string patientDOB) { BoolTO result = new BoolTO(); if (mySession == null || mySession.ConnectionSet == null || !mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(patientId)) { result.fault = new FaultTO("Must supply patient ID"); } if (result.fault != null) { return(result); } Patient patient = new Patient() { SSN = new SocSecNum(patientId), Name = new PersonName(patientName), DOB = patientDOB }; try { if (SocSecNum.isValid(patientId)) // if ID passed was SSN - turn in to { Patient[] matches = new PatientApi().match(mySession.ConnectionSet.BaseConnection, patient.SSN.toString()); if (matches == null || matches.Length == 0) { result.fault = new FaultTO("No patient found with that SSN!"); return(result); } if (matches.Length > 0) { result.fault = new FaultTO("Duplicate SSN found", "Please contact the system administrator"); return(result); } if (String.IsNullOrEmpty(matches[0].LocalPid)) { result.fault = new FaultTO("Invalid record associated with that SSN", "Please contact the system administrator"); return(result); } PatientTO vistaPatient = new PatientLib(mySession).select(matches[0].LocalPid); patient.LocalPid = matches[0].LocalPid; patient.MpiPid = vistaPatient.mpiPid; } //new AccountLib(mySession).setupMultiSourceQuery("pwd", patient.s mySession.ConnectionSet.setLocalPids(patient.MpiPid); IndexedHashtable ihs = new PatientApi().getIdProofingStatus(mySession.ConnectionSet, patient); if (ihs == null || ihs.Count == 0) { result.trueOrFalse = false; } else { result.trueOrFalse = true; for (int i = 0; i < ihs.Count; i++) // loop through - if any are false, result is false { if (!(bool)ihs.GetValue(i)) { result.trueOrFalse = false; break; } } } } catch (Exception exc) { result.fault = new FaultTO(exc); } finally { try { mySession.ConnectionSet.disconnectAll(); } catch (Exception) { } } return(result); }