Beispiel #1
0
        public async Task <IActionResult> CurrentVisit(long VisitId)
        {
            var currentVisit = await _visitService.GetById(new GetByIdInDTO
            {
                Id     = VisitId,
                UserId = _userManager.GetUserAsync(HttpContext.User).Result.Id
            });

            if (currentVisit == null || currentVisit.State == StateVisit.Completed)
            {
                return(RedirectToAction("TimeTable", "Home", new { area = "Doctor" }));
            }

            var allMedicament = await _medicamentService.GetAllMedicament();

            var patient = await _patientAccountService.GetPatientById(currentVisit.PatientId);

            var visits = await _visitService.GetCompletedVisits(currentVisit.PatientId);

            visits.Reverse();



            CurrentVisitVM viewModel = new CurrentVisitVM()
            {
                Medicaments = allMedicament,
                FirstName   = patient.FirstName,
                LastName    = patient.LastName,
                Birth       = patient.Birth,
                VisitID     = currentVisit.Id,
                State       = currentVisit.State,
                Visits      = visits,
                PatientID   = patient.UserID
            };
            var specializationOutDto = await _specializationService.GetAllAsync();

            specializationOutDto.Select(x => x.Name).ToList().ForEach(name =>
            {
                viewModel.Specializations.Add(new SelectListItem
                {
                    Text  = name,
                    Value = name
                });
            });

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> CurrentVisit(CurrentVisitVM vm)
        {
            if (vm.State == StateVisit.Completed)
            {
                return(RedirectToAction("TimeTable", "Home", new { area = "Doctor" }));
            }

            if (vm.selectedMedicaments != null && vm.selectedMedicaments.Count > 0)
            {
                var medicament = await _medicamentService.GetMedicamentByName(vm.selectedMedicaments);

                var prescriptionInDTO = new PrescriptionInDTO()
                {
                    Comments    = vm.DescriptionPrescription,
                    VisitId     = vm.VisitID,
                    Medicaments = medicament
                };
                await _prescriptionService.Create(prescriptionInDTO);
            }

            if (!string.IsNullOrEmpty(vm.selectedSpecialization))
            {
                var selectedSpecialization = await _specializationService.GetByNameAsync(vm.selectedSpecialization);

                var referralInDTO = new ReferralInDTO()
                {
                    Description      = vm.DescriptionReferral,
                    VisitId          = vm.VisitID,
                    SpecializationId = selectedSpecialization.First().SpecializationId
                };
                await _referralService.Create(referralInDTO);
            }

            await _visitService.UpdateVisit(new UpdateVisitInDTO()
            {
                Description = vm.DescriptionVisit, Id = vm.VisitID, State = StateVisit.Completed
            });

            return(View("Index"));
        }