public void ShouldGetSingleMedication()
        {
            // Setup
            Mock <IMedicationService> serviceMock = new Mock <IMedicationService>();

            serviceMock.Setup(s => s.GetMedications(It.IsAny <List <string> >())).Returns(new Dictionary <string, MedicationResult>());

            string drugIdentifier           = "000001";
            string paddedDin                = drugIdentifier.PadLeft(8, '0');
            MedicationController controller = new MedicationController(serviceMock.Object);

            // Act
            RequestResult <MedicationResult> actual = controller.GetMedication(drugIdentifier);

            // Verify
            serviceMock.Verify(s => s.GetMedications(new List <string> {
                paddedDin
            }), Times.Once());
            Assert.True(actual.TotalResultCount == 0);
        }
示例#2
0
        public void ShouldGetSingleMedication()
        {
            // Setup
            string drugIdentifier = "00000001";
            Dictionary <string, MedicationResult> expectedResult = new Dictionary <string, MedicationResult>()
            {
                {
                    drugIdentifier,
                    new MedicationResult()
                    {
                        DIN         = drugIdentifier,
                        FederalData = new FederalDrugSource()
                        {
                            DrugProduct = new DrugProduct()
                            {
                                DrugCode = drugIdentifier,
                            }
                        }
                    }
                },
            };

            Mock <IMedicationService> serviceMock = new Mock <IMedicationService>();

            serviceMock.Setup(s => s.GetMedications(It.IsAny <List <string> >())).Returns(expectedResult);


            string paddedDin = drugIdentifier.PadLeft(8, '0');
            MedicationController controller = new MedicationController(serviceMock.Object);

            // Act
            RequestResult <MedicationResult> actual = controller.GetMedication(drugIdentifier);

            // Verify
            serviceMock.Verify(s => s.GetMedications(new List <string> {
                paddedDin
            }), Times.Once());
            Assert.True(actual.TotalResultCount == 1);
        }
示例#3
0
        private void DeleteTherapy_Click(object sender, RoutedEventArgs e)
        {
            if (selectedTherapy == null)
            {
                ErrorMessage.Visibility = Visibility.Visible;
                Error.Text = ERROR_DELETE;
                return;
            }

            ModelHCI.MedicalRecordHCI record = Informations.currentRecord;
            var     recordToUpdate           = record.MedicalRecord;
            Therapy therapyToDelete          = null;

            foreach (Therapy therapy in recordToUpdate.Therapies)
            {
                Medication med = medicationController.GetMedication(therapy.Medication.MedId);
                if (med.Med.Equals(selectedTherapy.medication.medication.Med))
                {
                    therapyToDelete = therapy;
                }
            }
            if (therapyToDelete != null)
            {
                recordToUpdate.Therapies.Remove(therapyToDelete);
            }

            var recordUpdate = medicalRecordController.GetMedicalRecord(recordToUpdate.IdRecord);

            if (therapyToDelete != null)
            {
                recordUpdate.Therapies.Remove(therapyToDelete);
            }
            Informations.currentRecord.MedicalRecord = medicalRecordController.UpdateRecord(recordToUpdate);

            setListBoxes();
        }
示例#4
0
        public void SetValues()
        {
            if (currentRecord != null)
            {
                List <ModelHCI.AllergensHCI> source = new List <ModelHCI.AllergensHCI>();

                foreach (Allergens allergens in currentRecord.MedicalRecord.Allergies)
                {
                    source.Add(new ModelHCI.AllergensHCI()
                    {
                        allergen = allergens.Allergen, allergens = allergens
                    });
                }

                AllergiesList.ItemsSource = source;

                List <ModelHCI.TherapyHCI> therapies = new List <ModelHCI.TherapyHCI>();

                foreach (Therapy therapy in currentRecord.MedicalRecord.Therapies)
                {
                    Medication medication = medicationController.GetMedication(therapy.Medication.MedId);
                    therapies.Add(new ModelHCI.TherapyHCI()
                    {
                        medication = new ModelHCI.MedicationHCI()
                        {
                            name       = medication.Med,
                            medication = medication
                        },
                        therapy = therapy
                    });
                }

                TherapyList.ItemsSource = therapies;

                List <ModelHCI.DiagnosisHCI> ilnesses = new List <ModelHCI.DiagnosisHCI>();

                foreach (FamilyIllnessHistory therapy in currentRecord.MedicalRecord.FamilyIllnessHistory)
                {
                    foreach (Diagnosis diagnosis in therapy.Diagnosis)
                    {
                        Diagnosis diag = diagnosisController.GetDiagnosis(diagnosis.Code);
                        ilnesses.Add(new ModelHCI.DiagnosisHCI()
                        {
                            name = diag.Name, diagnosis = diag
                        });
                    }
                }

                FamilyIllnessHistory.ItemsSource = ilnesses;

                ilnesses = new List <ModelHCI.DiagnosisHCI>();

                foreach (Diagnosis diagnosis1 in currentRecord.MedicalRecord.IllnessHistory)
                {
                    Diagnosis diag = diagnosisController.GetDiagnosis(diagnosis1.Code);
                    ilnesses.Add(new ModelHCI.DiagnosisHCI()
                    {
                        name = diag.Name, diagnosis = diag
                    });
                }

                IllnessHistory.ItemsSource = ilnesses;
            }
        }