public PatientEventSummary GetEventSummary() { var seriesCount = 0; var nonSeriesCount = 0; IExtendable clinicalEventExtended; foreach (PatientClinicalEvent clinicalEvent in PatientClinicalEvents.Where(pce => pce.Archived == false)) { clinicalEventExtended = clinicalEvent; var value = clinicalEventExtended.GetAttributeValue("Is the adverse event serious?").ToString(); if (value == "1") { seriesCount += 1; } else { nonSeriesCount += 1; } } var model = new PatientEventSummary() { PatientId = Id, NonSeriesEventCount = nonSeriesCount, SeriesEventCount = seriesCount }; return(model); }
public void ArchiveClinicalEvent(int patientClinicalEventId, string reason, User user) { var patientClinicalEvent = PatientClinicalEvents.SingleOrDefault(t => t.Id == patientClinicalEventId); if (patientClinicalEvent == null) { throw new KeyNotFoundException($"Unable to locate clinical event {patientClinicalEventId} for patient {Id}"); } patientClinicalEvent.Archive(user, reason); }
public bool HasClinicalData() { var hasData = false; if (PatientClinicalEvents.Count() > 0 || PatientConditions.Count() > 0 || PatientLabTests.Count() > 0 || PatientMedications.Count() > 0 || Encounters.Count() > 0) { hasData = true; } ; return(hasData); }
private Boolean CheckEventOnsetDateWithNoResolutionDateBeforeOnset(int sourceTerminologyMedDraId, DateTime onsetDate, long patientClinicalEventId) { if (patientClinicalEventId > 0) { return(PatientClinicalEvents .OrderBy(pc => pc.OnsetDate) .Where(pc => pc.Id != patientClinicalEventId && pc.SourceTerminologyMedDra?.Id == sourceTerminologyMedDraId && onsetDate < pc.OnsetDate && pc.Archived == false) .Any()); } else { return(PatientClinicalEvents .OrderBy(pc => pc.OnsetDate) .Where(pc => pc.SourceTerminologyMedDra?.Id == sourceTerminologyMedDraId && onsetDate < pc.OnsetDate && pc.Archived == false) .Any()); } }
public void ChangeClinicalEventDetails(int patientClinicalEventId, DateTime?onsetDate, DateTime?resolutionDate, TerminologyMedDra sourceTerminology, string sourceDescription) { var patientClinicalEvent = PatientClinicalEvents.SingleOrDefault(t => t.Id == patientClinicalEventId); if (patientClinicalEvent == null) { throw new KeyNotFoundException($"Unable to locate clinical event {patientClinicalEventId} on patient {Id}"); } if (DateOfBirth.HasValue && onsetDate.HasValue) { if (onsetDate.Value.Date < DateOfBirth.Value.Date) { throw new DomainException("Onset Date should be after patient Date Of Birth"); } } if (DateOfBirth.HasValue && resolutionDate.HasValue) { if (resolutionDate.Value.Date < DateOfBirth.Value.Date) { throw new DomainException("Resolution Date should be after Date Of Birth"); } } if (sourceTerminology != null && onsetDate.HasValue) { if (CheckEventOnsetDateAgainstOnsetDateWithNoResolutionDate(sourceTerminology.Id, onsetDate.Value, patientClinicalEventId)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (CheckEventOnsetDateWithinRange(sourceTerminology.Id, onsetDate.Value, patientClinicalEventId)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (resolutionDate.HasValue) { if (CheckEventOnsetDateWithNoResolutionDateBeforeOnset(sourceTerminology.Id, onsetDate.Value, patientClinicalEventId)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } } } } // Check clinical event overlapping - RESOLUTION DATE if (resolutionDate.HasValue) { if (CheckEventResolutionDateAgainstOnsetDateWithNoResolutionDate(sourceTerminology.Id, resolutionDate.Value, patientClinicalEventId)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (CheckEventResolutionDateWithinRange(sourceTerminology.Id, resolutionDate.Value, patientClinicalEventId)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } } } } patientClinicalEvent.ChangeDetails(onsetDate, resolutionDate, sourceTerminology, sourceDescription); }
public PatientClinicalEvent AddClinicalEvent(DateTime?onsetDate, DateTime?resolutionDate, TerminologyMedDra sourceTerminology, string sourceDescription) { if (DateOfBirth.HasValue && onsetDate.HasValue) { if (onsetDate.Value.Date < DateOfBirth.Value.Date) { throw new DomainException("Onset Date should be after patient Date Of Birth"); } } if (DateOfBirth.HasValue && resolutionDate.HasValue) { if (resolutionDate.Value.Date < DateOfBirth.Value.Date) { throw new DomainException("Resolution Date should be after Date Of Birth"); } } if (sourceTerminology != null && onsetDate.HasValue) { if (CheckEventOnsetDateAgainstOnsetDateWithNoResolutionDate(sourceTerminology.Id, onsetDate.Value, 0)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (CheckEventOnsetDateWithinRange(sourceTerminology.Id, onsetDate.Value, 0)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (resolutionDate.HasValue) { if (CheckEventOnsetDateWithNoResolutionDateBeforeOnset(sourceTerminology.Id, onsetDate.Value, 0)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } } } } // Check clinical event overlapping - RESOLUTION DATE if (resolutionDate.HasValue) { if (CheckEventResolutionDateAgainstOnsetDateWithNoResolutionDate(sourceTerminology.Id, resolutionDate.Value, 0)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } else { if (CheckEventResolutionDateWithinRange(sourceTerminology.Id, resolutionDate.Value, 0)) { throw new DomainException("Duplication of adverse event. Please check onset and resolution dates"); } } } } var newPatientClinicalEvent = new PatientClinicalEvent(onsetDate, resolutionDate, sourceTerminology, sourceDescription); PatientClinicalEvents.Add(newPatientClinicalEvent); return(newPatientClinicalEvent); }