private void MatchMsgNodeToMappingRecursive(MsgNode node) { foreach (MsgNode childnode in node.Children) { // -- Hvis mappingsegment == null indikeres det med annen treenode farge. -- childnode.MappingSegment = MappingSelected.GetSegmentFromSection(childnode.MappingSectionName, childnode.Index_L1, childnode.Index_L2); MatchMsgNodeToMappingRecursive(childnode); // -- Erstatt verdien til segmentet hvis det skal være skjult -- if (childnode.MappingSegment != null) { // -- Sjekker om verdien skal skjules som ***** -- if (childnode.MappingSegment.HideValue) { childnode.Value = MSG_NODE_VALUE_HIDDEN; } // -- Sjekker om verdien skal vises i bold font -- if (childnode.MappingSegment.ShowValueAsBold) { childnode.ShowAsBoldFont = true; } childnode.ValidateNode(); } } }
/// <summary> /// Oppretter meldingsnoder for de ulike nivåene i meldingsfilen. /// </summary> /// <param name="strFileContent"></param> public void ImportHL7MsgFile(string strFileContent) { // _HL7SegmentCategories = new HL7SegmentCategories(); #region -- Find executable path-- FileInfo executableFi = new FileInfo(Application.ExecutablePath); // Hent mappingfilen fra programfolderen. //MappingFileFi = new FileInfo(Path.Combine(executableFi.DirectoryName, "Datamodel", MappingFileName)); //MappingSelected.ImportMapping(MappingFileFi); #endregion -- Find executable path -- this.MsgRootnode = new MsgNode("Root", strFileContent, 0, 0); MsgRootnode.CreateChildNodes_L1(SEPARATOR_LEVEL_0); //, false); // Setter Name og ekstraherer SourceString for nodene i nivå 0 foreach (MsgNode childnode in MsgRootnode.Children) { childnode.ExtractNameAndSourceStringFirstLevel(SEPARATOR_LEVEL_1); } // -- Populerer SectionIndex for hver msgNode -- int sectionIndesTmp = 0; foreach (MsgNode childnode in MsgRootnode.Children) { childnode.SectionIndex = sectionIndesTmp; sectionIndesTmp++; } foreach (MsgNode subNode_L0 in MsgRootnode.Children) { // -- Parse subnodes level 1 -- subNode_L0.CreateChildNodes_L2(SEPARATOR_LEVEL_1); //, true); //, false); //subNode_L0.Level = 2; foreach (MsgNode subNode_L1 in subNode_L0.Children) { if ( (subNode_L1.Value.Split(SEPARATOR_LEVEL_3_REPEATING_FIELD).Length > 1) && // Inneholder skilletegn for repeterende noder '~' (!(subNode_L1.MappingSectionName == "MSH" && subNode_L1.Level == 1 && subNode_L1.Index_L1 == 1 && subNode_L1.Index_L2 == 0)) //Hopp over node MSH 0,1. Den lister opp skilletegn ) { // -- Legge inn node for hver av de reperende feltene. F.eks varienende antall kopimottakere i OBR 28. subNode_L1.CreateChildNodes_L4(SEPARATOR_LEVEL_2, SEPARATOR_LEVEL_3_REPEATING_FIELD); } else { subNode_L1.CreateChildNodes_L3(SEPARATOR_LEVEL_2); //, true, false); //subNode_L1.Level = 3; //subNode_L1.Index_L2 = subNode_L0.Index_L2; } } } // -- Matcher mot mapping -- foreach (MsgNode childnode in this.MsgRootnode.Children) { childnode.MappingSegment = MappingSelected.GetSegmentFromSection(childnode.MappingSectionName, childnode.Index_L2, childnode.Index_L2); // -- Erstatt verdien til segmentet hvis det skal være skjult -- if (childnode.MappingSegment != null) { // -- Sjekker om verdien skal skjules som ***** -- if (childnode.MappingSegment.HideValue) { childnode.Value = MSG_NODE_VALUE_HIDDEN; } // -- Sjekker om verdien skal vises i bold font -- if (childnode.MappingSegment.ShowValueAsBold) { childnode.ShowAsBoldFont = true; } childnode.ValidateNode(); } MatchMsgNodeToMappingRecursive(childnode); } }