public TaggedTextArray getConfidentiality() { TaggedTextArray result = new TaggedTextArray(); if (!mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } if (result.fault != null) { return result; } try { PatientApi api = new PatientApi(); result = new TaggedTextArray(api.getConfidentiality(mySession.ConnectionSet)); } catch (Exception e) { result.fault = new FaultTO(e); } return result; }
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; }
public TaggedNoteArrays getNotesForBhie(string pwd, string mpiPid, string fromDate, string toDate, string nNotes) { TaggedNoteArrays result = new TaggedNoteArrays(); if (String.Equals(pwd, _mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.PRIMARY_CONFIG_SECTION][MdwsConfigConstants.BHIE_PASSWORD])) { result.fault = new FaultTO("Invalid application password"); } else if (String.IsNullOrEmpty(mpiPid)) { result.fault = new FaultTO("Missing mpiPid"); } else if (String.IsNullOrEmpty(fromDate)) { result.fault = new FaultTO("Missing fromDate"); } else if (String.IsNullOrEmpty(toDate)) { result.fault = new FaultTO("Missing toDate"); } if (result.fault != null) { return result; } if (nNotes == "") { nNotes = "50"; } try { int maxNotes = Convert.ToInt16(nNotes); PatientLib patLib = new PatientLib(_mySession); TaggedTextArray sites = patLib.getPatientSitesByMpiPid(mpiPid); if (sites == null) { return null; } if (sites.fault != null) { result.fault = sites.fault; return result; } string sitelist = ""; for (int i = 0; i < sites.count; i++) { if ((string)sites.results[i].tag == "200") { continue; } if (sites.results[i].fault != null) { } else { sitelist += (string)sites.results[i].tag + ','; } } sitelist = sitelist.Substring(0, sitelist.Length - 1); AccountLib acctLib = new AccountLib(_mySession); sites = acctLib.visitSites("BHIE", sitelist, MdwsConstants.CPRS_CONTEXT); if (sites.fault != null) { result.fault = sites.fault; return result; } PatientApi patApi = new PatientApi(); IndexedHashtable t = patApi.setLocalPids(_mySession.ConnectionSet, mpiPid); NoteApi api = new NoteApi(); IndexedHashtable tNotes = api.getNotes(_mySession.ConnectionSet, fromDate, toDate, maxNotes); IndexedHashtable tSumms = api.getDischargeSummaries(_mySession.ConnectionSet, fromDate, toDate, 50); result = new TaggedNoteArrays(mergeNotesAndDischargeSummaries(tNotes, tSumms)); } catch (Exception ex) { result.fault = new FaultTO(ex); } finally { if (_mySession.ConnectionSet != null) { _mySession.ConnectionSet.disconnectAll(); } } return result; }
// This is for iterating thru a list of patients at one site, getting the disabilities from only that site. public TaggedRatedDisabilityArray getRatedDisabilitiesForPatient(string dfn) { TaggedRatedDisabilityArray result = new TaggedRatedDisabilityArray(); if (!mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } if (result.fault != null) { return result; } try { PatientApi patApi = new PatientApi(); RatedDisability[] disabilities = patApi.getRatedDisabiliities(mySession.ConnectionSet.BaseConnection, dfn); result = new TaggedRatedDisabilityArray(mySession.ConnectionSet.BaseConnection.DataSource.SiteId.Id, disabilities); } catch (Exception e) { result.fault = new FaultTO(e); } return result; }
/// <summary> /// patientVisit /// This method is used by MHV and will probably be used by other PHR apps. /// </summary> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="homeSitecode">Station number</param> /// <param name="mpiPid">ICN</param> /// <param name="multiSite">Set to false for now</param> /// <returns>SiteArray: Nothing really in it though, except error messages</returns> public SiteArray patientVisit(string pwd, string homeSitecode, string mpiPid, bool multiSite) { SiteArray result = new SiteArray(); //Make sure we have all the args we need if (mySession == null || mySession.SiteTable == null) { result.fault = new FaultTO("No session has been started"); } else if (String.IsNullOrEmpty(homeSitecode)) { result.fault = new FaultTO("No homeSitecode"); } else if (mySession.SiteTable.getSite(homeSitecode) == null) { result.fault = new FaultTO("No site " + homeSitecode + " in the site table"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0 && mySession.ConnectionSet.HasConnection(homeSitecode)) { result.fault = new FaultTO("Site " + homeSitecode + " already connected"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0) { result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?"); } else if (mpiPid == "") { result.fault = new FaultTO("No MPI PID"); } if (result.fault != null) { return result; } Site homeSite = mySession.SiteTable.getSite(homeSitecode); mySession.Credentials = getAdministrativeCredentials(homeSite); mySession.Credentials.SecurityPhrase = pwd; string context = MdwsConstants.MDWS_CONTEXT; if (mySession.DefaultVisitMethod == MdwsConstants.NON_BSE_CREDENTIALS) { context = MdwsConstants.CPRS_CONTEXT; } mySession.PrimaryPermission = new MenuOption(context); try { mySession.User = doTheVisit(homeSitecode, mySession.Credentials, mySession.PrimaryPermission); PatientApi patientApi = new PatientApi(); string localPid = patientApi.getLocalPid(myCxn, mpiPid); if (localPid == "") { myCxn.disconnect(); result.fault = new FaultTO("No such patient at this site"); return result; } mySession.Patient = patientApi.select(myCxn, localPid); addMyCxn2CxnSet(); } catch (Exception e) { myCxn.disconnect(); result.fault = new FaultTO(e.Message); return result; } return result; }
internal TaggedPatientAssociateArray getPatientAssociates(AbstractConnection cxn, string dfn) { TaggedPatientAssociateArray result = new TaggedPatientAssociateArray(); if (dfn == "") { result.fault = new FaultTO("Missing dfn"); } if (result.fault != null) { return result; } try { PatientApi patientApi = new PatientApi(); PatientAssociate[] pas = patientApi.getPatientAssociates(cxn, dfn); result = new TaggedPatientAssociateArray(cxn.DataSource.SiteId.Id, pas); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
internal void addHomeData(Patient patient) { if (patient == null) { return; } try { Site site = mySession.SiteTable.getSite(patient.CmorSiteId); DataSource src = site.getDataSourceByModality("HIS"); MySession newMySession = new MySession(mySession.FacadeName); AccountLib accountLib = new AccountLib(newMySession); UserTO visitUser = accountLib.visitAndAuthorize(mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.BSE_CONFIG_SECTION][MdwsConfigConstants.SERVICE_ACCOUNT_PASSWORD], patient.CmorSiteId, mySession.ConnectionSet.BaseConnection.DataSource.SiteId.Id, mySession.User.Name.LastNameFirst, mySession.User.Uid, mySession.User.SSN.toString(), "OR CPRS GUI CHART"); PatientApi patientApi = new PatientApi(); patient.LocalPid = patientApi.getLocalPid(newMySession.ConnectionSet.BaseConnection, patient.MpiPid); patientApi.addHomeDate(newMySession.ConnectionSet.BaseConnection, patient); newMySession.ConnectionSet.BaseConnection.disconnect(); } catch (Exception) { // just pass back patient unchanged } }
/// <summary> /// Make a patient inquiry call (address, contact numbers, NOK, etc. information) /// </summary> /// <returns>TextTO with selected patient inquiry text</returns> public TextTO patientInquiry() { TextTO result = new TextTO(); if (!mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(mySession.ConnectionSet.getConnection(mySession.ConnectionSet.BaseSiteId).Pid)) { result.fault = new FaultTO("Need to select patient"); } if (result.fault != null) { return result; } try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(mySession.ConnectionSet.BaseSiteId); string selectedPatient = cxn.Pid; PatientApi api = new PatientApi(); string resultText = api.patientInquiry(cxn, selectedPatient); result = new TextTO(resultText); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
public TaggedPatientAssociateArrays getPatientAssociatesMS() { TaggedPatientAssociateArrays result = new TaggedPatientAssociateArrays(); if (result.fault != null) { return result; } try { PatientApi api = new PatientApi(); IndexedHashtable t = api.getPatientAssociates(mySession.ConnectionSet); return new TaggedPatientAssociateArrays(t); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
public TaggedOefOifArray getOefOif() { TaggedOefOifArray result = new TaggedOefOifArray(); string msg = MdwsUtils.isAuthorizedConnection(mySession, null); if (msg != "OK") { result.fault = new FaultTO(msg); } if (result.fault != null) { return result; } string sitecode = mySession.ConnectionSet.BaseSiteId; try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode); PatientApi api = new PatientApi(); OEF_OIF[] rex = api.getOefOif(cxn); result = new TaggedOefOifArray(sitecode, rex); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
public TaggedText getMOSReport(string appPwd, string EDIPI) { TaggedText result = new TaggedText(); if (String.IsNullOrEmpty(appPwd)) { result.fault = new FaultTO("Missing appPwd"); } else if (String.IsNullOrEmpty(EDIPI)) { result.fault = new FaultTO("Missing EDIPI"); } if (result.fault != null) { return result; } try { AbstractConnection cxn = new MdoOracleConnection(new DataSource() { ConnectionString = mySession.MdwsConfiguration.MosConnectionString }); PatientApi api = new PatientApi(); Patient p = new Patient() { EDIPI = EDIPI }; TextReport rpt = api.getMOSReport(cxn, p); result.text = rpt.Text; result.tag = "VADIR"; } catch (Exception exc) { result.fault = new FaultTO(exc); } return result; }
public TextTO getLocalPid(string sitecode, string mpiPid) { TextTO result = new TextTO(); string msg = MdwsUtils.isAuthorizedConnection(mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (mpiPid == "") { result.fault = new FaultTO("Missing mpiPid"); } if (result.fault != null) { return result; } if (String.IsNullOrEmpty(sitecode)) { sitecode = mySession.ConnectionSet.BaseSiteId; } try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode); PatientApi api = new PatientApi(); string localPid = api.getLocalPid(cxn, mpiPid); result = new TextTO(localPid); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
internal TaggedPatientArray matchByNameCityState(AbstractConnection cxn, string name, string city, string stateAbbr) { TaggedPatientArray result = new TaggedPatientArray(); if (name == "") { result.fault = new FaultTO("Missing name"); } else if (city == "") { result.fault = new FaultTO("Missing city"); } else if (stateAbbr == "") { result.fault = new FaultTO("Missing stateAbbr"); } else if (!State.isValidAbbr(stateAbbr)) { result.fault = new FaultTO("Invalid stateAbbr"); } if (result.fault != null) { return result; } try { PatientApi api = new PatientApi(); Patient[] matches = api.matchByNameCityState(cxn, name, city, stateAbbr); result = new TaggedPatientArray(cxn.DataSource.SiteId.Id, matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
internal TaggedPatientArray match(AbstractConnection cxn, string target) { TaggedPatientArray result = new TaggedPatientArray(); if (!cxn.IsConnected) { result = new TaggedPatientArray("Connection not open"); } else if (cxn.DataSource.Uid == "") { result = new TaggedPatientArray("No user authorized for lookup"); } else if (target == "") { result.fault = new FaultTO("Missing target"); } if (result.fault != null) { return result; } try { PatientApi patientApi = new PatientApi(); Patient[] matches = patientApi.match(cxn, target); result = new TaggedPatientArray(cxn.DataSource.SiteId.Id, matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
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 TaggedTextArray getCorrespondingIds(string sitecode, string patientId, string idType) { TaggedTextArray result = new TaggedTextArray(); if (mySession == null || mySession.ConnectionSet == null || mySession.ConnectionSet.BaseConnection == null || !mySession.ConnectionSet.HasBaseConnection || !mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("No connections", "Need to login?"); } else if (!String.IsNullOrEmpty(sitecode)) { result.fault = new FaultTO("Lookup by a specific sitecode is not currently supported - please leave this field empty and MDWS will query the base connection"); } else if (String.IsNullOrEmpty(patientId)) { result.fault = new FaultTO("Missing patient ID"); } else if (String.IsNullOrEmpty(idType)) { result.fault = new FaultTO("Missing ID type"); } else if (!String.Equals("DFN", idType, StringComparison.CurrentCultureIgnoreCase) && !String.Equals("ICN", idType, StringComparison.CurrentCultureIgnoreCase)) { result.fault = new FaultTO("Lookup by " + idType + " is not currently supported"); } if (result.fault != null) { return result; } if (String.IsNullOrEmpty(sitecode)) { sitecode = mySession.ConnectionSet.BaseSiteId; } try { if (String.Equals("ICN", idType, StringComparison.CurrentCultureIgnoreCase)) { PatientApi patientApi = new PatientApi(); string localPid = patientApi.getLocalPid(mySession.ConnectionSet.BaseConnection, patientId); result = new TaggedTextArray(patientApi.getTreatingFacilityIds(mySession.ConnectionSet.BaseConnection, localPid)); } else if (String.Equals("DFN", idType, StringComparison.CurrentCultureIgnoreCase)) { PatientApi patientApi = new PatientApi(); result = new TaggedTextArray(patientApi.getTreatingFacilityIds(mySession.ConnectionSet.BaseConnection, patientId)); } } catch (Exception exc) { result.fault = new FaultTO(exc); } return result; }
public TaggedPatientArray getPatientsByWard(string sitecode, string wardId) { TaggedPatientArray result = new TaggedPatientArray(); string msg = MdwsUtils.isAuthorizedConnection(mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (wardId == "") { result.fault = new FaultTO("Missing wardId"); } if (result.fault != null) { return result; } if (sitecode == null) { sitecode = mySession.ConnectionSet.BaseSiteId; } try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode); PatientApi patientApi = new PatientApi(); Patient[] matches = patientApi.getPatientsByWard(cxn, wardId); result = new TaggedPatientArray(sitecode, matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
public PatientTO select(string sitecode, string localPid) { PatientTO result = new PatientTO(); string msg = MdwsUtils.isAuthorizedConnection(mySession, sitecode); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (String.IsNullOrEmpty(localPid)) { result.fault = new FaultTO("Missing local PID"); } if (result.fault != null) { return result; } if (String.IsNullOrEmpty(sitecode)) { sitecode = mySession.ConnectionSet.BaseSiteId; } try { AbstractConnection cxn = mySession.ConnectionSet.getConnection(sitecode); PatientApi api = new PatientApi(); Patient p = api.select(cxn, localPid); result = new PatientTO(p); mySession.Patient = p; mySession.ConnectionSet.getConnection(sitecode).Pid = result.localPid; if (p.Confidentiality.Key > 0) { if (p.Confidentiality.Key == 1) { // do nothing here - M code takes care of this per documentation } else if (p.Confidentiality.Key == 2) { api.issueConfidentialityBulletin(mySession.ConnectionSet); } else if (p.Confidentiality.Key > 2) { mySession.ConnectionSet.disconnectAll(); throw new ApplicationException(p.Confidentiality.Value); } } } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
/// <summary> /// Given a national identifier find the patient's sites /// </summary> /// <param name="mpiPid"></param> /// <returns></returns> public TaggedTextArray getPatientSitesByMpiPid(string mpiPid) { TaggedTextArray result = new TaggedTextArray(); if (String.IsNullOrEmpty(mpiPid)) { result.fault = new FaultTO("Missing mpiPid"); } if (result.fault != null) { return result; } // Temporary visit to site 200 for initial lookup AccountLib acctLib = new AccountLib(mySession); result = acctLib.visitDoD(null); if (result.fault != null) { return result; } TextTO localPid = getLocalPid(mpiPid); if (localPid.fault != null) { result.fault = localPid.fault; return result; } if (String.IsNullOrEmpty(localPid.text)) { result.fault = new FaultTO("Empty DFN returned from VistA"); return result; } PatientApi patientApi = new PatientApi(); StringDictionary siteIds = patientApi.getRemoteSiteIds(mySession.ConnectionSet.BaseConnection, localPid.text); mySession.ConnectionSet.disconnectAll(); result = new TaggedTextArray(siteIds); return result; }
internal Patient getHomeData(Patient patient) { PatientApi api = new PatientApi(); api.addHomeDate(mySession.ConnectionSet.BaseConnection, patient); return patient; }
public TaggedPatientArrays match(string target) { TaggedPatientArrays result = new TaggedPatientArrays(); if (!mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(target)) { result.fault = new FaultTO("Missing target"); } if (result.fault != null) { return result; } try { PatientApi api = new PatientApi(); IndexedHashtable t = api.match(mySession.ConnectionSet, target); return new TaggedPatientArrays(t); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
/// <summary> /// </summary> /// <remarks> /// This method assumes there has been no login and therefore no credentials or user /// so it makes a new ConnectionSet, new credentials, etc. /// </remarks> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="sourceId">Station number</param> /// <param name="userId">DUZ</param> /// <param name="patientId">DFN</param> /// <returns>PersonsTO: a UserTO and a PatientTO</returns> public PersonsTO cprsLaunch(string pwd, string sourceId, string userId, string patientId) { PersonsTO result = new PersonsTO(); if (String.IsNullOrEmpty(sourceId)) { result.fault = new FaultTO("No sitecode!"); } else if (String.IsNullOrEmpty(userId)) { result.fault = new FaultTO("No DUZ!"); } else if (String.IsNullOrEmpty(patientId)) { result.fault = new FaultTO("No DFN!"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0) { result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?"); } if (result.fault != null) { return result; } // Get the site // Note the visit site and user site are the same! Site site = mySession.SiteTable.getSite(sourceId); if (site == null) { result.fault = new FaultTO("No site " + sourceId + " in sites table"); return result; } // Now select the patient try { User trueUser = getVisitorData(sourceId, userId, pwd); // Now visit as the real user // Note context has to be CPRS! result.user = visitAndAuthorize( pwd, sourceId, sourceId, trueUser.Name.getLastNameFirst(), userId, trueUser.SSN.toString(), mySession.DefaultPermissionString); if (result.user.fault != null) { result.fault = result.user.fault; return result; } PatientApi patientApi = new PatientApi(); mySession.Patient = patientApi.select(mySession.ConnectionSet.getConnection(sourceId), patientId); result.patient = new PatientTO(mySession.Patient); } catch (Exception e) { //mySession.cxnMgr.disconnect(); if (e.Message.StartsWith("Patient unknown to CPRS")) { result.patient.fault = new FaultTO(e.Message); } else { result.fault = new FaultTO(e.Message); } } return result; }
public TaggedPatientArrays matchByNameCityStateMS(string name, string city, string stateAbbr) { TaggedPatientArrays result = new TaggedPatientArrays(); string msg = MdwsUtils.isAuthorizedConnection(mySession); if (msg != "OK") { result.fault = new FaultTO(msg); } if (name == "") { result.fault = new FaultTO("Missing name"); } else if (city == "") { result.fault = new FaultTO("Missing city"); } else if (stateAbbr == "") { result.fault = new FaultTO("Missing stateAbbr"); } else if (!State.isValidAbbr(stateAbbr)) { result.fault = new FaultTO("Invalid stateAbbr"); } if (result.fault != null) { return result; } try { PatientApi api = new PatientApi(); IndexedHashtable matches = api.matchByNameCityState(mySession.ConnectionSet, name, city, stateAbbr); result = new TaggedPatientArrays(matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
/// <summary> /// After selecting a patient at one site, make subsequent queries multi-site. /// </summary> /// <remarks> /// This function will detect and visit all the other sites at which the patient /// has been seen. Subsequent queries, then, will return data from all these sources. /// This method requires a previous login or visit to have set the credentials in /// mySession, as well as a previous patient select to have set the patient in /// mySession. /// </remarks> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="context">If blank defaults to CPRS context</param> /// <returns>SiteArray: the sources subsequent queries will read from</returns> public SiteArray setupMultiSourcePatientQuery(string pwd, string context) { SiteArray result = new SiteArray(); //Make sure we have all the args we need if (mySession == null || mySession.SiteTable == null) { result.fault = new FaultTO("No site table"); } else if (mySession.Patient == null) { result.fault = new FaultTO("No patient", "Need to select a patient?"); } else if (String.IsNullOrEmpty(mySession.Patient.MpiPid)) { result.fault = new FaultTO("Patient has no ICN", "Need to select the patient?"); } else if (mySession.Patient.SiteIDs == null || mySession.Patient.SiteIDs.Length == 0) { result.fault = new FaultTO("Patient has no sites", "Need to select the patient?"); } if (result.fault != null) { return result; } if (String.IsNullOrEmpty(context)) { context = mySession.DefaultPermissionString; } try { Site[] sites = mySession.SiteTable.getSites(mySession.Patient.SiteIDs); List<DataSource> sources = new List<DataSource>(sites.Length); for (int i = 0; i < sites.Length; i++) { if (sites[i] == null) { continue; } DataSource src = sites[i].getDataSourceByModality("HIS"); if (src != null) { sources.Add(src); } } TaggedTextArray tta = setupMultiSourceQuery(pwd, sources, context); PatientApi patientApi = new PatientApi(); IndexedHashtable t = patientApi.setLocalPids(mySession.ConnectionSet, mySession.Patient.MpiPid); // we need to check confidentiality everywhere and issue bulletin if found at any site IndexedHashtable confidentialResults = patientApi.getConfidentiality(mySession.ConnectionSet); if (confidentialResults != null && confidentialResults.Count > 0) { KeyValuePair<int, string> highestConfidentialityResult = new KeyValuePair<int,string>(0, ""); for (int i = 0; i < confidentialResults.Count; i++) { KeyValuePair<int, string> siteResult = (KeyValuePair<int, string>)confidentialResults.GetValue(i); if (siteResult.Key > highestConfidentialityResult.Key) { highestConfidentialityResult = siteResult; } } if (highestConfidentialityResult.Key == 1) { // do nothing here - M code takes care of this per documentation } else if (highestConfidentialityResult.Key == 2) { patientApi.issueConfidentialityBulletin(mySession.ConnectionSet); } else if (highestConfidentialityResult.Key > 2) { // catch block below takes care of disconnecting all sites throw new ApplicationException(highestConfidentialityResult.Value); } } // end confidentiality result = new SiteArray(sites); for (int i = 0; i < result.sites.Length; i++) { if (mySession.ConnectionSet.ExcludeSite200 && result.sites[i].sitecode == "200") { result.sites[i].fault = new FaultTO("Site excluded"); } else if (t.ContainsKey(result.sites[i].sitecode)) { // TBD: fault in t? result.sites[i].pid = (string)t.GetValue(result.sites[i].sitecode); } } // copy faults over if any found foreach (TaggedText tt in tta.results) { if (tt.fault != null) { foreach (SiteTO s in result.sites) { if (String.Equals(s.sitecode, tt.tag)) { s.fault = tt.fault; } } } } } catch (Exception e) { result = new SiteArray(); result.fault = new FaultTO(e.Message); mySession.ConnectionSet.disconnectAll(); } return result; }
/// <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 PatientArray getPatientsByClinic(string clinicId, string startDate, string stopDate) { PatientArray result = new PatientArray(); string msg = MdwsUtils.isAuthorizedConnection(_mySession); if (msg != "OK") { result.fault = new FaultTO(msg); } else if (String.IsNullOrEmpty(clinicId)) { result.fault = new FaultTO("Missing clinicId"); } if (result.fault != null) { return result; } try { Patient[] matches = new PatientApi().getPatientsByClinic(_mySession.ConnectionSet.BaseConnection, clinicId, startDate, stopDate); result = new PatientArray(matches); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return result; }
public RadiologyReportTO getImagingReport(string ssn, string accessionNumber) { RadiologyReportTO result = new RadiologyReportTO(); if (!mySession.ConnectionSet.IsAuthorized) { result.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } else if (String.IsNullOrEmpty(ssn)) { result.fault = new FaultTO("Missing SSN"); } else if (String.IsNullOrEmpty(accessionNumber)) { result.fault = new FaultTO("Missing Accession Number"); } if (result.fault != null) { return result; } try { PatientApi patientApi = new PatientApi(); Patient[] matches = patientApi.match(mySession.ConnectionSet.BaseConnection, ssn); if (matches == null || matches.Length != 1) { result.fault = new FaultTO("More than one patient has that SSN in this site (" + mySession.ConnectionSet.BaseConnection.DataSource.SiteId.Id + ")"); return result; } RadiologyReport report = ImagingExam.getReportText(mySession.ConnectionSet.BaseConnection, matches[0].LocalPid, accessionNumber); result = new RadiologyReportTO(report); } catch (Exception e) { result.fault = new FaultTO(e); } return result; }