Esempio n. 1
0
        public int GetExistingDataLoadMismatch(Observation obx)
        {
            int existingDataLoadMismatchId = 0;

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            cmd.CommandText = "GetExistingDataLoadMismatch";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@LastName", obx.LastName));
            cmd.Parameters.Add(new SqlParameter("@FirstName", obx.FirstName));
            cmd.Parameters.Add(new SqlParameter("@Gender", obx.Gender));
            cmd.Parameters.Add(new SqlParameter("@DateOfBirth", obx.DOB));
            cmd.Parameters.Add(new SqlParameter("@SSN", obx.SSN));
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                existingDataLoadMismatchId = Convert.ToInt32(reader.GetValue(0));
            }

            reader.Close();

            return existingDataLoadMismatchId;
        }
Esempio n. 2
0
        public void ProcessFullMatchAndGoodValue(Observation obx)
        {
            string messageString = "User " + obx.UserCN + " (" + obx.FirstName + " " + obx.LastName + ") WAS found in our user database, as user (" + obx.UserId + "), and the test result was loaded.";
            Logger.LogLine(messageString);
            DAL.InsertNewTestResult(obx);
            DAL.UpdateProcessedObservationStatus(obx, true, messageString, null, null);

            // Add user ID to the user ID list, if not already in it
            if (!UserIdList.Contains(obx.UserId))
            {
                UserIdList.Add(obx.UserId);
            }

            // If a replacement value was used, mark the DataLoadValueError entry as resolved
            if (obx.DataLoadValueErrorID > 0 &&
                obx.ReplacementValue != null &&
                obx.ResultData == obx.ReplacementValue)
            {
                DAL.ResolveDataLoadValueError(obx.DataLoadValueErrorID);
            }
        }
Esempio n. 3
0
        public void InsertNewTestResult(Observation obx)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = SqlConnectionMain;

            Logger.LogLine("Inserting new test result for:");
            Logger.LogLine("   UserId:" + obx.UserId);
            Logger.LogLine("   TestId:" + obx.UserId);
            Logger.LogLine("   EntryDate:" + obx.UserId);

            // Add a new test result
            cmd.CommandText = "InsertNewTestResult";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@UserId", obx.UserId));
            cmd.Parameters.Add(new SqlParameter("@EntryDate", obx.EntryDate)); // Should come from the MSH segment...
            cmd.Parameters.Add(new SqlParameter("@Test", obx.ObservationIdText));
            cmd.Parameters.Add(new SqlParameter("@TestResult", ""));           // Do we need to compute this on test entry?
            cmd.Parameters.Add(new SqlParameter("@TestId", obx.TestId));
            cmd.Parameters.Add(new SqlParameter("@TestValue", obx.ResultData));
            cmd.Parameters.Add(new SqlParameter("@NormalRange", obx.ReferenceRange));
            cmd.ExecuteNonQuery();
        }
Esempio n. 4
0
        private void GetAutoMatchMappedUserId(Observation obx, List<AutoMatch> autoMatchList)
        {
            string obxLastName = obx.LastName.ToLower();
            string obxFirstName = obx.FirstName.ToLower();
            string obxGender = obx.Gender.ToLower();
            string obxSSN = obx.SSN;
            DateTime obxDOB = ImplausibleDateTime;  // A perfectly implausible date of birth...
            DateTime.TryParseExact(obx.DOB, DAL.DateFormats, new CultureInfo("en-US"), DateTimeStyles.None, out obxDOB);

            foreach (AutoMatch autoMatch in autoMatchList)
            {
                string autoMatchSSN = autoMatch.SSN;
                string autoMatchLastName = autoMatch.LastName.ToLower();
                string autoMatchFirstName = autoMatch.FirstName.ToLower();
                string autoMatchGender = autoMatch.Gender.ToLower();

                if (obxSSN == autoMatchSSN
                    &&
                    obxLastName == autoMatchLastName
                    &&
                    obxFirstName == autoMatchFirstName
                    &&
                    obxGender == autoMatchGender)
                {
                    if (obxDOB.Date == autoMatch.DOB.Date)
                    {
                        obx.UserId = autoMatch.MatchedToUserId;
                        return;
                    }
                }
            }
        }
Esempio n. 5
0
 private void GetExplicitMatchMappedUserIdAndTestId(Observation obx, List<ExplicitMatch> explicitMatchList)
 {
     foreach (ExplicitMatch explicitMatch in explicitMatchList)
     {
         if (obx.DataLoadMismatchTestID == explicitMatch.DataLoadMismatchTestId)
         {
             if (obx.UserId == 0)
             {
                 obx.UserId = explicitMatch.MatchedToUserId;
             }
             if (obx.TestId == 0)
             {
                 obx.TestId = explicitMatch.MatchedToTestId;
             }
             return;
         }
     }
 }
Esempio n. 6
0
 public void ProcessObservationMismatch(Observation obx)
 {
     string messageString = "User " + obx.UserCN + " (" + obx.FirstName + " " + obx.LastName + ") found as user (" + obx.UserId + "), BUT the test result was NOT loaded, because there was no USHC test corresponding to observation (" + obx.ObservationId + ").";
     Logger.LogLine(messageString);
     int mismatchTestId = RecordMismatchForLaterResolution(obx);
     DAL.UpdateProcessedObservationStatus(obx, false, messageString, mismatchTestId, null);
 }
Esempio n. 7
0
 public bool TestValueIsValid(Observation obx)
 {
     if (ContainsAtLeastOneDigit(obx.TestNormalRange) ||
         ContainsAtLeastOneDigit(obx.TestNormalRangeFemale))
     {
         decimal decimalResultData = 0;
         if (!decimal.TryParse(obx.ResultData, out decimalResultData))
         {
             return false;
         }
     }
     return true;
 }
Esempio n. 8
0
        public void InsertNewTestResult(Observation obx)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            Logger.LogLine("Inserting new test result for:");
            Logger.LogLine("   UserId:" + obx.UserId);
            Logger.LogLine("   TestId:" + obx.UserId);
            Logger.LogLine("   EntryDate:" + obx.UserId);

            // Add a new test result
            cmd.CommandText = "InsertNewTestResult";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@UserId", obx.UserId));
            cmd.Parameters.Add(new SqlParameter("@EntryDate", obx.EntryDate));  // Should come from the MSH segment...
            cmd.Parameters.Add(new SqlParameter("@Test", obx.ObservationIdText));
            cmd.Parameters.Add(new SqlParameter("@TestResult", ""));    // Do we need to compute this on test entry?
            cmd.Parameters.Add(new SqlParameter("@TestId", obx.TestId));
            cmd.Parameters.Add(new SqlParameter("@TestValue", obx.ResultData));
            cmd.Parameters.Add(new SqlParameter("@NormalRange", obx.ReferenceRange));
            cmd.ExecuteNonQuery();
        }
Esempio n. 9
0
        public List <Observation> GetObservationList()
        {
            List <Observation> obxList = new List <Observation>();

            SqlCommand    cmd = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = SqlConnectionMain;

            // Get previously processed observations that failed
            cmd.CommandText = "GetMessageObservationsFailed";
            reader          = cmd.ExecuteReader();
            while (reader.Read())
            {
                Observation obx = new Observation();
                obx.MessageId             = UtilitiesDAL.ToString(reader["MessageID"]);
                obx.SequenceId            = UtilitiesDAL.ToInt(reader["SequenceID"]);
                obx.CustomerString        = UtilitiesDAL.ToString(reader["CustomerString"]);
                obx.ObservationId         = UtilitiesDAL.ToString(reader["OBXID"]);
                obx.ObservationIdText     = UtilitiesDAL.ToString(reader["OBXIDTEXT"]);
                obx.ResultData            = UtilitiesDAL.ToString(reader["OBXRESULT"]);
                obx.ResultUnits           = UtilitiesDAL.ToString(reader["OBXUNITS"]);
                obx.ReferenceRange        = UtilitiesDAL.ToString(reader["OBXREFRANGE"]);
                obx.TestId                = UtilitiesDAL.ToInt(reader["TestID"]);
                obx.TestNormalRange       = UtilitiesDAL.ToString(reader["NormalRange"]);
                obx.TestNormalRangeFemale = UtilitiesDAL.ToString(reader["NormalRangeF"]);
                obx.InternalPatientId     = UtilitiesDAL.ToString(reader["PIDINTERNALPATIENTID"]);
                obx.SSN                    = GetSSN(reader);
                obx.LastName               = UtilitiesDAL.ToString(reader["PIDLASTNAME"]);
                obx.FirstName              = UtilitiesDAL.ToString(reader["PIDFIRSTNAME"]);
                obx.MiddleName             = UtilitiesDAL.ToString(reader["PIDMIDDLENAME"]);
                obx.DOB                    = UtilitiesDAL.ToString(reader["PIDDOB"]);
                obx.Gender                 = UtilitiesDAL.ToString(reader["PIDGENDER"]);
                obx.StreetAddress          = UtilitiesDAL.ToString(reader["PIDSTREET"]);
                obx.OtherAddress           = UtilitiesDAL.ToString(reader["PIDOTHER"]);
                obx.City                   = UtilitiesDAL.ToString(reader["PIDCITY"]);
                obx.State                  = UtilitiesDAL.ToString(reader["PIDSTATE"]);
                obx.Zip                    = UtilitiesDAL.ToString(reader["PIDZIP"]);
                obx.DataLoadMismatchTestID = UtilitiesDAL.ToInt(reader["DataLoadMismatchTestID"]);
                obx.DataLoadValueErrorID   = UtilitiesDAL.ToInt(reader["DataLoadValueErrorID"]);
                obx.ReplacementValue       = UtilitiesDAL.ToNullableString(reader["ReplacementValue"]);
                SpecialObxSetup(obx, reader);
                obxList.Add(obx);
            }
            reader.Close();

            // Get new never-before-processed observations
            cmd.CommandText = "GetMessageObservationsUnattempted";
            reader          = cmd.ExecuteReader();
            while (reader.Read())
            {
                Observation obx = new Observation();
                obx.MessageId             = UtilitiesDAL.ToString(reader["MessageID"]);
                obx.SequenceId            = UtilitiesDAL.ToInt(reader["SequenceID"]);
                obx.CustomerString        = UtilitiesDAL.ToString(reader["CustomerString"]);
                obx.ObservationId         = UtilitiesDAL.ToString(reader["OBXID"]);
                obx.ObservationIdText     = UtilitiesDAL.ToString(reader["OBXIDTEXT"]);
                obx.ResultData            = UtilitiesDAL.ToString(reader["OBXRESULT"]);
                obx.ResultUnits           = UtilitiesDAL.ToString(reader["OBXUNITS"]);
                obx.ReferenceRange        = UtilitiesDAL.ToString(reader["OBXREFRANGE"]);
                obx.TestId                = UtilitiesDAL.ToInt(reader["TestID"]);
                obx.TestNormalRange       = UtilitiesDAL.ToString(reader["NormalRange"]);
                obx.TestNormalRangeFemale = UtilitiesDAL.ToString(reader["NormalRangeF"]);
                obx.InternalPatientId     = UtilitiesDAL.ToString(reader["PIDINTERNALPATIENTID"]);
                obx.SSN                    = GetSSN(reader);
                obx.LastName               = UtilitiesDAL.ToString(reader["PIDLASTNAME"]);
                obx.FirstName              = UtilitiesDAL.ToString(reader["PIDFIRSTNAME"]);
                obx.MiddleName             = UtilitiesDAL.ToString(reader["PIDMIDDLENAME"]);
                obx.DOB                    = UtilitiesDAL.ToString(reader["PIDDOB"]);
                obx.Gender                 = UtilitiesDAL.ToString(reader["PIDGENDER"]);
                obx.StreetAddress          = UtilitiesDAL.ToString(reader["PIDSTREET"]);
                obx.OtherAddress           = UtilitiesDAL.ToString(reader["PIDOTHER"]);
                obx.City                   = UtilitiesDAL.ToString(reader["PIDCITY"]);
                obx.State                  = UtilitiesDAL.ToString(reader["PIDSTATE"]);
                obx.Zip                    = UtilitiesDAL.ToString(reader["PIDZIP"]);
                obx.DataLoadMismatchTestID = 0;
                obx.DataLoadValueErrorID   = 0;
                SpecialObxSetup(obx, reader);
                obxList.Add(obx);
            }
            reader.Close();

            FillInUserIdFields(obxList);

            return(obxList);
        }
Esempio n. 10
0
        private void SpecialObxSetup(Observation obx, SqlDataReader reader)
        {
            // Create the UserCN (username) that is used to identify the user for each observation
            string firstNameFirstLetter = (obx.FirstName.Length > 0) ? obx.FirstName.Substring(0, 1) : "";
            string lastName = obx.LastName;
            string lastFourOfSSN = (obx.SSN.Length == 9) ? obx.SSN.Substring(5, 4) : "XXXX";
            obx.UserCN = firstNameFirstLetter + lastName + lastFourOfSSN;

            // Extract the actual date part of the message date field
            string messageDateStringRaw = UtilitiesDAL.ToString(reader["EntryDate"]);
            string messageDateString = "";
            foreach (char ch in messageDateStringRaw.ToCharArray())
            {
                if (!char.IsDigit(ch))
                {
                    break;
                }
                messageDateString += ch;
            }
            DateTime messageDateTime;
            if (!DateTime.TryParseExact(messageDateString, DateFormats, new CultureInfo("en-US"), DateTimeStyles.None, out messageDateTime))
            {
                messageDateTime = DateTime.Now;
            }
            obx.EntryDate = messageDateTime;

            int firstComponentSeparatorPosition = obx.ResultData.IndexOf('^');
            if (firstComponentSeparatorPosition > -1)
            {
                obx.ResultData = obx.ResultData.Substring(0, firstComponentSeparatorPosition);
            }

            // Use the replacement value, if given
            if (obx.DataLoadValueErrorID > 0 &&
                obx.ReplacementValue != null)
            {
                obx.ResultData = obx.ReplacementValue;
            }
        }
Esempio n. 11
0
        public int InsertDataLoadMismatchTest(Observation obx, int dataLoadMismatchId)
        {
            int newDataLoadMismatchTestId = 0;

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            cmd.CommandText = "InsertDataLoadMismatchTest";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@DataLoadMismatchID", dataLoadMismatchId));
            cmd.Parameters.Add(new SqlParameter("@MatchedToTestID", (obx.TestId == 0) ? (object)DBNull.Value : obx.TestId));
            cmd.Parameters.Add(new SqlParameter("@ObservationID", obx.ObservationId));
            cmd.Parameters.Add(new SqlParameter("@ObservationTestMismatch", obx.TestId == 0));
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                newDataLoadMismatchTestId = Convert.ToInt32(reader.GetValue(0));
            }

            reader.Close();

            return newDataLoadMismatchTestId;
        }
Esempio n. 12
0
        private void GetUserIdBasedOnUserCN(Observation obx)
        {
            int censusUserId = 0;
            string censusGender = "";
            DateTime censusDOB = new DateTime();

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            // Get the matching UserId for the UserCN in the current observation
            cmd.CommandText = "GetUserIdBasedOnUserCN";

            if (UserCNCache.Keys.Contains(obx.UserCN))
            {
                Logger.LogLine("Found " + obx.UserCN + " in the cache");
                obx.UserId = UserCNCache[obx.UserCN];
            }
            else
            {
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new SqlParameter("@UserCN", obx.UserCN));
                reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    censusUserId = UtilitiesDAL.ToInt(reader["UserID"]);
                    censusGender = UtilitiesDAL.ToString(reader["Gender"]);
                    censusDOB = UtilitiesDAL.ToDateTime(reader["DOB"]);
                }
                obx.UserId = censusUserId;
                UserCNCache[obx.UserCN] = censusUserId;
                Logger.LogLine("Added " + obx.UserCN + " to the cache");
                if (censusUserId > 0
                    &&
                    !MatchOnGenderAndDOB(obx, censusGender, censusDOB))
                {
                    obx.UserId = 0;  // Treat as if user was not found, due to gender/DOB mismatch
                }

                reader.Close();
            }
        }
Esempio n. 13
0
        private bool MatchOnGenderAndDOB(Observation obx, string censusGender, DateTime censusDOB)
        {
            DateTime obxDOB;

            if (DateTime.TryParseExact(obx.DOB, DateFormats, new CultureInfo("en-US"), DateTimeStyles.None, out obxDOB))
            {
                if (censusDOB.Date == obxDOB
                    &&
                    censusGender.ToLower() == obx.Gender.ToLower())
                {
                    return true;
                }
            }
            return false;
        }
Esempio n. 14
0
        private void GetUserIdBasedOnSSN(Observation obx)
        {
            int censusUserId = 0;
            string censusGender = "";
            DateTime censusDOB = new DateTime();

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            // Get the matching UserId for the SSN in the current observation
            cmd.CommandText = "GetUserIdBasedOnSSN";

            if (obx.SSN.Length < 9)
            {
                Logger.LogLine("SSN (" + obx.SSN + ") is not long enough");
                obx.UserId = 0;
            }
            else if (SSNCache.Keys.Contains(obx.SSN))
            {
                Logger.LogLine("Found " + obx.SSN + " in the cache");
                obx.UserId = SSNCache[obx.SSN];
            }
            else
            {
                try
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(new SqlParameter("@SSN", obx.SSN));
                    reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        censusUserId = UtilitiesDAL.ToInt(reader["UserID"]);
                        censusGender = UtilitiesDAL.ToString(reader["Gender"]);
                        censusDOB = UtilitiesDAL.ToDateTime(reader["DOB"]);
                    }
                    obx.UserId = censusUserId;
                    SSNCache[obx.SSN] = censusUserId;
                    Logger.LogLine("Added " + obx.SSN + " to the cache");
                    if (censusUserId > 0
                        &&
                        !MatchOnGenderAndDOB(obx, censusGender, censusDOB))
                    {
                        obx.UserId = 0;  // Treat as if user was not found, due to gender/DOB mismatch
                    }

                    reader.Close();
                }
                catch (Exception ex)
                {
                    Logger.LogLine("Unexpected error when trying to process " + obx.SSN + " (" + ex.Message + ")");
                }
            }
        }
Esempio n. 15
0
        public void UpdateProcessedObservationStatus(Observation obx, bool success, string message, int? mismatchForLaterResolution, int? valueErrorId)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            // Add a new test result
            cmd.CommandText = "UpdateProcessedObservationStatus";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@MessageID", obx.MessageId));
            cmd.Parameters.Add(new SqlParameter("@SequenceID", obx.SequenceId));
            cmd.Parameters.Add(new SqlParameter("@Success", success));
            cmd.Parameters.Add(new SqlParameter("@Message", message));
            cmd.Parameters.Add(new SqlParameter("@DataLoadMismatchTestID", (success || !mismatchForLaterResolution.HasValue) ? (object)DBNull.Value : mismatchForLaterResolution.Value));
            cmd.Parameters.Add(new SqlParameter("@DataLoadValueErrorID", valueErrorId.HasValue ? valueErrorId.Value : (object)DBNull.Value));
            cmd.ExecuteNonQuery();
        }
Esempio n. 16
0
        public void InsertUnmappedObservation(Observation obx)
        {
            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            cmd.CommandText = "InsertUnmappedObservation";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@OBXID", obx.ObservationId));
            reader = cmd.ExecuteReader();

            reader.Close();
        }
Esempio n. 17
0
 private int RecordMismatchForLaterResolution(Observation obx)
 {
     int mismatchId = DAL.GetExistingDataLoadMismatch(obx);
     if (mismatchId == 0)
     {
         mismatchId = DAL.InsertDataLoadMismatch(obx);
     }
     if (obx.TestId == 0)
     {
         DAL.InsertUnmappedObservation(obx);
     }
     return DAL.InsertDataLoadMismatchTest(obx, mismatchId);
 }
Esempio n. 18
0
 public void ProcessNameMismatch(Observation obx)
 {
     string messageString = "User " + obx.UserCN + " (" + obx.FirstName + " " + obx.LastName + ") was NOT found in our user database.";
     Logger.LogLine(messageString);
     int mismatchTestId = RecordMismatchForLaterResolution(obx);
     DAL.UpdateProcessedObservationStatus(obx, false, messageString, mismatchTestId, null);
 }
Esempio n. 19
0
 private int RecordValueErrorForLaterResolution(Observation obx)
 {
     return DAL.InsertDataLoadValueError(obx);
 }
Esempio n. 20
0
        public int InsertDataLoadMismatch(Observation obx)
        {
            int newDataLoadMismatchId = 0;

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            cmd.CommandText = "InsertDataLoadMismatch";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@LastName", obx.LastName));
            cmd.Parameters.Add(new SqlParameter("@FirstName", obx.FirstName));
            cmd.Parameters.Add(new SqlParameter("@Gender", obx.Gender));
            cmd.Parameters.Add(new SqlParameter("@DateOfBirth", obx.DOB));
            cmd.Parameters.Add(new SqlParameter("@SSN", obx.SSN));
            cmd.Parameters.Add(new SqlParameter("@MatchedToUserID", (obx.UserId == 0) ? (object)DBNull.Value : obx.UserId));
            cmd.Parameters.Add(new SqlParameter("@CustomerString", obx.CustomerString));
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                newDataLoadMismatchId = Convert.ToInt32(reader.GetValue(0));
            }

            reader.Close();

            return newDataLoadMismatchId;
        }
Esempio n. 21
0
 public void ProcessInvalidTestValue(Observation obx)
 {
     string messageString = "User " + obx.UserCN + " (" + obx.FirstName + " " + obx.LastName + ") found as user (" + obx.UserId + "), BUT the test result was NOT loaded, because it appears to be invalid based on the USHC test normal ranges (" + obx.TestId + ": " + obx.TestNormalRange + ", " + obx.TestNormalRangeFemale + ").";
     Logger.LogLine(messageString);
     int valueErrorId = RecordValueErrorForLaterResolution(obx);
     DAL.UpdateProcessedObservationStatus(obx, false, messageString, null, valueErrorId);
 }
Esempio n. 22
0
        public int InsertDataLoadValueError(Observation obx)
        {
            int newDataLoadValueErrorId = 0;

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            cmd.CommandText = "InsertDataLoadValueError";
            cmd.Parameters.Clear();
            cmd.Parameters.Add(new SqlParameter("@SuppliedValue", obx.ResultData));
            cmd.Parameters.Add(new SqlParameter("@ReferenceRange", obx.ReferenceRange));
            cmd.Parameters.Add(new SqlParameter("@TestID", obx.TestId));
            cmd.Parameters.Add(new SqlParameter("@TestNormalRange", obx.TestNormalRange));
            cmd.Parameters.Add(new SqlParameter("@TestNormalRangeFemale", obx.TestNormalRangeFemale));
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                newDataLoadValueErrorId = Convert.ToInt32(reader.GetValue(0));
            }

            reader.Close();

            return newDataLoadValueErrorId;
        }
Esempio n. 23
0
 private int RecordValueErrorForLaterResolution(Observation obx)
 {
     return(DAL.InsertDataLoadValueError(obx));
 }
Esempio n. 24
0
        public List<Observation> GetObservationList()
        {
            List<Observation> obxList = new List<Observation>();

            SqlCommand cmd = new SqlCommand();
            SqlDataReader reader;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = SqlConnectionMain;

            // Get previously processed observations that failed
            cmd.CommandText = "GetMessageObservationsFailed";
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Observation obx = new Observation();
                obx.MessageId = UtilitiesDAL.ToString(reader["MessageID"]);
                obx.SequenceId = UtilitiesDAL.ToInt(reader["SequenceID"]);
                obx.CustomerString = UtilitiesDAL.ToString(reader["CustomerString"]);
                obx.ObservationId = UtilitiesDAL.ToString(reader["OBXID"]);
                obx.ObservationIdText = UtilitiesDAL.ToString(reader["OBXIDTEXT"]);
                obx.ResultData = UtilitiesDAL.ToString(reader["OBXRESULT"]);
                obx.ResultUnits = UtilitiesDAL.ToString(reader["OBXUNITS"]);
                obx.ReferenceRange = UtilitiesDAL.ToString(reader["OBXREFRANGE"]);
                obx.TestId = UtilitiesDAL.ToInt(reader["TestID"]);
                obx.TestNormalRange = UtilitiesDAL.ToString(reader["NormalRange"]);
                obx.TestNormalRangeFemale = UtilitiesDAL.ToString(reader["NormalRangeF"]);
                obx.InternalPatientId = UtilitiesDAL.ToString(reader["PIDINTERNALPATIENTID"]);
                obx.SSN = GetSSN(reader);
                obx.LastName = UtilitiesDAL.ToString(reader["PIDLASTNAME"]);
                obx.FirstName = UtilitiesDAL.ToString(reader["PIDFIRSTNAME"]);
                obx.MiddleName = UtilitiesDAL.ToString(reader["PIDMIDDLENAME"]);
                obx.DOB = UtilitiesDAL.ToString(reader["PIDDOB"]);
                obx.Gender = UtilitiesDAL.ToString(reader["PIDGENDER"]);
                obx.StreetAddress = UtilitiesDAL.ToString(reader["PIDSTREET"]);
                obx.OtherAddress = UtilitiesDAL.ToString(reader["PIDOTHER"]);
                obx.City = UtilitiesDAL.ToString(reader["PIDCITY"]);
                obx.State = UtilitiesDAL.ToString(reader["PIDSTATE"]);
                obx.Zip = UtilitiesDAL.ToString(reader["PIDZIP"]);
                obx.DataLoadMismatchTestID = UtilitiesDAL.ToInt(reader["DataLoadMismatchTestID"]);
                obx.DataLoadValueErrorID = UtilitiesDAL.ToInt(reader["DataLoadValueErrorID"]);
                obx.ReplacementValue = UtilitiesDAL.ToNullableString(reader["ReplacementValue"]);
                SpecialObxSetup(obx, reader);
                obxList.Add(obx);
            }
            reader.Close();

            // Get new never-before-processed observations
            cmd.CommandText = "GetMessageObservationsUnattempted";
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Observation obx = new Observation();
                obx.MessageId = UtilitiesDAL.ToString(reader["MessageID"]);
                obx.SequenceId = UtilitiesDAL.ToInt(reader["SequenceID"]);
                obx.CustomerString = UtilitiesDAL.ToString(reader["CustomerString"]);
                obx.ObservationId = UtilitiesDAL.ToString(reader["OBXID"]);
                obx.ObservationIdText = UtilitiesDAL.ToString(reader["OBXIDTEXT"]);
                obx.ResultData = UtilitiesDAL.ToString(reader["OBXRESULT"]);
                obx.ResultUnits = UtilitiesDAL.ToString(reader["OBXUNITS"]);
                obx.ReferenceRange = UtilitiesDAL.ToString(reader["OBXREFRANGE"]);
                obx.TestId = UtilitiesDAL.ToInt(reader["TestID"]);
                obx.TestNormalRange = UtilitiesDAL.ToString(reader["NormalRange"]);
                obx.TestNormalRangeFemale = UtilitiesDAL.ToString(reader["NormalRangeF"]);
                obx.InternalPatientId = UtilitiesDAL.ToString(reader["PIDINTERNALPATIENTID"]);
                obx.SSN = GetSSN(reader);
                obx.LastName = UtilitiesDAL.ToString(reader["PIDLASTNAME"]);
                obx.FirstName = UtilitiesDAL.ToString(reader["PIDFIRSTNAME"]);
                obx.MiddleName = UtilitiesDAL.ToString(reader["PIDMIDDLENAME"]);
                obx.DOB = UtilitiesDAL.ToString(reader["PIDDOB"]);
                obx.Gender = UtilitiesDAL.ToString(reader["PIDGENDER"]);
                obx.StreetAddress = UtilitiesDAL.ToString(reader["PIDSTREET"]);
                obx.OtherAddress = UtilitiesDAL.ToString(reader["PIDOTHER"]);
                obx.City = UtilitiesDAL.ToString(reader["PIDCITY"]);
                obx.State = UtilitiesDAL.ToString(reader["PIDSTATE"]);
                obx.Zip = UtilitiesDAL.ToString(reader["PIDZIP"]);
                obx.DataLoadMismatchTestID = 0;
                obx.DataLoadValueErrorID = 0;
                SpecialObxSetup(obx, reader);
                obxList.Add(obx);
            }
            reader.Close();

            FillInUserIdFields(obxList);

            return obxList;
        }