public List <trn_basic_measure_dtl> getVitalSign(string hn, string en) { using (Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls()) { var result = getVitalSignByHN(hn); if (result != null) { trn_basic_measure_dtl dtl = result.OrderByDescending(x => x.tbd_date).FirstOrDefault(); return(new List <trn_basic_measure_dtl> { dtl }); } return(new List <trn_basic_measure_dtl>()); } }
public void LoadData(int tpr_id) { try { if (tpr_id > 0) { using (InhCheckupDataContext dbc = new InhCheckupDataContext()) { trn_basic_measure_dtl objbmdtl = (from t1 in dbc.trn_basic_measure_dtls where t1.trn_basic_measure_hdr.tpr_id == tpr_id orderby t1.tbd_date descending select t1).FirstOrDefault(); if (objbmdtl != null) { lbdataBW.Text = objbmdtl.tbd_weight; lbdataBP.Text = objbmdtl.tbd_systolic + "/" + objbmdtl.tbd_diastolic; lbdataT.Text = objbmdtl.tbd_temp; lbdataHT.Text = objbmdtl.tbd_height; lbdataPR.Text = objbmdtl.tbd_pulse; lbdataRR.Text = objbmdtl.tbd_rr; } else { lbdataBW.Text = ""; lbdataBP.Text = ""; lbdataT.Text = ""; lbdataHT.Text = ""; lbdataPR.Text = ""; lbdataRR.Text = ""; } } } else { lbdataBW.Text = ""; lbdataBP.Text = ""; lbdataT.Text = ""; lbdataHT.Text = ""; lbdataPR.Text = ""; lbdataRR.Text = ""; } } catch (Exception) { } }
private void getVitalSign(int tpr_id) { try { using (InhCheckupDataContext dbc = new InhCheckupDataContext()) { trn_basic_measure_dtl basic = dbc.trn_basic_measure_dtls .Where(x => x.trn_basic_measure_hdr.tpr_id == tpr_id) .OrderByDescending(x => x.tbd_date) .FirstOrDefault(); txtHeight.Text = ConvertToInch(basic.tbd_height); txtWeight.Text = ConvertToPound(basic.tbd_weight); txtSystolic.Text = basic.tbd_systolic; txtDiastolic.Text = basic.tbd_diastolic; txtPulse.Text = basic.tbd_pulse; } } catch (Exception ex) { Program.MessageError(this.Name, "getVitalSign", ex, false); } }
public List <trn_basic_measure_dtl> getVitalSignByHN(string hn) { using (Service.WS_TrakcareCls ws = new Service.WS_TrakcareCls()) { DateTime dateNow = Program.GetServerDateTime(); DataTable dt = ws.GetVitalSignByHN(hn); if (dt != null) { if (dt.Rows.Count > 0) { List <trn_basic_measure_dtl> bmDtl = new List <trn_basic_measure_dtl>(); var result = dt.AsEnumerable() .GroupBy(x => x.Field <DateTime>("OBS_Date").Add(x.Field <TimeSpan>("OBS_Time"))) .OrderByDescending(x => x.Key) .Take(5); foreach (var re in result) { trn_basic_measure_dtl dtl = new trn_basic_measure_dtl(); foreach (var item in re) { int itemNo = item.Field <int>("OBS_Item_DR"); switch (itemNo) { case 230: dtl.tbd_weight = item.Field <string>("OBS_Value"); break; case 231: dtl.tbd_height = item.Field <string>("OBS_Value"); break; case 11: dtl.tbd_temp = item.Field <string>("OBS_Value"); break; case 129: dtl.tbd_systolic = item.Field <string>("OBS_Value"); break; case 128: dtl.tbd_diastolic = item.Field <string>("OBS_Value"); break; case 9: dtl.tbd_pulse = item.Field <string>("OBS_Value"); break; case 10: dtl.tbd_rr = item.Field <string>("OBS_Value"); break; case 134: dtl.tbd_bmi = item.Field <string>("OBS_Value"); break; case 176: dtl.tbd_waist = item.Field <string>("OBS_Value"); break; case 173: dtl.tbd_vision_lt = item.Field <string>("OBS_Value"); break; case 174: dtl.tbd_vision_rt = item.Field <string>("OBS_Value"); break; case 281: dtl.tbd_vision_with_lens = (item.Field <string>("OBS_Value") == "Y" || item.Field <string>("OBS_Value") == "y") ? true : false; break; } } dtl.tbd_date = re.Key; dtl.tbd_create_by = Program.CurrentUser.mut_username; dtl.tbd_create_date = dateNow; dtl.tbd_update_by = Program.CurrentUser.mut_username; dtl.tbd_update_date = dateNow; bmDtl.Add(dtl); } return(bmDtl); } } } return(null); }
public static void SaveBasicMeasurment(int tpr_id, bool _IsCallLab) { if (_IsCallLab == true) { using (InhCheckupDataContext dbc = new InhCheckupDataContext()) { trn_patient_regi tpr = dbc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault(); if (tpr != null) { trn_basic_measure_hdr hdr = tpr.trn_basic_measure_hdrs.FirstOrDefault(); if (hdr == null) { hdr = new trn_basic_measure_hdr(); tpr.trn_basic_measure_hdrs.Add(hdr); } List <trn_basic_measure_dtl> dtl = hdr.trn_basic_measure_dtls.ToList(); if (dtl.Count() > 0) { dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(dtl); } EmrClass.GetDataFromWSTrakCare tk = new EmrClass.GetDataFromWSTrakCare(); List <trn_basic_measure_dtl> newBmDtl = tk.getVitalSignByHN(tpr.trn_patient.tpt_hn_no); if (newBmDtl != null && newBmDtl.Count() > 0) { trn_basic_measure_dtl last_basic_dtl = newBmDtl.OrderByDescending(x => x.tbd_date).FirstOrDefault(); if (last_basic_dtl != null) { hdr.tbm_glass_or_contact = last_basic_dtl.tbd_vision_with_lens == true ? 'Y' : 'N'; } if (newBmDtl != null && newBmDtl.Count > 0) { hdr.trn_basic_measure_dtls.AddRange(newBmDtl); } } dbc.SubmitChanges(); } //if (Program.CurrentRegis != null) //{ //var objbmhdr = dbc.trn_basic_measure_hdrs.Where(c => c.tpr_id == tpr_id).ToList(); //dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(bmDtl); //if (objbmhdr.Count > 0) //{ //del data in trn_basic_measurement by tbm_id //var objdeldtl = dbc.trn_basic_measure_dtls.Where(c => c.tbm_id == objbmhdr[0].tbm_id); //dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(objdeldtl); //foreach (var data in objdeldtl) //{ // dbc.trn_basic_measure_dtls.DeleteOnSubmit(data); //} //dbc.SubmitChanges(); // Ws_GetDataByTrak.WS_GetDataBytrakSoapClient ws = new Ws_GetDataByTrak.WS_GetDataBytrakSoapClient(); // var hn = dbc.trn_patients.Where(c => c.tpt_id == Program.CurrentRegis.tpt_id).FirstOrDefault(); // //Search By HN // DataTable dt = ws.GetVitalSignByHN(hn.tpt_hn_no); // if (dt.Rows.Count != 0) // { // //ค้นหาวันที่ 5 วันล่าสุด จาก ws // var objseldatetop5 = (from myRow in dt.AsEnumerable() // select myRow).GroupBy(c => c.Field<DateTime>("OBS_Date")).Take(5).ToList(); // for (int i = 0; i < objseldatetop5.Count; i++) // { // //ค้นหาข้อมูลตามวันที่ // trn_basic_measure_dtl objnew = new trn_basic_measure_dtl(); // var objseldata = (from myRow in dt.AsEnumerable() // where myRow.Field<DateTime>("OBS_Date") == objseldatetop5[i].Key // select myRow).ToList(); // //save data to trn_basic_measurement_dlt // foreach (var data in objseldata) // { // switch ((int)data["OBS_Item_DR"]) // { // case 230: // objnew.tbd_weight = (string)data["OBS_Value"]; // break; // case 231: // objnew.tbd_height = (string)data["OBS_Value"]; // break; // case 11: // objnew.tbd_temp = (string)data["OBS_Value"]; // break; // case 129: // objnew.tbd_systolic = (string)data["OBS_Value"]; // break; // case 128: // objnew.tbd_diastolic = (string)data["OBS_Value"]; // break; // case 9: // objnew.tbd_pulse = (string)data["OBS_Value"]; // break; // case 10: // objnew.tbd_rr = (string)data["OBS_Value"]; // break; // case 134: // objnew.tbd_bmi = (string)data["OBS_Value"]; // break; // case 176: // objnew.tbd_waist = (string)data["OBS_Value"]; // break; // case 173: // objnew.tbd_vision_lt = (string)data["OBS_Value"]; // break; // case 174: // objnew.tbd_vision_rt = (string)data["OBS_Value"]; // break; // } // string _DateTime = String.Format("{0:yyyy/MM/dd}", data["OBS_Date"]); // objnew.tbd_date = Convert.ToDateTime(_DateTime + " " + data["OBS_Time"]); // objnew.tbm_id = objbmhdr[0].tbm_id; // objnew.tbd_create_by = Program.CurrentUser.mut_username; // objnew.tbd_create_date = Program.GetServerDateTime(); // objnew.tbd_update_by = Program.CurrentUser.mut_username; // objnew.tbd_update_date = Program.GetServerDateTime(); // } // dbc.trn_basic_measure_dtls.InsertOnSubmit(objnew); // } // } // dbc.SubmitChanges(); //} //} //if cur regis } //using } }
public void updateByVitalSignResult(ref trn_patient_regi pregis, List <APITrakcare.VitalSignResult> vsresult, DateTime dateNow, string user) { try { var hdr = pregis.trn_basic_measure_hdrs.FirstOrDefault(); if (hdr == null) { hdr = new trn_basic_measure_hdr(); hdr.tbm_create_by = user; hdr.tbm_create_date = dateNow; pregis.trn_basic_measure_hdrs.Add(hdr); } hdr.tbm_vision_left = null; hdr.tbm_vision_right = null; hdr.tbm_glass_or_contact = null; hdr.tbm_color_blind = null; hdr.tbm_vision_lvisual_with_lens = null; hdr.tbm_vision_rvisual_with_lens = null; hdr.tbm_vision_lvisual_out_lens = null; hdr.tbm_vision_rvisual_out_lens = null; hdr.tbm_update_by = user; hdr.tbm_update_date = dateNow; if (vsresult.Count > 0) { hdr.tbm_vision_left = convInt(vsresult[0].visionLeft); hdr.tbm_vision_right = convInt(vsresult[0].visionRight); hdr.tbm_glass_or_contact = vsresult[0].withlen ? 'Y' : 'N'; hdr.tbm_color_blind = vsresult[0].colorblind == null ? (char?)null : vsresult[0].colorblind.ToUpper() == "NA" ? 'X' : vsresult[0].colorblind.ToUpper() == "NO" ? 'N' : vsresult[0].colorblind.ToUpper() == "AB" ? 'A' : (char?)null; if (hdr.tbm_glass_or_contact == 'Y') { hdr.tbm_vision_lvisual_with_lens = vsresult[0].visionLeft; hdr.tbm_vision_rvisual_with_lens = vsresult[0].visionRight; } else { hdr.tbm_vision_lvisual_out_lens = vsresult[0].visionLeft; hdr.tbm_vision_rvisual_out_lens = vsresult[0].visionRight; } var dtls = hdr.trn_basic_measure_dtls.OrderBy(x => x.tbd_id).ToList(); int i; for (i = 0; i < vsresult.Count; i++) { trn_basic_measure_dtl dtl; if (i < dtls.Count) { dtl = dtls[i]; } else { dtl = new trn_basic_measure_dtl { tbd_create_by = user, tbd_create_date = dateNow }; hdr.trn_basic_measure_dtls.Add(dtl); } dtl.tbd_row_id = vsresult[i].rowid; dtl.tbd_en_no = vsresult[i].en; dtl.tbd_date = vsresult[i].vsDate; dtl.tbd_vision_lt = vsresult[i].visionLeft; dtl.tbd_vision_rt = vsresult[i].visionRight; dtl.tbd_bmi = vsresult[i].bmi; dtl.tbd_diastolic = vsresult[i].diastolic; dtl.tbd_height = vsresult[i].height; dtl.tbd_pulse = vsresult[i].pulse; dtl.tbd_rr = vsresult[i].respirationrate; dtl.tbd_systolic = vsresult[i].systolic; dtl.tbd_temp = vsresult[i].temperature; if (vsresult[i].withlen) { dtl.tbd_vision_lvisual_out_lens = null; dtl.tbd_vision_rvisual_out_lens = null; dtl.tbd_vision_lvisual_with_lens = vsresult[i].visionLeft; dtl.tbd_vision_rvisual_with_lens = vsresult[i].visionRight; } else { dtl.tbd_vision_lvisual_out_lens = vsresult[i].visionLeft; dtl.tbd_vision_rvisual_out_lens = vsresult[i].visionRight; dtl.tbd_vision_lvisual_with_lens = null; dtl.tbd_vision_rvisual_with_lens = null; } dtl.tbd_vision_with_lens = vsresult[i].withlen; dtl.tbd_waist = vsresult[i].Waist; dtl.tbd_weight = vsresult[i].weight; dtl.tbd_update_by = user; dtl.tbd_update_date = dateNow; } } } catch (Exception ex) { Class.globalCls.MessageError("VitalSignCls", "InsertByVitalSignResult", ex.Message); throw ex; } }
public void GetVistalSign(int tpr_id, string username) { using (InhCheckupDataContext dbc = new InhCheckupDataContext()) { DateTime dateNow = globalCls.GetServerDateTime(); trn_patient_regi tpr = dbc.trn_patient_regis.Where(x => x.tpr_id == tpr_id).FirstOrDefault(); if (tpr != null) { List <string> locCheckup = dbc.mst_hpc_sites.Where(x => x.mhs_status == 'A' && x.mhs_other_clinic == false).Select(x => x.mhs_code).ToList(); locCheckup.Add("01AMSCHK"); var res = GetVitalSign(tpr.trn_patient.tpt_hn_no);//.Where(x => locCheckup.Contains(x.Location)).OrderByDescending(x => x.VitalSignDate); trn_basic_measure_hdr hdr = tpr.trn_basic_measure_hdrs.FirstOrDefault(); if (hdr == null) { hdr = new trn_basic_measure_hdr(); hdr.tbm_create_by = username; hdr.tbm_create_date = dateNow; tpr.trn_basic_measure_hdrs.Add(hdr); } hdr.tbm_vision_left = null; hdr.tbm_vision_right = null; hdr.tbm_glass_or_contact = null; hdr.tbm_vision_lvisual_with_lens = null; hdr.tbm_vision_rvisual_with_lens = null; hdr.tbm_vision_lvisual_out_lens = null; hdr.tbm_vision_rvisual_out_lens = null; hdr.tbm_update_by = username; hdr.tbm_update_date = dateNow; var cur = res.Where(x => x.en == tpr.tpr_en_no).OrderByDescending(x => x.VitalSignDate).FirstOrDefault(); if (cur != null) { hdr.tbm_vision_left = ConvertToInt(cur.VisionLeft); hdr.tbm_vision_right = ConvertToInt(cur.VisionRight); hdr.tbm_glass_or_contact = cur.WithLen ? 'Y' : 'N'; hdr.tbm_color_blind = cur.ColorBlind == null ? (char?)null : cur.ColorBlind.ToUpper() == "NA" ? 'X' : cur.ColorBlind.ToUpper() == "NO" ? 'N' : cur.ColorBlind.ToUpper() == "AB" ? 'A' : (char?)null; if (hdr.tbm_glass_or_contact == 'Y') { hdr.tbm_vision_lvisual_with_lens = cur.VisionLeft; hdr.tbm_vision_rvisual_with_lens = cur.VisionRight; } else { hdr.tbm_vision_lvisual_out_lens = cur.VisionLeft; hdr.tbm_vision_rvisual_out_lens = cur.VisionRight; } } bool start = false; int count = 0; List <int> list_tbd_id = hdr.trn_basic_measure_dtls.Select(x => x.tbd_id).ToList(); foreach (var rs in res) { if (rs.Equals(cur)) { start = true; } if (start) { trn_basic_measure_dtl dtl = hdr.trn_basic_measure_dtls .Where(x => x.tbd_row_id == rs.rowid && x.tbd_en_no == rs.en && x.tbd_date == rs.VitalSignDate) .FirstOrDefault(); if (dtl == null) { dtl = new trn_basic_measure_dtl(); dtl.tbd_row_id = rs.rowid; dtl.tbd_create_by = username; dtl.tbd_create_date = dateNow; hdr.trn_basic_measure_dtls.Add(dtl); } else { list_tbd_id.Remove(dtl.tbd_id); } dtl.tbd_en_no = rs.en; dtl.tbd_date = rs.VitalSignDate; dtl.tbd_vision_lt = rs.VisionLeft; dtl.tbd_vision_rt = rs.VisionRight; dtl.tbd_bmi = rs.BMI; dtl.tbd_diastolic = rs.Diastolic; dtl.tbd_height = rs.Height; dtl.tbd_pulse = rs.Pulse; dtl.tbd_rr = rs.RespirationRate; dtl.tbd_systolic = rs.Systolic; dtl.tbd_temp = rs.Temperature; if (rs.WithLen) { dtl.tbd_vision_lvisual_out_lens = null; dtl.tbd_vision_rvisual_out_lens = null; dtl.tbd_vision_lvisual_with_lens = rs.VisionLeft; dtl.tbd_vision_rvisual_with_lens = rs.VisionRight; } else { dtl.tbd_vision_lvisual_out_lens = rs.VisionLeft; dtl.tbd_vision_rvisual_out_lens = rs.VisionRight; dtl.tbd_vision_lvisual_with_lens = null; dtl.tbd_vision_rvisual_with_lens = null; } dtl.tbd_vision_with_lens = rs.WithLen; dtl.tbd_waist = rs.Waist; dtl.tbd_weight = rs.Weight; dtl.tbd_update_by = username; dtl.tbd_update_date = dateNow; count++; } if (count == 3) { break; } } List <trn_basic_measure_dtl> listDeleteDtl = hdr.trn_basic_measure_dtls.Where(x => list_tbd_id.Contains(x.tbd_id)).ToList(); if (listDeleteDtl.Count > 0) { dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(listDeleteDtl); } try { dbc.SubmitChanges(); } catch (System.Data.Linq.ChangeConflictException) { foreach (System.Data.Linq.ObjectChangeConflict occ in dbc.ChangeConflicts) { dbc.Refresh(System.Data.Linq.RefreshMode.KeepChanges, occ.Object); } dbc.SubmitChanges(); } //trn_basic_measure_hdr hdr = tpr.trn_basic_measure_hdrs.FirstOrDefault(); //if (hdr == null) //{ // hdr = new trn_basic_measure_hdr(); // tpr.trn_basic_measure_hdrs.Add(hdr); //} //EnumerableRowCollection<DataRow> result = retrieveVitalSign(tpr.trn_patient.tpt_hn_no); //List<int> ListOBS_Item_DR = new List<int> //{ // 230, 231, 11, 129, 128, 9, 10, 134, 176, 173, 174, 281 //}; //if (result != null) //{ // if (result.Count() > 0) // { // var grpResultByID = result.Where(x => ListOBS_Item_DR.Contains(x.Field<int>("OBS_Item_DR"))) // .GroupBy(x => x.Field<int>("OBS_ParRef")) // .Select(x => new VitalSign // { // OBS_ParRef = x.Key, // OBS_DateTime = x.Select(y => y.Field<DateTime>("OBS_Date").Add(y.Field<TimeSpan>("OBS_Time"))).OrderByDescending(y => y).FirstOrDefault(), // PAADM_ADMNo = x.Select(y => y.Field<string>("PAADM_ADMNo")).FirstOrDefault(), // VitalSign_Dtl = x.GroupBy(y => y.Field<DateTime>("OBS_Date").Add(y.Field<TimeSpan>("OBS_Time"))) // .OrderByDescending(y => y.Key).FirstOrDefault() // .Select(y => new VitalSign.VitalSignDtl // { // OBS_Item_DR = y.Field<int>("OBS_Item_DR"), // OBS_Value = y.Field<string>("OBS_Value") // }).ToList() // }).ToList() // .OrderByDescending(x => x.OBS_DateTime); // bool start = false; // int countRec = 0; // List<int?> listNewRowID = new List<int?>(); // foreach (var rowID in grpResultByID) // { // if (rowID.PAADM_ADMNo == tpr.tpr_en_no) // { // start = true; // } // if (start) // { // countRec = countRec + 1; // listNewRowID.Add(rowID.OBS_ParRef); // trn_basic_measure_dtl dtl = hdr.trn_basic_measure_dtls.Where(x => x.tbd_row_id == rowID.OBS_ParRef).FirstOrDefault(); // if (dtl == null) // { // dtl = new trn_basic_measure_dtl(); // dtl.tbd_en_no = rowID.PAADM_ADMNo; // dtl.tbd_row_id = rowID.OBS_ParRef; // dtl.tbd_date = rowID.OBS_DateTime; // dtl.tbd_create_by = username; // dtl.tbd_create_date = dateNow; // hdr.trn_basic_measure_dtls.Add(dtl); // } // dtl.tbd_weight = null; // dtl.tbd_height = null; // dtl.tbd_temp = null; // dtl.tbd_systolic = null; // dtl.tbd_diastolic = null; // dtl.tbd_pulse = null; // dtl.tbd_rr = null; // dtl.tbd_bmi = null; // dtl.tbd_waist = null; // dtl.tbd_vision_lt = null; // dtl.tbd_vision_rt = null; // foreach (var item in rowID.VitalSign_Dtl) // { // switch (item.OBS_Item_DR) // { // case 230: // dtl.tbd_weight = item.OBS_Value; // break; // case 231: // dtl.tbd_height = item.OBS_Value; // break; // case 11: // dtl.tbd_temp = item.OBS_Value; // break; // case 129: // dtl.tbd_systolic = item.OBS_Value; // break; // case 128: // dtl.tbd_diastolic = item.OBS_Value; // break; // case 9: // dtl.tbd_pulse = item.OBS_Value; // break; // case 10: // dtl.tbd_rr = item.OBS_Value; // break; // case 134: // dtl.tbd_bmi = item.OBS_Value; // break; // case 176: // dtl.tbd_waist = item.OBS_Value; // break; // case 173: // dtl.tbd_vision_lt = item.OBS_Value; // break; // case 174: // dtl.tbd_vision_rt = item.OBS_Value; // break; // // Sumit Edit 23/12/2014 // case 281: // dtl.tbd_vision_with_lens = (item.OBS_Value == "Y" || item.OBS_Value == "y") ? true : false; // break; // } // } // dtl.tbd_update_by = username; // dtl.tbd_update_date = dateNow; // } // if (countRec == 5) break; // } // try // { // var eyesVS = hdr.trn_basic_measure_dtls // .OrderByDescending(x => x.tbd_date) // .Select(x => new // { // x.tbd_vision_rt, // x.tbd_vision_lt // }).FirstOrDefault(); // hdr.tbm_vision_right = Convert.ToInt32(eyesVS.tbd_vision_rt); // hdr.tbm_vision_left = Convert.ToInt32(eyesVS.tbd_vision_lt); // } // catch // { // } // List<trn_basic_measure_dtl> listDeleteDtl = hdr.trn_basic_measure_dtls.Where(x => !listNewRowID.Contains(x.tbd_row_id)).ToList(); // dbc.trn_basic_measure_dtls.DeleteAllOnSubmit(listDeleteDtl); // dbc.SubmitChanges(); // } //} } } }