예제 #1
0
파일: Patient.cs 프로젝트: romaner/PViMS
 public PatientCondition GetConditionForGroupAndDate(Condition group, DateTime date)
 {
     if (PatientConditions.Count == 0)
     {
         return(null);
     }
     else
     {
         return(PatientConditions.Where(pc => pc.Archived == false && pc.DateStart <= date && pc.TerminologyMedDra.ConditionMedDras.Any(cm => cm.Condition.Id == group.Id)).OrderByDescending(pc => pc.DateStart).FirstOrDefault());
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
파일: Patient.cs 프로젝트: MSH/PViMS-2
 public PatientCondition GetConditionForGroupAndDate(string condition, DateTime date)
 {
     if (PatientConditions.Count == 0)
     {
         return(null);
     }
     else
     {
         return(PatientConditions.Where(pc => pc.Archived == false && pc.TerminologyMedDra != null)
                .Where(pc => pc.OnsetDate <= date &&
                       pc.TerminologyMedDra.ConditionMedDras.Any(cm => cm.Condition.Description == condition))
                .OrderByDescending(pc => pc.OnsetDate)
                .FirstOrDefault());
     }
 }
예제 #4
0
파일: Patient.cs 프로젝트: MSH/PViMS-2
        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);
        }
예제 #5
0
파일: Patient.cs 프로젝트: MSH/PViMS-2
 private Boolean CheckConditionStartDateWithNoEndDateBeforeStart(int sourceTerminologyMedDraId, DateTime startDate, long patientConditionId)
 {
     if (patientConditionId > 0)
     {
         return(PatientConditions
                .OrderBy(pc => pc.OnsetDate)
                .Where(pc => pc.Id != patientConditionId &&
                       pc.TerminologyMedDra.Id == sourceTerminologyMedDraId &&
                       startDate < pc.OnsetDate &&
                       pc.Archived == false)
                .Any());
     }
     else
     {
         return(PatientConditions
                .OrderBy(pc => pc.OnsetDate)
                .Where(pc => pc.TerminologyMedDra.Id == sourceTerminologyMedDraId &&
                       startDate < pc.OnsetDate &&
                       pc.Archived == false)
                .Any());
     }
 }
예제 #6
0
파일: Patient.cs 프로젝트: MSH/PViMS-2
 private Boolean CheckConditionEndDateWithinRange(int sourceTerminologyMedDraId, DateTime outcomeDate, long patientConditionId)
 {
     if (patientConditionId > 0)
     {
         return(PatientConditions
                .OrderBy(pc => pc.OnsetDate)
                .Where(pc => pc.Id != patientConditionId &&
                       pc.TerminologyMedDra.Id == sourceTerminologyMedDraId &&
                       outcomeDate >= pc.OnsetDate &&
                       outcomeDate <= pc.OutcomeDate &&
                       pc.Archived == false)
                .Any());
     }
     else
     {
         return(PatientConditions
                .OrderBy(pc => pc.OnsetDate)
                .Where(pc => pc.TerminologyMedDra.Id == sourceTerminologyMedDraId &&
                       outcomeDate >= pc.OnsetDate &&
                       outcomeDate <= pc.OutcomeDate &&
                       pc.Archived == false)
                .Any());
     }
 }
예제 #7
0
파일: Patient.cs 프로젝트: MSH/PViMS-2
        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);
        }