Example #1
0
        public async Task <Result> InsertPatientAnswer(InsertPatientAnswerDto dto, int personId)
        {
            var patientId = (await _patientRepo.GetAsync(x => x.PersonId == personId))?.Id ?? 0;

            if (patientId == 0)
            {
                return(new ErrorResult("Patient not found!"));
            }

            var entity = new PatientAnswer
            {
                Score             = dto.Score,
                QuestionPoolId    = dto.QuestionId,
                AnswerDescription = dto.AnswerDescription,
                PatientId         = patientId
            };

            var question = _questionRepo.TableNoTracking
                           .Where(x => x.Id == dto.QuestionId)
                           .Select(x => new QuestionPool
            {
                Id           = x.Id,
                DepartmentId = x.DepartmentId,
                LowerLimit   = x.LowerLimit,
                UpperLimit   = x.UpperLimit
            }).FirstOrDefaultAsync();


            if (entity.Score <= question.Result.UpperLimit && entity.Score >= question.Result.LowerLimit)
            {
                entity.Result = true;
            }
            else
            {
                entity.Result = false;
            }

            entity.IsActive = true;

            return(await _repository.InsertAsync(entity));
        }
Example #2
0
        public async Task <IActionResult> InsertPatientAnswer([FromBody] InsertPatientAnswerDto entity)
        {
            var personId = _userService.PersonId;

            return(Ok(await _patientAnswerService.InsertPatientAnswer(entity, personId)));
        }