Esempio n. 1
0
        public void ArchiveMedication(int patientMedicationId, string reason, User user)
        {
            var patientMedication = PatientMedications.SingleOrDefault(t => t.Id == patientMedicationId);

            if (patientMedication == null)
            {
                throw new KeyNotFoundException($"Unable to locate medication {patientMedicationId} for patient {Id}");
            }

            patientMedication.Archive(user, reason);
        }
Esempio n. 2
0
        public void ChangeMedicationDetails(int patientMedicationId, DateTime startDate, DateTime?endDate, string dose, string doseFrequency, string doseUnit)
        {
            var patientMedication = PatientMedications.SingleOrDefault(t => t.Id == patientMedicationId);

            if (patientMedication == null)
            {
                throw new KeyNotFoundException($"Unable to locate medication {patientMedicationId} on patient {Id}");
            }

            if (DateOfBirth.HasValue)
            {
                if (startDate.Date < DateOfBirth.Value.Date)
                {
                    throw new DomainException("Start Date should be after patient Date Of Birth");
                }
            }

            if (DateOfBirth.HasValue && endDate.HasValue)
            {
                if (endDate.Value.Date < DateOfBirth.Value.Date)
                {
                    throw new DomainException("End Date should be after Date Of Birth");
                }
            }

            if (CheckMedicationStartDateAgainstStartDateWithNoEndDate(patientMedication.Concept.Id, startDate, patientMedicationId))
            {
                throw new DomainException("Duplication of medication. Please check start and end dates");
            }
            else
            {
                if (CheckMedicationStartDateWithinRange(patientMedication.Concept.Id, startDate, patientMedicationId))
                {
                    throw new DomainException("Duplication of medication. Please check start and end dates");
                }
                else
                {
                    if (endDate.HasValue)
                    {
                        if (CheckMedicationStartDateWithNoEndDateBeforeStart(patientMedication.Concept.Id, startDate, patientMedicationId))
                        {
                            throw new DomainException("Duplication of medication. Please check start and end dates");
                        }
                    }
                }
            }

            if (endDate.HasValue)
            {
                if (CheckMedicationEndDateAgainstStartDateWithNoEndDate(patientMedication.Concept.Id, endDate.Value, patientMedicationId))
                {
                    throw new DomainException("Duplication of medication. Please check start and end dates");
                }
                else
                {
                    if (CheckMedicationEndDateWithinRange(patientMedication.Concept.Id, endDate.Value, patientMedicationId))
                    {
                        throw new DomainException("Duplication of medication. Please check start and end dates");
                    }
                }
            }

            patientMedication.ChangeDetails(startDate, endDate, dose, doseFrequency, doseUnit);
        }