Пример #1
0
 public CdwLocationDao(AbstractConnection cxn)
 {
     _cxn = cxn as CdwConnection;
 }
Пример #2
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);
        }