public void CreatePatientDonorRequestsRelation(int patientRequestId, int donorRequestId)
        {
            var patientRequest = _patientRequestsRepository.GetById(patientRequestId);

            if (patientRequest == null)
            {
                throw new ArgumentException(nameof(patientRequestId));
            }

            var donorRequest = _donorRequestsRepository.GetById(donorRequestId);

            if (donorRequest == null)
            {
                throw new ArgumentException(nameof(donorRequestId));
            }

            var relation = new RequestsRelation()
            {
                PatientRequestId = patientRequestId,
                DonorRequestId   = donorRequestId,
                IsActive         = true
            };

            patientRequest.Status = PatientRequestStatuses.AwaitingForTransplanting;
            donorRequest.Status   = DonorRequestStatuses.NeedToScheduleTimeForOrganRetrieving;

            _donorRequestsRepository.Update(donorRequest);
            _patientRequestsRepository.Update(patientRequest);
            _requestsRelationsRepository.Add(relation);

            //TODO: send email to clinic/patient/donor that query status has been changed
        }
示例#2
0
        private void ScheduleMedicalExamInner(ScheduleMedicalExamViewModel model)
        {
            var donorOrganRequest = _donorRequestsRepository.GetById(model.DonorRequestId);

            if (donorOrganRequest == null)
            {
                //TODO: handle
                return;
            }

            var medicalExamEntity = new DonorMedicalExam()
            {
                ClinicId       = model.ClinicId,
                DonorRequestId = model.DonorRequestId,
                ScheduledAt    = model.ScheduledDateTime,
                Status         = MedicalExamStatuses.Scheduled
            };

            donorOrganRequest.Status = DonorRequestStatuses.ScheduledMedicalExamination;

            _medicalExamsService.AddMedicalExam(medicalExamEntity);
            _donorRequestsRepository.Update(donorOrganRequest);
        }