Esempio n. 1
0
 private void BtnLicenseRenewal_Click(object sender, EventArgs e)
 {
     if (cbxMedicalExamResult.SelectedIndex >= 0 && cbxMedicalExamType.SelectedIndex >= 0)
     {
         var exam = new MedicalExam
         {
             Created      = DateTime.Now,
             DateOfMaking = dtMedicalExamDateOfMaking.Value,
             Expires      = dtMedicalExamExpires.Value,
             Result       = (MedicalExamResult)cbxMedicalExamResult.SelectedIndex,
             Type         = (MedicalExamType)cbxMedicalExamType.SelectedIndex,
             Description  = txtMedicalExamDescription.Text,
             IsActive     = true
         };
         if (NewMedicalExamAdded?.Invoke(exam) == true)
         {
             _ = MessageBox.Show("Examen médico registrado satisfactoriamente.", "Nuevo exámen médico", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearFields();
             DialogResult = DialogResult.OK;
         }
         else
         {
             _            = MessageBox.Show("Ha ocurrido un error registrando el chequeo médico. Contacte al desarrollador para solicitar soporte acerca de este error.", "Error registrando examen", MessageBoxButtons.OK, MessageBoxIcon.Error);
             DialogResult = DialogResult.Cancel;
             Close();
         }
     }
     else
     {
         _ = MessageBox.Show("Rellene los campos debidamente.", "Error en el formulario", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public MedicalExam Add(MedicalExam medicalExam)
        {
            if (Get(medicalExam.Id) == null)
            {
                List <MedicalExam> medicalExams = GetAll();
                medicalExams.Add(medicalExam);
                WriteAll(medicalExams);

                return(medicalExam);
            }
            return(null);
        }
        public MedicalExam Remove(int id)
        {
            List <MedicalExam> medicalExams = GetAll();

            MedicalExam medicalExamToRemove = medicalExams.SingleOrDefault(r => r.Id == id);

            if (medicalExamToRemove != null)
            {
                medicalExams.Remove(medicalExamToRemove);
                WriteAll(medicalExams);
            }

            return(medicalExamToRemove);
        }
Esempio n. 4
0
        public Model.DoctorReview Update(Model.DoctorReview doctorReview)
        {
            MedicalExam medicalExam = _medicalExamRepository.Get(doctorReview.MedicalExam);

            if (medicalExam == null)
            {
                return(null);
            }

            medicalExam.DoctorReview = doctorReview;
            _medicalExamRepository.Update(medicalExam);

            return(doctorReview);
        }
        public MedicalExam Update(MedicalExam medicalExam)
        {
            List <MedicalExam> medicalExams = GetAll();

            for (int i = 0; i < medicalExams.Count; i++)
            {
                if (medicalExams[i].Id == medicalExam.Id)
                {
                    medicalExams[i] = medicalExam;
                    break;
                }
            }

            WriteAll(medicalExams);

            return(medicalExam);
        }
Esempio n. 6
0
        public RegisterMedicalExamResponse Ejecute(RegisterMedicalExamRequest request)
        {
            var turn = CalculateTurn(request);

            if (!ValidatePatient(request.Patient))
            {
                return new RegisterMedicalExamResponse {
                           Mensaje = "Este paciente ya tiene el maximo permitido de examenes programados"
                }
            }
            ;

            MedicalExam newExam = null;
            var         exam    = _unitOfWork.MedicalExamRepository.FindFirstOrDefault(e => e.Id == request.Identification);

            if (exam == null)
            {
                newExam = new MedicalExam();

                newExam.Name    = request.Name;
                newExam.Patient = new SearchPatientService(_unitOfWork)
                                  .Ejecute(new SearchPatientRequest {
                    Identification = request.Patient.Id
                }).Patient;                                                                          //request.Patient;
                newExam.Date  = request.Date;
                newExam.Turn  = turn;
                newExam.Time  = "Mañana";
                newExam.State = "Programado";
                newExam.GenerateCost();
                _unitOfWork.MedicalExamRepository.Add(newExam);
                _unitOfWork.Commit();
                return(new RegisterMedicalExamResponse {
                    Mensaje = "Examen medico creado satisfactoriamente"
                });
            }



            return(new RegisterMedicalExamResponse {
                Mensaje = "Error al registrar el examen medico"
            });
        }
        public async Task <IActionResult> NewType(MedicalExam model)
        {
            var db = new FileContext();

            if (db.MedicalExams.FirstOrDefault(x => x.ExamName == model.ExamName) == null || !string.IsNullOrEmpty(model.ExamName))
            {
                try
                {
                    await db.MedicalExams.AddAsync(model);

                    await db.SaveChangesAsync();
                }
                catch (Exception ex)
                {
                    return(RedirectToAction(nameof(NewType), new { e = "Error al intentar registrar: " + ex.Message }));
                }
                return(RedirectToAction(nameof(Index), new { e = "Operacion realizada con exito." }));
            }
            return(RedirectToAction(nameof(NewType), new { e = "Error al intentar registrar." }));
        }
Esempio n. 8
0
        public async Task EndExamService_ShouldReturnSuccess_WhenExamIsValid()
        {
            var examId     = Guid.NewGuid();
            var examResult = "oba";
            var dto        = new DtoEndExamInput
            {
                ExamId     = examId,
                ExamResult = examResult
            };
            var exam = new MedicalExam
            {
                Id = examId
            };

            _medicalExamRepository.Setup(x => x.GetById(examId)).ReturnsAsync(exam);
            _medicalExamRepository.Setup(x => x.Update(exam)).ReturnsAsync(exam);

            var response = await _service.Execute(examId, dto);

            Assert.Equal(HttpStatusCode.OK, response.Status);
        }
Esempio n. 9
0
        public async Task EndExamService_ShouldReturnError_WhenExamIsInvalid()
        {
            var examId     = Guid.NewGuid();
            var examResult = "oba";
            var dto        = new DtoEndExamInput
            {
                ExamId     = examId,
                ExamResult = examResult
            };
            var exam = new MedicalExam
            {
                Id = examId
            };

            MedicalExam exameNaoExistente = null;

            _medicalExamRepository.Setup(x => x.GetById(examId)).ReturnsAsync(exameNaoExistente);
            _medicalExamRepository.Setup(x => x.Update(exam)).ReturnsAsync(exam);

            var response = await _service.Execute(examId, dto);

            Assert.Equal(HttpStatusCode.BadRequest, response.Status);
        }
        public void RegisterMedicalExamCorrect()
        {
            var patient = new Patient();

            patient.Id       = "1066";
            patient.Name     = "Pedro";
            patient.Surname  = "Salcedo";
            patient.Age      = 25;
            patient.Gender   = "Masculino";
            patient.EPS      = "Saludvida";
            patient.Stratum  = 2;
            patient.Discount = 0.6;

            var medicalExam = new MedicalExam();

            medicalExam.Name    = "Examen de orina";
            medicalExam.Date    = DateTime.Now.AddDays(10);
            medicalExam.Date    = medicalExam.Date.AddHours(8);
            medicalExam.Patient = patient;
            medicalExam.GenerateCost();

            Assert.AreEqual(20000, medicalExam.Cost);
        }
Esempio n. 11
0
 public MedicalExam UpdateMedicalExam(MedicalExam medicalExam)
 {
     return(_medicalExamService.UpdateMedicalExam(medicalExam));
 }
Esempio n. 12
0
 public MedicalExam Add(MedicalExam medicalExam)
 {
     return(_medicalExamService.Add(medicalExam));
 }
Esempio n. 13
0
 public MedicalExam UpdateMedicalExam(MedicalExam medicalExam)
 {
     throw new NotImplementedException();
 }
Esempio n. 14
0
 public MedicalExam ScheduleMedicalExam(MedicalExam medicalExam)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
 public MedicalExam Add(MedicalExam medicalExam)
 => _medicalExamRepository.Add(medicalExam);
Esempio n. 16
0
 public MedicalExam UpdateMedicalExam(MedicalExam medicalExam)
 {
     return(_medicalExamRepository.Update(medicalExam));
 }
Esempio n. 17
0
 public Model.DoctorReview Get(MedicalExam medicalExam)
 => _medicalExamRepository.Get(medicalExam.Id).DoctorReview;
 public Model.DoctorReview SetDoctorReview(Model.DoctorReview doctorReview, MedicalExam medicalExam)
 {
     throw new NotImplementedException();
 }