Exemple #1
0
 public void InitialiseValues(string tag, DatasetInstance sourceInstance, PatientClinicalEvent clinicalEvent)
 {
     foreach (DatasetCategory dc in Dataset.DatasetCategories)
     {
         foreach (DatasetCategoryElement dce in dc.DatasetCategoryElements)
         {
             // Default using default value
             if (dce.DatasetElement.DefaultValue != null && dce.DatasetElement.DefaultValue != "")
             {
                 SetInstanceValue(dce.DatasetElement, dce.DatasetElement.DefaultValue);
             }
             else
             {
                 // Default using mapped value
                 if (sourceInstance != null)
                 {
                     MapValuesUsingInstance(dce, tag, sourceInstance);
                 }
                 if (clinicalEvent != null)
                 {
                     MapValuesUsingEvent(dce, tag, clinicalEvent);
                 }
             }
         }
     }
 }
Exemple #2
0
        private void MapValuesUsingEvent(DatasetCategoryElement dce, string tag, PatientClinicalEvent clinicalEvent)
        {
            IExtendable ptExtended = clinicalEvent.Patient;
            IExtendable ceExtended = clinicalEvent;

            if (dce.DestinationMappings.Where(dm => dm.Tag == tag).Count() > 0)
            {
                // Get the value to be translated
                var    mapping     = dce.DestinationMappings.Single(dm => dm.Tag == tag);
                string sourceValue = string.Empty;
                object objectValue;

                if (mapping.MappingType == MappingType.AttributeToElement || mapping.MappingType == MappingType.AttributeToValue)
                {
                    if (!String.IsNullOrWhiteSpace(mapping.PropertyPath) && !String.IsNullOrWhiteSpace(mapping.Property))
                    {
                        switch (mapping.PropertyPath)
                        {
                        case "Patient":
                            objectValue = ptExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";

                            break;

                        case "PatientClinicalEvent":
                            objectValue = ceExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";

                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrWhiteSpace(mapping.Property))
                        {
                            objectValue = ceExtended.GetAttributeValue(mapping.Property);
                            sourceValue = objectValue != null?objectValue.ToString() : "";
                        }
                    }
                }
                else
                {
                    Object src = clinicalEvent;
                    if (mapping.MappingType == MappingType.FirstClassToElement || mapping.MappingType == MappingType.FirstClassToValue)
                    {
                        if (!String.IsNullOrWhiteSpace(mapping.PropertyPath))
                        {
                            switch (mapping.PropertyPath)
                            {
                            case "Patient":
                                src = clinicalEvent.Patient;
                                break;

                            default:
                                break;
                            }
                        }
                        objectValue = src.GetType().GetProperty(mapping.Property).GetValue(src, null);
                        sourceValue = objectValue != null?objectValue.ToString() : "";
                    }
                }

                // Translate the value
                if (!String.IsNullOrWhiteSpace(sourceValue))
                {
                    var formattedValue = TranslateSourceValueForElement(mapping, sourceValue);

                    if (!String.IsNullOrWhiteSpace(formattedValue))
                    {
                        SetInstanceValue(dce.DatasetElement, formattedValue);
                    }
                }
            }
        }
Exemple #3
0
        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);
        }