use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class PackageMaintainer method check.
private void check(String ver) throws IOException {
System.out.println("Check " + ver);
List<String> allIds = listResources(Utilities.path(PATH, "hl7.fhir." + ver + ".examples", "package"));
List<String> coreIds = listResources(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package"));
for (String s : coreIds) {
if (!allIds.contains(s)) {
System.out.println("Core contains " + s + " but allIds doesn't");
}
}
for (String s : allIds) {
if (!coreIds.contains(s)) {
String c = s.substring(0, s.indexOf("-"));
if (Utilities.existsInList(c, "CodeSystem", "ValueSet", "ConceptMap", "StructureDefinition", "StructureMap", "NamingSystem", "SearchParameter", "OperationDefinition", "CapabilityStatement", "Conformance"))
System.out.println("Examples contains " + s + " but core doesn't");
}
}
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".core", "package")));
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".expansions", "package")));
if (!ver.equals("r2b"))
strip(new File(Utilities.path(PATH, "hl7.fhir." + ver + ".elements", "package")));
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class IEEE11073Convertor method generateLoincMdcMap.
private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException {
ConceptMap cm = new ConceptMap();
cm.setId("loinc-mdc");
cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc");
cm.setVersion("[todo]");
cm.setName("LoincMdcCrossMap");
cm.setTitle("Cross Map between LOINC and MDC");
cm.setStatus(PublicationStatus.DRAFT);
cm.setExperimental(true);
cm.setDateElement(new DateTimeType());
cm.setPublisher("HL7, Inc");
ContactDetail cd = cm.addContact();
cd.setName("LOINC + IEEE");
ContactPoint cp = cd.addTelecom();
cp.setSystem(ContactPointSystem.URL);
cp.setValue("http://loinc.org");
cm.setDescription("A Cross Map between the LOINC and MDC Code systems");
cm.setPurpose("To implementers map between medical device codes and LOINC codes");
cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use");
cm.setSource(new UriType("http://loinc.org/vs"));
cm.setTarget(new UriType(MDC_ALL_VALUES));
ConceptMapGroupComponent g = cm.addGroup();
g.setSource("urn:iso:std:iso:11073:10101");
g.setTarget("http://loinc.org");
CSVReader csv = new CSVReader(new FileInputStream(src));
csv.readHeaders();
while (csv.line()) {
SourceElementComponent e = g.addElement();
e.setCode(csv.cell("IEEE_CF_CODE10"));
e.setDisplay(csv.cell("IEEE_DESCRIPTION"));
TargetElementComponent t = e.addTarget();
t.setEquivalence(ConceptMapEquivalence.EQUIVALENT);
t.setCode(csv.cell("LOINC_NUM"));
t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
}
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
System.out.println("Done");
return cm;
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class ExamplesPackageBuilder method process.
private void process(String source) throws FHIRFormatError, FileNotFoundException, IOException {
Set<String> set = new HashSet<>();
for (File f : new File(source).listFiles()) {
if (f.getName().endsWith(".json")) {
JsonObject obj = JsonTrackingParser.parseJson(new FileInputStream(f));
if (obj.has("resourceType") && obj.has("id")) {
String type = obj.get("resourceType").getAsString();
String id = obj.get("id").getAsString();
byte[] content = TextFile.fileToBytes(f);
if (type.equals("ConceptMap")) {
System.out.println("convert " + f.getName());
content = r5ToR4B(content);
TextFile.bytesToFile(content, f);
}
// TextFile.bytesToFile(content, Utilities.path(dest2, type+"-"+id+".json"));
// if (!set.contains(type+"/"+id)) {
// set.add(type+"/"+id);
// pck.addFile(Category.RESOURCE, type+"-"+id+".json", content);
// }
}
}
}
// pck.finish();
//
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addMapHeaders.
private void addMapHeaders(XhtmlNode tr, Map<ConceptMap, String> mymaps) {
for (ConceptMap m : mymaps.keySet()) {
XhtmlNode td = tr.addTag("td");
XhtmlNode b = td.addTag("b");
XhtmlNode a = b.addTag("a");
a.setAttribute("href", prefix + mymaps.get(m));
a.addText(m.hasDescription() ? m.getDescription() : m.getName());
}
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addDefineRowToTable.
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int i, boolean hasHierarchy, boolean hasDisplay, boolean comment, boolean deprecated, Map<ConceptMap, String> maps, String system) {
boolean hasExtensions = false;
XhtmlNode tr = t.addTag("tr");
XhtmlNode td = tr.addTag("td");
if (hasHierarchy) {
td.addText(Integer.toString(i + 1));
td = tr.addTag("td");
String s = Utilities.padLeft("", '\u00A0', i * 2);
td.addText(s);
}
td.addText(c.getCode());
XhtmlNode a;
if (c.hasCodeElement()) {
a = td.addTag("a");
a.setAttribute("name", Utilities.nmtokenize(c.getCode()));
a.addText(" ");
}
if (hasDisplay) {
td = tr.addTag("td");
if (c.hasDisplayElement())
td.addText(c.getDisplay());
}
td = tr.addTag("td");
if (c != null)
smartAddText(td, c.getDefinition());
if (deprecated) {
td = tr.addTag("td");
Boolean b = ToolingExtensions.getDeprecated(c);
if (b != null && b) {
smartAddText(td, "Deprecated");
hasExtensions = true;
if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) {
Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue();
td.addText(" (replaced by ");
String url = getCodingReference(cc, system);
if (url != null) {
td.addTag("a").setAttribute("href", url).addText(cc.getCode());
td.addText(": " + cc.getDisplay() + ")");
} else
td.addText(cc.getCode() + " '" + cc.getDisplay() + "' in " + cc.getSystem() + ")");
}
}
}
if (comment) {
td = tr.addTag("td");
String s = ToolingExtensions.getComment(c);
if (s != null) {
smartAddText(td, s);
hasExtensions = true;
}
}
for (ConceptMap m : maps.keySet()) {
td = tr.addTag("td");
List<TargetElementComponent> mappings = findMappingsForCode(c.getCode(), m);
boolean first = true;
for (TargetElementComponent mapping : mappings) {
if (!first)
td.addTag("br");
first = false;
XhtmlNode span = td.addTag("span");
span.setAttribute("title", mapping.hasEquivalence() ? mapping.getEquivalence().toCode() : "");
span.addText(getCharForEquivalence(mapping));
a = td.addTag("a");
a.setAttribute("href", prefix + maps.get(m) + "#" + makeAnchor(mapping.getCodeSystem(), mapping.getCode()));
a.addText(mapping.getCode());
if (!Utilities.noString(mapping.getComments()))
td.addTag("i").addText("(" + mapping.getComments() + ")");
}
}
for (CodeType e : ToolingExtensions.getSubsumes(c)) {
hasExtensions = true;
tr = t.addTag("tr");
td = tr.addTag("td");
String s = Utilities.padLeft("", '.', i * 2);
td.addText(s);
a = td.addTag("a");
a.setAttribute("href", "#" + Utilities.nmtokenize(e.getValue()));
a.addText(c.getCode());
}
for (ConceptDefinitionComponent cc : c.getConcept()) {
hasExtensions = addDefineRowToTable(t, cc, i + 1, hasHierarchy, hasDisplay, comment, deprecated, maps, system) || hasExtensions;
}
return hasExtensions;
}
Aggregations