public IList <ConsultationProduct> ShowAll(MedicalConsultation medicalConsultation)
 {
     using (var context = new EFContext())
     {
         return(context.ConsultationProducts.Where(ce => ce.MedicalConsultation.MedicalConsultationId == medicalConsultation.MedicalConsultationId).ToList <ConsultationProduct>());
     }
 }
        public async Task AddMedicalConsultationService_ShouldReturnSuccess_WhenMcIsValid()
        {
            var doctorId  = Guid.NewGuid();
            var patientId = Guid.NewGuid();
            var consult   = new MedicalConsultation();
            var dto       = new DtoAddMedicalConsultationInput
            {
                PatientId = patientId
            };

            var doctor = new Doctor {
                Id = doctorId
            };
            var patient = new Patient {
                Id = patientId
            };

            _userRepository.Setup(x => x.GetById(doctorId)).ReturnsAsync(doctor);
            _patientRepository.Setup(x => x.GetById(patientId)).ReturnsAsync(patient);
            _mcRepository.Setup(x => x.Insert(consult)).ReturnsAsync(consult);

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

            Assert.Equal(HttpStatusCode.OK, response.Status);
        }
Ejemplo n.º 3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (!txtId.Text.Equals(""))
            {
                MessageBox.Show("A caixa de Id deve estar vazia, aperte em resetar para limpa-la.");
                return;
            }
            else if (allFullfilled())
            {
                var vetId   = Convert.ToInt64(cbVet.SelectedValue);
                var ownerId = Convert.ToInt64(cbOwner.SelectedValue);
                var petId   = Convert.ToInt64(cbPet.SelectedValue);

                Vet   vet   = (Vet)vetService.GetById(vetId);
                Owner owner = (Owner)ownerService.GetById(ownerId);
                Pet   pet   = (Pet)petService.GetById(petId);

                Composition.AddSlice <Owner, Pet>(owner, pet);

                List <ConsultationProduct> consultationProducts = new List <ConsultationProduct>();
                List <ConsultationExam>    consultationExams    = new List <ConsultationExam>();

                currentlyBeingRegistered = new MedicalConsultation(dtScheduleDate.Value, vetId, ownerId, petId, consultationProducts, consultationExams);

                medicalConsultationService.Insert(currentlyBeingRegistered);

                long?medicalConsultationId = medicalConsultationService.GetId(currentlyBeingRegistered);

                if (currentlyBeingPrescribedProducts != null)
                {
                    foreach (ConsultationProduct prescribedProduct in currentlyBeingPrescribedProducts)
                    {
                        ConsultationProduct newEntry = prescribedProduct;
                        newEntry.MedicalConsultationId = medicalConsultationId;
                        consultationProductService.Insert(newEntry);
                    }
                }

                if (currentlyBeingPrescribedExams != null)
                {
                    foreach (ConsultationExam prescribedExam in currentlyBeingPrescribedExams)
                    {
                        ConsultationExam newEntry = prescribedExam;
                        newEntry.MedicalConsultationId = medicalConsultationId;
                        consultationExamService.Insert(newEntry);
                    }
                }

                resetForm();

                refreshDataGridView();
                refreshDataGridViewPrescriptedExams();
                refreshDataGridViewPrescriptedProducts();
            }
        }
Ejemplo n.º 4
0
        public async Task CreateMedicalReportService_ShouldReturnError_WhenReportIsInvalid()
        {
            var creatorId = Guid.NewGuid();
            var mcId      = Guid.NewGuid();
            var report    = "mockReport";
            var dto       = new DtoCreateMedicalReportInput
            {
                MedicalConsultationId = mcId,
                Report = report
            };
            MedicalConsultation invalidMc = null;

            _mcRepository.Setup(x => x.GetById(mcId)).ReturnsAsync(invalidMc);

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

            Assert.Equal(HttpStatusCode.BadRequest, response.Status);
        }
Ejemplo n.º 5
0
        private void loadMedicalConsultationData(MedicalConsultation medicalConsultation)
        {
            currentlyBeingPrescribedExams    = (List <ConsultationExam>)consultationExamService.ShowAll(medicalConsultation);
            currentlyBeingPrescribedProducts = (List <ConsultationProduct>)consultationProductService.ShowAll(medicalConsultation);

            refreshDataGridViewPrescriptedExams();
            refreshDataGridViewPrescriptedProducts();

            txtId.Text = Convert.ToString(medicalConsultation.MedicalConsultationId).Trim();

            cbVet.SelectedValue = 0;
            cbVet.SelectedValue = medicalConsultation.VetId;

            cbOwner.SelectedValue = 0;
            cbOwner.SelectedValue = medicalConsultation.OwnerId;

            cbPet.SelectedValue = 0;
            cbPet.SelectedValue = medicalConsultation.PetId;
        }
Ejemplo n.º 6
0
        public async Task CreateMedicalReportService_ShouldReturnSuccess_WhenReportIsValid()
        {
            var creatorId = Guid.NewGuid();
            var mcId      = Guid.NewGuid();
            var report    = "mockReport";
            var dto       = new DtoCreateMedicalReportInput
            {
                MedicalConsultationId = mcId,
                Report = report
            };
            var mc = new MedicalConsultation {
                Id = mcId
            };

            _mcRepository.Setup(x => x.GetById(mcId)).ReturnsAsync(mc);

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

            Assert.Equal(HttpStatusCode.OK, response.Status);
        }
Ejemplo n.º 7
0
        private void resetForm()
        {
            txtId.Clear();
            dtScheduleDate.Value  = DateTime.Today;
            cbVet.SelectedIndex   = 0;
            cbOwner.SelectedIndex = 0;
            cbPet.SelectedIndex   = 0;

            currentlyBeingRegistered = null;

            currentlyBeingPrescribedProducts = null;
            refreshDataGridViewPrescriptedProducts();

            currentlyBeingPrescribedExams = null;
            refreshDataGridViewPrescriptedExams();

            resetFormPrescriptProduct();
            resetFormPrescriptExam();

            cbVet.BackColor   = DefaultBackColor;
            cbOwner.BackColor = DefaultBackColor;
            cbPet.BackColor   = DefaultBackColor;
        }
Ejemplo n.º 8
0
        public async Task ScheduleExamService_ShouldReturnError_WhenExamIsInvalid()
        {
            var mcId = Guid.NewGuid();
            var meId = Guid.NewGuid();
            var dto  = new DtoScheduleExamInput
            {
                MedicalConsultationId = mcId,
                MedicalEquipamentId   = meId,
                ExamDate = DateTime.Now.AddDays(-1)
            };
            var mc = new MedicalConsultation {
                Id = mcId
            };
            var me = new MedicalEquipament {
                Id = meId
            };

            _mcRepository.Setup(x => x.GetById(mcId)).ReturnsAsync(mc);
            _meRepository.Setup(x => x.GetById(meId)).ReturnsAsync(me);

            var response = await _service.Execute(dto);

            Assert.Equal(HttpStatusCode.BadRequest, response.Status);
        }
 public IList <ConsultationExam> ShowAll(MedicalConsultation medicalConsultation)
 {
     return(consultationExamDAL.ShowAll(medicalConsultation));
 }
Ejemplo n.º 10
0
        private void btnAlter_Click(object sender, EventArgs e)
        {
            if (txtId.Text.Trim().Equals(String.Empty))
            {
                MessageBox.Show("A caixa de Id não deve estar vazia, selecione uma consulta antes de alterar.");
                return;
            }
            else if (allFullfilled())
            {
                currentlyBeingRegistered = new MedicalConsultation();

                var vetId   = Convert.ToInt64(cbVet.SelectedValue);
                var ownerId = Convert.ToInt64(cbOwner.SelectedValue);
                var petId   = Convert.ToInt64(cbPet.SelectedValue);

                Vet   vet   = (Vet)vetService.GetById(vetId);
                Owner owner = (Owner)ownerService.GetById(ownerId);
                Pet   pet   = (Pet)petService.GetById(petId);

                long?medicalConsultationId = Convert.ToInt64(txtId.Text);

                Composition.AddSlice <Owner, Pet>(owner, pet);

                List <ConsultationProduct> consultationProducts = new List <ConsultationProduct>();
                List <ConsultationExam>    consultationExams    = new List <ConsultationExam>();

                currentlyBeingRegistered = new MedicalConsultation(dtScheduleDate.Value, vetId, ownerId, petId, consultationProducts, consultationExams)
                {
                    MedicalConsultationId = medicalConsultationId
                };

                if (currentlyBeingPrescribedProducts != null)
                {
                    foreach (ConsultationProduct prescribedProduct in currentlyBeingPrescribedProducts)
                    {
                        ConsultationProduct newEntry = prescribedProduct;
                        newEntry.MedicalConsultationId = medicalConsultationId;
                        //se já não estiver registrado
                        if (newEntry.ConsultationProductId == null)
                        {
                            consultationProductService.Insert(newEntry);
                        }
                    }
                }

                if (currentlyBeingPrescribedExams != null)
                {
                    foreach (ConsultationExam prescribedExam in currentlyBeingPrescribedExams)
                    {
                        ConsultationExam newEntry = prescribedExam;
                        newEntry.MedicalConsultationId = medicalConsultationId;
                        //se já não estiver registrado
                        if (newEntry.ConsultationExamId == null)
                        {
                            consultationExamService.Insert(newEntry);
                        }
                    }
                }

                medicalConsultationService.Alter(currentlyBeingRegistered);

                refreshDataGridView();
                refreshDataGridViewPrescriptedExams();
                refreshDataGridViewPrescriptedProducts();

                resetForm();
            }
        }
Ejemplo n.º 11
0
 public IList <ConsultationProduct> ShowAll(MedicalConsultation medicalConsultation)
 {
     return(consultationProductDAL.ShowAll(medicalConsultation));
 }