Example #1
0
        public static List <Appointment> GetApptConsult(string epi, CacheADOConnection con)
        {
            var apps  = new List <Appointment>();
            var query = QueryString.GetApptConsult(epi);

            try
            {
                using (var cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (var pair in query.Item2)
                    {
                        cmd.AddInputParameters(new { key = pair.Value });
                    }
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var appDatetime = string.IsNullOrEmpty(reader["AS_Date"].ToString()) ? new Tuple <string, string>("", "") : new Tuple <string, string>(reader["AS_Date"].ToString(), reader["AS_SessStartTime"].ToString());
                            var appDate     = string.IsNullOrEmpty(appDatetime.Item1) ? "" : DateTime.Parse(appDatetime.Item1).ToString("dd/MM/yyyy");
                            var appTime     = string.IsNullOrEmpty(appDatetime.Item2) ? "" : DateTime.Parse(appDatetime.Item2).ToString("HH:mm");

                            var app = new Appointment()
                            {
                                AS_Date           = appDate,
                                AS_SessStartTime  = appTime,
                                APPT_Status       = reader["APPT_Status"].ToString(),
                                PAADM_VisitStatus = reader["PAADM_VisitStatus"].ToString(),
                                CTLOC_Code        = reader["CTLOC_Code"].ToString(),
                                CTLOC_Desc        = reader["CTLOC_Desc"].ToString(),
                                CTPCP_Desc        = reader["CTPCP_Desc"].ToString(),
                                SER_Desc          = reader["SER_Desc"].ToString()
                            };

                            apps.Add(app);
                        }
                    }
                }

                apps = apps.OrderBy(a => string.IsNullOrEmpty(a.AS_Date) ? (DateTime?)null : DateTime.ParseExact(a.AS_Date, "dd/MM/yyyy", null))
                       .ThenBy(a => string.IsNullOrEmpty(a.AS_SessStartTime) ? (DateTime?)null : DateTime.ParseExact(a.AS_SessStartTime, "HH:mm", null)).ToList();
            }
            catch (Exception)
            {
                return(apps);
            }

            return(apps);
        }
Example #2
0
        public static Tuple <User, string> GetUser(string username, string password)
        {
            var    model   = new User();
            string message = string.Empty;

            var query = TrakCareQuery.GetUser(username);

            using (CacheConnection con = new CacheConnection(Constants.Cache))
            {
                con.Open();
                using (CacheCommand cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (KeyValuePair <string, string> pair in query.Item2)
                    {
                        var key = pair.Key;
                        cmd.AddInputParameters(new { key = pair.Value });
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            User user = new User()
                            {
                                SSUSR_Initials = reader["SSUSR_Initials"].ToString(),
                                SSUSR_Name     = reader["SSUSR_Name"].ToString(),
                                SSUSR_Password = reader["SSUSR_Password"].ToString()
                            };

                            if (Helper.CheckPassword(user, password))
                            {
                                model   = user;
                                message = "Login Success.";
                            }
                            else
                            {
                                message = "Login fail.";
                            }
                        }
                    }
                }
            }

            return(new Tuple <User, string>(model, message));
        }
Example #3
0
        public static IEnumerable <AlertMsg> GetAlertMsg(string hn, CacheConnection con)
        {
            List <AlertMsg> alertMsgs = new List <AlertMsg>();

            var query = QueryString.GetAlertMsg(hn);

            try
            {
                using (var cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (KeyValuePair <string, string> pair in query.Item2)
                    {
                        cmd.AddInputParameters(new { key = pair.Value });
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            AlertMsg result = new AlertMsg()
                            {
                                ALERTCAT_Code = reader["ALERTCAT_Code"].ToString(),
                                ALERTCAT_Desc = reader["ALERTCAT_Desc"].ToString(),
                                ALM_Message   = reader["ALM_Message"].ToString(),
                                ALM_Status    = reader["ALM_Status"].ToString()
                            };
                            alertMsgs.Add(result);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(alertMsgs);
        }
Example #4
0
        public static PatientCategory GetPatientCategory(string hn, CacheConnection con)
        {
            var result = new PatientCategory();

            var query = QueryString.GetPatientCategory(hn);

            try
            {
                using (var cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (var pair in query.Item2)
                    {
                        cmd.AddInputParameters(new { key = pair.Value });
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            result = new PatientCategory()
                            {
                                PCAT_CODE = reader["PCAT_CODE"].ToString(),
                                PCAT_Desc = reader["PCAT_Desc"].ToString()
                            };

                            return(result);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// Execute command string
        /// Close database connection
        /// </summary>
        /// <param name="cmdString"></param>
        /// <param name="conString"></param>
        /// <param name="hn"></param>
        /// <returns>Datatable</returns>
        public static DataTable DtBindDataCommandWithValuesMultiple(string cmdString, CacheConnection con, string hn)
        {
            var dt = new DataTable();

            try
            {
                using (var cmd = new CacheCommand(cmdString, con))
                {
                    cmd.AddInputParameters(new { PAPMI_No = hn, PAPMI_No1 = hn });
                    using (var reader = cmd.ExecuteReader())
                    {
                        dt.Load(reader);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(dt);
        }
Example #6
0
        /// <summary>
        /// Execute command string
        /// Close database connection
        /// </summary>
        /// <param name="cmdString"></param>
        /// <param name="conString"></param>
        /// <param name="dics"></param>
        /// <returns>DataTable</returns>
        public static DataTable DtBindDataCommandWihDictionary(string cmdString, string conString, Dictionary <string, string> dics)
        {
            var dt = new DataTable();

            using (var con = ConnectCache.DBUtils.GetDBConnection())
            {
                try
                {
                    con.Open();
                    using (var cmd = new CacheCommand(cmdString, con))
                    {
                        foreach (KeyValuePair <string, string> pair in dics)
                        {
                            var key = pair.Key;
                            cmd.AddInputParameters(new { key = pair.Value });
                        }
                        using (var reader = cmd.ExecuteReader())
                        {
                            dt.Load(reader);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                finally
                {
                    con.Close();
                    con.Dispose();
                }
            }

            return(dt);
        }
Example #7
0
        public static PatientRegisLoc GetRegisConsultLocation(string hn)
        {
            var regisLocList = GetPatientRegisLoc(hn).Item2;

            var loclist = new List <string>();
            var locs    = "";

            if (!hn.Contains("-"))
            {
                hn = Regex.Replace(hn, @"^(.{2})(.{2})(.{6})$", "$1-$2-$3");
            }

            var query = QueryString.GetRegisConsultLocation(hn);

            var con = ConnectCache.DBUtils.GetDBConnection();

            try
            {
                con.Open();
                using (var cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (var pair in query.Item2)
                    {
                        cmd.AddInputParameters(new { key = pair.Value });
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var loc = string.Equals(reader["LocRegis"].ToString(), reader["LocConsult"].ToString(), StringComparison.CurrentCultureIgnoreCase)
                                ? new Tuple <bool, string, string>(true, reader["LocRegis"].ToString(), "")
                                : new Tuple <bool, string, string>(false, reader["LocRegis"].ToString(), reader["LocConsult"].ToString());
                            if (loc.Item1)
                            {
                                loclist.Add(loc.Item2);
                            }
                            else
                            {
                                loclist.Add(loc.Item2);
                                loclist.Add(loc.Item3);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            foreach (var regisLoc in regisLocList)
            {
                loclist.Add(regisLoc.CTLOC_Code);
            }

            loclist = loclist.Distinct().ToList();

            locs = string.Join(",", loclist);

            var locRegisConsult = new PatientRegisLoc()
            {
                Papmi_No = hn,
                RegisLoc = locs
            };

            return(locRegisConsult);
        }
Example #8
0
        public static Tuple <PatientRegisLoc, List <LocRegis> > GetPatientRegisLoc(string hn, string loc = "")
        {
            var lstLocRegis = new List <LocRegis>();
            var locs        = Empty;

            if (!hn.Contains("-"))
            {
                hn = Regex.Replace(hn, @"^(.{2})(.{2})(.{6})$", "$1-$2-$3");
            }

            var query = QueryString.GetPatientRegisLoc(hn);

            var con = ConnectCache.DBUtils.GetDBConnection();

            try
            {
                con.Open();
                using (var cmd = new CacheCommand(query.Item1, con))
                {
                    foreach (var pair in query.Item2)
                    {
                        cmd.AddInputParameters(new { key = pair.Value });
                    }
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var newRegis = string.Equals(reader["CTLOC_Code"].ToString(), loc,
                                                         StringComparison.CurrentCultureIgnoreCase);
                            locs += IsNullOrEmpty(locs)
                                ? reader["CTLOC_Code"].ToString()
                                : $"|{reader["CTLOC_Code"].ToString()}";
                            var locRegis = new LocRegis()
                            {
                                CTLOC_Code = reader["CTLOC_Code"].ToString(),
                                NewRegis   = newRegis
                            };
                            lstLocRegis.Add(locRegis);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }


            var patientRegisLoc = new PatientRegisLoc()
            {
                Papmi_No = hn,
                RegisLoc = locs
            };

            return(new Tuple <PatientRegisLoc, List <LocRegis> >(patientRegisLoc, lstLocRegis));
        }