public SiteArray getAllInstitutions() { SiteArray siteResults = new SiteArray(); if (!mySession.ConnectionSet.IsAuthorized) { siteResults.fault = new FaultTO("Connections not ready for operation", "Need to login?"); } if (siteResults.fault != null) { return(siteResults); } try { List <Site> sites = HospitalLocation.getAllInstitutions(mySession.ConnectionSet.BaseConnection); siteResults = new SiteArray(sites); } catch (Exception e) { siteResults.fault = new FaultTO(e); } return(siteResults); }
public SiteArray getSitesForCounty(string fips) { SiteArray result = new SiteArray(); if (fips == "") { result.fault = new FaultTO("Missing fips"); } if (result.fault != null) { return(result); } try { SitesApi api = new SitesApi(); Site[] sites = api.getClosestFacilities(fips, mySession.MdwsConfiguration.SqlConnectionString); result = new SiteArray(sites); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }
public SiteArray getSiteDivisions(string sitecode) { SiteArray result = new SiteArray(); if (sitecode == "") { result.fault = new FaultTO("Missing sitecode"); } if (result.fault != null) { return(result); } try { EncounterApi api = new EncounterApi(); Site[] sites = api.getSiteDivisions(mySession.ConnectionSet.getConnection(sitecode), sitecode); result = new SiteArray(sites); } catch (Exception e) { result.fault = new FaultTO(e); } return(result); }
public void setupMultiSiteQuery(string securityPhrase) { SiteArray result = _emrSvc.setupMultiSiteQuery(securityPhrase); if (result.fault != null) { throw new ApplicationException(result.fault.message); } }
public TaggedChemHemRptArray getChemHemReportsByReportDateFromSite( string pwd, string sitecode, string mpiPid, string fromDate, string toDate) { TaggedChemHemRptArray result = new TaggedChemHemRptArray(); if (String.IsNullOrEmpty(sitecode)) { result.fault = new FaultTO("Missing sitecode"); } else if (mpiPid == "") { result.fault = new FaultTO("Missing mpiPid"); } else if (fromDate == "") { result.fault = new FaultTO("Missing fromDate"); } if (result.fault != null) { return(result); } if (toDate == "") { toDate = DateTime.Now.ToString("yyyyMMdd"); } AccountLib acctLib = new AccountLib(mySession); try { // Visit as DoD user... SiteArray sites = acctLib.patientVisit(pwd, sitecode, mpiPid, false); if (sites.fault != null) { result.fault = sites.fault; return(result); } // Get the labs... ChemHemReport[] rpts = ChemHemReport.getChemHemReports(mySession.ConnectionSet.getConnection(sitecode), fromDate, toDate); result = new TaggedChemHemRptArray(sitecode, rpts); } catch (Exception e) { result.fault = new FaultTO(e.Message); } finally { mySession.close(); } return(result); }
public SiteTO patientVisit(string pwd, string sitecode, string mpiPid) { SiteTO result = new SiteTO(); if (mySession == null || mySession.SiteTable == null) { result.fault = new FaultTO("No session has been started"); } else if (sitecode == "") { result.fault = new FaultTO("No sitecode"); } else if (mySession.SiteTable.getSite(sitecode) == null) { result.fault = new FaultTO("No site " + sitecode + " in the site table"); } else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0 && mySession.ConnectionSet.HasConnection(sitecode)) { result.fault = new FaultTO("Site " + sitecode + " 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); } SiteArray sa = patientVisit(pwd, sitecode, mpiPid, false); if (sa.fault == null) { result.fault = sa.fault; } else if (sa.sites.Length == 0) { result.fault = new FaultTO("Unable to connect to site " + sitecode); } else { result = sa.sites[0]; } return(result); }
public TaggedAppointmentArray getAppointmentsFromSite( string pwd, string sitecode, string mpiPid) { TaggedAppointmentArray result = new TaggedAppointmentArray(); if (String.IsNullOrEmpty(sitecode)) { result.fault = new FaultTO("Missing sitecode"); } else if (String.IsNullOrEmpty(mpiPid)) { result.fault = new FaultTO("Missing mpiPid"); } if (result.fault != null) { return(result); } AccountLib acctLib = new AccountLib(mySession); try { // Visit as DoD user... SiteArray sites = acctLib.patientVisit(pwd, sitecode, mpiPid, false); if (sites.fault != null) { result.fault = sites.fault; return(result); } // Get the labs... EncounterApi api = new EncounterApi(); Appointment[] appts = api.getAppointments(mySession.ConnectionSet.getConnection(sitecode)); for (int i = 0; i < appts.Length; i++) { appts[i].Status = undecodeApptStatus(appts[i].Status); } result = new TaggedAppointmentArray(sitecode, appts); } catch (Exception e) { result.fault = new FaultTO(e.Message); } finally { mySession.close(); } return(result); }
public TextTO getHealthSummary(string pwd, string sitecode, string mpiPid, string displayName) { TextTO result = new TextTO(); if (String.IsNullOrEmpty(sitecode)) { result.fault = new FaultTO("Missing sitecode"); } else if (mpiPid == "") { result.fault = new FaultTO("Missing mpiPid"); } else if (displayName == "") { result.fault = new FaultTO("Missing displayName"); } if (result.fault != null) { return(result); } AccountLib acctLib = new AccountLib(mySession); try { // Visit as DoD user... SiteArray sites = acctLib.patientVisit(pwd, sitecode, mpiPid, false); if (sites.fault != null) { result.fault = sites.fault; return(result); } // Get the labs... ClinicalLib clinicalLib = new ClinicalLib(mySession); result = clinicalLib.getAdHocHealthSummaryByDisplayName(sitecode, displayName); } catch (Exception e) { result.fault = new FaultTO(e.Message); } finally { mySession.close(); } return(result); }
/// <summary> /// Allow a client application to specifiy their sites file by name /// </summary> /// <param name="sitesFileName">The name of the sites file</param> /// <returns>SiteArray of parsed sites file</returns> public SiteArray setSites(string sitesFileName) { SiteArray result = new SiteArray(); try { _siteTable = new mdo.SiteTable(_mdwsConfig.ResourcesPath + "xml\\" + sitesFileName); _mdwsConfig.FacadeConfiguration.SitesFileName = sitesFileName; watchSitesFile(_mdwsConfig.ResourcesPath + "xml\\"); result = new SiteArray(_siteTable.Sites); } catch (Exception) { result.fault = new FaultTO("A sites file with that name does not exist on the server!"); } return(result); }
public string SiteNum() { var obj = new JArray(); List <string> sites = GetAllSites(); //get all projects's sites, class and Purpose List <Users> user = db.Users.ToList(); List <Projects> project = db.Projects.ToList(); var result = from p in project join u in user on p.UserId equals u.UserId select new { u.Site, u.Class }; foreach (var item in sites) { List <Chart.SiteData> datas = new List <Chart.SiteData>(); var a = result.Where(p => p.Site == item).GroupBy(x => x.Class).Select(c => new { Char = c.Key, Count = c.Count() }).ToList(); if (a.Count() != 0) { for (int i = 0; i < a.Count(); i++) { var b = a[i]; Chart.SiteData temp = new Chart.SiteData(); temp.ClassName = b.Char; temp.Num = b.Count; datas.Add(temp); } } else { //沒有資料填無 Chart.SiteData temp = new Chart.SiteData(); temp.ClassName = "無"; temp.Num = 1; datas.Add(temp); } SiteArray ary = new SiteArray(); ary.Site = item; ary.SiteData = datas; obj.Add(JObject.FromObject(ary)); } var convertJson = JsonConvert.SerializeObject(obj, Formatting.Indented); return(convertJson); }
public SiteArray getConnectedSites() { if (mySession.ConnectionSet == null || mySession.ConnectionSet.Count == 0) { return(null); } SiteArray result = new SiteArray(); result.sites = new SiteTO[mySession.ConnectionSet.Count]; result.count = mySession.ConnectionSet.Count; int i = 0; foreach (KeyValuePair <string, gov.va.medora.mdo.dao.AbstractConnection> cxn in mySession.ConnectionSet.Connections) { result.sites[i] = new SiteTO(); result.sites[i].displayName = cxn.Value.DataSource.SiteId.Name; i++; } return(result); }
public string AllSiteNum() { //get all projects's sites and Purpose List <Users> user = db.Users.ToList(); List <Projects> project = db.Projects.ToList(); var result = from p in project join u in user on p.UserId equals u.UserId select new { u.Site, p.Purpose }; //get all sites List <string> sites = GetAllSites(); var obj = new JArray(); //User的Site foreach (var item in sites) { List <Chart.SiteData> datas = new List <Chart.SiteData>(); String[] purpose = { "尋找關鍵因子", "預測迴歸趨勢", "時間序列分析" }; for (int i = 0; i < purpose.Count(); i++) { Chart.SiteData temp = new Chart.SiteData(); temp.ClassName = purpose[i]; temp.Num = result.Where(p => p.Purpose == purpose[i] && p.Site == item).Count(); datas.Add(temp); } SiteArray ary = new SiteArray(); ary.Site = item; ary.SiteData = datas; obj.Add(JObject.FromObject(ary)); } var convertJson = JsonConvert.SerializeObject(obj, Formatting.Indented); return(convertJson); }
/// <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); }
/// <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); }