Exemplo n.º 1
0
    protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label lblId = (Label)GrdRegistration.Rows[e.RowIndex].FindControl("lblId");

        RegisterPatient registerPatient = RegisterPatientDB.GetByID(Convert.ToInt32(lblId.Text));

        if (BookingDB.GetCountByPatientAndOrg(registerPatient.Patient.PatientID, registerPatient.Organisation.OrganisationID) > 0)
        {
            SetErrorMessage("Can not remove registration of '" + registerPatient.Patient.Person.FullnameWithoutMiddlename + "' to '" + registerPatient.Organisation.Name + "' because there exists a booking for this patient there.");
            return;
        }

        try
        {
            RegisterPatientDB.UpdateInactive(Convert.ToInt32(lblId.Text), false);
        }
        catch (ForeignKeyConstraintException fkcEx)
        {
            if (Utilities.IsDev())
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
            }
            else
            {
                HideTableAndSetErrorMessage("Can not delete because other records depend on this");
            }
        }

        FillGrid();
    }
 public RegisterPatientViewModel(RegisterPatient open, tblClinicPatient p, tblUser user)
 {
     register        = open;
     newUser         = user;
     newPatient      = p;
     isEditingWindow = true;
 }
        public async Task <IActionResult> FinishCreate(RegisterPatient registerPatient)
        {
            if (ModelState.IsValid)
            {
                var user = new IdentityUser
                {
                    UserName    = registerPatient.Username,
                    Email       = registerPatient.Email,
                    PhoneNumber = registerPatient.Phone
                };
                var result = await _userManager.CreateAsync(user, registerPatient.Password);

                await _userManager.AddClaimAsync(user, new Claim(ClaimTypes.Role, "Patient"));

                InsuranceCompany I = _context.InsuranceCompanies.Find(registerPatient.SelectedInsuranceCompanyId);
                Patient          p = new Patient
                {
                    FirstName        = registerPatient.FirstName,
                    MiddleName       = registerPatient.MiddleName,
                    LastName         = registerPatient.LastName,
                    Gender           = registerPatient.Gender,
                    Image            = registerPatient.Image,
                    Mobile           = registerPatient.Mobile,
                    BloodType        = registerPatient.BloodType,
                    Birthdate        = registerPatient.Birthdate,
                    DisplayName      = registerPatient.DisplayName,
                    InsuranceCompany = I,
                    Address          = registerPatient.Address,
                    User             = user
                };
                if (User.IsInRole("Doctor"))
                {
                    Doctor         doctor   = _context.Doctors.Single(d => d.User.Id == _userManager.GetUserId(User));
                    Doctor_Patient Relation = new Doctor_Patient()
                    {
                        Doctor  = doctor,
                        Patient = p
                    };
                    _context.Add(Relation);
                }

                _context.Add(p);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Search)));
            }
            InsuranceCompany[] IC = _context.InsuranceCompanies.ToArray();
            SelectListItem[]   InsuranceCompanies = new SelectListItem[IC.Length + 1];
            InsuranceCompanies[0] = new SelectListItem {
                Value = null, Text = "none"
            };
            for (int i = 0; i < IC.Length; i++)
            {
                InsuranceCompanies[i + 1] = new SelectListItem {
                    Value = "" + IC[i].Id, Text = IC[i].Name
                };
            }
            ViewData["InsuranceCompanies"] = InsuranceCompanies;
            return(View(registerPatient));
        }
 public static RegisterPatient[] GetAll(bool inc_deleted_patients = true, bool inc_deceased_patients = true, bool inc_deleted_orgs = true, string organistion_group_type_ids = null, string organistion_type_ids = null)
 {
     DataTable tbl = GetDataTable(inc_deleted_patients, inc_deceased_patients, inc_deleted_orgs, organistion_group_type_ids, organistion_type_ids);
     RegisterPatient[] list = new RegisterPatient[tbl.Rows.Count];
     for(int i=0; i<tbl.Rows.Count; i++)
         list[i] = LoadAll(tbl.Rows[i]);
     return list;
 }
Exemplo n.º 5
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            RegisterPatient item = new RegisterPatient(user);

            panel1.Controls.Clear();
            //item.Top = 10;
            //item.Left = 10;
            panel1.Controls.Add(item);
        }
Exemplo n.º 6
0
 private void RegistrationExecute()
 {
     try
     {
         RegisterPatient reg = new RegisterPatient();
         reg.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 7
0
    public static RegisterPatient[] RemoveByID(RegisterPatient[] registered_patients, int id_to_remove)
    {
        RegisterPatient[] newList = new RegisterPatient[registered_patients.Length - 1];

        bool found = false;
        for (int i = 0; i < registered_patients.Length; i++)
        {
            if (registered_patients[i].RegisterPatientID != id_to_remove)
                newList[i - (found ? 1 : 0)] = registered_patients[i];
            else
                found = true;
        }

        return newList;
    }
 private void AddPatientExecute()
 {
     try
     {
         RegisterPatient register = new RegisterPatient();
         register.ShowDialog();
         if ((register.DataContext as RegisterPatientViewModel).isUpdated == true)
         {
             patientList = Service.Service.PatientsList();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 9
0
        public ActionResult Create(RegisterPatient patient)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    WebSecurity.CreateUserAndAccount(patient.RM.UserName, patient.RM.Password);

                    WebSecurity.Login(patient.RM.UserName, patient.RM.Password);

                    bool      pat_role = false;
                    string [] roles    = Roles.GetAllRoles();
                    for (int i = 0; i < roles.Length; i++)
                    {
                        if (roles[i] == "Patient")
                        {
                            pat_role = true;
                        }
                    }


                    if (pat_role == false)
                    {
                        Roles.CreateRole("Patient");
                    }

                    Roles.AddUsersToRole(new[] { patient.RM.UserName }, "Patient");
                    CardiologistV2.DAL.DatabaseContext db = new DAL.DatabaseContext();
                    db.Users.Add(new Models.User()
                    {
                        UserID = WebSecurity.GetUserId(patient.RM.UserName)
                    });

                    patient.ThePatient.PatientID = WebSecurity.GetUserId(patient.RM.UserName);
                    db.Patients.Add(patient.ThePatient);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (MembershipCreateUserException e)
                {
                    // ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }
            return(View(patient));
        }
 private void EditPatientDateExecute()
 {
     try
     {
         int             id     = patient.patientId;
         int?            userId = patient.userId;
         tblUser         user   = Service.Service.UserById(userId);
         RegisterPatient create = new RegisterPatient(patient, user);
         create.ShowDialog();
         if ((create.DataContext as RegisterPatientViewModel).isUpdated == true)
         {
             patientList = Service.Service.PatientsList();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 11
0
        public async Task <IActionResult> Create(RegisterPatient registerPatient, IFormFile file)
        {
            string image = "avatar.jpg";

            if (_userManager.Users.Any(u => u.UserName == registerPatient.Username))
            {
                ModelState.AddModelError(String.Empty, "User name already taken");
                ViewData["message"] = "Already Taken";
                return(View(registerPatient));
            }

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    var filePath = Path.GetTempFileName();
                    using (FileStream filestream = System.IO.File.Create(_environment.WebRootPath + "\\images\\" + file.FileName))
                    {
                        image = file.FileName;
                        file.CopyTo(filestream);
                        filestream.Flush();
                    }
                }
                registerPatient.Image = image;
                InsuranceCompany[] IC = _context.InsuranceCompanies.ToArray();
                SelectListItem[]   InsuranceCompanies = new SelectListItem[IC.Length + 1];
                InsuranceCompanies[0] = new SelectListItem {
                    Value = "0", Text = "none"
                };
                for (int i = 0; i < IC.Length; i++)
                {
                    InsuranceCompanies[i + 1] = new SelectListItem {
                        Value = "" + IC[i].Id, Text = IC[i].Name
                    };
                }
                ViewData["InsuranceCompanies"] = InsuranceCompanies;

                return(View("~/Views/Patients/FinishCreate.cshtml", registerPatient));
            }

            return(View(registerPatient));
        }
Exemplo n.º 12
0
    public static RegisterPatient[] RemoveByID(RegisterPatient[] registered_patients, int id_to_remove)
    {
        RegisterPatient[] newList = new RegisterPatient[registered_patients.Length - 1];

        bool found = false;

        for (int i = 0; i < registered_patients.Length; i++)
        {
            if (registered_patients[i].RegisterPatientID != id_to_remove)
            {
                newList[i - (found ? 1 : 0)] = registered_patients[i];
            }
            else
            {
                found = true;
            }
        }

        return(newList);
    }
 public RegisterPatientViewModel(RegisterPatient open)
 {
     register   = open;
     newUser    = new tblUser();
     newPatient = new tblClinicPatient();
 }
Exemplo n.º 14
0
 public RegisterView()
 {
     InitializeComponent();
     register = new RegisterPatient();
     SexComboBox.SelectedItem = "Mężczyzna";
 }
 public DefaultRegisterPatientBuilder(RegisterPatient registerPatient)
 {
     _registerPatient = registerPatient;
 }
Exemplo n.º 16
0
        private HospitalEvent ConvertToActorEvent(Common.Entities.IHospitalEvent dbEvent)
        {
            HospitalEvent hospitalEvent = null;

            switch (dbEvent.EventType)
            {
                case HospitalEventType.PatientArrival:
                    hospitalEvent = new RegisterPatient(dbEvent.HospitalId, dbEvent.PatiendId, dbEvent.EventTime, _diseases[dbEvent.DiseaseType.Value]);
                    break;

                case HospitalEventType.PatientLeaving:
                    hospitalEvent = new UnregisterPatient(dbEvent.HospitalId, dbEvent.PatiendId, dbEvent.EventTime);
                    break;

                case HospitalEventType.PatientTakenInChargeByDoctor:
                    hospitalEvent = new BeginAppointmentWithDoctor(dbEvent.HospitalId, dbEvent.PatiendId, dbEvent.DoctorId.Value, dbEvent.EventTime, _diseases[dbEvent.DiseaseType.Value]);
                    break;

                default:
                    throw new ArgumentException("Unexpected hospital event type");
            }

            return hospitalEvent;
        }