Esempio n. 1
0
        private void loadValues()
        {
            string strRoutineName = "loadValues";

            try
            {
                IED eied = iedList.ElementAt(editIndex);
                if (eied != null)
                {
                    uciec104.txtUnitID.Text        = eied.UnitID;
                    uciec104.txtRemoteIP.Text      = eied.RemoteIP;
                    uciec104.txtASDUaddress.Text   = eied.ASDUAddr;
                    uciec104.cmbASDU.SelectedIndex = uciec104.cmbASDU.FindStringExact(eied.ASDUSize);
                    uciec104.CmbIOA.SelectedIndex  = uciec104.CmbIOA.FindStringExact(eied.IOASize);
                    uciec104.CmbCOT.SelectedIndex  = uciec104.CmbCOT.FindStringExact(eied.COTSize);
                    uciec104.txtRetries.Text       = eied.Retries;
                    uciec104.txtTimeOut.Text       = eied.TimeOutMS;
                    uciec104.txtT0.Text            = eied.T0;
                    uciec104.txtT1.Text            = eied.T1;
                    uciec104.txtT2.Text            = eied.T2;
                    uciec104.txtT3.Text            = eied.T3;
                    uciec104.txtW.Text             = eied.W;
                    uciec104.txtK.Text             = eied.K;
                    uciec104.txtDevice.Text        = eied.Device;
                    uciec104.txtDescription.Text   = eied.Description;
                    //Ajay:06/07/2018
                    uciec104.txtRdeudantIP.Text = eied.RedundantIP;
                    uciec104.txtTCPPort.Text    = eied.TCPPort; //Ajay: 19/09/2018
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void loadValues()
        {
            string strRoutineName = "loadValues";

            try
            {
                IED eied = iedList.ElementAt(editIndex);
                if (eied != null)
                {
                    uciec.txtUnitID.Text      = eied.UnitID;
                    uciec.txtASDUaddress.Text = eied.ASDUAddr;
                    uciec.txtDevice.Text      = eied.Device;
                    uciec.txtRetries.Text     = eied.Retries;
                    uciec.txtTimeOut.Text     = eied.TimeOutMS;
                    if (eied.DR.ToLower() == "enable")
                    {
                        uciec.chkDR.Checked = true;
                    }
                    else
                    {
                        uciec.chkDR.Checked = false;
                    }
                    uciec.txtDescription.Text = eied.Description;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void GenerateSocialHistoryEmpty(III hl7III, Factory hl7Factory)
        {
            IEntry entry = functionalStatus.Section.Entry.Append();

            entry.AsObservation.ClassCode = "OBS";
            entry.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            IIVXB_TS TS = hl7Factory.CreateIVXB_TS();

            hl7III = entry.AsObservation.Id.Append();
            hl7III.Init(Guid.NewGuid().ToString());
            hl7III = entry.AsObservation.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.78");
            IED ED = hl7Factory.CreateED();

            entry.AsObservation.Code.Code           = "ASSERTION";
            entry.AsObservation.Code.DisplayName    = "Assertion";
            entry.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.5.4";
            entry.AsObservation.Code.CodeSystemName = "ActCode";
            entry.AsObservation.StatusCode.Init("completed");
            entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS(), high: new IVXB_TS());
            ICD CD = hl7Factory.CreateCD();

            CD.NullFlavor = "UNK";
            entry.AsObservation.Value.Add(CD);
        }
        private void btnExportIED_Click(object sender, EventArgs e)
        {
            string strRoutineName = "btnExportIED_Click";

            try
            {
                if (uciec101.lvIEDList.CheckedItems.Count != 1)
                {
                    MessageBox.Show("Select single IED for export!!!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                ListViewItem lvi    = uciec101.lvIEDList.CheckedItems[0];
                IED          expObj = null;
                //Now get the IED object...
                foreach (IED iedObj in iedList)
                {
                    if (iedObj.UnitID == lvi.Text)
                    {
                        expObj = iedObj;
                        break;
                    }
                }
                Utils.SaveIEDFile(expObj.exportIED());
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void fillOptions()
        {
            string strRoutineName = "fillOptions";

            try
            {
                //Fill ASDU size...
                uciec104.cmbASDU.Items.Clear();
                foreach (String br in IED.getASDUsizes())
                {
                    uciec104.cmbASDU.Items.Add(br.ToString());
                }
                uciec104.cmbASDU.SelectedIndex = 0;

                //Fill IOA size...
                uciec104.CmbIOA.Items.Clear();
                foreach (String br in IED.getIOAsizes())
                {
                    uciec104.CmbIOA.Items.Add(br.ToString());
                }
                uciec104.CmbIOA.SelectedIndex = 0;

                //Fill COT size...
                uciec104.CmbCOT.Items.Clear();
                foreach (String br in IED.getCOTsizes())
                {
                    uciec104.CmbCOT.Items.Add(br.ToString());
                }
                uciec104.CmbCOT.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public GseControlSelectionForm(IED ied) : this()
        {
            _ied = ied;

            LoadGrid(ied);

            AddDescriptions();
        }
 private bool IsUnitIDUnique(string unitID)
 {
     for (int i = 0; i < iedList.Count; i++)
     {
         IED ied = iedList.ElementAt(i);
         if (ied.UnitID == unitID && (mode == Mode.ADD || editIndex != i))
         {
             return(false);
         }
     }
     return(true);
 }
        public void GenerateProblemEntryEmpty(string refId, 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;
            IIVXB_TS TS = hl7Factory.CreateIVXB_TS();

            hl7III = entry.AsAct.Id.Append();
            hl7III.Init(Convert.ToString(Guid.NewGuid()));
            hl7III = entry.AsAct.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.3");
            entry.AsAct.Code.Code           = "CONC";
            entry.AsAct.Code.CodeSystem     = "2.16.840.1.113883.5.6";
            entry.AsAct.Code.CodeSystemName = "HL7ActClass";
            entry.AsAct.Code.DisplayName    = "Concern";
            entry.AsAct.StatusCode.Init("completed");
            entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
            IEntryRelationship entryRel = entry.AsAct.EntryRelationship.Append();

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

            TempId.Root = "2.16.840.1.113883.10.20.22.4.4";
            hl7III      = entryRel.AsObservation.Id.Append();
            hl7III.Root = Guid.NewGuid().ToString();
            entryRel.AsObservation.Code.Code           = "55607006";
            entryRel.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.6.96";
            entryRel.AsObservation.Code.DisplayName    = "Problem";
            entryRel.AsObservation.Code.CodeSystemName = "SNOMED CT";
            IED ED = hl7Factory.CreateED();

            ED.Reference.Value          = refId;
            entryRel.AsObservation.Text = ED;
            ICS CS = hl7Factory.CreateCS();

            CS.Init("completed");
            entryRel.AsObservation.StatusCode    = CS;
            entryRel.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS(), high: new IVXB_TS());
            ICD CD = hl7Factory.CreateCD();

            CD.Code           = "55607006";
            CD.CodeSystem     = "2.16.840.1.113883.6.96";
            CD.CodeSystemName = "SNOMED CT";
            CD.DisplayName    = Convert.ToString("Problem");
            entryRel.AsObservation.Value.Add(CD);
        }
Esempio n. 9
0
        private void loadValues()
        {
            IED eied = iedList.ElementAt(editIndex);

            if (eied != null)
            {
                uclp.txtUnitID.Text          = eied.UnitID;
                uclp.txtDevice.Text          = eied.Device;
                uclp.txtTapRatio.Text        = eied.DefaultTapRatio;
                uclp.txtTxOffsetCurrent.Text = eied.TXOffsetCurrent;
                uclp.txtDescription.Text     = eied.Description;
            }
        }
        private void LoadGrid(IED ied)
        {
            var column = dataGridView.Columns[3] as DataGridViewComboBoxColumn;

            column.Items.Clear();
            column.Items.AddRange(ProfileRegistry.Profiles.Keys.ToArray());

            List <GseControlSelection> ds = new List <GseControlSelection>();

            foreach (var gse in ied.GseControls)
            {
                ds.Add(new GseControlSelection()
                {
                    Name       = gse.Name,
                    GseControl = gse
                });
            }
            dataGridView.DataSource = ds;
        }
        private void IedCombo_SelectedValueChanged(object sender, EventArgs e)
        {
            IED ied = iedCombo.SelectedValue as IED;

            treeView.Nodes.Clear();

            TreeNode node = new TreeNode("GOOSE");

            node.Tag = ied;
            treeView.Nodes.Add(node);
            foreach (var gse in ied.GseControls)
            {
                TreeNode g = new TreeNode(gse.Name);
                g.Tag = gse;
                node.Nodes.Add(g);
            }
            treeView.ExpandAll();
            treeView.SelectedNode = node;

            createConfigButton.Visible = true;
        }
        private void loadValues()
        {
            string strRoutineName = "loadValues";

            try
            {
                IED eied = iedList.ElementAt(editIndex);
                if (eied != null)
                {
                    ucadr.txtUnitID.Text      = eied.UnitID;
                    ucadr.txtDevice.Text      = eied.Device;
                    ucadr.txtRetries.Text     = eied.Retries;
                    ucadr.txtTimeOut.Text     = eied.TimeOutMS;
                    ucadr.txtDescription.Text = eied.Description;
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + Ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnExportIED_Click(object sender, EventArgs e)
        {
            if (ucmod.lvIEDList.CheckedItems.Count != 1)
            {
                MessageBox.Show("Select single IED for export!!!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            ListViewItem lvi    = ucmod.lvIEDList.CheckedItems[0];
            IED          expObj = null;

            //Now get the IED object...
            foreach (IED iedObj in iedList)
            {
                if (iedObj.UnitID == lvi.Text)
                {
                    expObj = iedObj;
                    break;
                }
            }
            Utils.SaveIEDFile(expObj.exportIED());// exportIED
        }
        private bool IsUnitIDUnique(string unitID)
        {
            string strRoutineName = "IsUnitIDUnique";

            try
            {
                for (int i = 0; i < iedList.Count; i++)
                {
                    IED ied = iedList.ElementAt(i);
                    if (ied.UnitID == unitID && (mode == Mode.ADD || editIndex != i))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception Ex)
            {
                throw Ex;
                //MessageBox.Show(strRoutineName + ": " + "Error: " + Ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void loadValues()
        {
            IED eied = iedList.ElementAt(editIndex);

            if (eied != null)
            {
                ucmod.txtUnitID.Text   = eied.UnitID;
                ucmod.txtRemoteIP.Text = eied.RemoteIP;
                ucmod.txtTCPPort.Text  = eied.TCPPort;
                ucmod.txtDevice.Text   = eied.Device;
                ucmod.txtRetries.Text  = eied.Retries;
                ucmod.txtTimeOut.Text  = eied.TimeOutMS;
                if (eied.DR.ToLower() == "enable")
                {
                    ucmod.chkDR.Checked = true;
                }
                else
                {
                    ucmod.chkDR.Checked = false;
                }
                ucmod.txtDescription.Text = eied.Description;
            }
        }
        public void GenerateSocialHistoryEntry(string observerValue, ref int refId, string obsrvType, III hl7III, Factory hl7Factory)
        {
            if (obsrvType == "Smoking")
            {
                IEntry entry = functionalStatus.Section.Entry.Append();
                //GetSNOMED(obsrvType)
                entry.AsObservation.ClassCode = "OBS";
                entry.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
                IIVXB_TS TS = hl7Factory.CreateIVXB_TS();
                hl7III = entry.AsObservation.Id.Append();
                hl7III.Init(Guid.NewGuid().ToString());
                hl7III = entry.AsObservation.TemplateId.Append();
                hl7III.Init("2.16.840.1.113883.10.20.22.4.78");
                //entry.AsObservation.Code.Code = IIf(obsrvType = "Smoking", "230056004", IIf(obsrvType = "Alcohol", "160573003", IIf(obsrvType = "Drugs", "228423003", "229819007")))
                IED ED = hl7Factory.CreateED();
                entry.AsObservation.Code.Code           = "ASSERTION";
                entry.AsObservation.Code.DisplayName    = "Assertion";
                entry.AsObservation.Code.CodeSystem     = "2.16.840.1.113883.5.4";
                entry.AsObservation.Code.CodeSystemName = "ActCode";
                //ED.Reference.Value = "#Sec" + refId
                //entry.AsObservation.Code.OriginalText = ED
                //entry.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.96"
                //entry.AsObservation.Code.DisplayName = IIf(obsrvType = "Smoking", "Cigarette smoking", IIf(obsrvType = "Alcohol", "Alcohol consumption", IIf(obsrvType = "Drugs", "Drugs consumption", "Tobacoo consumption")))

                entry.AsObservation.StatusCode.Init("completed");
                entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS(), high: new IVXB_TS());
                //entry.AsObservation.EffectiveTime.High.Value = "UNK"
                ICD CD = hl7Factory.CreateCD();
                CD.CodeSystemName = "SNOMED CT";
                //= observerValue
                CD.CodeSystem  = "2.16.840.1.113883.6.96";
                CD.Code        = "77176002";
                CD.DisplayName = "Cigarette smoking";
                CD.OriginalText.Reference.Value = "#Sec" + refId;
                entry.AsObservation.Value.Add(CD);
                refId = refId + 1;
            }
            else
            {
                IEntry entry = functionalStatus.Section.Entry.Append();
                GetSNOMED(obsrvType);
                entry.TypeCode = x_ActRelationshipEntry.DRIV;
                entry.AsObservation.ClassCode = "OBS";
                entry.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
                IIVXB_TS TS = hl7Factory.CreateIVXB_TS();
                hl7III = entry.AsObservation.Id.Append();
                hl7III.Init(Guid.NewGuid().ToString());
                hl7III = entry.AsObservation.TemplateId.Append();
                hl7III.Init("2.16.840.1.113883.10.20.22.4.38");
                entry.AsObservation.Code.Code = (obsrvType == "Smoking" ? "230056004" : (obsrvType == "Alcohol" ? "160573003" : (obsrvType == "Drugs" ? "228423003" : "229819007")));
                IED ED = hl7Factory.CreateED();
                ED.Reference.Value = "#Sec" + refId;
                entry.AsObservation.Code.OriginalText = ED;
                entry.AsObservation.Code.CodeSystem   = "2.16.840.1.113883.6.96";
                entry.AsObservation.Code.DisplayName  = (obsrvType == "Smoking" ? "Cigarette smoking" : (obsrvType == "Alcohol" ? "Alcohol consumption" : (obsrvType == "Drugs" ? "Drugs consumption" : "Tobacoo consumption")));

                entry.AsObservation.StatusCode.Init("completed");
                entry.AsObservation.EffectiveTime.NullFlavor = "UNK";
                IST ST = hl7Factory.CreateST();
                ST.Text = observerValue;
                entry.AsObservation.Value.Add(ST);
                refId = refId + 1;
            }
        }
        public void GenerateProblemEntry(PatientProblemes patientProblem, string refId, DateTime dateofbirth, 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;
            IIVXB_TS TS = hl7Factory.CreateIVXB_TS();

            hl7III = entry.AsAct.Id.Append();

            hl7III.Init(Convert.ToString(patientProblem.PatientGuid));
            hl7III = entry.AsAct.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.3");
            entry.AsAct.Code.Code           = "CONC";
            entry.AsAct.Code.CodeSystem     = "2.16.840.1.113883.5.6";
            entry.AsAct.Code.CodeSystemName = "LOINC";

            entry.AsAct.StatusCode.Init((Convert.ToString(patientProblem.Status) == "Active" ? "active" : "completed"));
            if (patientProblem.DateDiagnosed != null)
            {
                entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
            }
            else
            {
                entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                //entry.AsAct.EffectiveTime.NullFlavor = "UNK";

                /* Not Compiled
                 * entry.AsAct.EffectiveTime = new IVL_TS().Init(Value:null, low:new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)),high:null,width:null,center:null);*/
                // Setting the DateTime.
            }

            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.4";
            hl7III      = entryRel.AsObservation.Id.Append();
            hl7III.Root = Guid.NewGuid().ToString();

            entryRel.AsObservation.Code.Code        = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "404684003" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "282291009" : "409586006";
            entryRel.AsObservation.Code.CodeSystem  = "2.16.840.1.113883.6.96";
            entryRel.AsObservation.Code.DisplayName = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "Finding" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "Diagnosis" : "Complaint";


            IED ED = hl7Factory.CreateED();

            ED.Reference.Value          = refId;
            entryRel.AsObservation.Text = ED;
            ICS CS = hl7Factory.CreateCS();

            CS.Init("completed");
            entryRel.AsObservation.StatusCode = CS;

            if (Convert.ToString(patientProblem.Status) == "Resolved")
            {
                if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value))
                {
                    entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                }
                else
                {
                    entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                    //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK";

                    /* Not Compiled
                     * entryRel.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS());
                     * // Because Allergy Start Date is Missing.
                     *
                     * entryRel.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/
                }
            }
            else
            {
                if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value))
                {
                    entryRel.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                    //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK";
                }
                else
                {
                    entryRel.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                    //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK";

                    /* Not Compiled
                     * entryRel.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS());
                     * entryRel.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/
                }
            }

            ICD CD = hl7Factory.CreateCD();

            string snomedCode = GetSNOMED(Convert.ToString(patientProblem.Description));

            if (string.IsNullOrEmpty(snomedCode))
            {
                CD.NullFlavor = "UNK";
            }
            else
            {
                CD.Code           = snomedCode;
                CD.CodeSystem     = "2.16.840.1.113883.6.96";
                CD.CodeSystemName = "SNOMED CT";
                CD.DisplayName    = Convert.ToString(patientProblem.Description);
            }

            entryRel.AsObservation.Value.Add(CD);

            ///''''''''''''Problem Observation''''''''''''''''''
            IEntryRelationship entryProblemObs = entryRel.AsObservation.EntryRelationship.Append();

            entryProblemObs.TypeCode = x_ActRelationshipEntryRelationship.SUBJ;
            entryProblemObs.AsObservation.ClassCode = "OBS";
            entryProblemObs.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            TempId      = entryProblemObs.AsObservation.TemplateId.Append();
            TempId.Root = "2.16.840.1.113883.10.20.22.4.4";
            hl7III      = entryProblemObs.AsObservation.Id.Append();
            hl7III.Root = Guid.NewGuid().ToString();

            entryProblemObs.AsObservation.Code.Code        = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "404684003" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "282291009" : "409586006";
            entryProblemObs.AsObservation.Code.CodeSystem  = "2.16.840.1.113883.6.96";
            entryProblemObs.AsObservation.Code.DisplayName = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "Finding" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "Diagnosis" : "Complaint";

            ED = hl7Factory.CreateED();
            ED.Reference.Value = refId;
            entryProblemObs.AsObservation.Text = ED;
            CS = hl7Factory.CreateCS();
            CS.Init("completed");
            entryProblemObs.AsObservation.StatusCode = CS;

            if (Convert.ToString(patientProblem.Status) == "Resolved")
            {
                if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value))
                {
                    entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                    //entryProblemObs.AsObservation.EffectiveTime.NullFlavor = "UNK";
                }
                else
                {
                    entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());

                    /* Not Compiled
                     * entryProblemObs.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS());
                     * // Because Allergy Start Date is Missing.
                     * entryProblemObs.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/
                }
            }
            else
            {
                if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value))
                {
                    entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());
                }
                else
                {
                    entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS());

                    /* Not Compiled
                     * entryProblemObs.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS());
                     * entryProblemObs.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/
                }
            }

            CD         = hl7Factory.CreateCD();
            snomedCode = GetSNOMED(Convert.ToString(patientProblem.Description));
            if (string.IsNullOrEmpty(snomedCode))
            {
                CD.NullFlavor = "UNK";
            }
            else
            {
                CD.Code        = snomedCode;
                CD.CodeSystem  = "2.16.840.1.113883.6.96";
                CD.DisplayName = Convert.ToString(patientProblem.Description);
            }

            entryProblemObs.AsObservation.Value.Add(CD);


            ///'''''''''''' Age Observation''''''''''''''''''

            if ((!object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value)))
            {
                IEntryRelationship age_EntryRel = entryRel.AsObservation.EntryRelationship.Append();
                age_EntryRel.TypeCode                = x_ActRelationshipEntryRelationship.SUBJ;
                age_EntryRel.InversionInd            = true;
                age_EntryRel.InversionIndSpecified   = true;
                age_EntryRel.AsObservation.ClassCode = "OBS";
                age_EntryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
                hl7III = age_EntryRel.AsObservation.TemplateId.Append();
                hl7III.Init("2.16.840.1.113883.10.20.22.4.31");
                CD = hl7Factory.CreateCD();
                CD.Init("445518008", "2.16.840.1.113883.6.96", "", "Age");
                age_EntryRel.AsObservation.Code = CD;
                age_EntryRel.AsObservation.StatusCode.Init("completed");
                IPQ PQ = hl7Factory.CreatePQ();
                PQ.Value = calcYear(Convert.ToDateTime(patientProblem.DateDiagnosed), dateofbirth);
                PQ.Unit  = "a";
                age_EntryRel.AsObservation.Value.Add(PQ);
            }

            ///'''''''''''' Problem Status Observation'''''''''''''
            IEntryRelationship problemStatus_EntryRel = entryRel.AsObservation.EntryRelationship.Append();

            problemStatus_EntryRel.TypeCode                = x_ActRelationshipEntryRelationship.REFR;
            problemStatus_EntryRel.InversionInd            = true;
            problemStatus_EntryRel.InversionIndSpecified   = true;
            problemStatus_EntryRel.AsObservation.ClassCode = "OBS";
            problemStatus_EntryRel.AsObservation.MoodCode  = x_ActMoodDocumentObservation.EVN;
            hl7III = problemStatus_EntryRel.AsObservation.TemplateId.Append();
            hl7III.Init("2.16.840.1.113883.10.20.22.4.6");

            CD = hl7Factory.CreateCD();
            CD.Init("33999-4", "2.16.840.1.113883.6.1", "LOINC", "Status");
            problemStatus_EntryRel.AsObservation.Code = CD;
            problemStatus_EntryRel.AsObservation.StatusCode.Init("completed");
            //55561003-Active, 73425007-Inactive, 413322009- Resolved
            CD = hl7Factory.CreateCD();

            CD.Init((Convert.ToString(patientProblem.Status) == "Active" ? "55561003" : (Convert.ToString(patientProblem.Status) == "Inactive" ? "73425007" : "413322009")), "2.16.840.1.113883.6.96", "SNOMED CT", Convert.ToString(patientProblem.Status));
            problemStatus_EntryRel.AsObservation.Value.Add(CD);
        }
Esempio n. 18
0
 public void LoadIed(IED ied)
 {
     headerLabel.Text    = $"{ied.Name} - GOOSE";
     dataGrid.DataSource = ied.GseControls;
 }
Esempio n. 19
0
        public static List <IED> Parse(string filePath)
        {
            List <IED> list = new List <IED>();

            XDocument doc = XDocument.Load(filePath);
            var       ns  = doc.Root.GetDefaultNamespace();

            var iedNodes = doc.Root.Elements(ns + "IED");

            foreach (var node in iedNodes)
            {
                string mrid = string.Empty;

                var mridNode = node.Elements(ns + "Private").FirstOrDefault(x => x.Attribute("type").Value == "mRID");
                if (mridNode != null)
                {
                    mrid = mridNode.Value;
                }
                else
                {
                    mrid = Guid.NewGuid().ToString().ToLower();
                }
                IED ied = new IED()
                {
                    Name = node.Attribute("name").Value,
                    MRID = mrid
                };

                // Access point LDO
                //var accessPoint = node.Elements(ns + "AccessPoint").FirstOrDefault(x => x.Attribute("name").Value == "LD0");
                var accessPoint = GetAccessPoint(node, ns);
                if (accessPoint != null)
                {
                    // Server

                    var server = accessPoint.Element(ns + "Server");

                    if (server != null)
                    {
                        // LD0
                        //var ld0 = server.Elements(ns + "LDevice").FirstOrDefault(x => x.Attribute("inst").Value == "LD0");
                        var ld0 = GetLD0(server, ns);
                        if (ld0 != null)
                        {
                            // LN0
                            var ln0 = ld0.Element(ns + "LN0");
                            if (ln0 != null)
                            {
                                // GSEControl
                                var gseControls = ln0.Elements(ns + "GSEControl");
                                if (gseControls != null && gseControls.Count() > 0)
                                {
                                    // Found GOOSE control blocks
                                    list.Add(ied);

                                    foreach (var gseControlNode in gseControls)
                                    {
                                        GseControl gseControl = new GseControl()
                                        {
                                            IED           = ied,
                                            LogicalDevice = "LD0",
                                            LogicalNode   = ln0.Attribute("lnClass").Value,
                                            Name          = gseControlNode.Attribute("name").Value,
                                            GooseId       = gseControlNode.Attribute("appID").Value,
                                            ConfRev       = gseControlNode.Attribute("confRev").Value,
                                            Dataset       = new DataSet()
                                            {
                                                Name = gseControlNode.Attribute("datSet").Value
                                            }
                                        };
                                        SetCommunication(doc.Root, ns, gseControl);

                                        ied.GseControls.Add(gseControl);

                                        var dataSetNode = ln0.Elements(ns + "DataSet").FirstOrDefault(x => x.Attribute("name").Value == gseControl.Dataset.Name);
                                        if (dataSetNode != null)
                                        {
                                            // FCDAs
                                            foreach (var fcdaNode in dataSetNode.Elements(ns + "FCDA"))
                                            {
                                                FCDA fcda = new FCDA()
                                                {
                                                    LDInst  = fcdaNode.Attribute("ldInst").Value,
                                                    Prefix  = fcdaNode.Attribute("prefix")?.Value,
                                                    LnClass = fcdaNode.Attribute("lnClass").Value,
                                                    LnInst  = Convert.ToInt32(fcdaNode.Attribute("lnInst").Value),
                                                    DoName  = fcdaNode.Attribute("doName").Value,
                                                    DaName  = fcdaNode.Attribute("daName").Value
                                                };

                                                var logicalDevice = server.Elements(ns + "LDevice").FirstOrDefault(x => x.Attribute("inst").Value == fcda.LDInst);
                                                //Get lnType
                                                var ln = logicalDevice.Elements(ns + "LN").
                                                         FirstOrDefault(x => x.Attribute("prefix")?.Value == fcda.Prefix &&
                                                                        x.Attribute("lnClass")?.Value == fcda.LnClass &&
                                                                        x.Attribute("inst")?.Value == fcda.LnInst.ToString());

                                                fcda.LnTypeId = ln.Attribute("lnType")?.Value;

                                                SetDataTypeForFCDA(doc.Root, ns, fcda);

                                                gseControl.Dataset.FCDAs.Add(fcda);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }