protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "rtickets" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); } // cheks if is call from another form if (Request.QueryString["Report"] != null) report = Request.QueryString["Report"]; if (Request.QueryString["FDate"] != null) fDate = CntWeb.ParseUrlDate(Request.QueryString["FDate"]); if (Request.QueryString["TDate"] != null) tDate = CntWeb.ParseUrlDate(Request.QueryString["TDate"]); if (Request.QueryString["Diary"] != null) diary = CntAriCli.GetDiary(int.Parse(Request.QueryString["Diary"]),ctx); if (Request.QueryString["Visit"] != null) visit = CntAriCli.GetVisit(int.Parse(Request.QueryString["Visit"]), ctx); if (Request.QueryString["Treatment"] != null) treatment = CntAriCli.GetTreatment(int.Parse(Request.QueryString["Treatment"]), ctx); if (Request.QueryString["Invoice"] != null) invoice = CntAriCli.GetInvoice(int.Parse(Request.QueryString["Invoice"]), ctx); if (Request.QueryString["PrescriptionGlasses"] != null) prescriptionGlasses = CntAriCli.GetPrescriptionGlasses(int.Parse(Request.QueryString["PrescriptionGlasses"]), ctx); }
public static void ImportTreatment(OleDbConnection con, AriClinicContext ctx) { // (0) Borra tipos previos ctx.Delete(ctx.Treatments); ctx.SaveChanges(); // (1) Dar de alta los diferentes diagnósticos string sql = "SELECT * FROM HistFarm"; cmd = new OleDbCommand(sql, con); da = new OleDbDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "ConFarmacos"); int nreg = ds.Tables["ConFarmacos"].Rows.Count; int reg = 0; foreach (DataRow dr in ds.Tables["ConFarmacos"].Rows) { reg++; Console.WriteLine("Tratamientos {0:#####0} de {1:#####0} {2}", reg, nreg, "TREATMENT"); int id = (int)dr["IdFarm"]; Drug dia = (from d in ctx.Drugs where d.OftId == id select d).FirstOrDefault<Drug>(); id = (int)dr["NumHis"]; Patient patient = (from p in ctx.Patients where p.OftId == id select p).FirstOrDefault<Patient>(); DateTime treatmentDate = (DateTime)dr["Fecha"]; Treatment t = (from tr in ctx.Treatments where tr.Patient.PersonId == patient.PersonId && tr.Drug.DrugId == dia.DrugId && tr.TreatmentDate == treatmentDate select tr).FirstOrDefault<Treatment>(); if (t == null) { t = new Treatment(); ctx.Add(t); } t.Patient = patient; t.Drug = dia; if ((int)dr["TipoProc"] == 1) { id = (int)dr["ExtProc"]; t.BaseVisit = (from v in ctx.BaseVisits where v.OftRefVisita == id select v).FirstOrDefault<BaseVisit>(); } t.TreatmentDate = treatmentDate; t.Recommend = (string)dr["Posologia"]; t.Quantity = (int)(float)dr["Cantidad"]; ctx.SaveChanges(); } }
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { RefreshGrid(true); if (e.Argument == "new") { //RadGrid1.CurrentPageIndex = RadGrid1.PageCount - 1; RadGrid1.Rebind(); } if (e.Argument == "yes") { if (Session["DeleteId"] != null) { try { treatmentId = (int)Session["DeleteId"]; treatment = (from da in ctx.Treatments where da.TreatmentId == treatmentId select da).FirstOrDefault<Treatment>(); ctx.Delete(treatment); ctx.SaveChanges(); RefreshGrid(true); Session["DeleteId"] = null; } catch (Exception ex) { Session["Exception"] = ex; string command = String.Format("showDialog('Error','{0}','error',null, 0, 0)", Resources.GeneralResource.DeleteRecordFail); RadAjaxManager1.ResponseScripts.Add(command); } } } }
protected void Page_Init(object sender, EventArgs e) { ctx = new AriClinicContext("AriClinicContext"); // security control, it must be a user logged if (Session["User"] == null) Response.Redirect("Default.aspx"); else { user = (User)Session["User"]; user = CntAriCli.GetUser(user.UserId, ctx); Process proc = (from p in ctx.Processes where p.Code == "treatment" select p).FirstOrDefault<Process>(); per = CntAriCli.GetPermission(user.UserGroup, proc, ctx); btnAccept.Visible = per.Modify; if (user.Professionals.Count > 0) { professional = user.Professionals[0]; rdcProfessional.Items.Clear(); rdcProfessional.Items.Add(new RadComboBoxItem(professional.FullName, professional.PersonId.ToString())); rdcProfessional.SelectedValue = professional.PersonId.ToString(); } } // if (Request.QueryString["TreatmentId"] != null) { treatmentId = Int32.Parse(Request.QueryString["TreatmentId"]); treatment = CntAriCli.GetTreatment(treatmentId, ctx); LoadData(treatment); } else { rdpTreatmentDate.SelectedDate = DateTime.Now; if (Session["Professional"] != null) LoadProfessionalCombo((Professional)Session["Professional"]); } // if (Request.QueryString["PatientId"] != null) { patientId = int.Parse(Request.QueryString["PatientId"]); patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); } // if (Request.QueryString["VisitId"] != null) { visitId = int.Parse(Request.QueryString["VisitId"]); visit = CntAriCli.GetVisit(visitId, ctx); patientId = visit.Patient.PersonId; patient = CntAriCli.GetPatient(patientId, ctx); // fix rdc with patient rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(patient.FullName, patient.PersonId.ToString())); rdcPatient.SelectedValue = patient.PersonId.ToString(); // rdpTreatmentDate.SelectedDate = visit.VisitDate; LoadProfessionalCombo(visit.Professional); } }
protected void UnloadData(Treatment tr) { tr.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx); tr.TreatmentDate = (DateTime)rdpTreatmentDate.SelectedDate; tr.Drug = CntAriCli.GetDrug(int.Parse(rdcDrug.SelectedValue), ctx); if (visit != null) tr.BaseVisit = visit; tr.Recommend = txtRecommend.Text; if (txtQuantity.Text != "") tr.Quantity = (int)txtQuantity.Value; if (rdcProfessional.SelectedValue != "") { tr.Professional = CntAriCli.GetProfessional(int.Parse(rdcProfessional.SelectedValue), ctx); } }
protected void LoadData(Treatment tr) { // Load patient data rdcPatient.Items.Clear(); rdcPatient.Items.Add(new RadComboBoxItem(tr.Patient.FullName, tr.Patient.PersonId.ToString())); rdcPatient.SelectedValue = tr.Patient.PersonId.ToString(); // Load diagnostic data rdcDrug.Items.Clear(); rdcDrug.Items.Add(new RadComboBoxItem(tr.Drug.Name, tr.Drug.DrugId.ToString())); rdcDrug.SelectedValue = tr.Drug.DrugId.ToString(); // Load professional if (tr.Professional != null) { rdcProfessional.Items.Clear(); rdcProfessional.Items.Add(new RadComboBoxItem(tr.Professional.FullName, tr.Professional.PersonId.ToString())); rdcProfessional.SelectedValue = tr.Professional.PersonId.ToString(); } rdpTreatmentDate.SelectedDate = tr.TreatmentDate; txtRecommend.Text = tr.Recommend; if (tr.Quantity != 0) txtQuantity.Value = tr.Quantity; }
protected bool CreateChange() { if (!DataOk()) return false; if (treatment == null) { treatment = new Treatment(); newTreatment = true; UnloadData(treatment); ctx.Add(treatment); } else { drug = CntAriCli.GetDrug(drugId, ctx); UnloadData(treatment); } ctx.SaveChanges(); return true; }