Search in sources :

Example 1 with BuildExtensions

use of org.hl7.fhir.r5.utils.BuildExtensions in project org.hl7.fhir.core by hapifhir.

the class ExtensionDefinitionGenerator method buildExtensions.

private void buildExtensions(StructureDefinition type, List<StructureDefinition> list) throws FHIRException {
    for (ElementDefinition ed : type.getDifferential().getElement()) {
        if (ed.getPath().contains(".")) {
            if (!ed.getPath().endsWith(".extension") && !ed.getPath().endsWith(".modifierExtension")) {
                StructureDefinition ext = generateExtension(type, ed);
                if (ext != null) {
                    list.add(ext);
                    context.cacheResource(ext);
                }
            }
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition) ElementDefinition(org.hl7.fhir.r4.model.ElementDefinition)

Example 2 with BuildExtensions

use of org.hl7.fhir.r5.utils.BuildExtensions in project org.hl7.fhir.core by hapifhir.

the class ExtensionDefinitionGenerator method buildExtensions.

private List<StructureDefinition> buildExtensions(List<StructureDefinition> definitions) throws FHIRException {
    Set<String> types = new HashSet<>();
    List<StructureDefinition> list = new ArrayList<>();
    for (StructureDefinition type : definitions) if (type.getDerivation() == TypeDerivationRule.SPECIALIZATION && !type.getName().contains(".") && !types.contains(type.getName()) && type.getKind() != StructureDefinitionKind.PRIMITIVETYPE && !Utilities.existsInList(type.getName(), "Extension", "Narrative")) {
        types.add(type.getName());
        buildExtensions(type, list);
    }
    return list;
}
Also used : StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition)

Example 3 with BuildExtensions

use of org.hl7.fhir.r5.utils.BuildExtensions in project org.hl7.fhir.core by hapifhir.

the class ExtensionDefinitionGenerator method generate.

private void generate() throws IOException, FHIRException {
    List<StructureDefinition> definitions = loadSource();
    List<StructureDefinition> extensions = buildExtensions(definitions);
    for (StructureDefinition ext : extensions) pu.generateSnapshot(extbase, ext, ext.getUrl(), "http://hl7.org/fhir/R4", ext.getName());
    savePackage(extensions);
}
Also used : StructureDefinition(org.hl7.fhir.r4.model.StructureDefinition)

Aggregations

StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)3 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)1