Search in sources :

Example 6 with CompositeDefinition

use of org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition in project kindling by HL7.

the class Regenerator method generateSearchParams.

private void generateSearchParams(String root, ResourceDefn r) throws FileNotFoundException, IOException {
    Bundle bnd = new Bundle();
    bnd.setId(r.getName() + "-search-params");
    for (String s : sorted(r.getSearchParams().keySet())) {
        SearchParameterDefn spd = r.getSearchParams().get(s);
        SearchParameter sp = new SearchParameter();
        sp.setId(r.getName() + "-" + spd.getCode());
        bnd.addEntry().setResource(sp);
        sp.setUrl("http://hl7.org/fhir/build/SearchParameter/" + sp.getId());
        sp.setCode(spd.getCode());
        sp.setDescription(spd.getDescription());
        sp.setXpath(spd.getXPath());
        switch(spd.getType()) {
            case composite:
                sp.setType(SearchParamType.COMPOSITE);
                break;
            case date:
                sp.setType(SearchParamType.DATE);
                break;
            case number:
                sp.setType(SearchParamType.NUMBER);
                break;
            case quantity:
                sp.setType(SearchParamType.QUANTITY);
                break;
            case reference:
                sp.setType(SearchParamType.REFERENCE);
                break;
            case special:
                sp.setType(SearchParamType.SPECIAL);
                break;
            case string:
                sp.setType(SearchParamType.STRING);
                break;
            case token:
                sp.setType(SearchParamType.TOKEN);
                break;
            case uri:
                sp.setType(SearchParamType.URI);
                break;
        }
        sp.setXpathUsage(spd.getxPathUsage());
        CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(",");
        for (String p : spd.getPaths()) {
            b.append(p);
        }
        if (!Utilities.noString(b.toString())) {
            sp.addExtension(BuildExtensions.EXT_PATH, new StringType(b.toString()));
        }
        sp.setExpression(spd.getExpression());
        if (spd.hasManualTypes()) {
            for (String t : sorted(spd.getManualTypes())) {
                sp.addTarget(t);
            }
        }
        if (spd.getStandardsStatus() != null) {
            sp.addExtension(ToolingExtensions.EXT_STANDARDS_STATUS, new CodeType(spd.getStandardsStatus().toCode()));
        }
        for (CompositeDefinition c : spd.getComposites()) {
            sp.addComponent().setExpression(c.getExpression()).setDefinition(c.getDefinition());
        }
    }
    File fn = new File(Utilities.path(root, bnd.fhirType().toLowerCase() + "-" + bnd.getId() + ".gen.xml"));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), bnd);
    fn.setLastModified(r.getTimestamp());
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) StringType(org.hl7.fhir.r5.model.StringType) Bundle(org.hl7.fhir.r5.model.Bundle) SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) FileOutputStream(java.io.FileOutputStream) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeType(org.hl7.fhir.r5.model.CodeType) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) File(java.io.File) CompositeDefinition(org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition)

Aggregations

CompositeDefinition (org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition)5 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)4 SearchParameter (org.hl7.fhir.r5.model.SearchParameter)3 CommonSearchParameter (org.hl7.fhir.definitions.model.CommonSearchParameter)2 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 CodeType (org.hl7.fhir.r5.model.CodeType)2 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)2 StandardsStatus (org.hl7.fhir.utilities.StandardsStatus)2 BaseRuntimeChildDefinition (ca.uhn.fhir.context.BaseRuntimeChildDefinition)1 BaseRuntimeElementCompositeDefinition (ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition)1 BaseRuntimeElementDefinition (ca.uhn.fhir.context.BaseRuntimeElementDefinition)1 RuntimeElemContainedResourceList (ca.uhn.fhir.context.RuntimeElemContainedResourceList)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1