Exemple #1
0
        public void AddPatientRequestToQueue(PatientOrganRequestViewModel model)
        {
            var isOrganInfoExist = _organInfoService.IfOrganInfoExists(model.OrganInfoId);

            if (!isOrganInfoExist)
            {
                throw new ArgumentException(nameof(model.OrganInfoId));
            }

            if (!Enum.IsDefined(typeof(PatientRequestPriority), model.QueryPriority))
            {
                model.QueryPriority = PatientRequestPriority.Normal;
            }

            var user            = _userManager.FindByEmailAsync(model.Email).Result;
            var patientUserInfo = user == null
                ? _userInfoService.RegisterPatient(model)
                : _userInfoService.GetUserInfoByUserId(user.Id);

            var patientRequest = new PatientRequest()
            {
                OrganInfoId   = model.OrganInfoId,
                PatientInfoId = patientUserInfo.UserInfoId,
                Priority      = model.QueryPriority,
                Message       = model.AdditionalInfo,
                Status        = PatientRequestStatuses.AwaitingForDonor
            };

            _patientRequestsRepository.Add(patientRequest);

            //TODO: send email to patient email with credentials
            //TODO: send email to clinic that query has been added
        }
Exemple #2
0
        public void RegisterDonorOrganRequest(DonorRequestViewModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!_organInfoService.IfOrganInfoExists(request.OrganInfoId))
            {
                throw new ArgumentException("Organ Info does not exist.");
            }

            //TODO: validate contacts

            var      user          = _userManager.FindByEmailAsync(request.Email).Result;
            UserInfo donorUserInfo = user == null
                ? _userInfoService.RegisterDonor(request)
                : _userInfoService.GetUserInfoByUserId(user.Id);

            RegisterDonorOrganRequestInner(request, donorUserInfo);
        }