public void LoadData() { try { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { if (mrm_code == "RG") { DateTime dateNow = Program.GetServerDateTime(); List <sp_get_waiting_room_hdrResult> result = cdc.tmp_getptarriveds .Where(x => (x.flag_success == null || x.flag_success == 'N') && x.ctloc_code == mhs_code && x.paadm_admdate.Value.Date == dateNow.Date) .OrderBy(x => x.appt_arrivaltime) .Select(x => new sp_get_waiting_room_hdrResult { tpt_hn_no = x.papmi_no, tpt_othername = x.ttl_desc + x.papmi_name + " " + x.papmi_name2 }).ToList(); int inx = 1; result.ForEach(x => x.priority = inx++); DGV_Waiting.Columns["colBtnCancelQueue"].Visible = false; DGV_Waiting.Columns["colSendToCheckB"].Visible = false; DGV_Waiting.DataSource = result; } else { mst_room_hdr room_hdr = cdc.mst_room_hdrs .Where(x => x.mhs_id == mhs_id && x.mrm_code == mrm_code) .FirstOrDefault(); if (room_hdr != null) { List <sp_get_waiting_room_hdrResult> result = cdc.sp_get_waiting_room_hdr(room_hdr.mrm_id).ToList(); if (result.Count() == 0) { DGV_Waiting.DataSource = new List <sp_get_waiting_room_hdrResult>(); } else { if (mrm_code == "BM" || mrm_code == "SC" || mrm_code == "PH") { DGV_Waiting.Columns["colBtnCancelQueue"].Visible = false; DGV_Waiting.Columns["colSendToCheckB"].Visible = false; DGV_Waiting.DataSource = result; } else if (mrm_code == "EM") { int?eye_nurse_mvt_id = cdc.mst_events.Where(x => x.mvt_code == "EN").Select(x => x.mvt_id).FirstOrDefault(); result = result.OrderBy(x => eye_nurse_mvt_id == x.mvt_id ? 0 : 1) .Select((x, inx) => new sp_get_waiting_room_hdrResult { priority = inx + 1, tpr_id = x.tpr_id, tps_id = x.tps_id, mvt_id = x.mvt_id, tpr_queue_no = x.tpr_queue_no, tpt_hn_no = x.tpt_hn_no, tpt_othername = x.tpt_othername, holded = x.holded, reserved = x.reserved }).ToList(); DGV_Waiting.DataSource = result; } else { DGV_Waiting.DataSource = result; } } lbtitle1.Text = string.Format(room_hdr.mrm_ename + "(Total {0})", DGV_Waiting.Rows.Count.ToString()); } else { lbtitle1.Text = ""; } } } } catch (Exception ex) { Program.MessageError(this.Name, "LoadData", ex, false); DGV_Waiting.DataSource = new List <sp_get_waiting_room_hdrResult>(); } }
public void ShowWaiting(int no, string txtSearch, int mhs_id, string roomCode) { using (InhCheckupDataContext cdc = new InhCheckupDataContext()) { Class.FunctionDataCls func = new Class.FunctionDataCls(); string mhs_code = cdc.mst_hpc_sites.Where(x => x.mhs_id == mhs_id).Select(x => x.mhs_code).FirstOrDefault(); DateTime dateNow = Program.GetServerDateTime(); DateTime ResetDate = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 0, 0, 0); TimeSpan timenow = dateNow.TimeOfDay; if (roomCode == "RG") { List <gridProp> result = cdc.vw_tmp_arrives.Where(x => (x.flag_success == null || x.flag_success == 'N') && x.ctloc_code == Program.CurrentSite.mhs_code && x.paadm_admdate.Value.Date == dateNow.Date) .OrderBy(x => x.appt_arrivaltime) .Select(x => new gridProp { hn_no = x.papmi_no, patient_name = x.ttl_desc + x.papmi_name + " " + x.papmi_name2 }).ToList(); int number = 1; result.ForEach(x => x.no = number++); gridBS.DataSource = result; } else { using (InhCheckupDataContext contxt = new InhCheckupDataContext()) { mst_room_hdr mstRoom = contxt.mst_room_hdrs .Where(x => x.mhs_id == mhs_id && x.mrm_status == 'A' && x.mrm_code == roomCode) .FirstOrDefault(); if (mstRoom != null) { List <sp_get_waiting_room_hdrResult> result = contxt.sp_get_waiting_room_hdr(mstRoom.mrm_id).ToList(); List <gridProp> data = result.Where(x => (txtSearch == null || txtSearch == string.Empty ? true : (x.tpt_hn_no.Contains(txtSearch) || (x.tpt_hn_no.Replace("-", "").Contains(txtSearch)) || (x.tpt_othername.ToUpper()).Contains(txtSearch.ToUpper())))) .OrderBy(x => x.priority) .Select((x, inx) => new gridProp { no = inx + 1, tpr_id = (int)x.tpr_id, tps_id = (int)x.tps_id, mhs_id = mhs_id, mvt_id = x.mvt_id, mrm_id = mstRoom.mrm_id, hn_no = x.tpt_hn_no, patient_name = x.tpt_othername, callstatus = x.holded == true ? "HD" : null }).ToList(); gridBS.DataSource = data; DGV_Waiting.AutoGenerateColumns = false; DGV_Waiting.DataSource = gridBS; lbtitle1.Text = string.Format(no.ToString() + ".Waiting " + mstRoom.mrm_ename + "(Total {0})", gridBS.Count.ToString()); if (roomCode == "RG" || roomCode == "BM" || roomCode == "SC" || roomCode == "PH") { DGV_Waiting.Columns["colBtnCancelQueue"].Visible = false; DGV_Waiting.Columns["colSendToCheckB"].Visible = false; } else if (roomCode == "DC") { foreach (DataGridViewRow row in DGV_Waiting.Rows) { gridProp gp = (gridProp)gridBS[row.Index]; bool checkDoctorResult = (cdc.mst_events.Where(x => x.mvt_id == gp.mvt_id).Select(x => x.mvt_code).FirstOrDefault() == "DC"); if (!func.checkPassedCheckPointB(gp.tpr_id) || checkDoctorResult) { row.Cells["colBtnCancelQueue"] = new DataGridViewTextBoxCell(); row.Cells["colSendToCheckB"] = new DataGridViewTextBoxCell(); } } } } } // List<gridProp> result = cdc.trn_patient_queues.Where(x => x.tps_status == "NS" && // (mhs_id == 0 // ? true // : x.mst_room_hdr.mhs_id == mhs_id) && // x.mst_room_hdr.mrm_code == roomCode && // x.tps_create_date.Value.Date == dateNow.Date && // (txtSearch == null || txtSearch == string.Empty // ? true // : (x.trn_patient_regi.trn_patient.tpt_hn_no.Contains(txtSearch) || // (x.trn_patient_regi.trn_patient.tpt_hn_no.Replace("-", "").Contains(txtSearch)) || // (x.trn_patient_regi.trn_patient.tpt_othername.ToUpper()).Contains(txtSearch.ToUpper())))) // .GroupBy(x => x.tpr_id) // .Select(x => x.OrderByDescending(y => y.tps_update_date).FirstOrDefault()) // .Select(x => new gridProp // { // tpr_id = x.tpr_id, // tps_id = x.tps_id, // mhs_id = x.mst_room_hdr.mhs_id, // mvt_id = x.mvt_id, // mrm_id = x.mrm_id, // hn_no = x.trn_patient_regi.trn_patient.tpt_hn_no, // patient_name = x.trn_patient_regi.trn_patient.tpt_othername, // callstatus = x.tps_call_status == "HD" ? "HD" : null, // // Add Data for Order BY // vip_hpc = (x.trn_patient_regi.trn_patient.tpt_vip_hpc == true) ? "Y" : "N", // hold_flag = (x.tps_call_status == "HD" && (timenow.Subtract(x.tps_hold_date.Value.TimeOfDay)).TotalMinutes >= 0) ? "Y" : "N", // bmSeq = Convert.ToInt32((x.tps_bm_seq != null) ? x.tps_bm_seq : 99), // ordDate = Convert.ToDateTime((x.tps_call_status == "HD") ? x.tps_hold_date : x.tps_create_date), // RTN_Nurse = x.trn_patient_regi.tpr_return_screening, // type_EyeNurse = ((from t in cdc.mst_events where t.mvt_id == x.mvt_id select t.mvt_code).FirstOrDefault() == "EN") ? "Y" : "N", // type_Lower = x.trn_patient_regi.tpr_miss_lower // }).ToList(); // // Add Order each Station // if (mhs_code == "01HPC2" || mhs_code == "01HPC3") // { // if (roomCode == "SC") // { // result = result.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.RTN_Nurse).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // else if (roomCode == "EM") // { // result = result.OrderByDescending(x => x.type_EyeNurse).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // else if (roomCode == "US") // { // result = result.OrderByDescending(x => x.type_Lower).ThenByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // else // { // result = result.OrderByDescending(x => x.vip_hpc).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // } // else // { // if (roomCode == "EM") // { // result = result.OrderByDescending(x => x.type_EyeNurse).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // else if (roomCode == "US") // { // result = result.OrderByDescending(x => x.type_Lower).ThenByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // else // { // result = result.OrderByDescending(x => x.hold_flag).ThenBy(x => x.bmSeq).ThenBy(x => x.ordDate).ToList(); // } // } // int number = 1; // result.ForEach(x => x.no = number++); // gridBS.DataSource = result; //} //DGV_Waiting.AutoGenerateColumns = false; //DGV_Waiting.DataSource = gridBS; //mst_room_hdr mrm = cdc.mst_room_hdrs.Where(x => x.mrm_code == roomCode && x.mhs_id == mhs_id).FirstOrDefault(); //if (mrm != null) //{ // lbtitle1.Text = string.Format(no.ToString() + ".Waiting " + mrm.mrm_ename + "(Total {0})", gridBS.Count.ToString()); // if (roomCode == "RG" || roomCode == "BM" || roomCode == "SC" || roomCode == "PH") // { // DGV_Waiting.Columns["colBtnCancelQueue"].Visible = false; // DGV_Waiting.Columns["colSendToCheckB"].Visible = false; // } // else if (roomCode == "DC") // { // foreach (DataGridViewRow row in DGV_Waiting.Rows) // { // gridProp gp = (gridProp)gridBS[row.Index]; // bool checkDoctorResult = (cdc.mst_events.Where(x => x.mvt_id == gp.mvt_id).Select(x => x.mvt_code).FirstOrDefault() == "DC"); // if (!func.checkPassedCheckPointB(gp.tpr_id) || checkDoctorResult) // { // row.Cells["colBtnCancelQueue"] = new DataGridViewTextBoxCell(); // row.Cells["colSendToCheckB"] = new DataGridViewTextBoxCell(); // } // } // } //} //else //{ // lbtitle1.Text = string.Empty; //} } } }