public static CdaSimpleObservation CreateObservation(POCD_MT000040Observation pocdObservation)
        {
            CdaSimpleObservation returnVal = null;

            if (pocdObservation.value != null)
            {
                if (pocdObservation.value.Length > 0)
                {
                    ANY first = pocdObservation.value[0];

                    if (first is INT)
                    {
                        returnVal = new CdaIntObservation(pocdObservation);
                    }
                    else if (first is TS)
                    {
                        returnVal = new CdaDateObservation(pocdObservation);
                    }
                    else if (first is PQ)
                    {
                        returnVal = new CdaPqObservation(pocdObservation);
                    }
                    else if (first is ST)
                    {
                        returnVal = new CdaTextObservation(pocdObservation);
                    }
                }
            }

            return(returnVal);
        }
        public static CdaPqObservation CreateSocialPqObservation(Observation observation)
        {
            CdaPqObservation returnVal = CreatePqObservation(observation);

            if (returnVal != null)
            {
                returnVal.TemplateIds = new CdaTemplateIdList(CcdSocialHistoryObservationTemplateId, SimpleObservationTemplateId, SocialHistoryObservationTemplateId);
            }

            return(returnVal);
        }
        /// <summary>
        /// Create an observation where the value has unit information
        /// </summary>
        /// <param name="observation"></param>
        /// <returns></returns>
        public static CdaPqObservation CreatePqObservation(Observation observation)
        {
            CdaPqObservation returnVal;

            bool ok = false;

            // *** First get the integer value ***
            int    val  = -1;
            double val2 = 0;

            if (int.TryParse(observation.Value, out val))
            {
                ok = true;
            }
            else if (double.TryParse(observation.Value, out val2))
            {
                ok = true;
            }

            if (ok)
            {
                // *** Create the observation ***
                returnVal = new CdaPqObservation();

                // *** Add amount, unit information ***
                returnVal.Value = observation.Value;
                returnVal.Unit  = observation.Unit;

                // *** Add Id, status ***
                returnVal.Id     = Guid.NewGuid().ToString(); // observation.Ien;
                returnVal.Status = Hl7ProblemActStatus.completed;

                // *** Add code ***
                returnVal.Code = new CdaCode()
                {
                    CodeSystem = observation.CodeSystem, Code = observation.Code, DisplayName = observation.Description
                };

                returnVal.EffectiveTime = new CdaEffectiveTime()
                {
                    High = observation.EntryDate
                };
            }
            else
            {
                returnVal = null;
            }

            return(returnVal);
        }
        public static CdaPqObservation CreatePregnancyHistoryPqObservation(Observation observation)
        {
            CdaPqObservation returnVal = CreatePqObservation(observation);

            if (returnVal != null)
            {
                returnVal.TemplateIds   = new CdaTemplateIdList(SimpleObservationTemplateId, PregnancyObservationTemplateId);
                returnVal.EffectiveTime = new CdaEffectiveTime()
                {
                    Value = observation.EntryDate
                };
            }

            return(returnVal);
        }
        public static CdaPqObservation CreateVitalSignsObservation(Observation observation)
        {
            CdaPqObservation returnVal = CreatePqObservation(observation);

            if (returnVal != null)
            {
                returnVal.TemplateIds = new CdaTemplateIdList(SimpleObservationTemplateId, CcdVitalSignsTemplateId, VitalSignsTemplateId);

                returnVal.EffectiveTime = new CdaEffectiveTime()
                {
                    High = observation.EntryDate
                };
            }

            return(returnVal);
        }
        internal static CdaPqObservation CreateLabObservation(Lab lab)
        {
            CdaPqObservation returnVal = new CdaPqObservation();

            returnVal.Mood = x_ActMoodDocumentObservation.EVN;
            returnVal.TemplateIds.AddId("1.3.6.1.4.1.19376.1.3.1.6");

            // *** Add Id, status ***
            returnVal.Id     = Guid.NewGuid().ToString(); // observation.Ien;
            returnVal.Status = Hl7ProblemActStatus.completed;

            // *** Effective Time ***
            if (lab.Resulted != null)
            {
                returnVal.EffectiveTime = new CdaEffectiveTime()
                {
                    High = lab.Resulted.ToDateTime()
                }
            }
            ;

            // *** Value ***
            if (lab.Result != null)
            {
                decimal val = 0.0m;
                if (decimal.TryParse(lab.Result.Value, out val))
                {
                    returnVal.Value = lab.Result.Value;
                }
            }

            // *** Units ***
            if (lab.Units != null)
            {
                returnVal.Unit = lab.Units.Value;
            }

            // *** Code ***
            if (lab.Loinc != null)
            {
                if (!string.IsNullOrWhiteSpace(lab.Loinc.Value))
                {
                    returnVal.Code = new CdaCode()
                    {
                        CodeSystem  = CodingSystem.Loinc,
                        Code        = lab.Loinc.Value,
                        DisplayName = lab.Test.Value
                    }
                }
            }
            ;

            if (returnVal.Code == null)
            {
                // *** Use VUID if there is one ***
                string id = "";
                if (lab.VuId != null)
                {
                    if (!string.IsNullOrWhiteSpace(lab.VuId.Value))
                    {
                        id = lab.VuId.Value;

                        returnVal.Code = new CdaCode()
                        {
                            CodeSystem  = CodingSystem.Vha,
                            Code        = id,
                            DisplayName = lab.Test.Value
                        };
                    }
                }
            }

            if (returnVal.Code == null)
            {
                returnVal.Code = new CdaCode()
                {
                    DisplayName = lab.Test.Value
                }
            }
            ;

            // *** Reference Range ***
            CdaReferenceRange range = new CdaReferenceRange();

            if (lab.Low != null)
            {
                decimal val = 0.0m;
                if (decimal.TryParse(lab.Low.Value, out val))
                {
                    range.Low = lab.Low.Value;
                }
            }

            if (lab.High != null)
            {
                decimal val = 0.0m;
                if (decimal.TryParse(lab.High.Value, out val))
                {
                    range.High = lab.High.Value;
                }
            }

            if (lab.Units != null)
            {
                range.Units = lab.Units.Value;
            }

            returnVal.ReferenceRange = range;

            // *** Interpretation Code ***
            if (lab.Interpretation != null)
            {
                returnVal.InterpretationCode = lab.Interpretation.Value;
            }

            return(returnVal);
        }
        //private StrucDocText GetSectionText()
        //{
        //    // *** Get the text section ***

        //    StrucDocText returnVal = new StrucDocText();

        //    // *** Create list of items ***
        //    List<object> textItems = new List<object>();

        //    // *** Add narrative ***
        //    if (!string.IsNullOrWhiteSpace(this.Narrative))
        //    {
        //        StrucDocParagraph narrativeParagraph = new StrucDocParagraph();
        //        narrativeParagraph.Text = new string[] { this.Narrative };

        //        textItems.Add(narrativeParagraph);
        //    }

        //    // *** Add entries ***
        //    StrucDocTable entriesTble = this.GetTable();

        //    // *** Add entries to items list ***
        //    textItems.Add(entriesTble);

        //    // *** Add items as array ***
        //    returnVal.Items = textItems.ToArray();

        //    return returnVal;
        //}

        protected override StrucDocTable GetEntriesTable()
        {
            // *** Create the table ***
            StrucDocTable returnTable = null;

            if (this.Observations.Count > 0)
            {
                returnTable = new StrucDocTable();

                // *** Create Header information ***
                returnTable.thead             = new StrucDocThead();
                returnTable.thead.tr          = new StrucDocTr[] { new StrucDocTr() };
                returnTable.thead.tr[0].Items = new StrucDocTh[] {
                    new StrucDocTh()
                    {
                        Text = new string[] { "Description" }
                    },
                    new StrucDocTh()
                    {
                        Text = new string[] { "Amount" }
                    },
                    new StrucDocTh()
                    {
                        Text = new string[] { "Comment" }
                    },
                };

                // *** Create Body Information ***
                returnTable.tbody = new StrucDocTbody[] { new StrucDocTbody() };
                List <StrucDocTr> trList = new List <StrucDocTr>();

                // *** Create a Row for each observation ***
                foreach (CdaSimpleObservation obs in this.Observations)
                {
                    // *** Create the row ***
                    StrucDocTr tr = new StrucDocTr()
                    {
                        ID = obs.ReferenceId
                    };

                    // *** Create a list of TD ***
                    List <StrucDocTd> tdList = new List <StrucDocTd>();

                    // *** Add TD's ***
                    string problemDescription;
                    if (obs.NegationIndicator)
                    {
                        problemDescription = string.Format("(Patient Does Not Have) {0}", obs.Code.DisplayName);
                    }
                    else
                    {
                        problemDescription = obs.Code.DisplayName;
                    }

                    tdList.Add(new StrucDocTd()
                    {
                        Text = new string[] { problemDescription }
                    });
                    if (obs is CdaPqObservation)
                    {
                        CdaPqObservation pqObs = (CdaPqObservation)obs;
                        tdList.Add(new StrucDocTd()
                        {
                            Text = new string[] { pqObs.Amount }
                        });
                    }
                    else
                    {
                        tdList.Add(new StrucDocTd()
                        {
                            Text = new string[] { "N/A" }
                        });
                    }

                    tdList.Add(new StrucDocTd()
                    {
                        Text = new string[] { obs.Comment }
                    });

                    tr.Items = tdList.ToArray();

                    trList.Add(tr);
                }

                // *** Add rows to body ***
                returnTable.tbody[0].tr = trList.ToArray();
            }

            return(returnTable);
        }
Beispiel #8
0
        protected override StrucDocTable GetEntriesTable()
        {
            // *** Create the table ***
            StrucDocTable returnTable = null;

            if (this.Observations.Count > 0)
            {
                returnTable = new StrucDocTable();

                // *** Create Header information ***
                returnTable.thead             = new StrucDocThead();
                returnTable.thead.tr          = new StrucDocTr[] { new StrucDocTr() };
                returnTable.thead.tr[0].Items = new StrucDocTh[] {
                    new StrucDocTh()
                    {
                        Text = new string[] { "Measurement" }
                    },
                    new StrucDocTh()
                    {
                        Text = new string[] { "Value" }
                    },
                    new StrucDocTh()
                    {
                        Text = new string[] { "Comment" }
                    },
                };

                // *** Create Body Information ***
                returnTable.tbody = new StrucDocTbody[] { new StrucDocTbody() };
                List <StrucDocTr> trList = new List <StrucDocTr>();

                // *** Create a Row for each observation ***
                foreach (CdaPqObservation obs in this.Observations)
                {
                    // *** Create the row ***
                    StrucDocTr tr = new StrucDocTr()
                    {
                        ID = obs.ReferenceId
                    };

                    // *** Create a list of TD ***
                    List <StrucDocTd> tdList = new List <StrucDocTd>();

                    // *** Add TD's ***
                    tdList.Add(new StrucDocTd()
                    {
                        Text = new string[] { obs.Code.DisplayName }
                    });
                    if (obs is CdaPqObservation)
                    {
                        CdaPqObservation pqObs = (CdaPqObservation)obs;
                        tdList.Add(new StrucDocTd()
                        {
                            Text = new string[] { pqObs.Amount }
                        });
                    }
                    else
                    {
                        tdList.Add(new StrucDocTd()
                        {
                            Text = new string[] { "N/A" }
                        });
                    }

                    tdList.Add(new StrucDocTd()
                    {
                        Text = new string[] { obs.Comment }
                    });

                    tr.Items = tdList.ToArray();

                    trList.Add(tr);
                }

                // *** Add rows to body ***
                returnTable.tbody[0].tr = trList.ToArray();
            }

            return(returnTable);
        }