Logins and visits.
예제 #1
0
        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
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        public TaggedTextArray sitesHavePatch(string sitelist, string patchId)
        {
            TaggedTextArray result = new TaggedTextArray();

            //if (mySession.ConnectionSet.Count == 0 || !mySession.ConnectionSet.IsAuthorized)
            //{
            //    result.fault = new FaultTO(NO_CONNECTIONS);
            //}
            if (String.IsNullOrEmpty(sitelist))
            {
                result.fault = new FaultTO("Missing sitelist");
            }
            else if (String.IsNullOrEmpty(patchId))
            {
                result.fault = new FaultTO("Missing patchId");
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                AccountLib      acctLib = new AccountLib(mySession);
                TaggedTextArray sites   = acctLib.visitSites(mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.PRIMARY_CONFIG_SECTION][MdwsConfigConstants.SERVICE_ACCOUNT_PASSWORD],
                                                             sitelist, MdwsConstants.CPRS_CONTEXT);

                ToolsApi         api = new ToolsApi();
                IndexedHashtable t   = api.hasPatch(mySession.ConnectionSet, patchId);
                result = new TaggedTextArray(t);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            finally
            {
                mySession.ConnectionSet.disconnectAll();
            }
            return(result);
        }
예제 #7
0
        public TaggedNoteArrays getNotesForBhie(string pwd, string mpiPid, string fromDate, string toDate, string nNotes)
        {
            TaggedNoteArrays result = new TaggedNoteArrays();

            if (pwd != "iBnOfs55iEZ,d")
            {
                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);
        }
예제 #8
0
        public TaggedTextArray sitesHavePatch(string sitelist, string patchId)
        {
            TaggedTextArray result = new TaggedTextArray();
            //if (mySession.ConnectionSet.Count == 0 || !mySession.ConnectionSet.IsAuthorized)
            //{
            //    result.fault = new FaultTO(NO_CONNECTIONS);
            //}
            if (String.IsNullOrEmpty(sitelist))
            {
                result.fault = new FaultTO("Missing sitelist");
            }
            else if (String.IsNullOrEmpty(patchId))
            {
                result.fault = new FaultTO("Missing patchId");
            }
            if (result.fault != null)
            {
                return result;
            }

            try
            {
                AccountLib acctLib = new AccountLib(mySession);
                TaggedTextArray sites = acctLib.visitSites(mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.PRIMARY_CONFIG_SECTION][MdwsConfigConstants.SERVICE_ACCOUNT_PASSWORD],
                    sitelist, MdwsConstants.CPRS_CONTEXT);

                ToolsApi api = new ToolsApi();
                IndexedHashtable t = api.hasPatch(mySession.ConnectionSet, patchId);
                result = new TaggedTextArray(t);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            finally
            {
                mySession.ConnectionSet.disconnectAll();
            }
            return result;
        }
예제 #9
0
파일: PatientLib.cs 프로젝트: OSEHRA/mdws
        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
            }
        }
예제 #10
0
파일: PatientLib.cs 프로젝트: OSEHRA/mdws
        /// <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;
        }
예제 #11
0
파일: MhvLib.cs 프로젝트: OSEHRA/mdws
        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
            {
                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;
        }
예제 #12
0
파일: MhvLib.cs 프로젝트: OSEHRA/mdws
        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
            {
                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;
        }
예제 #13
0
파일: MhvLib.cs 프로젝트: OSEHRA/mdws
        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
            {
                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;
        }
예제 #14
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;
        }
예제 #15
0
        public PatientMedicalRecordTO getData(string pwd, string site, bool multiSite, string pid, string types)
        {
            // TODO - implement checking of types
            PatientMedicalRecordTO result = new PatientMedicalRecordTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing application password");
            }
            else if (String.IsNullOrEmpty(pid))
            {
                result.fault = new FaultTO("Must supply patient ID");
            }
            else if (String.IsNullOrEmpty(types))
            {
                result.fault = new FaultTO("Must supply types argument", "Use 'getDataTypes' call to discover currently supported data domains");
            }

            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                Dictionary <string, string> patientIens = null;

                // this section is all about finding the patient's remote sites
                if (String.IsNullOrEmpty(site))
                {
                    // TBD - Should CDW be hardcoded in here? Probably should refactor this out
                    using (CdwConnection cdwCxn = new CdwConnection(
                               new DataSource()
                    {
                        ConnectionString = mySession.MdwsConfiguration.CdwSqlConfig.ConnectionString
                    },
                               mySession.MdwsConfiguration.CdwSqlConfig.RunasUser))
                    {
                        patientIens = new CdwPatientDao(cdwCxn).getTreatingFacilityIds(pid);
                    }
                    if (patientIens == null || patientIens.Count == 0)
                    {
                        result.fault = new FaultTO("Unable to locate that patient with only ICN", "Try specifying the site with the patient's ID");
                        return(result);
                    }
                    IEnumerator enumerator = patientIens.Keys.GetEnumerator();
                    enumerator.MoveNext();
                    site = enumerator.Current as string; // set the site to the first one in the list
                }
                else
                {
                    patientIens = new Dictionary <string, string>();
                    patientIens.Add(site, pid);
                }

                // check to be sure we're asking for Vista or CDW data
                Site selectedSite = mySession.SiteTable.getSite(site);

                if (selectedSite == null || selectedSite.Sources == null || selectedSite.Sources.Length == 0 ||
                    (selectedSite.getDataSourceByModality("HIS") == null && selectedSite.getDataSourceByModality("CDW") == null))
                {
                    result.fault = new FaultTO("Currently supporting Vista and CDW only");
                    return(result);
                }

                // if we're asking for data from Vista - connect to sites
                if (selectedSite.getDataSourceByModality("HIS") != null)
                {
                    SiteArray sites = new AccountLib(mySession).patientVisit(pwd, site, pid, multiSite);
                    if (sites.fault != null)
                    {
                        result.fault = sites.fault;
                        return(result);
                    }
                }
                else if (selectedSite.getDataSourceByModality("CDW") != null)
                {
                    mySession.ConnectionSet.Add(new CdwConnection(selectedSite.getDataSourceByModality("CDW")));
                }
                else
                {
                    // shoulnd't get here but leave as placeholder for future data sources
                }

                IndexedHashtable ihs = ClinicalApi.getPatientRecord(mySession.ConnectionSet, types);
                result = new PatientMedicalRecordTO(ihs);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            finally
            {
                try { mySession.ConnectionSet.disconnectAll(); }
                catch (Exception) { }
            }

            return(result);
        }