public ExameModel GetId(int id) { var exame = exameServico.BuscarPorId(id); var exameModel = new ExameModel().FromEntity(exame); return(exameModel); }
public ActionResult Edit(int id, ExameModel exameModel) { if (ModelState.IsValid) { var exame = _mapper.Map <Exame>(exameModel); _exameService.Editar(exame); } return(RedirectToAction(nameof(Index))); }
public ActionResult Create(ExameModel exameModel) { if (ModelState.IsValid) { var exame = _mapper.Map <Exame>(exameModel); _exameService.Inserir(exame); } return(RedirectToAction(nameof(Index))); }
public Guid Salvar(ExameModel exame) { using (var db = new MainContextFactory().CreateDbContext(null)) { db.Exames.Add(exame); db.SaveChanges(); return(exame.Id); } }
public ExameModel Alterar(int id, [FromBody] ExameModel exameModel) { var exame = exameModel.ToEntity(); exame.Id = id; exameServico.Salvar(exame); return(new ExameModel().FromEntity(exame)); }
public async Task <IActionResult> EnviarSMS(int id, PesquisaExameViewModel pesquisaExame, IFormCollection collection) { ExameViewModel exameView = _exameContext.GetById(id); var usuario = _usuarioContext.RetornLoggedUser((ClaimsIdentity)User.Identity); var trabalhaMunicipio = _pessoaTrabalhaMunicipioContext.GetByIdPessoa(usuario.UsuarioModel.IdPessoa); var trabalhaEstado = _pessoaTrabalhaEstadoContext.GetByIdPessoa(usuario.UsuarioModel.IdPessoa); try { string statusAnteriorSMS = exameView.Exame.StatusNotificacao; ExameModel exame = exameView.Exame; if (new Util.TelefoneCelularAttribute().IsValid(exameView.Paciente.FoneCelular)) { if (exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_ENVIADO)) { exame = await _smsService.ConsultarSMSExameAsync(trabalhaEstado, trabalhaMunicipio, exame); } else if (exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_NAO) || exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_PROBLEMAS)) { exame = await _smsService.EnviarSMSResultadoExameAsync(trabalhaEstado, trabalhaMunicipio, exame, exameView.Paciente); } } if (statusAnteriorSMS.Equals(ExameModel.NOTIFICADO_ENVIADO) && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_SIM)) { TempData["mensagemSucesso"] = "SMS foi entregue com SUCESSO!"; } else if (statusAnteriorSMS.Equals(ExameModel.NOTIFICADO_NAO) && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_ENVIADO)) { TempData["mensagemSucesso"] = "SMS enviado com SUCESSO!"; } else if (statusAnteriorSMS.Equals(ExameModel.NOTIFICADO_NAO) && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_NAO)) { TempData["mensagemErro"] = "Ocorreram problemas no envio do SMS. Favor conferir telefone e repetir operação em alguns minutos."; } else if (statusAnteriorSMS.Equals(ExameModel.NOTIFICADO_ENVIADO) && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_ENVIADO)) { TempData["mensagemErro"] = "Ainda aguardando resposta da operadora. Favor repetir a consulta em alguns minutos."; } else if (statusAnteriorSMS.Equals(ExameModel.NOTIFICADO_ENVIADO) && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_PROBLEMAS)) { TempData["mensagemErro"] = "Operadora não conseguiu entregar o SMS. Favor conferir telefone e repetir envio em alguns minutos."; } } catch (ServiceException se) { TempData["mensagemErro"] = se.Message; } return(RedirectToAction("Notificate", "Exame", pesquisaExame)); }
// GET: ExameController/Edit/5 public ActionResult Edit(int id) { IEnumerable <Consulta> listaConsultas = _consultaService.ObterTodos(); IEnumerable <Animal> listaAnimais = _animalService.ObterTodos(); IEnumerable <Tipoexame> listaTipoexames = _tipoexameService.ObterTodos(); Exame exame = _exameService.Obter(id); ViewBag.IdConsulta = new SelectList(listaConsultas, "IdConsulta", "Descricao", null); ViewBag.IdAnimal = new SelectList(listaAnimais, "IdAnimal", "Nome", null); ViewBag.IdTipoExame = new SelectList(listaTipoexames, "IdTipoExame", "Tipo", null); ExameModel exameModel = _mapper.Map <ExameModel>(exame); return(View(exameModel)); }
// GET: ExameController/Details/5 public ActionResult Details(int id) { Exame exame = _exameService.Obter(id); Consulta consulta = _consultaService.Obter(exame.IdConsulta); Animal animal = _animalService.Obter(exame.IdAnimal); Tipoexame tipoExame = _tipoexameService.Obter(exame.IdTipoExame); ViewBag.IdConsulta = consulta.Descricao; ViewBag.IdAnimal = animal.Nome; ViewBag.IdTipoExame = tipoExame.Tipo; ExameModel exameModel = _mapper.Map <ExameModel>(exame); return(View(exameModel)); }
public ExameModel Cadastrar(ExameModel exameModel) { exameModel.Validar(); var exame = exameModel.ToEntity(); exameServico.Salvar(exame); exame = exameServico.BuscarPorId(exame.Id); var body = $"Olá, foi adicionado o exame \"{exame.Nome}\". <br />"; body += $"Nome do exame: {exame.Nome}<br />"; return(new ExameModel().FromEntity(exame)); }
private Exame ModelToEntityImportacao(ExameViewModel item, ExameModel exame) { return(new Exame { IdExame = exame != null ? exame.IdExame : 0, IdPaciente = item.Paciente.Idpessoa, IdVirusBacteria = item.Exame.IdVirusBacteria, IdAgenteSaude = item.Exame.IdAgenteSaude, DataExame = item.Exame.DataExame, DataInicioSintomas = item.Exame.DataInicioSintomas, DataNotificacao = DateTime.Now, IgG = item.Exame.IgG, IgM = item.Exame.IgM, Pcr = item.Exame.Pcr, IgMigG = item.Exame.IgGIgM, IdMunicipio = item.Exame.IdMunicipio, IdEstado = item.Exame.IdEstado, IdEmpresaSaude = item.Exame.IdEmpresaSaude, IdAreaAtuacao = item.Exame.IdAreaAtuacao, CodigoColeta = item.Exame.CodigoColeta, PerdaOlfatoPaladar = Convert.ToByte(item.Exame.PerdaOlfatoPaladar), Febre = Convert.ToByte(item.Exame.Febre), Tosse = Convert.ToByte(item.Exame.Tosse), Coriza = Convert.ToByte(item.Exame.Coriza), DificuldadeRespiratoria = Convert.ToByte(item.Exame.DificuldadeRespiratoria), DorGarganta = Convert.ToByte(item.Exame.DorGarganta), Diarreia = Convert.ToByte(item.Exame.Diarreia), DorOuvido = Convert.ToByte(item.Exame.DorOuvido), Nausea = Convert.ToByte(item.Exame.Nausea), DorAbdominal = Convert.ToByte(item.Exame.DorAbdominal), IdNotificacao = "", OutroSintomas = "", MetodoExame = item.Exame.MetodoExame, StatusNotificacao = exame != null ? exame.StatusNotificacao : "N" }); }
public IActionResult CalculaResultadoExame(bool aguardandoResultado, string iggIgm, string igm, string igg, string pcr) { return(Ok(ExameModel.CalculaResultadoExame(aguardandoResultado, iggIgm, igm, igg, pcr))); }
private ConfiguracaoNotificarModel BuscarConfiguracaoSMS(PessoaTrabalhaEstadoModel trabalhaEstado, PessoaTrabalhaMunicipioModel trabalhaMunicipio, ExameModel exame) { ConfiguracaoNotificarModel configuracaoNotificar = null; if (trabalhaEstado != null) { configuracaoNotificar = BuscarConfiguracaoNotificar(trabalhaEstado.IdEstado, trabalhaEstado.IdEmpresaExame); } else if (trabalhaMunicipio != null) { configuracaoNotificar = BuscarConfiguracaoNotificar(trabalhaMunicipio.IdMunicipio); } if (configuracaoNotificar == null) { throw new ServiceException("Não possui créditos para notificações por SMS. Por favor entre em contato pelo email [email protected] para saber como usar esse serviço no MonitoraSUS."); } else if (configuracaoNotificar.QuantidadeSmsdisponivel == 0 && exame.StatusNotificacao.Equals(ExameModel.NOTIFICADO_NAO)) { throw new ServiceException("Não possui créditos para enviar SMS. " + "Por favor entre em contato pelo email [email protected] se precisar novos créditos."); } return(configuracaoNotificar); }
public async System.Threading.Tasks.Task <ExameModel> EnviarSMSResultadoExameAsync(PessoaTrabalhaEstadoModel trabalhaEstado, PessoaTrabalhaMunicipioModel trabalhaMunicipio, ExameModel exame, PessoaModel pessoa) { ConfiguracaoNotificarModel configuracaoNotificar = BuscarConfiguracaoSMS(trabalhaEstado, trabalhaMunicipio, exame); try { string mensagem = "[MonitoraSUS]Olá, " + pessoa.Nome + ". "; if (exame.Resultado.Equals(ExameModel.RESULTADO_POSITIVO)) { mensagem += configuracaoNotificar.MensagemPositivo; } else if (exame.Resultado.Equals(ExameModel.RESULTADO_NEGATIVO)) { mensagem += configuracaoNotificar.MensagemNegativo; } else if (exame.Resultado.Equals(ExameModel.RESULTADO_RECUPERADO)) { mensagem += configuracaoNotificar.MensagemCurado; } else if (exame.Resultado.Equals(ExameModel.RESULTADO_INDETERMINADO)) { mensagem += configuracaoNotificar.MensagemIndeterminado; } else if (exame.Resultado.Equals(ExameModel.RESULTADO_AGUARDANDO)) { return(exame); } else if (exame.Resultado.Equals(ExameModel.RESULTADO_IGMIGG)) { return(exame); } var cliente = new HttpClient(); string url = "https://api.smsdev.com.br/send?key=" + configuracaoNotificar.Token + "&type=9&"; var uri = url + "number=" + pessoa.FoneCelular + "&msg=" + mensagem; var resultadoEnvio = await cliente.GetStringAsync(uri); ResponseSMSModel jsonResponse = JsonConvert.DeserializeObject <ResponseSMSModel>(resultadoEnvio); exame.IdNotificacao = jsonResponse.Id.ToString(); exame.StatusNotificacao = ExameModel.NOTIFICADO_ENVIADO; _context.Update(exame); _context.SaveChanges(); Configuracaonotificar configura = _context.Configuracaonotificar.Where(s => s.IdConfiguracaoNotificar == configuracaoNotificar.IdConfiguracaoNotificar).FirstOrDefault(); if (configura != null) { configura.QuantidadeSmsdisponivel -= 1; _context.Update(configura); } return(exame); } catch (HttpRequestException) { return(exame); } }
public async System.Threading.Tasks.Task <ExameModel> ConsultarSMSExameAsync(PessoaTrabalhaEstadoModel trabalhaEstado, PessoaTrabalhaMunicipioModel trabalhaMunicipio, ExameModel exame) { ConfiguracaoNotificarModel configuracaoNotificar = BuscarConfiguracaoSMS(trabalhaEstado, trabalhaMunicipio, exame); try { var cliente = new HttpClient(); string url = "https://api.smsdev.com.br/get?key=" + configuracaoNotificar.Token + "&action=status&"; var uri = url + "id=" + exame.IdNotificacao; var resultadoEnvio = await cliente.GetStringAsync(uri); ConsultaSMSModel jsonResponse = JsonConvert.DeserializeObject <ConsultaSMSModel>(resultadoEnvio); if (jsonResponse.Descricao.Equals("RECEBIDA")) { exame.StatusNotificacao = ExameModel.NOTIFICADO_SIM; _context.Update(exame); _context.SaveChanges(); } else if (jsonResponse.Descricao.Equals("ERRO")) { exame.StatusNotificacao = ExameModel.NOTIFICADO_PROBLEMAS; _context.Update(exame); _context.SaveChanges(); } } catch (HttpRequestException) { return(exame); } return(exame); }
public ActionResult Delete(int id, ExameModel exameModel) { _exameService.Remover(id); return(RedirectToAction(nameof(Index))); }