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());
}
Aggregations