コード例 #1
0
ファイル: DoctorController.cs プロジェクト: alikaraki/Shafam
        public ActionResult ReferPatient(ReferPatientViewModel model, int patientId)
        {
            int thisDocId = _identityProvider.GetAuthenticatedUserId();

            // Refer patient to the doctor associated with referredDocId
            _patientManagementService.ReferPatient(patientId, thisDocId, int.Parse(model.ReferredDoctorId));

            return(RedirectToAction("ReferPatient", "Doctor", new { patientId = patientId }));
        }
コード例 #2
0
        public async Task <IActionResult> Refer([Bind] ReferPatientViewModel model)
        {
            var currentPatient = _context.Patient.Find(model.PatientId);

            model.ReferredToMd = model.ReferredToMd == 0 ? null : model.ReferredToMd;
            if (ModelState.IsValid && model.ReferredTo != 0 && model.Department != 0)
            {
                var patient  = setNormalPatientForm(model);
                var tracking = setNormalTracking(patient);
                var activity = SetNormalActivity(tracking);
                _context.Add(tracking);
                _context.Add(activity);
                _context.Add(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ListPatients", "ViewPatients"));
            }
            else
            {
                ModelState.AddModelError("ReferredTo", "Please select a Facility.");
                ModelState.AddModelError("Department", "Please select a Department.");
            }
            var facility    = _context.Facility.Single(x => x.Id.Equals(UserFacility()));
            var patientView = new PatientViewModel
            {
                Id          = currentPatient.Id,
                Name        = GlobalFunctions.GetFullName(currentPatient),
                Age         = GlobalFunctions.ComputeAge(currentPatient.DateOfBirth),
                Sex         = currentPatient.Sex,
                CivilStatus = currentPatient.CivilStatus,
                Address     = GlobalFunctions.GetAddress(currentPatient),
                PhicStatus  = currentPatient.PhicStatus,
                PhicId      = currentPatient.PhicId
            };
            var referTo = _context.Facility
                          .Where(x => x.Id != UserFacility())
                          .Where(x => x.ProvinceId.Equals(UserProvince()));

            ViewBag.ReferredTo      = new SelectList(referTo, "Id", "Name", model.ReferredTo);
            ViewBag.Patient         = patientView;
            ViewBag.Facility        = facility.Name;
            ViewBag.FacilityAddress = GlobalFunctions.GetAddress(facility);

            return(PartialView(model));
        }