protected override SchemaRow ReadRow(ExcelWorksheet schemaWorksheet, int row) { if (row > schemaWorksheet.Dimension.End.Row) { return(null); } X12SchemaRow schemaRow = new X12SchemaRow(); schemaRow.Grouping = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, GroupingIndex); schemaRow.Loop = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, LoopIndex); schemaRow.Segment = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, SegmentIndex); schemaRow.DataElementTag = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, DataElementTagIndex); schemaRow.DataElementName = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, DataElementNameIndex); base.ReadBasicRowData(schemaWorksheet, schemaRow, row); // This code was added during contingency field handling, however maps migration project generate spec certs without contingencies and hence the following code was removed. // if (string.IsNullOrWhiteSpace(schemaRow.DataElementTag) == false && string.Compare(schemaRow.DataElementTag, "HL03", true) == 0) // schemaRow.IsTriggerField = true; // Check for invalid loop names if (string.IsNullOrWhiteSpace(schemaRow.Loop) == false && string.Equals(schemaRow.Loop, "n/a", StringComparison.InvariantCultureIgnoreCase) == false && schemaRow.Loop.Trim().Contains('|')) { AddValidationResult(ResultType.Error, row, GCExcelReaderHelper.GetColumnIndex(MinMaxIndex), string.Format("Invalid loop value {0}", schemaRow.Loop)); } return(schemaRow); }
private IPluglet GetSegment(ExcelWorksheet schemaWorksheet, ref int row, out string nextLoopName) { // TODO: Handle this in better way if (row > schemaWorksheet.Dimension.End.Row) { nextLoopName = null; return(null); } // Currently setting Min and Max for segment is hard coded as 0, 1, since these values are not present in excel int segmentMinOccur = 0; int segmentMaxOccur = 100; bool isIgnore; // First read Segment row X12SchemaRow segmentRow = ReadRow(schemaWorksheet, row) as X12SchemaRow; nextLoopName = segmentRow.Loop; if (nextLoopName == null) { nextLoopName = string.Empty; } segmentMinOccur = string.Compare(segmentRow.MandatoryFlag, "Y", true) == 0 ? 1 : 0; segmentMaxOccur = string.Compare(segmentRow.MandatoryFlag, "N", true) == 0 ? 0 : 1000; isIgnore = string.Compare(segmentRow.IgnoreFlag, "I", true) == 0; IPluglet segment = new Pluglet(segmentRow.Segment, segmentRow.DataElementTag, PlugletType.Segment, null, segmentMinOccur, segmentMaxOccur, isIgnore); string xPath = nextLoopName; if (string.Compare(xPath, "n/a", true) == 0) { xPath = nextLoopName = string.Empty; } if (string.IsNullOrWhiteSpace(xPath) == false) { xPath = string.Format("X12{0}{1}Loop{2}{3}{4}", segment.PathSeperator, xPath, segment.PathSeperator, segment.Tag, segment.PathSeperator); } else { xPath = string.Format("X12{0}{1}{2}", segment.PathSeperator, segment.Tag, segment.PathSeperator); } ++row; IPluglet dataPluglet = null; int minOccurs, maxOccurs; // Now read all data elements till groupping column has some value (indicates new Segment started) while ((segmentRow = ReadRow(schemaWorksheet, row) as X12SchemaRow) != null) { if (string.IsNullOrEmpty(segmentRow.Grouping) == false) { break; } // TODO: What about mandatory flag value 'X'? minOccurs = string.Compare(segmentRow.MandatoryCode, "M", true) == 0 && string.Compare(segmentRow.MandatoryFlag, "Y", true) == 0 ? 1 : 0; maxOccurs = string.Compare(segmentRow.MandatoryFlag, "N", true) == 0 ? 0 : 1; isIgnore = string.Compare(segmentRow.IgnoreFlag, "I", true) == 0; dataPluglet = new Pluglet( new PlugletInput() { Name = segmentRow.DataElementTag, Definition = segmentRow.DataElementName, Type = PlugletType.Data, Parent = segment, MinOccurs = minOccurs, MaxOccurs = maxOccurs, IsIgnore = isIgnore, IsTriggerField = segmentRow.IsTriggerField }); ++row; dataPluglet.DataType = ReadDataType(segmentRow, schemaWorksheet, string.Format("{0}{1}", xPath, segmentRow.DataElementTag), ref row); } FillInMissingChildren(segment); return(segment); }