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

        //
        if (Request.QueryString["DiagnosticAssignedId"] != null)
        {
            diagnosticAssignedId = Int32.Parse(Request.QueryString["DiagnosticAssignedId"]);
            diagnosticAssigned   = CntAriCli.GetDiagnosticAssigned(diagnosticAssignedId, ctx);
            LoadData(diagnosticAssigned);
        }
        else
        {
            rdpDiagnosticDate.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;
            // by default disgnostic assigned date is the visit date
            rdpDiagnosticDate.SelectedDate = visit.VisitDate;
        }
    }