コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Patient.cs プロジェクト: MSH/PViMS-2
        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);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: Patient.cs プロジェクト: MSH/PViMS-2
 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());
     }
 }
コード例 #5
0
ファイル: Patient.cs プロジェクト: MSH/PViMS-2
        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);
        }
コード例 #6
0
ファイル: Patient.cs プロジェクト: MSH/PViMS-2
        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);
        }