public void ChangeDetails(DateTime?onsetDate, DateTime?resolutionDate, TerminologyMedDra sourceTerminology, string sourceDescription) { OnsetDate = onsetDate; ResolutionDate = resolutionDate; SourceTerminologyMedDra = sourceTerminology; SourceTerminologyMedDraId = sourceTerminology?.Id; SourceDescription = sourceDescription; }
public PatientClinicalEvent(DateTime?onsetDate, DateTime?resolutionDate, TerminologyMedDra sourceTerminology, string sourceDescription) { PatientClinicalEventGuid = Guid.NewGuid(); Archived = false; OnsetDate = onsetDate; ResolutionDate = resolutionDate; if (sourceTerminology != null) { SourceTerminologyMedDra = sourceTerminology; SourceTerminologyMedDraId = sourceTerminology.Id; } SourceDescription = sourceDescription; }
public PatientCondition AddOrUpdatePatientCondition(long id, TerminologyMedDra sourceTerm, DateTime onsetDate, DateTime?outComeDate, Outcome outcome, TreatmentOutcome treatmentOutcome, string caseNumber, string comments, string conditionSource, PatientStatus deceasedStatus) { PatientCondition patientCondition = null; if (id == 0) { patientCondition = new PatientCondition { ConditionSource = conditionSource, TerminologyMedDra = sourceTerm, OnsetDate = onsetDate, OutcomeDate = outComeDate, Outcome = outcome, TreatmentOutcome = treatmentOutcome, CaseNumber = caseNumber, Comments = comments }; PatientConditions.Add(patientCondition); } // Has person died if (outcome?.Description == "Fatal" && GetCurrentStatus()?.PatientStatus.Description != "Died") { // set patient status to deceased in patient history PatientStatusHistories.Add(new PatientStatusHistory() { EffectiveDate = outComeDate ?? DateTime.Now, //set effective date to outcome date have set it to use todays day if null but this will not happen as autosetToDeceased will only become true when an end date is supplied first Comments = $"Marked as deceased through Patient Condition ({sourceTerm.DisplayName})", PatientStatus = deceasedStatus }); } return(patientCondition); }
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); }