Ejemplo n.º 1
0
 public void ChangeConditionDetails(DateTime onsetDate, DateTime?outcomeDate, Outcome outcome, TreatmentOutcome treatmentOutcome, string caseNumber, string comments)
 {
     OnsetDate        = onsetDate;
     OutcomeDate      = outcomeDate;
     Outcome          = outcome;
     TreatmentOutcome = treatmentOutcome;
     CaseNumber       = caseNumber;
     Comments         = comments;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void ChangeConditionDetails(int patientConditionId, int sourceTerminologyMedDraId, DateTime startDate, DateTime?outcomeDate, Outcome outcome, TreatmentOutcome treatmentOutcome, string caseNumber, string comments)
        {
            var patientCondition = PatientConditions.SingleOrDefault(t => t.Id == patientConditionId);

            if (patientCondition == null)
            {
                throw new KeyNotFoundException($"Unable to locate condition {patientConditionId} on patient {Id}");
            }

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

            if (outcomeDate.HasValue)
            {
                if (outcomeDate < DateOfBirth)
                {
                    throw new DomainException("Outcome Date should be after Date Of Birth");
                }
            }

            if (CheckConditionStartDateAgainstStartDateWithNoEndDate(sourceTerminologyMedDraId, startDate, patientConditionId))
            {
                throw new DomainException("Duplication of condition. Please check condition start and outcome dates");
            }
            else
            {
                if (CheckConditionStartDateWithinRange(sourceTerminologyMedDraId, startDate, patientConditionId))
                {
                    throw new DomainException("Duplication of condition. Please check condition start and outcome dates");
                }
                else
                {
                    if (outcomeDate.HasValue)
                    {
                        if (CheckConditionStartDateWithNoEndDateBeforeStart(sourceTerminologyMedDraId, startDate, patientConditionId))
                        {
                            throw new DomainException("Duplication of condition. Please check condition start and outcome dates");
                        }
                    }
                }
            }

            if (outcomeDate.HasValue)
            {
                if (CheckConditionEndDateAgainstStartDateWithNoEndDate(sourceTerminologyMedDraId, outcomeDate.Value, patientConditionId))
                {
                    throw new DomainException("Duplication of condition. Please check condition start and outcome dates");
                }
                else
                {
                    if (CheckConditionEndDateWithinRange(sourceTerminologyMedDraId, outcomeDate.Value, patientConditionId))
                    {
                        throw new DomainException("Duplication of condition. Please check condition start and outcome dates");
                    }
                }
            }

            patientCondition.ChangeConditionDetails(startDate, outcomeDate, outcome, treatmentOutcome, caseNumber, comments);
        }