public static void Execute(Prescription prescription, PrescriptionDto pDto) { if (prescription.Drug.Generic == "" || prescription.Drug.Route == "" || prescription.Drug.Shape == "") return; _setScenariosVisibility(prescription, pDto); }
public void PrescriptionDtoCanMapToPrescriptionBo() { var pDto = new PrescriptionDto(); pDto.startDate = DateTime.Parse("2011-07-01 12:00:00").ToString(CultureInfo.CurrentCulture); Prescription p = PrescriptionAssembler.AssemblePrescriptionBo(pDto); Assert.AreEqual(p.StartDate, DateTime.Parse("2011-07-01 12:00:00")); }
private static void _setScenariosVisibility(Prescription prescription, PrescriptionDto pDto) { for (int i = 0; i < _scenarios.Length; i++) { _scenarios[i].SetVisibilities(prescription, pDto); } _setSubstanceQuantityVisibility(pDto); }
public void ThatIfDrugGenericRouteAndShapeAreSetSubstanceQuantityIsVisible() { var prescription = Prescription.NewPrescription(); prescription.Drug.Generic = "paracetamol"; prescription.Drug.Route = "rect"; prescription.Drug.Shape = "zetp"; var prescriptionDto = new PrescriptionDto(); PrescriptionVisibility.Execute(prescription, prescriptionDto); Assert.IsTrue(prescriptionDto.substanceQuantity.visible); }
public void ThatIfDrugGenericRouteAndShapeAreNotSetSubstanceQuantityIsNotVisible() { var prescription = Prescription.NewPrescription(); prescription.Drug.Generic = ""; prescription.Drug.Route= ""; prescription.Drug.Shape = ""; var prescriptionDto = new PrescriptionDto(); PrescriptionVisibility.Execute(prescription, prescriptionDto); Assert.IsFalse(prescriptionDto.substanceQuantity.visible); }
public static PrescriptionDto AssemblePrescriptionDto(Prescription prescription) { var prescriptionDto = new PrescriptionDto(); prescriptionDto.startDate = prescription.StartDate.ToString(); prescriptionDto.Id = prescription.Id.ToString(); prescriptionDto.drugGeneric = prescription.Drug.Generic; prescriptionDto.drugRoute = prescription.Drug.Route; prescriptionDto.drugShape = prescription.Drug.Shape; prescriptionDto.prescriptionFrequency = UnitValueDto.AssembleUnitValueDto(prescription.Frequency); prescriptionDto.prescriptionDuration = UnitValueDto.AssembleUnitValueDto(prescription.Duration); prescriptionDto.substanceQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Components[0].Substances[0].Quantity); prescriptionDto.substanceDrugConcentration = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Components[0].Substances[0].DrugConcentration); prescriptionDto.adminQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Quantity); prescriptionDto.adminTotal = UnitValueDto.AssembleUnitValueDto(prescription.Total); prescriptionDto.adminRate = UnitValueDto.AssembleUnitValueDto(prescription.Rate); prescriptionDto.drugQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Drug.Quantity); prescriptionDto.doseQuantity = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Quantity); prescriptionDto.doseTotal = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Total); prescriptionDto.doseRate = UnitValueDto.AssembleUnitValueDto(prescription.Doses[0].Rate); var weightUnitValue = UnitValue.NewUnitValue(); weightUnitValue.Unit = prescription.PatientWeightUnit; weightUnitValue.BaseValue = prescription.PatientWeight; prescriptionDto.patientWeight = UnitValueDto.AssembleUnitValueDto(weightUnitValue); var lengthUnitValue = UnitValue.NewUnitValue(); lengthUnitValue.Unit = prescription.PatientLengthUnit; lengthUnitValue.BaseValue = prescription.PatientLength; prescriptionDto.patientLength = UnitValueDto.AssembleUnitValueDto(lengthUnitValue); prescriptionDto.PID = prescription.PID; prescriptionDto.verbalization = "";// PrescriptionVerbalization.Verbalize(prescription); prescriptionDto.AdminVolume = prescription.AdminVolume; prescriptionDto.DoseVolume = prescription.DoseVolume; var bsa = prescription.PatientBsa; prescriptionDto.patientBSA = new UnitValueDto() { unit = "m2", value = bsa, state = "calculated" }; PrescriptionVisibility.Execute(prescription, prescriptionDto); return prescriptionDto; }
public void ThatVisibilityIsNotExecutedWhenNoShapeIsSet() { var p = Prescription.NewPrescription(); p.Drug.Generic = "paracetamol"; p.Drug.Route = "rect"; p.Drug.Shape = ""; var prescriptionDto = new PrescriptionDto(); Isolate.NonPublic.WhenCalled<PrescriptionVisibility>("Execute").CallOriginal(); PrescriptionVisibility.Execute(p, prescriptionDto); Isolate.Verify.NonPublic.WasNotCalled(typeof(PrescriptionVisibility), "_setScenariosVisibility"); }
public void SetVisibilities(Prescription prescription, PrescriptionDto _prescriptionDto) { if (_scenarioIsTrue(prescription)) { _prescriptionDto.drugQuantity.visible = true; _prescriptionDto.substanceDrugConcentration.visible = true; _prescriptionDto.prescriptionSolution.visible = true; _prescriptionDto.prescriptionOnrequest.visible = true; _prescriptionDto.prescriptionContinuous.visible = true; _prescriptionDto.prescriptionInfusion.visible = true; } }
public static ReadOnlyCollection<PrescriptionDto> GetPrescriptions(string patientId) { if (patientId == "") throw new InvalidIdException(); var prescriptions = Repository.GetPrescriptionsByPatientId(patientId); var prescriptionDtos = new PrescriptionDto[prescriptions.Length]; for (var i = 0; i < prescriptions.Length; i++) prescriptionDtos[i] = PrescriptionAssembler.AssemblePrescriptionDto(prescriptions[i]); return prescriptionDtos.ToList().AsReadOnly(); }
public void SetVisibilities(Prescription prescription, PrescriptionDto _prescriptionDto) { if (_scenarioIsTrue(prescription)) { _prescriptionDto.prescriptionFrequency.visible = true; _prescriptionDto.prescriptionDuration.visible = false; _prescriptionDto.doseQuantity.visible = true; _prescriptionDto.adminQuantity.visible = true; _prescriptionDto.adminTotal.visible = false; _prescriptionDto.doseTotal.visible = false; _prescriptionDto.adminRate.visible = false; _prescriptionDto.doseRate.visible = false; } }
public void PrescriptionDtoShouldMapToDrugBo() { var pDto = new PrescriptionDto(); pDto.drugGeneric = "paracetamol"; pDto.drugRoute = "rect"; pDto.drugShape = "zetp"; Prescription p = PrescriptionAssembler.AssemblePrescriptionBo(pDto); Drug d = p.Drug; Assert.AreEqual(d.Generic, "paracetamol"); Assert.AreEqual(d.Route, "rect"); Assert.AreEqual(d.Shape, "zetp"); }
public static Prescription AssemblePrescriptionBo(PrescriptionDto prescriptionDto) { var prescription = Prescription.NewPrescription(); DateTime dt; if(DateTime.TryParse(prescriptionDto.startDate, out dt)) { prescription.StartDate = dt; } prescription.Drug.Generic = prescriptionDto.drugGeneric; prescription.Drug.Route = prescriptionDto.drugRoute; prescription.Drug.Shape = prescriptionDto.drugShape; prescription.PID = prescriptionDto.PID; prescription.Frequency = UnitValueDto.AssembleUnitValue(prescription.Frequency, prescriptionDto.prescriptionFrequency); prescription.Duration = UnitValueDto.AssembleUnitValue(prescription.Duration, prescriptionDto.prescriptionDuration); prescription.Continuous = (prescriptionDto.prescriptionContinuous.value == "on"); prescription.OnRequest = (prescriptionDto.prescriptionOnrequest.value == "on"); prescription.Solution = (prescriptionDto.prescriptionSolution.value == "on"); prescription.Infusion = (prescriptionDto.prescriptionInfusion.value == "on"); prescription.Drug.Quantity = UnitValueDto.AssembleUnitValue(prescription.Drug.Quantity, prescriptionDto.drugQuantity); prescription.Quantity = UnitValueDto.AssembleUnitValue(prescription.Quantity, prescriptionDto.adminQuantity); prescription.Rate = UnitValueDto.AssembleUnitValue(prescription.Rate, prescriptionDto.adminRate); prescription.Total = UnitValueDto.AssembleUnitValue(prescription.Total, prescriptionDto.adminTotal); prescription.Doses[0].Quantity = UnitValueDto.AssembleUnitValue(prescription.Doses[0].Quantity, prescriptionDto.doseQuantity); prescription.Doses[0].Total = UnitValueDto.AssembleUnitValue(prescription.Doses[0].Total, prescriptionDto.doseTotal); prescription.Doses[0].Rate = UnitValueDto.AssembleUnitValue(prescription.Doses[0].Rate, prescriptionDto.doseRate); prescription.Drug.Components[0].Substances[0].Quantity = UnitValueDto.AssembleUnitValue(prescription.Drug.Components[0].Substances[0].Quantity, prescriptionDto.substanceQuantity); prescription.Drug.Components[0].Substances[0].DrugConcentration = UnitValueDto.AssembleUnitValue(prescription.Drug.Components[0].Substances[0].DrugConcentration, prescriptionDto.substanceDrugConcentration); var weightUnitValue = UnitValueDto.AssembleUnitValue(null, prescriptionDto.patientWeight); prescription.PatientWeightUnit = weightUnitValue.Unit; prescription.PatientWeight = weightUnitValue.BaseValue; var lengthUnitValue = UnitValueDto.AssembleUnitValue(null, prescriptionDto.patientLength); prescription.PatientLengthUnit = lengthUnitValue.Unit; prescription.PatientLength = lengthUnitValue.BaseValue; return prescription; }
public static PrescriptionDto SavePrescription(PrescriptionDto prescriptionDto, string patientId) { var prescription = PrescriptionAssembler.AssemblePrescriptionBo(prescriptionDto); Repository.SavePrescription(prescription, patientId); return PrescriptionAssembler.AssemblePrescriptionDto(prescription); }
public void ThatPrescriptionsServiceCanSavePrescription() { var pDto = new PrescriptionDto(); pDto.drugGeneric = "paracetamol"; pDto.drugRoute = "rect"; pDto.drugShape = "zetp"; pDto.startDate = "2011-07-01 12:00:00"; pDto.substanceQuantity = new UnitValueDto(); pDto.substanceQuantity.unit = "mg"; pDto = PrescriptionService.SavePrescription(pDto, "8697898"); Assert.IsTrue(pDto.Id != Guid.Empty.ToString()); }
public void ThatPrescriptionsServiceCanGetPrescriptions() { var prescriptionDto = new PrescriptionDto(); prescriptionDto.drugGeneric = "paracetamol"; prescriptionDto.drugRoute = "rect"; prescriptionDto.drugShape = "zetp"; PrescriptionService.SavePrescription(prescriptionDto, "0004588"); var prescriptions = PrescriptionService.GetPrescriptions("0004588"); Assert.IsTrue(prescriptions.Count > 0); }
public void ThatPrescriptionsServiceCanGetPrescriptionById() { PatientService.SavePatient("1234567"); var prescriptionDto = new PrescriptionDto(); prescriptionDto.drugGeneric = "paracetamol"; prescriptionDto.drugRoute = "rect"; prescriptionDto.drugShape = "zetp"; PrescriptionService.SavePrescription(prescriptionDto, "1234567"); var prescriptions = PrescriptionService.GetPrescriptions("1234567"); var lastPrescription = prescriptions[0]; var prescription = PrescriptionService.GetPrescriptionById(lastPrescription.Id); Assert.IsTrue(prescription.PID != "" && prescription.Id != Guid.Empty.ToString()); }
public void CreatePrescription() { _prescription = Prescription.NewPrescription(); _prescription.Drug.Generic = "paracetamol"; _prescription.Drug.Shape = "zetp"; _prescription.Drug.Route = "rect"; _prescriptionDto = new PrescriptionDto(); }
private static void _setSubstanceQuantityVisibility(PrescriptionDto pDto) { pDto.substanceQuantity.visible = true; }
public static PrescriptionDto UpdatePrescription(PrescriptionDto prescriptionDto, string patientId) { var prescription = PrescriptionAssembler.AssemblePrescriptionBo(prescriptionDto); var pc = new PrescriptionCalculator(prescription); pc.Calculate(); return PrescriptionAssembler.AssemblePrescriptionDto(prescription); }
public ActionResult UpdatePrescription(string patientId, PrescriptionDto prescriptionDto) { return this.Direct(PrescriptionService.UpdatePrescription(prescriptionDto, patientId)); }