コード例 #1
0
        public async Task Create(ReferralInDTO referral)
        {
            var visit = await _repositoryVisit.GetAsync(x => x, x => x.Id == referral.VisitId);

            var specialization = await _repositorySpecialization.GetAsync(x => x, x => x.Id == referral.SpecializationId);

            var newReferral = new Referral()
            {
                Description      = referral.Description,
                VisitId          = referral.VisitId,
                Visit            = visit.FirstOrDefault(),
                Specialization   = specialization.FirstOrDefault(),
                SpecializationId = referral.SpecializationId,
                ExpiryDate       = DateTime.Now.AddDays(30)
            };
            await _repositoryReferral.InsertAsync(newReferral);
        }
コード例 #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"));
        }