コード例 #1
0
        public async Task <CustomResponse <Acolhimento> > AdicionarAcolhimento(Acolhimento acolhimento, Guid userId)
        {
            var _response = new CustomResponse <Acolhimento>();

            try
            {
                var _pessoaMaster = (PessoaProfissional)_contextKlinikos.Pessoas.Where(x => x.Master).FirstOrDefault();

                await this.Adicionar(acolhimento, userId);

                await _serviceAcolhimentoHistorico.AdicionarHistoricoAcolhimento(acolhimento, _pessoaMaster);


                _response.StatusCode = StatusCodes.Status201Created;
                _response.Result     = acolhimento;
                _response.Message    = "Incluído com sucesso";
            }
            catch (Exception ex)
            {
                _response.Message = ex.InnerException.Message;
                Error.LogError(ex);
            }

            return(_response);
        }
コード例 #2
0
        public async Task <CustomResponse <FilaRegistro> > AdicionarPacienteFila(FilaRegistro filaRegistro, Guid userId)
        {
            var _response = new CustomResponse <FilaRegistro>();

            try
            {
                var _pessoaMaster = (PessoaProfissional)_contextKlinikos.Pessoas.Where(x => x.Master).FirstOrDefault();

                var _pacienteJaAcolhido = false;


                if (filaRegistro.Acolhimento.PessoaPaciente.PessoaId != Guid.Empty)
                {
                    _pacienteJaAcolhido = _contextKlinikos.FilaRegistro.Any(x => x.Acolhimento.PessoaPaciente.PessoaId == filaRegistro.Acolhimento.PessoaPaciente.PessoaId && x.Ativo);
                }

                if (!_pacienteJaAcolhido)
                {
                    await this.Adicionar(filaRegistro, userId);
                }
                else
                {
                    _response.StatusCode = StatusCodes.Status409Conflict;
                    _response.Message    = "Paciente já acolhido";
                    return(_response);
                }


                if (filaRegistro.Acolhimento != null)
                {
                    await _serviceAcolhimentoHistorico.AdicionarHistoricoAcolhimento(filaRegistro.Acolhimento, _pessoaMaster);


                    if (filaRegistro.Acolhimento.PessoaPaciente != null)
                    {
                        await _servicePessoaHistorico.AdicionarHistoricoPaciente(filaRegistro.Acolhimento.PessoaPaciente, _pessoaMaster);
                    }


                    var _filaRegistroEvento = new FilaRegistroEvento
                    {
                        FilaRegistro           = filaRegistro,
                        DataFilaRegistroEvento = filaRegistro.DataEntradaFilaRegistro,
                        EventoId           = _contextDominio.Eventos.Where(x => x.Sigla == "A").FirstOrDefault().EventoId,
                        PessoaProfissional = filaRegistro.Acolhimento.PessoaProfissional
                    };


                    await _serviceFilaRegistroEvento.Adicionar(_filaRegistroEvento, userId);
                }



                _response.StatusCode = StatusCodes.Status201Created;
                _response.Result     = filaRegistro;
                _response.Message    = "Incluído com sucesso";
            }
            catch (Exception ex)
            {
                _response.Message = ex.InnerException.Message;
                Error.LogError(ex);
            }

            return(_response);
        }