public void GetTotalSpendPerPostcode_DictionaryReturnedFromDA_DictionaryReturned()
        {
            // Create dictionary to be returned
            regionSpends = new Dictionary<string, decimal>
                               {
                                   { Region.EastMidlands.ToString(), 5M },
                                   { Region.EastOfEngland.ToString(), 6M }
                               };
            // Mock query
            query.Setup(q => q.Result).Returns(regionSpends);
            QueryFactory.Setup(f => f.CalcTotalSpendPerPostcode(Practices)).Returns(query.Object);
            // Mock reader
            PrescriptionsReader.Setup(r => r.ExecuteQuery(query.Object));
            // Instantiate service
            PrescriptionsService = new PrescriptionsService(Practices, PrescriptionsReader.Object, QueryFactory.Object);

            // Call method
            var result = PrescriptionsService.GetTotalSpendPerPostcode();

            // Check data returned unchanged
            Assert.IsTrue(result[Region.EastMidlands.ToString()] == 5M && result[Region.EastOfEngland.ToString()] == 6M);
            Assert.AreEqual(regionSpends.Count, 2);
            // Check reader was called
            PrescriptionsReader.VerifyAll();
        }
        public void GetAverageActCostPerRegion_ValidBnfCodeSupplied_CorrectResultsReturned()
        {
            // Mock the queries list
            decimal queryReturnValue = 0M;
            foreach (var r in Region.All)
            {
                var query = new Mock<ICalcAvgCostByCodeByRegion>();
                query.Setup(q => q.Region).Returns(r);
                query.Setup(q => q.Result).Returns(queryReturnValue++);
                QueryFactory.Setup(
                    f => f.CalcAvgCostByCodeByRegion(Data.BnfCode1, It.Is<Region>(m => m.Equals(r)), Practices))
                    .Returns(query.Object);
            }
            // Mock reader
            PrescriptionsReader.Setup(r => r.ExecuteQuery(It.IsAny<List<ICalcAvgCostByCodeByRegion>>()));
            // Instantiate service
            PrescriptionsService = new PrescriptionsService(Practices, PrescriptionsReader.Object, QueryFactory.Object);

            // Call method
            var result = PrescriptionsService.GetAverageActCostPerRegion(Data.BnfCode1);

            // Check returned list is correct
            decimal expectedReturnValue = 0M;
            Assert.AreEqual(result.Count(r => r.Value == expectedReturnValue++), Region.All.Count);
            Assert.AreEqual(result.Count, Region.All.Count);
            // Check DA called
            // PrescriptionsReader.VerifyAll();
        }
Exemplo n.º 3
0
        private static void Process(PracticesService practicesService, PrescriptionsService prescriptionService)
        {

            // Find out how many practices there are in London
            Console.WriteLine("How many practices are in London?");
            int practicesInLondon = practicesService.GetPracticeCountByRegion(Region.London);
            Console.WriteLine(practicesInLondon);

            // Find out the average national cost of a peppermint oil prescription
            Console.WriteLine("What was the average actual cost of all peppermint oil prescriptions?");
            decimal averagePepermintOilCost = prescriptionService.GetAverageActCost("0102000T0");
            Console.WriteLine(averagePepermintOilCost.ToString("£0.00"));

            // Find the 5 highest spending postcodes
            Console.WriteLine("Which 5 post codes have the highest actual spend, and how much did each spend in total?");
            // Get postcode spends
            var totalPostcodeSpends = prescriptionService.GetTotalSpendPerPostcode();
            // Get top 5
            var topFive = totalPostcodeSpends.OrderByDescending(p => p.Value).Take(5).ToList();
            // Write to console
            topFive.ForEach(p => Console.WriteLine(p.Key + " " + p.Value.ToString("£0.00")));

            // Find average price of Flucloxacillin
            Console.WriteLine(
                "For each region, what was the average price per prescription of Flucloxacillin,"
                + " and how did this vary from the national mean?");
            // Get average cost per region
            var averageFlucloxacillinRegions = prescriptionService.GetAverageActCostPerRegion("0501012G0");
            // Get average cost for country
            decimal averageFlucloxacillinNational = prescriptionService.GetAverageActCost("0501012G0");
            // Write to console
            Console.WriteLine("National: " + averageFlucloxacillinNational.ToString("£0.00"));
            averageFlucloxacillinRegions.ForEach(
                r =>
                Console.WriteLine(
                    r.Key + " " + r.Value.ToString("£0.00") + "; "
                    + (r.Value - averageFlucloxacillinNational).ToString("£0.00")));

            // Find by region the percentage difference between the NIC and Act Cost for
            Console.WriteLine(
                "For each region for Simeticone, what was the average Actual Cost "
                + "as a percentage of the average Net Ingredient Cost?");
            var actPercentageOfNic = prescriptionService.GetFractionActCostOfNicByRegion("0103050E0");
            actPercentageOfNic.ForEach(r => Console.WriteLine(r.Key + " " + r.Value.ToString("0.00%")));

            Console.ReadLine();
        }
        public void SavePrescription(string patientFullName, string doctorFullName, List <Tuple <string, int> > medicineBoxNamesAndQuantities)
        {
            int patientId                    = PatientService.GetIdByFullName(patientFullName);
            int doctorDiplomaNumber          = DoctorService.GetDiplomaNumberByFullName(doctorFullName);
            List <MedicineBox> medicineBoxes = new List <MedicineBox>(medicineBoxNamesAndQuantities.Count);

            foreach (var medicineBoxNameAndQuantity in medicineBoxNamesAndQuantities)
            {
                medicineBoxes.AddRange(MedicineBoxService.GetUnsoldMedicineBoxesByMedicineName(medicineBoxNameAndQuantity.Item1, medicineBoxNameAndQuantity.Item2));
            }

            var newPrescriptionId = PrescriptionsService.SaveNewAndGetPrescriptionId(patientId, doctorDiplomaNumber);

            foreach (var medicineBox in medicineBoxes)
            {
                MedicineBoxService.UpdateMedicineBoxPrescriptionId(medicineBox, newPrescriptionId);
            }
        }
        public void GetAverageActCost_ValidBnfCodeGiven_CorrectAverageCostCalculated()
        {
            // Mock query
            query.Setup(q => q.Result).Returns(5M);
            QueryFactory.Setup(f => f.CalcAvgCostByCode(Data.BnfCode1)).Returns(query.Object);
            // Mock reader
            PrescriptionsReader.Setup(r => r.ExecuteQuery(query.Object));
            // Create instance of service
            PrescriptionsService = new PrescriptionsService(GetPractices(), PrescriptionsReader.Object, QueryFactory.Object);

            // Call service
            var result = PrescriptionsService.GetAverageActCost(Data.BnfCode1);

            // Ensure result is as returned by query
            Assert.AreEqual(result, 5M);
            // Ensure query execution was called
            PrescriptionsReader.VerifyAll();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Performing startup...");
            //Create instances of practice service and prescription service
            var practicesService = new PracticesService();
            var prescriptionService = new PrescriptionsService(practicesService.Practices);
            Console.WriteLine("Startup completed.");
            if (askBooleanQuestion("Process all at once?"))
            {
                ProcessOnce(practicesService, prescriptionService);
            }
            else
            {
                Process(practicesService, prescriptionService);
            }

            Console.ReadLine();
        }
        public List <GivenProduct> GetLastGivenProductsForThePharmacy()
        {
            //Get List of Sale and List of Prescriptions
            var sales         = SalesService.GetLastSalesForThePharmacy(count: 30);
            var prescriptions = PrescriptionsService.GetLastPrescriptionsForThePharmacy(count: 30);

            //Merge Sales and List to Single List
            var salesOrPrescription = MergeSalesAndPrescriptions(sales, prescriptions);

            //Sort the List
            var sortedSalesOrPrescriptions = SortSalesOrPrescriptionByDate(salesOrPrescription);

            //Change type to GivenProduct from Sorted SalesOrPrescriptions List
            var givenProducts = new List <GivenProduct>(30);

            for (int index = 0; index < givenProducts.Capacity; index++)
            {
                givenProducts.Add(new GivenProduct(index + 1, sortedSalesOrPrescriptions[index]));
            }

            return(givenProducts);
        }
Exemplo n.º 8
0
        private void ShowSelectedInfo()
        {
            if (listViewSales.SelectedItems.Count == 0)
            {
                return;
            }

            var type = listViewSales.SelectedItems[0].SubItems[1].Text;
            var id   = int.Parse(listViewSales.SelectedItems[0].Tag.ToString());

            if (type.Equals("Sale"))
            {
                var showSaleInfo = new ShowSaleInfo(SalesService.GetSaleById(id));
                showSaleInfo.ShowDialog(this);
                showSaleInfo.Dispose();
            }
            else
            {
                var showPrescriptionInfo = new ShowPrescriptionInfo(PrescriptionsService.GetPrescriptionById(id));
                showPrescriptionInfo.ShowDialog(this);
                showPrescriptionInfo.Dispose();
            }
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            using (HealthDbContext db = new HealthDbContext())
            {
                //db.Database.EnsureDeleted();
                //db.Database.EnsureCreated();

                db.Database.Migrate();

                //Seed seed = new Seed();
                //seed.SeedDataBase(db);

                IBloodsService           bloodsService                = new BloodsService(db);
                IAddressesService        addressesService             = new AddressesService(db);
                IPhonesService           phonesService                = new PhonesService(db);
                IEmailsService           emailsService                = new EmailsService(db);
                IRelativesService        relativesService             = new RelativesService(db, addressesService, phonesService, emailsService);
                IDoctorsService          doctorsService               = new DoctorsService(db, addressesService, phonesService, emailsService);
                IPersonsService          personsService               = new PersonsService(db, addressesService, phonesService, emailsService, relativesService);
                IVaccinesService         vaccinesService              = new VaccinesService(db);
                IAllergiesService        allergiesService             = new AllergiesService(db);
                IChronicDiseasesService  chronicDiseasesService       = new ChronicDiseasesService(db);
                IPersonDiseasesService   personVaccinesService        = new PersonVaccinesService(db, vaccinesService);
                IPersonDiseasesService   personAlleriesService        = new PersonAllergiesService(db, allergiesService);
                IPersonDiseasesService   personChronicDiseasesService = new PersonChronicDiseasesService(db, chronicDiseasesService);
                IMedicinesService        medicinesService             = new MedicinesService(db);
                IPrescriptionsService    prescriptionsService         = new PrescriptionsService(db, medicinesService);
                IReferralsService        referralsService             = new ReferralsService(db);
                ITreatmentsService       treatmentsService            = new TreatmentsService(db);
                IExaminationsService     examinationsService          = new ExaminationsService(db);
                IHospitalizationsService hospitalizationsService      = new HospitalizationsService(db, examinationsService, treatmentsService);



                #region
                //examinationsService.Add(new ExaminationInputModel()
                //{
                //    Date = "21.09.2019",
                //    Diagnosis = "very sick man",
                //    DoctorId = "bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d",

                //});


                //prescriptionsService.Add("565d1e5a-68df-45ab-8fea-e9d914fc891f");

                //prescriptionsService.AddMedicine("7db87d46-6d71-4355-a482-95e2bf726465",
                //    new MedicineInputModel()
                //    {
                //        Name = "Mesalazin Unipharm",
                //        DaylyDoze = "250mg"
                //    });

                //examinationsService.AddPrescription("565d1e5a-68df-45ab-8fea-e9d914fc891f", "7db87d46-6d71-4355-a482-95e2bf726465");

                //string referralId = referralsService.Add(new ReferralInputModel()
                //                                    {
                //                                        ExaminationId = "565d1e5a-68df-45ab-8fea-e9d914fc891f",
                //                                        Specialty = "Cardiologist"
                //                                    });

                //examinationsService.AddReferral("565d1e5a-68df-45ab-8fea-e9d914fc891f", referralId);

                //hospitalizationsService.AddExamination("22a65132-1949-4e13-bbbc-35201429d0fb", "565d1e5a-68df-45ab-8fea-e9d914fc891f");
                //hospitalizationsService.AddTreatment("22a65132-1949-4e13-bbbc-35201429d0fb", "44f6112f-542a-4eaf-a0b9-5685441f3937");


                //hospitalizationsService.Add(new HospitalizationInputModel()
                //{
                //    EnterDate = "20.08.2019",
                //    DischargeDate = "25.08.2019",
                //    HospitalId = 1,
                //    PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d"
                //});

                //hospitalizationsService.Add(new HospitalizationInputModel()
                //{
                //    EnterDate = "20.09.2019",
                //    HospitalId = 1,
                //    PersonId = "9c591451-96e6-4dff-a225-32f092c7b56d"
                //});


                //treatmentsService.Add(new TreatmentInputModel()
                //{
                //    Description = "knee surgery...",
                //    Date = "21.09.2019",
                //    DoctorId = "bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    HospitalizationId = "22a65132-1949-4e13-bbbc-35201429d0fb"
                //});

                //doctorsService.Add(new DoctorInputModel()
                //{
                //    FirstName = "Boiko",
                //    LastName = "Penkov",
                //    HospitalId = 1,
                //    Specialty = "Cardiologist",
                //    Address = new AddressInputModel()
                //    {
                //        Town = "Sofia",
                //        Street = "ul. Alen Mak 1"
                //    },
                //    Phone = new PhoneInputModel()
                //    {
                //        PhoneNumber = "0888989898"
                //    },
                //    Email = new EmailAddressInputModel()
                //    {
                //        Email = "*****@*****.**"
                //    },
                //});



                //personChronicDiseasesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Parkinson disease",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //personChronicDiseasesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Parkinson disease new",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //personAlleriesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Wheat[26]",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //personAlleriesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Wheat[26] (1)",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //personVaccinesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Strontium chloride",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //personVaccinesService.AddPersonDiseaseInfo("bedfa8a0-46d7-4369-8f85-fe3b1be57095",
                //    "9c591451-96e6-4dff-a225-32f092c7b56d", new PersonDiseaseInfoInputModel()
                //    {
                //        Name = "Strontium chloride new",
                //        DiagnosedOn = "13.10.1973"
                //    });

                //PersonInputModel personInputModel = new PersonInputModel()
                //{
                //    FirstName = "Kamen",
                //    MiddleName = "Dimitrov",
                //    LastName = "Pankov",
                //    PersonalNumber = "7310136488",
                //    BloodId = bloodsService.GetBloodId(BloodType.A, RhD.Negative),
                //    HasHealthInsurance = true,
                //    Address = new AddressInputModel()
                //    {
                //        Town = "Sofia",
                //        Street = "Lerin 45"
                //    }
                //};

                //personsService.Add(personInputModel);

                //Person person = personsService.GetPerson("9c591451-96e6-4dff-a225-32f092c7b56d");

                //personsService.AddPhone("9c591451-96e6-4dff-a225-32f092c7b56d", new PhoneInputModel()
                //{
                //    PhoneNumber = "0888086820"
                //});

                //personsService.AddEmail("9c591451-96e6-4dff-a225-32f092c7b56d", new EmailAddressInputModel()
                //{
                //    Email = "*****@*****.**"
                //});

                //personsService.AddRelative("9c591451-96e6-4dff-a225-32f092c7b56d",
                //    new RelativeInputModel()
                //    {
                //        FirstName = "Desi",
                //        MiddleName = "Svetlozarova",
                //        LastName = "Velkovska",
                //        Address = new AddressInputModel()
                //        {
                //            Town = "Sofia",
                //            Street = "ul. Dobrudjanski krai 1"
                //        },
                //        Phone = new PhoneInputModel()
                //        {
                //            PhoneNumber = "0888127876"
                //        },
                //        Email = new EmailAddressInputModel()
                //        {
                //            Email = "*****@*****.**"
                //        },
                //        RelativeType = "spouse"
                //    });


                #endregion
            }
        }