private IList <ValueSet> GetValueSetsFromFlatFileFormat(string path, bool genereateNarrative = true) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException(nameof(path)); } if (!File.Exists(path)) { throw new FileNotFoundException($"File not found: '{path}'.", path); } IList <ValueSet> valueSets = new List <ValueSet>(); var engine = new MasterDetailEngine <ValueSetHeader, ValueSetCodeReferences>(new MasterDetailSelector(RecordSelector)) { Encoding = new UTF8Encoding() }; MasterDetails <ValueSetHeader, ValueSetCodeReferences>[] masterDetails = engine.ReadFile(path); foreach (MasterDetails <ValueSetHeader, ValueSetCodeReferences> masterDetail in masterDetails) { _logger.LogDebug($"ValueSet: {masterDetail.Master.Id} - {masterDetail.Master.Title}"); ValueSet valueSet = new ValueSet { Id = masterDetail.Master.Id, Name = masterDetail.Master.Name, Title = masterDetail.Master.Title, Status = PublicationStatus.Draft, Version = masterDetail.Master.Version, Publisher = masterDetail.Master.Publisher, }; ValueSet.ConceptSetComponent conceptSet = new ValueSet.ConceptSetComponent { System = masterDetail.Master.System }; valueSet.Compose = new ValueSet.ComposeComponent { Include = new List <ValueSet.ConceptSetComponent> { conceptSet } }; foreach (ValueSetCodeReferences valueSetCodeReference in masterDetail.Details) { _logger.LogDebug($"ValueSetCodeReference: {valueSetCodeReference.Code} - {valueSetCodeReference.Display}"); conceptSet.Concept.Add(new ValueSet.ConceptReferenceComponent { Code = valueSetCodeReference.Code, Display = valueSetCodeReference.Display }); } if (genereateNarrative) { valueSet.GenerateAndSetNarrative(); } valueSets.Add(valueSet); } return(valueSets); }