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 == "procedureassigned"
                            select p).FirstOrDefault<Process>();
            per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
            btnAccept.Visible = per.Modify;
        }

        // 
        if (Request.QueryString["ProcedureAssignedId"] != null)
        {
            procedureAssignedId = Int32.Parse(Request.QueryString["ProcedureAssignedId"]);
            procedureAssigned = CntAriCli.GetProcedureAssigned(procedureAssignedId, ctx);
            LoadData(procedureAssigned);
        }
        else
        {
            rdpProcedureDate.SelectedDate = DateTime.Now;
        }
        //
        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();
            rdcPatient.Enabled = false;
        }
        //
        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();
            rdcPatient.Enabled = false;
            //
            rdpProcedureDate.SelectedDate = visit.VisitDate;
        }

    }
 protected void UnloadData(ProcedureAssigned pra)
 {
     pra.Patient = CntAriCli.GetPatient(int.Parse(rdcPatient.SelectedValue), ctx);
     pra.ProcedureDate = (DateTime)rdpProcedureDate.SelectedDate;
     pra.Procedure = CntAriCli.GetProcedure(int.Parse(rdcProcedure.SelectedValue), ctx);
     if (visit != null)
         pra.BaseVisit = visit;
     pra.Comments = txtComments.Text;
 }
    protected void LoadData(ProcedureAssigned pra)
    {
        // Load patient data
        rdcPatient.Items.Clear();
        rdcPatient.Items.Add(new RadComboBoxItem(pra.Patient.FullName, pra.Patient.PersonId.ToString()));
        rdcPatient.SelectedValue = pra.Patient.PersonId.ToString();

        // Load procedure data
        rdcProcedure.Items.Clear();
        rdcProcedure.Items.Add(new RadComboBoxItem(pra.Procedure.Name, pra.Procedure.ProcedureId.ToString()));
        rdcProcedure.SelectedValue = pra.Procedure.ProcedureId.ToString();

        rdpProcedureDate.SelectedDate = pra.ProcedureDate;
        txtComments.Text = pra.Comments;
    }
 protected bool CreateChange()
 {
     if (!DataOk())
         return false;
     if (procedureAssigned == null)
     {
         procedureAssigned = new ProcedureAssigned();
         UnloadData(procedureAssigned);
         ctx.Add(procedureAssigned);
     }
     else
     {
         procedure = CntAriCli.GetProcedure(procedureId, ctx);
         UnloadData(procedureAssigned);
     }
     ctx.SaveChanges();
     return true;
 }
 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
             {
                 labTestAssignedId = (int)Session["DeleteId"];
                 labTestAssigned = (from da in ctx.ProcedureAssigneds
                                    where da.ProcedureAssignedId == labTestAssignedId
                                    select da).FirstOrDefault<ProcedureAssigned>();
                 ctx.Delete(labTestAssigned);
                 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);
             }
         }
     }
 }
Exemple #6
0
        public static void ImportProceduresAssigned(OleDbConnection con, AriClinicContext ctx)
        {
            // (0) Borra tipos previos
            ctx.Delete(ctx.ProcedureAssigneds);
            ctx.SaveChanges();

            // (1) Dar de alta los diferentes diagnósticos
            string sql = "SELECT * FROM HistProc";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConProcedimientos");
            int nreg = ds.Tables["ConProcedimientos"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConProcedimientos"].Rows)
            {
                reg++;
                Console.WriteLine("Procedimientos {0:#####0} de {1:#####0} {2}", reg, nreg, "ASGPROCS");
                int id = (int)dr["IdProEs"];
                Procedure procedure = (from p in ctx.Procedures
                                 where p.OftId == id
                                 select p).FirstOrDefault<Procedure>();
                id = (int)dr["NumHis"];
                Patient patient = (from p in ctx.Patients
                                   where p.OftId == id
                                   select p).FirstOrDefault<Patient>();
                DateTime procedureDate = (DateTime)dr["Fecha"];

                ProcedureAssigned pa = (from pas in ctx.ProcedureAssigneds
                                        where pas.Patient.PersonId == patient.PersonId
                                        && pas.Procedure.ProcedureId == procedure.ProcedureId
                                        && pas.ProcedureDate == procedureDate
                                        select pas).FirstOrDefault<ProcedureAssigned>();
                if (pa == null)
                {
                    pa = new ProcedureAssigned();
                    ctx.Add(pa);
                }
                pa.Patient = patient;
                pa.Procedure = procedure;
                pa.ProcedureDate = procedureDate;
                pa.Comments = (string)dr["Observa"];
                ctx.SaveChanges();
            }
        }