Inheritance: Person
Esempio n. 1
0
 public TaggedPatientArray(string tag, Patient patient)
 {
     this.tag = tag;
     if (patient == null)
     {
         this.count = 0;
         return;
     }
     this.patients = new PatientTO[1];
     this.patients[0] = new PatientTO(patient);
     this.count = 1;
 }
Esempio n. 2
0
 private void setProps(Patient[] mdo)
 {
     if (mdo == null)
     {
         return;
     }
     patients = new PatientTO[mdo.Length];
     for (int i = 0; i < mdo.Length; i++)
     {
         patients[i] = new PatientTO(mdo[i]);
     }
     count = mdo.Length;
 }
Esempio n. 3
0
 public TaggedPatientArray(string tag, Patient[] patients)
 {
     this.tag = tag;
     if (patients == null)
     {
         this.count = 0;
         return;
     }
     this.patients = new PatientTO[patients.Length];
     for (int i = 0; i < patients.Length; i++)
     {
         this.patients[i] = new PatientTO(patients[i]);
     }
     this.count = patients.Length;
 }
Esempio n. 4
0
 public void addHomeData(Patient patient)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
        Patient getNextPatient(SqlDataReader reader)
        {
            Patient p = new Patient();
            p.LocalSiteId = (reader.GetInt16(reader.GetOrdinal("sitecode"))).ToString();

            Decimal d = Convert.ToDecimal(reader.GetDecimal(reader.GetOrdinal("localPid")));
            if ((d - Math.Floor(d)) > 0)
            {
                p.LocalPid = (d).ToString();
            }
            else
            {
                p.LocalPid = (Convert.ToInt64(d)).ToString();
            }
            p.Name = new PersonName(reader.GetString(reader.GetOrdinal("name")));
            p.SSN = new SocSecNum(reader.GetString(reader.GetOrdinal("ssn")));

            if (!reader.IsDBNull(reader.GetOrdinal("gender")))
            {
                p.Gender = reader.GetBoolean(reader.GetOrdinal("gender")) ? "M" : "F"; // 1 or true == male, 0 or false == female
            }
            else
            {
                p.Gender = "";
            }
            if (!reader.IsDBNull(reader.GetOrdinal("vistaDOB")))
            {
                p.DOB = reader.GetString(reader.GetOrdinal("vistaDOB"));
            }
            p.MpiPid = (reader.GetInt32(reader.GetOrdinal("icn"))).ToString();
            p.MpiChecksum = (reader.GetInt32(reader.GetOrdinal("icnx"))).ToString();

            p.Demographics = new Dictionary<string, DemographicSet>();
            DemographicSet demogs = new DemographicSet();
            demogs.PhoneNumbers = new List<PhoneNum>();
            demogs.EmailAddresses = new List<EmailAddress>();
            demogs.StreetAddresses = new List<Address>();

            if (!reader.IsDBNull(reader.GetOrdinal("homePhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("homePhone"))));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("workPhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("workPhone"))));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("cellPhone")))
            {
                demogs.PhoneNumbers.Add(new PhoneNum(reader.GetString(reader.GetOrdinal("cellPhone"))));
            }

            if (!reader.IsDBNull(reader.GetOrdinal("emailAddress")))
            {
                demogs.EmailAddresses.Add(new EmailAddress(reader.GetString(reader.GetOrdinal("emailAddress"))));
            }

            Address address = new Address();
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine1")))
            {
                address.Street1 = reader.GetString(reader.GetOrdinal("addressLine1"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine2")))
            {
                address.Street2 = reader.GetString(reader.GetOrdinal("addressLine2"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("addressLine3")))
            {
                address.Street3 = reader.GetString(reader.GetOrdinal("addressLine3"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("city")))
            {
                address.City = reader.GetString(reader.GetOrdinal("city"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("county")))
            {
                address.County = reader.GetString(reader.GetOrdinal("county"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("state")))
            {
                address.State = reader.GetString(reader.GetOrdinal("state"));
            }
            if (!reader.IsDBNull(reader.GetOrdinal("zipcode")))
            {
                address.Zipcode = reader.GetString(reader.GetOrdinal("zipcode"));
            }
            demogs.StreetAddresses.Add(address);

            p.Demographics.Add(p.LocalSiteId, demogs);

            return p;
        }
Esempio n. 6
0
        /// <summary>
        /// Query NPT database for all patients with a given SSN
        /// </summary>
        /// <param name="ssn">SSN (Social Security Number)</param>
        /// <returns>An array of all patients matching the given SSN or an empty collection
        /// if not matches are located</returns>
        public Patient[] getPatient(string ssn)
        {
            if (String.IsNullOrEmpty(ssn))
            {
                throw new MdoException(MdoExceptionCode.ARGUMENT_NULL_SSN);
            }

            SqlCommand cmd = new SqlCommand("SELECT * FROM " + PATIENT_TABLE + " WHERE ssn=@SSN;");

            SqlParameter ssnParam = new SqlParameter("@SSN", System.Data.SqlDbType.Char, 9);
            ssnParam.Value = ssn;
            cmd.Parameters.Add(ssnParam);

            _myCxn.SqlParameters = cmd.Parameters; // kind of a hack to use SQL parameters
            _myCxn.connect();
            SqlDataReader reader = (SqlDataReader)_myCxn.query(cmd.CommandText);

            try
            {
                IList<Patient> list = getPatientsFromDataReader(reader);
                Patient[] p = new Patient[list.Count];
                list.CopyTo(p, 0);
                return p;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                _myCxn.disconnect();
            }
        }
Esempio n. 7
0
 public void close()
 {
     _cxnSet.disconnectAll();
     _user = null;
     _patient = null;
 }
Esempio n. 8
0
 internal Patient getHomeData(Patient patient)
 {
     PatientApi api = new PatientApi();
     api.addHomeDate(mySession.ConnectionSet.BaseConnection, patient);
     return patient;
 }
Esempio n. 9
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
            }
        }
Esempio n. 10
0
 public PatientArray(Patient[] mdo)
 {
     setProps(mdo);
 }
Esempio n. 11
0
        /// <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;
        }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
 public UserPatientTO(User user, Patient patient)
 {
     this.user = new UserTO(user);
     this.patient = new PatientTO(patient);
 }
Esempio n. 14
0
        public PatientTO(Patient mdo)
        {
            if (mdo == null)
            {
                return;
            }
            this.name = this.patientName = mdo.Name == null ? "" : mdo.Name.getLastNameFirst();
            this.ssn = mdo.SSN == null ? "" : mdo.SSN.toString();
            this.dob = mdo.DOB;
            this.gender = mdo.Gender;
            this.mpiPid = mdo.MpiPid;
            this.mpiChecksum = mdo.MpiChecksum;
            this.localPid = mdo.LocalPid;
            this.sitePids = mdo.SitePids == null || mdo.SitePids.Count == 0 ? null : new TaggedTextArray(mdo.SitePids);
            this.vendorPid = mdo.VendorPid;
            this.location = new HospitalLocationTO(mdo.Location);
            this.age = mdo.Age;
            this.cwad = mdo.Cwad;
            this.restricted = mdo.IsRestricted;
            //this.admitTimestamp = mdo.AdmitTimestamp.Year == 1 ? "" : mdo.AdmitTimestamp.ToString("yyyyMMdd.HHmmss");
            this.admitTimestamp = mdo.AdmitTimestamp;
            this.serviceConnected = mdo.IsServiceConnected;
            this.scPercent = mdo.ScPercent;
            this.inpatient = mdo.IsInpatient;
            //this.deceasedDate = mdo.DeceasedDate.Year == 1 ? "" : mdo.DeceasedDate.ToString("yyyyMMdd.HHmmss");
            this.deceasedDate = mdo.DeceasedDate;
            this.confidentiality = new TaggedText(mdo.Confidentiality);
            this.needsMeansTest = mdo.NeedsMeansTest;
            this.cmorSiteId = mdo.CmorSiteId;
            this.activeInsurance = mdo.ActiveInsurance;
            this.isTestPatient = mdo.IsTestPatient;
            this.maritalStatus = mdo.MaritalStatus;
            this.ethnicity = mdo.Ethnicity;
            this.currentMeansStatus = mdo.CurrentMeansStatus;
            this.hasInsurance = mdo.HasInsurance;
            this.preferredFacility = new TaggedText(mdo.PreferredFacility);
            this.patientType = mdo.PatientType;
            this.isVeteran = mdo.IsVeteran;
            this.patientFlags = new TaggedTextArray(mdo.PatientFlags);
            this.isLocallyAssignedMpiPid = mdo.IsLocallyAssignedMpiPid;
            if (mdo.HomeAddress != null)
            {
                this.homeAddress = new AddressTO(mdo.HomeAddress);
            }
            if (mdo.HomePhone != null)
            {
                this.homePhone = new PhoneNumTO(mdo.HomePhone);
            }
            if (mdo.CellPhone != null)
            {
                this.cellPhone = new PhoneNumTO(mdo.CellPhone);
            }
            if (mdo.SiteIDs != null)
            {
                Site[] a = new Site[mdo.SiteIDs.Length];
                for (int i = 0; i < mdo.SiteIDs.Length; i++)
                {
                    a[i] = new Site(mdo.SiteIDs[i].Id, mdo.SiteIDs[i].Name);
                    a[i].LastEventTimestamp = mdo.SiteIDs[i].LastSeenDate;
                    a[i].LastEventReason = mdo.SiteIDs[i].LastEvent;
                }
                this.sites = new SiteArray(a);
            }
            if (mdo.Team != null)
            {
                this.team = new TeamTO(mdo.Team);
            }

            if (mdo.Demographics != null && mdo.Demographics.Count > 0)
            {
                this.demographics = new DemographicSetTO[mdo.Demographics.Count];
                string[] keys = new string[mdo.Demographics.Count];
                mdo.Demographics.Keys.CopyTo(keys, 0);
                for (int i = 0; i < mdo.Demographics.Count; i++)
                {
                    this.demographics[i] = new DemographicSetTO(keys[i], mdo.Demographics[keys[i]]);
                }
            }
        }
Esempio n. 15
0
 public TextReport getMOSReport(Patient patient)
 {
     throw new NotImplementedException();
 }
Esempio n. 16
0
 internal void addHomeData(Patient[] patients)
 {
     for (int i = 0; i < patients.Length; i++)
     {
         addHomeData(patients[i]);
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Match a patient on Name, SSN and DOB
        /// </summary>
        /// <param name="p">The patient to match</param>
        /// <returns>An array of patients matching the passed patient</returns>
        public Patient[] getPatient(Patient p)
        {
            if (p == null || p.SSN == null || !p.SSN.IsValid || p.Name == null || String.IsNullOrEmpty(p.DOB))
            {
                throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Must supply valid SSN, Name and DOB to match");
            }
            try
            {
                utils.DateUtils.IsoDateStringToDateTime(p.DOB);
            }
            catch (Exception)
            {
                throw new MdoException(MdoExceptionCode.ARGUMENT_DATE_FORMAT, "Patient DOB should be in ISO format: YYYYMMDD");
            }

            //SqlTransaction tx = conn.BeginTransaction();
            SqlCommand cmd = new SqlCommand("SELECT * FROM " + PATIENT_TABLE +
                " WHERE ssn=@SSN AND name=@NAME AND vistaDOB=@DOB;");

            SqlParameter ssnParam = new SqlParameter("@SSN", System.Data.SqlDbType.Char, 9);
            ssnParam.Value = p.SSN.toString();
            cmd.Parameters.Add(ssnParam);

            SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar, 255);
            nameParam.Value = p.Name.LastNameFirst;
            cmd.Parameters.Add(nameParam);

            SqlParameter dobParam = new SqlParameter("@DOB", SqlDbType.VarChar, 7);
            dobParam.Value = vista.VistaTimestamp.fromDateTimeShortString(utils.DateUtils.IsoDateStringToDateTime(p.DOB));
            cmd.Parameters.Add(dobParam);

            _myCxn.SqlParameters = cmd.Parameters; // kind of a hack to use SQL parameters
            _myCxn.connect();
            SqlDataReader reader = (SqlDataReader)_myCxn.query(cmd.CommandText);

            try
            {
                IList<Patient> list = getPatientsFromDataReader(reader);
                Patient[] patients = new Patient[list.Count];
                list.CopyTo(patients, 0);
                return patients;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                _myCxn.disconnect();
            }
        }
Esempio n. 18
0
File: Order.cs Progetto: OSEHRA/mdo
 public static Order writeSimpleOrderByPolicy(
     AbstractConnection cxn,
     Patient patient,
     String duz,
     String esig,
     String locationIen,
     String orderIen,
     DateTime startDate)
 {
     return getDao(cxn).writeSimpleOrderByPolicy(patient, duz, esig, locationIen, orderIen, startDate);
 }