コード例 #1
0
        public List <PlanOfCare> FillPlanOfCare(IEntryCollection entryCollection)
        {
            List <PlanOfCare> planOfCare = new List <PlanOfCare>();

            foreach (IEntry singleRecord in entryCollection)
            {
                IObservation observation  = singleRecord.AsObservation;
                IAct         entryAct     = singleRecord.AsAct;
                string       goal         = null;
                string       instructions = null;
                if (observation != null)
                {
                    meterialCode = observation.Code;
                    goal         = meterialCode.DisplayName;
                    datetime     = observation.EffectiveTime;
                }
                if (entryAct != null)
                {
                    instructions = entryAct.Text.Text;
                }
                PlanOfCare ptPlanOfCare = new PlanOfCare();
                ptPlanOfCare.Goal         = goal;
                ptPlanOfCare.PlannedDate  = datetime != null ? datetime.Center != null ? new DateTime?(datetime.Center.AsDateTime) : null : null;
                ptPlanOfCare.Instructions = instructions;
                planOfCare.Add(ptPlanOfCare);
            }


            return(planOfCare);
        }
コード例 #2
0
        public static IEntryCollection GetPaged(this IEntryCollection entries, int pageIndex, int pageSize)
        {
            if (pageIndex < 0)
            {
                throw new ArgumentOutOfRangeException("pageIndex");
            }
            if (pageSize < 1)
            {
                throw new ArgumentOutOfRangeException("pageSize");
            }
            var pagedCollection = new EntryCollection();
            var index           = 0;
            var startIndex      = pageIndex * pageSize;
            var endIndex        = startIndex + pageSize;

            foreach (var entry in entries)
            {
                if (index >= startIndex)
                {
                    pagedCollection.Add(entry);
                }
                index++;
                if (index >= endIndex)
                {
                    break;
                }
            }
            return(pagedCollection);
        }
コード例 #3
0
        public List <ProcedureList> FillProcedure(IEntryCollection entryCollection)
        {
            List <ProcedureList> procedureList = new List <ProcedureList>();

            foreach (IEntry entryitem in entryCollection)
            {
                IProcedure entryProcedure = entryitem.AsProcedure;
                if (entryProcedure != null)
                {
                    IObservation entryObservatio = entryitem.AsObservation;
                    ICD          meterialCode;
                    //if (entryProcedure != null)
                    //{
                    //    meterialCode = entryProcedure.Code;
                    //}
                    //else
                    //{
                    //    meterialCode = entryObservatio.Code;
                    //}
                    meterialCode = entryProcedure.Code;
                    ProcedureList ptprocedureList = new ProcedureList();
                    ptprocedureList.CPTCodes    = meterialCode.Code;
                    ptprocedureList.Description = meterialCode.DisplayName;
                    procedureList.Add(ptprocedureList);
                }
            }

            return(procedureList);
        }
コード例 #4
0
        public List <LabResult> FillLabResults(IEntryCollection entryCollection)
        {
            List <LabResult> labResult = new List <LabResult>();

            foreach (IEntry entryitem in entryCollection)
            {
                IOrganizer            entryOrganizer = entryitem.AsOrganizer;
                IComponent4Collection entryComponent = entryOrganizer.Component;
                LabResult             ptLabResult    = new LabResult();
                foreach (IComponent4 obserComponent in entryComponent)
                {
                    IObservation    entryObservation = obserComponent.AsObservation;
                    IReferenceRange referenceRange   = entryObservation.ReferenceRange.FirstOrDefault();
                    meterialCode = entryObservation.Code;
                    try{ valueCode = (IPQ)entryObservation.Value[0]; }catch (Exception) {}
                    ptLabResult.TestPerformed = meterialCode.DisplayName;
                    ptLabResult.ReportDate    = entryObservation.EffectiveTime == null ? null : new DateTime?(Convert.ToDateTime(entryObservation.EffectiveTime.AsDateTime));
                    ptLabResult.LonicCode     = meterialCode.Code;
                    ptLabResult.Units         = valueCode != null?valueCode.Unit.ToString() : string.Empty;

                    ptLabResult.TestResultn = valueCode != null?valueCode.Value.ToString():string.Empty;

                    ptLabResult.NormalFindings = referenceRange != null ? referenceRange.ObservationRange.Text != null ? referenceRange.ObservationRange.Text.Text : null : null;
                }
                labResult.Add(ptLabResult);
            }

            return(labResult);
        }
コード例 #5
0
        public List <Immunization> FillImmunization(IEntryCollection entryCollection)
        {
            List <Immunization> immunization = new List <Immunization>();

            foreach (IEntry singleRecord in entryCollection)
            {
                ISubstanceAdministration entrySubstanceAdministration = singleRecord.AsSubstanceAdministration;
                ISXCM_TS    efftime             = entrySubstanceAdministration.EffectiveTime[0];
                IConsumable substanseConsumable = entrySubstanceAdministration.Consumable;
                ICE         manufacturedProduct = entrySubstanceAdministration.Consumable.ManufacturedProduct.AsMaterial.Code;
                if (manufacturedProduct != null)
                {
                    Immunization ptImmunization = new Immunization();
                    ptImmunization.ApproximateDate = efftime != null ? efftime.Value != null ? new DateTime?(efftime.AsDateTime) : null : null;
                    ptImmunization.CVX             = Convert.ToInt32(manufacturedProduct.Code);
                    ptImmunization.Vaccine         = manufacturedProduct.OriginalText != null ? manufacturedProduct.OriginalText.Text : null;
                    if (entrySubstanceAdministration.Consumable.ManufacturedProduct.ManufacturerOrganization != null)
                    {
                        ptImmunization.Manufacturer = entrySubstanceAdministration.Consumable.ManufacturedProduct.ManufacturerOrganization.Name.ToString();
                    }
                    else
                    {
                        ptImmunization.Manufacturer = null;
                    }
                    immunization.Add(ptImmunization);
                }
            }

            return(immunization);
        }
コード例 #6
0
        public List <Encounters> FillEncounters(IEntryCollection entryCollection, string name)
        {
            List <Encounters> encounters = new List <Encounters>();

            foreach (IEntry entryitem in entryCollection)
            {
                Encounters         ptEncounters      = new Encounters();
                IEncounter         entryEncounter    = entryitem.AsEncounter;
                IEntryRelationship entryRelationItem = entryEncounter.EntryRelationship.FirstOrDefault();
                if (entryRelationItem != null)
                {
                    IObservation observation = entryRelationItem.AsObservation;
                    IIVL_TS      efftime     = observation.EffectiveTime;
                    if (efftime == null)
                    {
                        throw new InvalidOperationException();
                    }
                    IANY   observationvalue = observation.Value.FirstOrDefault();
                    ICD    str      = (ICD)observationvalue;
                    string location = observation.Participant.Count > 0 ? observation.Participant[0].ParticipantRole.AsPlayingEntity.Name[0].Text : null;
                    ptEncounters.Code = str.Code;
                    ptEncounters.EncounterDescription = str.DisplayName;
                    ptEncounters.PerformerName        = name;
                    //ptEncounters.EncounterDate = efftime != null ? efftime.Low != null ? efftime.Low.Value != null ? new DateTime?(Convert.ToDateTime(efftime.Low.AsDateTime)) : null : null : efftime.Value != null ? new DateTime?(Convert.ToDateTime(efftime.AsDateTime)) : null;
                }
                encounters.Add(ptEncounters);
            }

            return(encounters);
        }
コード例 #7
0
        public SocialHistoryModel FillSocialHistory(IEntryCollection entryCollection)
        {
            SocialHistoryModel ptSocialHistory = new SocialHistoryModel();

            foreach (IEntry singleentry in entryCollection)
            {
                IObservation socialObservation = singleentry.AsObservation;
                if (socialObservation.TemplateId.Select(s => s.Root.ToString()).FirstOrDefault() == "2.16.840.1.113883.10.20.22.4.38")
                {
                    ICD     socialCode    = socialObservation.Code;
                    IIVL_TS effectiveTime = socialObservation.EffectiveTime;
                    if (socialCode.Code == "230056004" || socialCode.Code == "229819007")
                    {
                        ptSocialHistory.Smoker = socialCode.Code != null ? socialCode.Code : null;
                    }
                    if (socialCode.Code == "160573003")
                    {
                        //ptSocialHistory.EntryDate = effectiveTime != null ? effectiveTime.Low != null ? effectiveTime.Low.Value != null ? effectiveTime.Low.Value.ToString() : null : null : null;
                        ptSocialHistory.Alcohol = socialCode.Code != null ? socialCode.Code : null;
                    }
                    if (socialCode.Code == "363908000")
                    {
                        //ptSocialHistory.EntryDate = effectiveTime != null ? effectiveTime.Low != null ? effectiveTime.Low.Value != null ? effectiveTime.Low.Value.ToString() : null : null : null;
                        ptSocialHistory.Drugs = socialCode.Code != null ? socialCode.Code : null;
                    }
                    if (socialCode.Code == "81703003")
                    {
                        //ptSocialHistory.EntryDate = effectiveTime != null ? effectiveTime.Low != null ? effectiveTime.Low.Value != null ? effectiveTime.Low.Value.ToString() : null : null : null;
                        ptSocialHistory.Tobacoo = socialCode.Code != null ? socialCode.Code : null;
                    }
                    ptSocialHistory.EntryDate = effectiveTime != null ? effectiveTime.Low != null ? effectiveTime.Low.Value != null?effectiveTime.Low.Value.ToString() : null : null : null;
                }
            }
            return(ptSocialHistory);
        }
コード例 #8
0
        public List <PatientProblemes> FillProblems(IEntryCollection entryCollection)
        {
            List <PatientProblemes> Problemes = new List <PatientProblemes>();

            foreach (IEntry singleentry in entryCollection)
            {
                IObservation     probObservation = singleentry.AsAct.EntryRelationship.FirstOrDefault().AsObservation;
                IIVL_TS          effectivetime   = probObservation.EffectiveTime;
                IANY             probValue       = probObservation.Value[0];
                ICD              itemVlues       = (ICD)probValue;
                PatientProblemes ptproblem       = new PatientProblemes();
                ptproblem.ProblemCode = itemVlues.Code != null ? itemVlues.Code : null;
                IEntryRelationship ObserentryRelation = probObservation.EntryRelationship.Where(e => e.AsObservation.Code.Code.ToString() == "33999-4").FirstOrDefault();
                if (ObserentryRelation != null)
                {
                    IANY probStatusVal = ObserentryRelation.AsObservation.Value.FirstOrDefault();
                    ICD  StatusVlues   = (ICD)probStatusVal;
                    ptproblem.Status = StatusVlues.DisplayName;
                }
                else
                {
                    ptproblem.Status = null;
                }
                ptproblem.DateDiagnosed = effectivetime.Low != null ? effectivetime.Low.Value != null?effectivetime.Low.AsDateTime.ToString() : null : null;

                ptproblem.Description = itemVlues.DisplayName != null ? itemVlues.DisplayName : null;
                Problemes.Add(ptproblem);
            }
            return(Problemes);
        }
コード例 #9
0
        public List <VitalSigns> FillVitalSigns(IEntryCollection entryCollection)
        {
            List <VitalSigns> vitalSigns = new List <VitalSigns>();

            foreach (IEntry singleentry in entryCollection)
            {
                IOrganizer            organizer = singleentry.AsOrganizer;
                IComponent4Collection component = organizer.Component;
                IIVL_TS effectivetime           = organizer.EffectiveTime;
                if (effectivetime == null)
                {
                    throw new InvalidOperationException();
                }
                VitalSigns ptvitalSigns = new VitalSigns();
                try
                {
                    ptvitalSigns.VitalDate = effectivetime.AsDateTime;
                }
                catch (Exception)
                {
                    ptvitalSigns.VitalDate = effectivetime != null ? effectivetime.Low != null ? effectivetime.Low.Value != null ? new DateTime?(effectivetime.Low.AsDateTime) : null : null : effectivetime.Value != null ? new DateTime?(effectivetime.AsDateTime) : new DateTime?(effectivetime.AsDateTime);
                }


                foreach (IComponent4 orgComponent in component)
                {
                    IObservation orgObservation             = orgComponent.AsObservation;
                    ICD          itemCode                   = orgObservation.Code;
                    IANY         vitalSignsObservationValue = orgObservation.Value[0];
                    IPQ          itemVlues                  = (IPQ)vitalSignsObservationValue;

                    if (itemCode.Code != null)
                    {
                        if (itemCode.Code.ToString() == "8302-2")
                        {
                            ptvitalSigns.Height     = Convert.ToInt16(itemVlues.Value);
                            ptvitalSigns.HeightUnit = Convert.ToString(itemVlues.Unit);
                        }
                        if (itemCode.Code.ToString() == "3141-9")
                        {
                            ptvitalSigns.WEIGHT     = Convert.ToInt16(itemVlues.Value);
                            ptvitalSigns.WeightUnit = Convert.ToString(itemVlues.Unit);
                        }
                        if (itemCode.Code.ToString() == "8480-6")
                        {
                            ptvitalSigns.BloodPressure         = itemVlues.Value.ToString() + " " + itemVlues.Unit.ToString();
                            ptvitalSigns.BloodPressureSystolic = itemVlues.Value.ToString();
                        }

                        if (itemCode.Code.ToString() == "8462-4")
                        {
                            ptvitalSigns.BloodPressureDiastolic = itemVlues.Value.ToString();
                        }
                    }
                }
                vitalSigns.Add(ptvitalSigns);
            }
            return(vitalSigns);
        }
コード例 #10
0
        public List <PatientMedication> FillMedication(IEntryCollection entryCollection)
        {
            List <PatientMedication> Medication = new List <PatientMedication>();

            foreach (IEntry entryitem in entryCollection)
            {
                ISubstanceAdministration entrySubstanceAdministration = entryitem.AsSubstanceAdministration;
                foreach (var timeitem in entrySubstanceAdministration.EffectiveTime)
                {
                    var    obj     = timeitem.GetType();
                    string objname = obj.Name;
                    switch (objname)
                    {
                    case "IVL_TS":
                        datetime = (IIVL_TS)timeitem;
                        break;

                    case "PIVL_TS":
                        timeduration = (IPIVL_TS)timeitem;
                        break;
                    }
                }
                IIVL_PQ            doseQuantity      = entrySubstanceAdministration.DoseQuantity;
                IIVL_PQ            rateQuantity      = entrySubstanceAdministration.RateQuantity;
                ICE                meterialCode      = entrySubstanceAdministration.Consumable.ManufacturedProduct.AsMaterial.Code;
                IEntryRelationship entryRelationShip = entrySubstanceAdministration.EntryRelationship.Where(e => e.TypeCode.ToString() == "RSON").FirstOrDefault();
                if (entryRelationShip != null)
                {
                    IANY entryvalue      = entryRelationShip.AsObservation.Value.FirstOrDefault();
                    ICE  valueCollection = (ICE)entryvalue;
                }
                PatientMedication ptMedication = new PatientMedication();
                ptMedication.Medication = meterialCode.Translation.FirstOrDefault() != null?meterialCode.Translation.FirstOrDefault().DisplayName : meterialCode.DisplayName != null ? meterialCode.DisplayName : null;

                ptMedication.RxNorm    = meterialCode.Code != null ? meterialCode.Code : null;
                ptMedication.Frequency = timeduration != null ? timeduration.Value != null?timeduration.Value.ToString() : null : null;

                ptMedication.doseUnit = doseQuantity.Value.ToString() + " " + doseQuantity.Unit != null?doseQuantity.Unit.ToString() : "";

                ptMedication.StartDate = datetime.Low != null ? datetime.Low.Value != null ? new DateTime?(datetime.Low.AsDateTime) : null : null;
                ptMedication.EndDate   = datetime.High != null ? datetime.High.Value != null ? new DateTime?(datetime.High.AsDateTime) : null : null;
                Medication.Add(ptMedication);
            }

            return(Medication);
        }
コード例 #11
0
        public List <FunctionalStatus> FillFunctionalStatus(IEntryCollection entryCollection)
        {
            List <FunctionalStatus> functionalStatus = new List <FunctionalStatus>();

            foreach (IEntry entryitem in entryCollection)
            {
                IObservation     entryObservation = entryitem.AsObservation;
                IIVL_TS          effectiveDate    = entryObservation.EffectiveTime;
                IANY             functionalValue  = entryObservation.Value[0];
                ICD              cD = (ICD)functionalValue;
                FunctionalStatus ptfunctionalStatus = new FunctionalStatus();
                ptfunctionalStatus.StatusDate  = effectiveDate != null ? effectiveDate.Low != null ? effectiveDate.Low.Value != null ? new DateTime?(effectiveDate.Low.AsDateTime) : null : null : null;
                ptfunctionalStatus.Description = cD.DisplayName;
                ptfunctionalStatus.Code        = cD.Code;
                functionalStatus.Add(ptfunctionalStatus);
            }

            return(functionalStatus);
        }
コード例 #12
0
        public List <PatientAllergies> FillAllergies(IEntryCollection entryCollection)
        {
            List <PatientAllergies> alleryies = new List <PatientAllergies>();

            foreach (IEntry entryitem in entryCollection)
            {
                IAct entryact = entryitem.AsAct;
                IEntryRelationship entryRelationship  = entryact.EntryRelationship[0];
                IObservation       entryobservation   = entryRelationship.AsObservation;
                IIVL_TS            effectivetime      = entryact.EffectiveTime;
                IParticipant2      allergyParticipant = entryobservation.Participant[0];
                IParticipantRole   participantRole    = allergyParticipant.ParticipantRole;
                IPlayingEntity     playingEntity      = participantRole.AsPlayingEntity;
                ICE              code        = playingEntity.Code;
                IPNCollection    name        = playingEntity.Name;
                string           substance   = name != null && name.Count() > 0 ? name[0].Text : code.DisplayName;
                PatientAllergies ptallergies = new PatientAllergies();
                ptallergies.substance = substance;
                IEntryRelationship entryRelationshipMFST = entryobservation.EntryRelationship.Where(r => r.TypeCode.ToString() == "MFST").FirstOrDefault();
                if (entryRelationshipMFST != null && entryRelationshipMFST.AsObservation.Value != null)
                {
                    IANY Reactionvaluecollection = entryRelationshipMFST.AsObservation.Value.FirstOrDefault();
                    CD   valuesReaction          = (CD)Reactionvaluecollection;
                    ptallergies.reaction = valuesReaction.DisplayName;
                }
                ptallergies.rxNorm = code.Code;
                IEntryRelationship entryRelationshipSUBJ = entryobservation.EntryRelationship.Where(r => r.TypeCode.ToString() == "SUBJ").FirstOrDefault();
                if (entryRelationshipSUBJ != null && entryRelationshipSUBJ.AsObservation.Value != null)
                {
                    IANY Statusvaluecollection = entryRelationshipSUBJ.AsObservation.Value.FirstOrDefault();
                    ICE  values = (ICE)Statusvaluecollection;
                    ptallergies.status = values.DisplayName;
                }
                if (effectivetime != null && effectivetime.Value != null)
                {
                    ptallergies.allergyDate = effectivetime.AsDateTime.ToString();
                }
                alleryies.Add(ptallergies);
            }

            return(alleryies);
        }
コード例 #13
0
        public Dictionary <string, ArrayList> GetDataCollection(ISection sections, PatientClinicalInformation ptInformation)
        {
            Dictionary <string, ArrayList> componententries = new Dictionary <string, ArrayList>();
            IEntryCollection           entries     = sections.Entry;
            IStrucDocText              sectiontext = sections.Text;
            IStrucDocElementCollection textitem    = sectiontext.Items;

            if (entries.Count() > 0)
            {
                int count = 0;
                foreach (IEntry singlerecord in entries)
                {
                    itemAct       = singlerecord.AsAct;
                    itemEncounter = singlerecord.AsEncounter;
                    itemSubstanceAdministration = singlerecord.AsSubstanceAdministration;
                    observation = singlerecord.AsObservation;
                    organizer   = singlerecord.AsOrganizer;
                    procedure   = singlerecord.AsProcedure;
                    //if(sections.Code.Code== "18776-5")
                    // {

                    // }
                    ArrayList arrayList = new ArrayList();
                    if (itemAct != null)
                    {
                        entryRelationship = itemAct.EntryRelationship;
                        IIVL_TS efftime = itemAct.EffectiveTime;
                        if (efftime != null && efftime.Low != null)
                        {
                            if (efftime.Low.Value != null)
                            {
                                arrayList.Add(efftime.Low.AsDateTime.ToString());
                            }
                            else
                            {
                                arrayList.Add("null");
                            }
                        }
                        else
                        {
                            arrayList.Add("null");
                        }
                        if (entryRelationship != null && entryRelationship.Count > 0)
                        {
                            observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault();
                            if (observation != null)
                            {
                                if (observation.Participant.Count() > 0)
                                {
                                    string participent = observation.Participant.Select(p => p.ParticipantRole).FirstOrDefault().AsPlayingEntity.Name.FirstOrDefault().Text;
                                    arrayList.Add(participent);
                                }

                                entity = observation.EntryRelationship;
                                foreach (IEntryRelationship singlentity in entity)
                                {
                                    IObservation entityobservation = singlentity.AsObservation;
                                    IANY         observationvalue  = entityobservation.Value.FirstOrDefault();
                                    if (observationvalue != null)
                                    {
                                        var    obj     = observationvalue.GetType();
                                        string objname = obj.Name;
                                        switch (objname)
                                        {
                                        default:
                                            ICD strcd = (ICD)observationvalue;
                                            arrayList.Add(strcd.Code);
                                            arrayList.Add(strcd.DisplayName);
                                            break;

                                        case "PQ":
                                            IPQ strpq = (IPQ)observationvalue;
                                            arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString());
                                            break;
                                        }
                                    }
                                }

                                componententries.Add(count.ToString(), arrayList);
                                count++;
                            }
                        }
                        else
                        {
                            arrayList.Add(itemAct.Text.Text);
                            componententries.Add(count.ToString(), arrayList);
                            count++;
                        }
                    }
                    else if (itemEncounter != null)
                    {
                        entryRelationship = itemEncounter.EntryRelationship;
                        if ((entryRelationship.Select(t => t.TypeCode).FirstOrDefault().ToString()) == "RSON")
                        {
                            observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault();
                            IIVL_TS efftime          = observation.EffectiveTime;
                            IANY    observationvalue = observation.Value.FirstOrDefault();
                            ICD     str = (ICD)observationvalue;
                            arrayList.Add(str.DisplayName);
                            arrayList.Add(ptInformation.ptClinicInformation.ClinicName);
                            if (efftime.Low != null)
                            {
                                arrayList.Add(efftime.Low.AsDateTime);
                            }
                            else
                            {
                                arrayList.Add(null);
                            }
                            arrayList.Add(str.Code);
                        }

                        componententries.Add(count.ToString(), arrayList);
                        count++;
                    }
                    else if (itemSubstanceAdministration != null)
                    {
                        consumable          = itemSubstanceAdministration.Consumable;
                        manufacturedProduct = consumable.ManufacturedProduct;
                        material            = manufacturedProduct.AsMaterial;
                        arrayList.Add(material.Code.Code);
                        arrayList.Add(itemSubstanceAdministration.StatusCode.Code.ToString());
                        ISXCM_TSCollection efftime = itemSubstanceAdministration.EffectiveTime;
                        if (efftime.Count > 1)
                        {
                            foreach (IVL_TS daterange in efftime)
                            {
                                string startdatetime = daterange.Low != null ? daterange.Low.Value != null?daterange.Low.AsDateTime.ToString() : "null" : "null";

                                string EndDAtetime = daterange.High != null ? daterange.High.Value != null?daterange.High.AsDateTime.ToString() : "null" : "null";

                                arrayList.Add(startdatetime);
                                arrayList.Add(EndDAtetime);
                                break;
                            }
                        }
                        else
                        {
                            arrayList.Add(efftime[0].AsDateTime.ToString());
                        }

                        arrayList.Add(material.Code.DisplayName);
                        if (itemSubstanceAdministration.DoseQuantity != null)
                        {
                            arrayList.Add(itemSubstanceAdministration.DoseQuantity.Value.ToString() + " " + itemSubstanceAdministration.DoseQuantity.Unit.ToString());
                        }
                        else
                        {
                            arrayList.Add("NA");
                        }
                        if (manufacturedProduct.ManufacturerOrganization != null)
                        {
                            arrayList.Add(manufacturedProduct.ManufacturerOrganization.Name.ToString());
                        }
                        else
                        {
                            arrayList.Add("NA");
                        }

                        componententries.Add(count.ToString(), arrayList);
                        count++;
                    }
                    else if (observation != null)
                    {
                        if (observation.Value.Count > 0)
                        {
                            IANY observationvalue = observation.Value.FirstOrDefault();
                            ICD  str = (ICD)observationvalue;
                            arrayList.Add(str.Code);
                            arrayList.Add(str.DisplayName);
                            IIVL_TS efftime = observation.EffectiveTime;
                            if (efftime != null && efftime.Low != null)
                            {
                                if (efftime.Low.Value != null)
                                {
                                    arrayList.Add(efftime.Low.AsDateTime.ToString());
                                }
                                else
                                {
                                    arrayList.Add("null");
                                }
                            }
                            else
                            {
                                arrayList.Add("null");
                            }
                        }
                        else
                        {
                            arrayList.Add(null);
                            arrayList.Add(null);
                            arrayList.Add(null);
                        }

                        componententries.Add(count.ToString(), arrayList);
                        count++;
                    }
                    else if (organizer != null)
                    {
                        IComponent4Collection orgComponent = organizer.Component;

                        foreach (IComponent4 objItem in orgComponent)
                        {
                            IObservation orgObservation = objItem.AsObservation;
                            arrayList.Add(orgObservation.Code.DisplayName);
                            if (orgObservation.Value != null)
                            {
                                IANY   observationvalue = orgObservation.Value.FirstOrDefault();
                                var    obj     = observationvalue.GetType();
                                string objname = obj.Name;

                                switch (objname)
                                {
                                default:
                                    ICD strcd = (ICD)observationvalue;
                                    arrayList.Add(strcd.Code);
                                    arrayList.Add(strcd.DisplayName);
                                    break;

                                case "PQ":
                                    IPQ strpq = (IPQ)observationvalue;
                                    arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString());
                                    break;
                                }
                                //IPQ str = (IPQ)observationvalue;
                                //arrayList.Add(str.Value.ToString() + " " + str.Unit.ToString());
                            }
                            IIVL_TS efftime = orgObservation.EffectiveTime;
                            if (efftime != null && efftime.Low != null)
                            {
                                if (efftime.Low.Value != null)
                                {
                                    arrayList.Add(efftime.Low.AsDateTime.ToString());
                                }
                                else
                                {
                                    arrayList.Add("null");
                                }
                            }
                            else
                            {
                                arrayList.Add("null");
                            }
                            if (orgObservation.ReferenceRange != null)
                            {
                                if (orgObservation.ReferenceRange.Count > 0)
                                {
                                    arrayList.Add(orgObservation.ReferenceRange[0].ObservationRange.Text.Text);
                                }
                                else
                                {
                                    arrayList.Add("NA");
                                }
                            }
                        }
                        arrayList.Add(organizer.Code.Code);
                        componententries.Add(count.ToString(), arrayList);
                        count++;
                    }
                    else if (procedure != null)
                    {
                        if (procedure.Code != null)
                        {
                            arrayList.Add(procedure.Code.Code);
                            arrayList.Add(procedure.Code.DisplayName);
                        }
                        else
                        {
                            arrayList.Add(null);
                            arrayList.Add(null);
                        }
                        componententries.Add(count.ToString(), arrayList);
                        count++;
                    }
                }
            }

            return(componententries);
        }