private void ProcessValueSetSheet(ImportCheckResponse response, SheetData sheetData, WorkbookPart wbPart, bool firstRowIsHeader) { var rows = sheetData.Descendants <Row>(); foreach (var row in rows) { if (firstRowIsHeader && row.RowIndex.Value == 1) { continue; } var cells = row.Descendants <Cell>(); if (cells.Count() < 2) { response.Errors.Add(string.Format("Row {0} on valueset sheet does not have the required number of cells (2)", row.RowIndex.Value)); continue; } Cell nameCell = cells.SingleOrDefault(y => y.CellReference == "A" + row.RowIndex.Value.ToString()); Cell oidCell = cells.SingleOrDefault(y => y.CellReference == "B" + row.RowIndex.Value.ToString()); var name = GetCellValue(nameCell, wbPart); var oid = GetCellValue(oidCell, wbPart); ImportValueSetChange change = new ImportValueSetChange(); ValueSet foundValueSet = this.tdb.ValueSets.SingleOrDefault(y => y.Oid == oid); if (foundValueSet == null) { change.ChangeType = ImportValueSetChange.ChangeTypes.Add; } else { change.Id = foundValueSet.Id; if (foundValueSet.Name != name) { change.ChangeType = ImportValueSetChange.ChangeTypes.Update; } } change.Oid = oid; change.Name = name; response.ValueSets.Add(change); } }
private void ProcessValueSetSheet(ImportCheckResponse response, SheetData sheetData, WorkbookPart wbPart, bool firstRowIsHeader) { var rows = sheetData.Descendants <Row>(); foreach (var row in rows) { if (firstRowIsHeader && row.RowIndex.Value == 1) { continue; } var cells = row.Descendants <Cell>(); if (cells.Count() < 2) { response.Errors.Add(string.Format("Row {0} on valueset sheet does not have the required number of cells (2)", row.RowIndex.Value)); continue; } Cell nameCell = cells.SingleOrDefault(y => y.CellReference == "A" + row.RowIndex.Value.ToString()); Cell oidCell = cells.SingleOrDefault(y => y.CellReference == "B" + row.RowIndex.Value.ToString()); var name = GetCellValue(nameCell, wbPart); var identifier = GetCellValue(oidCell, wbPart); if (string.IsNullOrEmpty(identifier)) { response.Errors.Add(string.Format("Row {0} on valueset sheet does not specify an identifier for the value set", row.RowIndex.Value)); continue; } if (!identifier.StartsWith("http://") && !identifier.StartsWith("https://") && !identifier.StartsWith("urn:oid:")) { response.Errors.Add(string.Format("Row {0}'s identifier on valueset sheet must be correctly formatted as one of: http[s]://XXXX or urn:oid:XXXX", row.RowIndex.Value)); continue; } ImportValueSetChange change = new ImportValueSetChange(); ValueSet foundValueSet = (from vs in this.tdb.ValueSets join vsi in this.tdb.ValueSetIdentifiers on vs.Id equals vsi.ValueSetId where vsi.Identifier.ToLower().Trim() == identifier.ToLower().Trim() select vs) .Distinct() .FirstOrDefault(); if (foundValueSet == null) { change.ChangeType = ImportValueSetChange.ChangeTypes.Add; } else { change.ValueSet = foundValueSet; change.Id = foundValueSet.Id; if (foundValueSet.Name != name) { change.ChangeType = ImportValueSetChange.ChangeTypes.Update; } } change.Oid = identifier; change.Name = name; response.ValueSets.Add(change); } }