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);
        }