setLocalPids() public method

public setLocalPids ( ConnectionSet cxns, string mpiPid ) : IndexedHashtable
cxns ConnectionSet
mpiPid string
return IndexedHashtable
コード例 #1
0
ファイル: AccountLib.cs プロジェクト: OSEHRA/mdws
        /// <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;
        }
コード例 #2
0
ファイル: NoteLib.cs プロジェクト: OSEHRA/mdws
        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;
        }