Ejemplo n.º 1
0
        public List <AutoMatch> GetAutoMatchMappings()
        {
            List <AutoMatch> autoMatchList = new List <AutoMatch>();

            SqlCommand    cmd = new SqlCommand();
            SqlDataReader reader;

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

            // Get previously defined patient ID mappings
            cmd.CommandText = "GetAutoMatchMappings";
            reader          = cmd.ExecuteReader();
            while (reader.Read())
            {
                AutoMatch autoMatch = new AutoMatch();
                autoMatch.LastName        = UtilitiesDAL.ToString(reader["LastName"]);
                autoMatch.FirstName       = UtilitiesDAL.ToString(reader["FirstName"]);
                autoMatch.Gender          = UtilitiesDAL.ToString(reader["Gender"]);
                autoMatch.DOB             = UtilitiesDAL.ToDateTime(reader["DateOfBirth"]);
                autoMatch.SSN             = UtilitiesDAL.ToString(reader["SSN"]).Replace("-", "");
                autoMatch.MatchedToUserId = UtilitiesDAL.ToInt(reader["MatchedToUserID"]);
                autoMatchList.Add(autoMatch);
            }
            reader.Close();

            return(autoMatchList);
        }
Ejemplo n.º 2
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 + ")");
                }
            }
        }
Ejemplo n.º 3
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();
            }
        }