Search in sources :

Example 26 with IWorkerContext

use of org.hl7.fhir.dstu2016may.utils.IWorkerContext in project org.hl7.fhir.core by hapifhir.

the class XLSXWriter method processElement.

/*  private void findMapKeys(StructureDefinition def, List<StructureDefinitionMappingComponent> maps, IWorkerContext context) {
  	maps.addAll(def.getMapping());
  	if (def.getBaseDefinition()!=null) {
  	  StructureDefinition base = context.fetchResource(StructureDefinition.class, def.getBaseDefinition());
  	  findMapKeys(base, maps, context);
  	}
  }*/
public void processElement(ElementDefinition ed) throws Exception {
    Row row = sheet.createRow(sheet.getLastRowNum() + 1);
    int i = 0;
    addCell(row, i++, ed.getPath(), styles.get("body"));
    addCell(row, i++, ed.getSliceName());
    addCell(row, i++, itemList(ed.getAlias()));
    addCell(row, i++, ed.getLabel());
    addCell(row, i++, ed.getMin());
    addCell(row, i++, ed.getMax());
    addCell(row, i++, ed.getMustSupport() ? "Y" : "");
    addCell(row, i++, ed.getIsModifier() ? "Y" : "");
    addCell(row, i++, ed.getIsSummary() ? "Y" : "");
    addCell(row, i++, itemList(ed.getType()));
    addCell(row, i++, ed.getShort());
    addCell(row, i++, ed.getDefinition());
    addCell(row, i++, ed.getComment());
    addCell(row, i++, ed.getRequirements());
    addCell(row, i++, ed.getDefaultValue() != null ? renderType(ed.getDefaultValue()) : "");
    addCell(row, i++, ed.getMeaningWhenMissing());
    addCell(row, i++, ed.hasFixed() ? renderType(ed.getFixed()) : "");
    addCell(row, i++, ed.hasPattern() ? renderType(ed.getPattern()) : "");
    // todo...?
    addCell(row, i++, ed.hasExample() ? renderType(ed.getExample().get(0).getValue()) : "");
    addCell(row, i++, ed.hasMinValue() ? renderType(ed.getMinValue()) : "");
    addCell(row, i++, ed.hasMaxValue() ? renderType(ed.getMaxValue()) : "");
    addCell(row, i++, (ed.hasMaxLength() ? Integer.toString(ed.getMaxLength()) : ""));
    if (ed.hasBinding()) {
        addCell(row, i++, ed.getBinding().getStrength() != null ? ed.getBinding().getStrength().toCode() : "");
        addCell(row, i++, ed.getBinding().getDescription());
        if (ed.getBinding().getValueSet() == null)
            addCell(row, i++, "");
        else
            addCell(row, i++, ed.getBinding().getValueSet());
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    addCell(row, i++, itemList(ed.getCode()));
    if (ed.hasSlicing()) {
        addCell(row, i++, itemList(ed.getSlicing().getDiscriminator()));
        addCell(row, i++, ed.getSlicing().getDescription());
        addCell(row, i++, ed.getSlicing().getOrdered());
        addCell(row, i++, ed.getSlicing().getRules() != null ? ed.getSlicing().getRules().toCode() : "");
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    if (ed.getBase() != null) {
        addCell(row, i++, ed.getBase().getPath());
        addCell(row, i++, ed.getBase().getMin());
        addCell(row, i++, ed.getBase().getMax());
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    addCell(row, i++, itemList(ed.getCondition()));
    addCell(row, i++, itemList(ed.getConstraint()));
    for (StructureDefinitionMappingComponent mapKey : def.getMapping()) {
        String mapString = "";
        for (ElementDefinitionMappingComponent map : ed.getMapping()) {
            if (map.getIdentity().equals(mapKey.getIdentity()))
                mapString = map.getMap();
        }
        addCell(row, i++, mapString);
    }
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionMappingComponent) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) ElementDefinitionMappingComponent(org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionMappingComponent)

Example 27 with IWorkerContext

use of org.hl7.fhir.dstu2016may.utils.IWorkerContext in project org.hl7.fhir.core by hapifhir.

the class TestingUtilities method getSharedWorkerContext.

/**
 * Get an existing instantiation of a WorkerContext if available
 *
 * @param version FHIR Version to get context for
 * @return
 */
public static IWorkerContext getSharedWorkerContext(String version) {
    if ("4.5.0".equals(version)) {
        // temporary work around
        version = "4.4.0";
    }
    String v = VersionUtilities.getMajMin(version);
    if (fcontexts == null) {
        fcontexts = new HashMap<>();
    }
    if (!fcontexts.containsKey(v)) {
        IWorkerContext fcontext = getWorkerContext(version);
        fcontexts.put(v, fcontext);
    }
    return fcontexts.get(v);
}
Also used : IWorkerContext(org.hl7.fhir.r5.context.IWorkerContext)

Example 28 with IWorkerContext

use of org.hl7.fhir.dstu2016may.utils.IWorkerContext in project org.hl7.fhir.core by hapifhir.

the class CSVWriter method processElement.

/*  private void findMapKeys(StructureDefinition def, List<StructureDefinitionMappingComponent> maps, IWorkerContext context) {
  	maps.addAll(def.getMapping());
  	if (def.getBaseDefinition()!=null) {
  	  StructureDefinition base = context.fetchResource(StructureDefinition.class, def.getBaseDefinition());
  	  findMapKeys(base, maps, context);
  	}
  }*/
public void processElement(ElementDefinition ed) throws Exception {
    CSVLine line = new CSVLine();
    lines.add(line);
    line.addString(ed.getPath());
    line.addString(ed.getSliceName());
    line.addString(itemList(ed.getAlias()));
    line.addString(ed.getLabel());
    line.addValue(ed.getMin());
    line.addValue(ed.getMax());
    line.addString(ed.getMustSupport() ? "Y" : "");
    line.addString(ed.getIsModifier() ? "Y" : "");
    line.addString(ed.getIsSummary() ? "Y" : "");
    line.addString(itemList(ed.getType()));
    line.addString(ed.getShort());
    line.addString(ed.getDefinition());
    line.addString(ed.getComment());
    line.addString(ed.getRequirements());
    line.addString(ed.getDefaultValue() != null ? renderType(ed.getDefaultValue()) : "");
    line.addString(ed.getMeaningWhenMissing());
    line.addString(ed.hasFixed() ? renderType(ed.getFixed()) : "");
    line.addString(ed.hasPattern() ? renderType(ed.getPattern()) : "");
    // todo...?
    line.addString(ed.hasExample() ? renderType(ed.getExample().get(0).getValue()) : "");
    line.addString(ed.hasMinValue() ? renderType(ed.getMinValue()) : "");
    line.addString(ed.hasMaxValue() ? renderType(ed.getMaxValue()) : "");
    line.addValue((ed.hasMaxLength() ? Integer.toString(ed.getMaxLength()) : ""));
    if (ed.hasBinding()) {
        line.addString(ed.getBinding().getStrength() != null ? ed.getBinding().getStrength().toCode() : "");
        line.addString(ed.getBinding().getDescription());
        if (ed.getBinding().getValueSet() == null)
            line.addString("");
        else if (ed.getBinding().getValueSet() instanceof Reference)
            line.addString(ed.getBinding().getValueSetReference().getReference());
        else
            line.addString(ed.getBinding().getValueSetUriType().getValue());
    } else {
        line.addValue("");
        line.addValue("");
        line.addValue("");
    }
    line.addString(itemList(ed.getCode()));
    if (ed.hasSlicing()) {
        line.addString(itemList(ed.getSlicing().getDiscriminator()));
        line.addString(ed.getSlicing().getDescription());
        line.addBoolean(ed.getSlicing().getOrdered());
        line.addString(ed.getSlicing().getRules() != null ? ed.getSlicing().getRules().toCode() : "");
    } else {
        line.addValue("");
        line.addValue("");
        line.addValue("");
    }
    if (ed.getBase() != null) {
        line.addString(ed.getBase().getPath());
        line.addValue(ed.getBase().getMin());
        line.addValue(ed.getBase().getMax());
    } else {
        line.addValue("");
        line.addValue("");
        line.addValue("");
    }
    line.addString(itemList(ed.getCondition()));
    line.addString(itemList(ed.getConstraint()));
    for (StructureDefinitionMappingComponent mapKey : def.getMapping()) {
        for (ElementDefinitionMappingComponent map : ed.getMapping()) {
            if (map.getIdentity().equals(mapKey.getIdentity()))
                line.addString(map.getMap());
        }
    }
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent) Reference(org.hl7.fhir.dstu3.model.Reference) ElementDefinitionMappingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionMappingComponent)

Example 29 with IWorkerContext

use of org.hl7.fhir.dstu2016may.utils.IWorkerContext in project org.hl7.fhir.core by hapifhir.

the class XLSXWriter method processElement.

/*  private void findMapKeys(StructureDefinition def, List<StructureDefinitionMappingComponent> maps, IWorkerContext context) {
  	maps.addAll(def.getMapping());
  	if (def.getBaseDefinition()!=null) {
  	  StructureDefinition base = context.fetchResource(StructureDefinition.class, def.getBaseDefinition());
  	  findMapKeys(base, maps, context);
  	}
  }*/
public void processElement(ElementDefinition ed) throws Exception {
    Row row = sheet.createRow(sheet.getLastRowNum() + 1);
    int i = 0;
    addCell(row, i++, ed.getPath(), styles.get("body"));
    addCell(row, i++, ed.getSliceName());
    addCell(row, i++, itemList(ed.getAlias()));
    addCell(row, i++, ed.getLabel());
    addCell(row, i++, ed.getMin());
    addCell(row, i++, ed.getMax());
    addCell(row, i++, ed.getMustSupport() ? "Y" : "");
    addCell(row, i++, ed.getIsModifier() ? "Y" : "");
    addCell(row, i++, ed.getIsSummary() ? "Y" : "");
    addCell(row, i++, itemList(ed.getType()));
    addCell(row, i++, ed.getShort());
    addCell(row, i++, ed.getDefinition());
    addCell(row, i++, ed.getComment());
    addCell(row, i++, ed.getRequirements());
    addCell(row, i++, ed.getDefaultValue() != null ? renderType(ed.getDefaultValue()) : "");
    addCell(row, i++, ed.getMeaningWhenMissing());
    addCell(row, i++, ed.hasFixed() ? renderType(ed.getFixed()) : "");
    addCell(row, i++, ed.hasPattern() ? renderType(ed.getPattern()) : "");
    // todo...?
    addCell(row, i++, ed.hasExample() ? renderType(ed.getExample().get(0).getValue()) : "");
    addCell(row, i++, ed.hasMinValue() ? renderType(ed.getMinValue()) : "");
    addCell(row, i++, ed.hasMaxValue() ? renderType(ed.getMaxValue()) : "");
    addCell(row, i++, (ed.hasMaxLength() ? Integer.toString(ed.getMaxLength()) : ""));
    if (ed.hasBinding()) {
        addCell(row, i++, ed.getBinding().getStrength() != null ? ed.getBinding().getStrength().toCode() : "");
        addCell(row, i++, ed.getBinding().getDescription());
        if (ed.getBinding().getValueSet() == null)
            addCell(row, i++, "");
        else
            addCell(row, i++, ed.getBinding().getValueSet());
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    addCell(row, i++, itemList(ed.getCode()));
    if (ed.hasSlicing()) {
        addCell(row, i++, itemList(ed.getSlicing().getDiscriminator()));
        addCell(row, i++, ed.getSlicing().getDescription());
        addCell(row, i++, ed.getSlicing().getOrdered());
        addCell(row, i++, ed.getSlicing().getRules() != null ? ed.getSlicing().getRules().toCode() : "");
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    if (ed.getBase() != null) {
        addCell(row, i++, ed.getBase().getPath());
        addCell(row, i++, ed.getBase().getMin());
        addCell(row, i++, ed.getBase().getMax());
    } else {
        addCell(row, i++, "");
        addCell(row, i++, "");
        addCell(row, i++, "");
    }
    addCell(row, i++, itemList(ed.getCondition()));
    addCell(row, i++, itemList(ed.getConstraint()));
    for (StructureDefinitionMappingComponent mapKey : def.getMapping()) {
        String mapString = "";
        for (ElementDefinitionMappingComponent map : ed.getMapping()) {
            if (map.getIdentity().equals(mapKey.getIdentity()))
                mapString = map.getMap();
        }
        addCell(row, i++, mapString);
    }
}
Also used : StructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) Row(org.apache.poi.ss.usermodel.Row) ElementDefinitionMappingComponent(org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent)

Example 30 with IWorkerContext

use of org.hl7.fhir.dstu2016may.utils.IWorkerContext in project org.hl7.fhir.core by hapifhir.

the class Manager method build.

public static Element build(IWorkerContext context, StructureDefinition sd) {
    Property p = new Property(context, sd.getSnapshot().getElementFirstRep(), sd);
    Element e = new Element(null, p);
    return e;
}
Also used : NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement)

Aggregations

FileInputStream (java.io.FileInputStream)6 FileOutputStream (java.io.FileOutputStream)6 JsonElement (com.google.gson.JsonElement)5 File (java.io.File)5 IWorkerContext (org.hl7.fhir.r5.context.IWorkerContext)5 JsonSyntaxException (com.google.gson.JsonSyntaxException)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 UcumEssenceService (org.fhir.ucum.UcumEssenceService)4 TextFile (org.hl7.fhir.utilities.TextFile)4 IWorkerContext (org.hl7.fhir.r4b.context.IWorkerContext)3 FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)3 Row (org.apache.poi.ss.usermodel.Row)2 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 ElementDefinitionMappingComponent (org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionMappingComponent)2 StructureDefinitionMappingComponent (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent)2 NamedElement (org.hl7.fhir.r4b.elementmodel.ParserBase.NamedElement)2 ElementDefinitionMappingComponent (org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionMappingComponent)2 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)2