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); }
public static string GetLastEpisode(string hn) { var epiNo = InterSystemsDa.BindDataCommand(QueryString.GetLastEpisode(hn), Constants.Cache89); return(epiNo); }
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)); }
public static string GetHn(string epiNo) { var hn = InterSystemsDa.BindDataCommand(QueryString.GetPatientHn(epiNo), Constants.Cache89); return(hn); }