public void CreateEncounterEmptyEntry(III hl7III, Factory hl7factory)
        {
            IEntry entry = functionalStatus.Section.Entry.Append();

            entry.TypeCode        = x_ActRelationshipEntry.DRIV;
            entry.AsAct.ClassCode = x_ActClassDocumentEntryAct.ACT;
            entry.AsAct.MoodCode  = x_DocumentActMood.EVN;
            hl7III            = entry.AsAct.Id.Append();
            hl7III.NullFlavor = "UNK";
            hl7III            = entry.AsAct.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.30");
            entry.AsAct.Code.Code           = "48765-2";
            entry.AsAct.Code.CodeSystem     = "2.16.840.1.113883.6.1";
            entry.AsAct.Code.CodeSystemName = "LOINC";
            entry.AsAct.Code.DisplayName    = "Allergies, adverse reactions, alerts";
            entry.AsAct.StatusCode.Code     = "completed";
            entry.AsAct.EffectiveTime       = new IVL_TS().Init(low: new IVXB_TS(), high: new IVXB_TS());
            // If Status Complete

            IEntryRelationship entryRel = entry.AsAct.EntryRelationship.Append();

            entryRel.TypeCode = x_ActRelationshipEntryRelationship.SUBJ;
            entryRel.AsObservation.ClassCode = "OBS";
            entryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            III TempId = entryRel.AsObservation.TemplateId.Append();

            TempId.Root = "2.16.840.1.113883.10.20.22.4.7";
            entryRel.AsObservation.StatusCode.Code = "completed";
            hl7III           = entryRel.AsObservation.Id.Append();
            hl7III.Root      = "1.3.6.1.4.1.22812.11.0.100610.4.10.2";
            hl7III.Extension = "41700060";
            entryRel.AsObservation.Code.Code       = "ASSERTION";
            entryRel.AsObservation.Code.CodeSystem = "2.16.840.1.113883.5.4";
            entryRel.AsObservation.EffectiveTime   = new IVL_TS().Init(low: new IVXB_TS());
            CD obsValueAsCD = new CD();

            obsValueAsCD.NullFlavor = "UNK";
            entryRel.AsObservation.Value.Add(obsValueAsCD);
            PN pn = new PN();

            pn.Text = "N/A";
            IParticipant2 parti = hl7factory.CreateParticipant2();

            parti.TypeCode = "CSM";
            parti.ParticipantRole.ClassCode = "MANU";
            parti.ParticipantRole.AsPlayingEntity.ClassCode       = "MMAT";
            parti.ParticipantRole.AsPlayingEntity.Code.NullFlavor = "UNK";
            parti.ParticipantRole.AsPlayingEntity.Name.Add(pn);
            entryRel.AsObservation.Participant.Add(parti);
        }
        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);
        }
Exemplo n.º 3
0
        public void GenerateAllergyEntry(PatientAllergies patientAllergies, III hl7III, Factory hl7factory)
        {
            IEntry entry = functionalStatus.Section.Entry.Append();

            entry.TypeCode        = x_ActRelationshipEntry.DRIV;
            entry.AsAct.ClassCode = x_ActClassDocumentEntryAct.ACT;
            entry.AsAct.MoodCode  = x_DocumentActMood.EVN;
            hl7III = entry.AsAct.Id.Append();
            hl7III.Init("36e3e930-7b14-11db-9fe1-0800200c9a66");
            hl7III = entry.AsAct.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.30");
            entry.AsAct.Code.Code           = "48765-2";
            entry.AsAct.Code.CodeSystem     = "2.16.840.1.113883.6.1";
            entry.AsAct.Code.CodeSystemName = "LOINC";

            entry.AsAct.Code.DisplayName = "Allergies, adverse reactions, alerts";

            entry.AsAct.StatusCode.Code = Convert.ToString(patientAllergies.status).ToLower();

            if (Convert.ToString(patientAllergies.status) == "Active")
            {
                entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                // If Status Active
            }
            else
            {
                entry.AsAct.EffectiveTime = new IVL_TS().Init(high: new IVXB_TS());
                // If Status is Not Active
            }

            IEntryRelationship entryRel = entry.AsAct.EntryRelationship.Append();

            entryRel.TypeCode = x_ActRelationshipEntryRelationship.SUBJ;
            entryRel.AsObservation.ClassCode = "OBS";
            entryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            III TempId = entryRel.AsObservation.TemplateId.Append();

            TempId.Root = "2.16.840.1.113883.10.20.22.4.7";
            entryRel.AsObservation.StatusCode.Code = "completed";
            hl7III      = entryRel.AsObservation.Id.Append();
            hl7III.Root = "4adc1020-7b14-11db-9fe1-0800200c9a66";
            entryRel.AsObservation.Code.Code       = "ASSERTION";
            entryRel.AsObservation.Code.CodeSystem = "2.16.840.1.113883.5.4";
            ICS CS = hl7factory.CreateCS();

            CS.Init("completed");

            entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK";
            // Because Allergy Start Date is Missing.
            CD obsValueAsCD = new CD();
            CE obsValueAsCE = new CE();

            //obsValueAsCD.Code = patientAllergies.AllergyType == "Medication" ? "416098002" : patientAllergies.AllergyType == "Food" ? "414285001" : patientAllergies.AllergyType == "Environmental" ? "419199007" : "420134006";//(patientAllergies.AllergyType == "Medication" ? "416098002" : (patientAllergies.AllergyType == "Food" ? "414285001" : (patientAllergies.AllergyType == "Environmental" ? "426232007" : "106190000")));
            //// Allergy Type SNOMED Code(Environmental Alergy:426232007, Food Allergy: 414285001, Medication Allergy: 416098002, Other Allergy: 106190000)
            //obsValueAsCD.DisplayName = (patientAllergies.AllergyType == "Medication" ? "Drug allergy" : (patientAllergies.AllergyType == "Food" ? "Food allergy" : (patientAllergies.AllergyType == "Environmental" ? "Environmental allergy" : "Other allergy")));

            obsValueAsCD.CodeSystem     = "2.16.840.1.113883.6.96";
            obsValueAsCD.CodeSystemName = "SNOMED CT";
            obsValueAsCD.OriginalText.Reference.Value = "#" + Convert.ToString(patientAllergies.allergyId);
            // "#reaction1" ' Dynamic Value
            entryRel.AsObservation.Value.Add(obsValueAsCD);
            PN pn = new PN();

            pn.Text = patientAllergies.substance;
            IParticipant2 parti = hl7factory.CreateParticipant2();

            parti.TypeCode = "CSM";
            parti.ParticipantRole.ClassCode = "MANU";
            parti.ParticipantRole.AsPlayingEntity.ClassCode = "MMAT";
            parti.ParticipantRole.AsPlayingEntity.Code.Code = Convert.ToString(patientAllergies.rxNorm);
            //"314422" ' Dynamic Value
            parti.ParticipantRole.AsPlayingEntity.Code.DisplayName = patientAllergies.substance;
            //"ALLERGENIC EXTRACT, PENICILLIN" ' Dynamic Value
            parti.ParticipantRole.AsPlayingEntity.Code.CodeSystem     = "2.16.840.1.113883.6.88";
            parti.ParticipantRole.AsPlayingEntity.Code.CodeSystemName = "RxNorm";
            parti.ParticipantRole.AsPlayingEntity.Code.OriginalText.Reference.Value = "";
            //"#" & Convert.ToString(dtRow("ReactionID"))
            parti.ParticipantRole.AsPlayingEntity.Name.Add(pn);
            entryRel.AsObservation.Participant.Add(parti);

            ///'' Allergy Status Observation '''''''''''
            IEntryRelationship obs_EntryRel = entryRel.AsObservation.EntryRelationship.Append();

            obs_EntryRel.TypeCode                = x_ActRelationshipEntryRelationship.SUBJ;
            obs_EntryRel.InversionInd            = true;
            obs_EntryRel.InversionIndSpecified   = true;
            obs_EntryRel.AsObservation.ClassCode = "OBS";
            obs_EntryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            hl7III      = obs_EntryRel.AsObservation.TemplateId.Append();
            hl7III.Root = "2.16.840.1.113883.10.20.22.4.28";
            obs_EntryRel.AsObservation.Code.Code           = "33999-4";
            obs_EntryRel.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.6.1";
            obs_EntryRel.AsObservation.Code.CodeSystemName = "LOINC";
            obs_EntryRel.AsObservation.Code.DisplayName    = "Status";
            obs_EntryRel.AsObservation.StatusCode.Code     = "completed";


            obsValueAsCE             = new CE();
            obsValueAsCE.Code        = Convert.ToString(patientAllergies.status) == "Active" ? "55561003" : patientAllergies.status == "Inactive" ? "73425007" : "413322009";
            obsValueAsCE.DisplayName = Convert.ToString(patientAllergies.status);
            obsValueAsCE.CodeSystem  = "2.16.840.1.113883.6.96";

            obs_EntryRel.AsObservation.Value.Add(obsValueAsCE);
            obs_EntryRel.InversionInd          = true;
            obs_EntryRel.InversionIndSpecified = true;
            ///' Allergy Reaction Observation
            if (!string.IsNullOrEmpty(patientAllergies.reaction))
            {
                obs_EntryRel                         = entryRel.AsObservation.EntryRelationship.Append();
                obs_EntryRel.TypeCode                = x_ActRelationshipEntryRelationship.MFST;
                obs_EntryRel.InversionInd            = true;
                obs_EntryRel.InversionIndSpecified   = true;
                obs_EntryRel.AsObservation.ClassCode = "OBS";
                obs_EntryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
                hl7III = obs_EntryRel.AsObservation.TemplateId.Append();
                hl7III.Init("2.16.840.1.113883.10.20.22.4.9");
                hl7III = obs_EntryRel.AsObservation.Id.Append();
                hl7III.Init("4adc1020-7b14-11db-9fe1-0800200c9a64");
                obs_EntryRel.AsObservation.Code.NullFlavor = "UNK";
                //obs_EntryRel.AsObservation.Text.Reference.Value = "#" & Convert.ToString(dtRow("ReactionID")) '"#reaction1"
                obs_EntryRel.AsObservation.StatusCode.Code = "completed";
                obs_EntryRel.AsObservation.EffectiveTime   = new IVL_TS().Init(low: new IVXB_TS(), high: new IVXB_TS());
                obsValueAsCD = new CD();
                if (!string.IsNullOrEmpty(GetSNOMED(patientAllergies.reaction)))
                {
                    obsValueAsCD.Code = GetSNOMED(patientAllergies.reaction);
                    // Dynamic Value ''
                }

                obsValueAsCD.DisplayName = patientAllergies.reaction;
                //"Hives"
                obsValueAsCD.CodeSystem = "2.16.840.1.113883.6.96";
                obsValueAsCD.OriginalText.Reference.Value = "#" + Convert.ToString(patientAllergies.allergyId);
                obs_EntryRel.AsObservation.Value.Add(obsValueAsCD);
            }

            ///' Allergy Severity Observation
            if (!string.IsNullOrEmpty(patientAllergies.reaction))
            {
                obs_EntryRel                         = entryRel.AsObservation.EntryRelationship.Append();
                obs_EntryRel.TypeCode                = x_ActRelationshipEntryRelationship.SUBJ;
                obs_EntryRel.InversionInd            = true;
                obs_EntryRel.InversionIndSpecified   = true;
                obs_EntryRel.AsObservation.ClassCode = "OBS";
                obs_EntryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
                hl7III = obs_EntryRel.AsObservation.TemplateId.Append();
                hl7III.Init("2.16.840.1.113883.10.20.22.4.8");
                obs_EntryRel.AsObservation.Code.Code           = "SEV";
                obs_EntryRel.AsObservation.Code.DisplayName    = "Severity Observation";
                obs_EntryRel.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.5.4";
                obs_EntryRel.AsObservation.Code.CodeSystemName = "ActCode";
                //obs_EntryRel.AsObservation.Text.Reference.Value = "#severity1"
                obs_EntryRel.AsObservation.StatusCode.Code = "completed";
                obsValueAsCD             = new CD();
                obsValueAsCD.Code        = (Convert.ToString(patientAllergies.reaction) == "Mild" ? "255604002" : (Convert.ToString(patientAllergies.reaction) == "Moderate" ? "6736007" : "24484000"));
                obsValueAsCD.DisplayName = patientAllergies.reaction;
                // Moderate or Mild or severe"
                obsValueAsCD.CodeSystem     = "2.16.840.1.113883.6.96";
                obsValueAsCD.CodeSystemName = "SNOMED CT";
                obsValueAsCD.OriginalText.Reference.Value = "#" + Convert.ToString(patientAllergies.allergyId);
                obs_EntryRel.AsObservation.Value.Add(obsValueAsCD);
            }
        }