private ValueSet ConvertValueSetFromR4ToR3(string path) { string data; using (TextReader reader = new StreamReader(path)) data = reader.ReadToEnd(); R4Model.ValueSet valueSet = null; if (SerializationUtil.ProbeIsXml(data)) { valueSet = _r4XmlParser.Parse <R4Model.ValueSet>(data); } else if (SerializationUtil.ProbeIsJson(data)) { valueSet = _r4JsonParser.Parse <R4Model.ValueSet>(data); } else { Assert.True(false, $"File '{path}' does not contain valid Xml or Json"); } if (valueSet == null) { return(null); } FhirConverter converter = new FhirConverter(FhirVersion.R3, FhirVersion.R4); return(converter.Convert <ValueSet, R4Model.ValueSet>(valueSet)); }
public static Narrative GenerateNarrative(this R4Model.ValueSet valueSet) { StringBuilder div = new StringBuilder(); div.Append("<div xmlns=\"http://www.w3.org/1999/xhtml\">"); div.Append($"<p>Value set \"{valueSet.Id}: {valueSet.Name}\"</p>"); div.Append($"<p>Developed by: {valueSet.Publisher}</p>"); div.Append($"<p>Published for testing purposes on {valueSet.Date}</p>"); div.Append($"<p>This value set contains the following codes from code system: {valueSet.Id}</p>"); div.Append("<ol>"); foreach (var conceptSet in valueSet.Compose.Include) { foreach (var concept in conceptSet.Concept) { div.Append($"<li>{concept.Code}: {concept.Display}</li>"); } } div.Append("</ol>"); div.Append("</div>"); return(new Narrative { Status = Narrative.NarrativeStatus.Generated, Div = div.ToString() }); }