//藥物劑量:接SearchPatient選擇的PatientID public List <Dictionary <string, object> > GetMedDose(PresentViewModel vm) { List <Dictionary <string, object> > mRet = new List <Dictionary <string, object> >(); string PatientIDstr = "PID = '" + vm.P_ID_Value + "'"; string SQL = " select MedPRS, doseUnit, RealDose, Time13, PID, 學名 from [CYCH].[dbo].[MedPRS_Name] where " + PatientIDstr + " order by MedPRS, Time13 asc "; using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); } if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Dictionary <string, object> aSeries = new Dictionary <string, object>(); aSeries["MedPRS"] = dr["MedPRS"]; aSeries["Time13"] = dr["Time13"]; aSeries["Dose"] = dr["RealDose"]; aSeries["DoseUnit"] = dr["doseUnit"]; aSeries["MedPRS_Name"] = dr["學名"]; mRet.Add(aSeries); } } } return(mRet); }
//抓取病患對照名字&其藥物名單(目前沒用到0702) public IEnumerable <PresentViewModel> GetPatientName(PresentViewModel vm) { IEnumerable <PresentViewModel> mRet = Enumerable.Empty <PresentViewModel>(); string PatientIDstr = ""; PatientIDstr = "PatientID = '" + vm.P_ID_Value + "'"; string SQL = "select distinct * from [masterFakeData].[dbo].[藥物劑量0409] where " + PatientIDstr; using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); } if (dt.Rows.Count > 0) { var query = from r in dt.AsEnumerable() select new PresentViewModel { Name = r.Field <string>("Name") ?? "", Gender = r.Field <string>("Gender") ?? "", Age = r.Field <string>("Age") ?? "", //Birth = r.Field<string>("Birth") ?? "" }; mRet = query; } } return(mRet); }
//查詢選擇的值:病患的基本數值 public IEnumerable <PresentViewModel> GetP_ID_Value(PresentViewModel vm) { IEnumerable <PresentViewModel> mRet = Enumerable.Empty <PresentViewModel>(); string PatientIDstr; PatientIDstr = "PID = '" + vm.P_ID_Value + "'"; string SQL = "select Time13, BT, HR, SBP, DBP, RR from [CYCH].[dbo].[allPatientData] where " + PatientIDstr; using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); } if (dt.Rows.Count > 0) { var query = from r in dt.AsEnumerable() select new PresentViewModel { SBP = r.Field <string>("SBP") ?? "null", DBP = r.Field <string>("DBP") ?? "null", BT = r.Field <string>("BT") ?? "null", HR = r.Field <string>("HR") ?? "null", RR = r.Field <string>("RR") ?? "null", Time13 = r.Field <string>("Time13") ?? "" }; mRet = query; } } return(mRet); }
//下拉式選單 public PresentViewModel GetDropList() { PresentViewModel vm = new PresentViewModel(); string SQL = " select distinct PID from [CYCH].[dbo].[allPatientData] order by PID asc"; using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); } if (dt.Rows.Count > 0) { IEnumerable <SelectListItem> query = from r in dt.AsEnumerable() select new SelectListItem { Value = r.Field <string>("PID") ?? "", Text = r.Field <string>("PID") ?? "", }; vm.P_ID = query; } } return(vm); }
//病歷時間點 public List <string> GetMedTime(PresentViewModel vm) { List <string> mRet = new List <string>(); string PatientIDstr = ""; PatientIDstr = "PID ='" + vm.P_ID_Value + "'"; string SQL = "SELECT distinct [DateTime] FROM [CYCH].[dbo].[t20190221_tokensentance] where " + PatientIDstr; using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); } if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { foreach (DataColumn column in dt.Columns) { mRet.Add(row[column].ToString()); } } } } return(mRet); }
//搜尋病患頁面 public ActionResult SearchPatient() { PresentViewModel vm = new PresentViewModel(); PresentModel p = new PresentModel(); vm = p.GetDropList(); return(View(vm)); }
//public ActionResult Test() //{ // PresentModel p = new PresentModel(); // IEnumerable<PresentViewModel> vm_med = p.GetMed(); // return View(vm_med); //} // public ActionResult SearchByMed(string med) //{ // string searchMed = null; // if (!String.IsNullOrEmpty(searchMed)) // { // using(Models.PresentModel p = new Models.PresentModel()) // { // var result = (from s in p.GetMed() // where s.Med_Code == searchMed // select s).ToList(); // return View("Test", result); // } // } // else // { // return View("Test", new List<Models.PresentModel>()); // } //} public ActionResult Test(string id) { PresentModel p = new PresentModel(); PresentViewModel vm = new PresentViewModel(); vm = p.GetPatientID(); IEnumerable <PresentViewModel> vm_EHRContent = p.GetEHRContent(); string jsonSeries = JsonConvert.SerializeObject(vm_EHRContent); ViewBag.item = jsonSeries; IEnumerable <PresentViewModel> vm3 = p.GetMed_TARGO(); string jsonSeries3 = JsonConvert.SerializeObject(vm3); ViewBag.item3 = jsonSeries3; return(View(vm)); }
//catch patient ID public PresentViewModel GetPatientID() { // IEnumerable<PresentViewModel> mRet = Enumerable.Empty<PresentViewModel>(); string SQL = "select distinct RegisterID FROM [dbo].[t20190221_splitprocessing]"; PresentViewModel vm = new PresentViewModel(); using (DataTable dt = new DataTable()) { using (SqlConnection conn = new SqlConnection(connstr)) using (SqlCommand cmd = new SqlCommand(SQL, conn)) using (SqlDataAdapter adt = new SqlDataAdapter(cmd)) { conn.Open(); adt.Fill(dt); if (dt.Rows.Count > 0) { IEnumerable <SelectListItem> query = from r in dt.AsEnumerable() select new SelectListItem { Value = r.Field <string>("RegisterID") ?? "", Text = r.Field <string>("RegisterID") ?? "" }; vm.RegisterID = query; //var query = from r in dt.AsEnumerable() // select new PresentViewModel // { // RegisterID = r.Field<string>("RegisterID") ?? "" // }; //mRet = query; } } } return(vm); }
public IHttpActionResult PresentView() { try { int ff; if (User != null && int.TryParse(User.Identity.GetUserId(), out ff)) { PresentViewModel v = new PresentViewModel(); var ui = _userManager.GetUser(ff); /*v.PresentUrl = "http://mibarim.ir/Driver/DriverRate?useruid="+ui.UserUId; * v.WebViewPageUrl = "http://mibarim.ir/Driver/DriverRatePage?useruid=" + ui.UserUId;*/ v.PresentUrl = null; v.WebViewPageUrl = null; return(Json(_responseProvider.GenerateResponse(v, "PresentView"))); } else { return (ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "You are unauthorized to see Info!"))); } } catch (Exception e) { if (e.InnerException != null) { _logmanager.Log(Tag, "PresentView", e.Message + "-" + e.InnerException.Message); } else { _logmanager.Log(Tag, "PresentView", e.Message); } } return(Json(_responseProvider.GenerateUnknownErrorResponse())); }
public ActionResult SearchPatient(PresentViewModel vm) { Session["PatientID"] = vm.P_ID_Value; //紀錄patientID PresentModel p = new PresentModel(); //病患資料 IEnumerable <PresentViewModel> getPatientData = p.GetP_ID_Value(vm); string jsonSeries = JsonConvert.SerializeObject(getPatientData); TempData["item"] = jsonSeries; //要跨Action要使用TempData才能記住資料 //病患藥物劑量 List <Dictionary <string, object> > mRet_Dose = new List <Dictionary <string, object> >(); mRet_Dose = p.GetMedDose(vm); List <Dictionary <string, object> > samedateDose = new List <Dictionary <string, object> >(); for (int i = 0; i < mRet_Dose.Count; i++) { if (samedateDose.Count == 0) { Dictionary <string, object> dict = new Dictionary <string, object>(); //拿MedPRS的時間 dict.Add("MedPRS", mRet_Dose[i]["MedPRS"]); dict.Add("Time13", mRet_Dose[i]["Time13"]); dict.Add("Dose", mRet_Dose[i]["Dose"]); dict.Add("DoseUnit", mRet_Dose[i]["DoseUnit"]); dict.Add("MedPRS_Name", mRet_Dose[i]["MedPRS_Name"]); samedateDose.Add(dict); } else { var mRet_DoseCount = samedateDose.Count; bool IsExist = false; for (int n = 0; n < mRet_DoseCount; n++) { if (samedateDose[n].ContainsValue(mRet_Dose[i]["MedPRS"]) && samedateDose[n].ContainsValue(mRet_Dose[i]["Time13"])) { IsExist = true; samedateDose[n]["Dose"] = float.Parse(samedateDose[n]["Dose"].ToString()) + float.Parse(mRet_Dose[i]["Dose"].ToString()); break; } else { IsExist = false; } } if (IsExist == false) { Dictionary <string, object> dict = new Dictionary <string, object>(); //拿MedPRS的時間 dict.Add("MedPRS", mRet_Dose[i]["MedPRS"]); dict.Add("Time13", mRet_Dose[i]["Time13"]); dict.Add("Dose", mRet_Dose[i]["Dose"]); dict.Add("DoseUnit", mRet_Dose[i]["DoseUnit"]); dict.Add("MedPRS_Name", mRet_Dose[i]["MedPRS_Name"]); samedateDose.Add(dict); } } } string jsonSeries_mRet_Dose = JsonConvert.SerializeObject(samedateDose); TempData["item_MedDose"] = jsonSeries_mRet_Dose; //病歷時間 List <string> vm_medTime = p.GetMedTime(vm); string medTimeStr = ""; for (int i = 0; i < vm_medTime.Count; i++) { if (i == 0) { medTimeStr = "[ { x:" + vm_medTime[i] + ", title:'R' }"; } else if (i == (vm_medTime.Count - 1)) { medTimeStr = medTimeStr + ",{ x:" + vm_medTime[i] + ", title:'R' }]"; } else { medTimeStr = medTimeStr + ",{ x:" + vm_medTime[i] + ", title:'R'}"; } } TempData["item_medTime"] = medTimeStr; return(RedirectToAction("Index")); //將頁面導到 Index_0430TesT }