Search in sources :

Example 1 with OperationDefinitionRenderer

use of org.hl7.fhir.r5.renderers.OperationDefinitionRenderer in project kindling by HL7.

the class ProfileGenerator method generate.

public OperationDefinition generate(String name, String id, String resourceName, Operation op, ResourceDefn rd) throws Exception {
    OperationDefinition opd = new OperationDefinition();
    op.setResource(opd);
    if (Utilities.noString(op.getFmm()))
        ToolingExtensions.addIntegerExtension(opd, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(rd.getFmmLevel()));
    else
        ToolingExtensions.addIntegerExtension(opd, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(op.getFmm()));
    ToolingExtensions.setStandardsStatus(opd, op.getStandardsStatus() == null ? rd.getStatus() : op.getStandardsStatus(), op.getNormativeVersion());
    opd.setId(FormatUtilities.makeId(id));
    opd.setUrl("http://hl7.org/fhir/OperationDefinition/" + id);
    opd.setName(op.getName());
    opd.setTitle(op.getTitle());
    opd.setVersion(version.toCode());
    opd.setPublisher("HL7 (FHIR Project)");
    opd.addContact().getTelecom().add(org.hl7.fhir.r5.model.Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
    opd.getContact().get(0).getTelecom().add(org.hl7.fhir.r5.model.Factory.newContactPoint(ContactPointSystem.EMAIL, "fhir@lists.hl7.org"));
    opd.setDescription(preProcessMarkdown(op.getDoco(), "Operation Documentation"));
    opd.setStatus(op.getStandardsStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.ACTIVE : PublicationStatus.DRAFT);
    opd.setDate(genDate.getTime());
    if (op.getKind().toLowerCase().equals("operation"))
        opd.setKind(OperationKind.OPERATION);
    else if (op.getKind().toLowerCase().equals("query"))
        opd.setKind(OperationKind.QUERY);
    else {
        throw new Exception("Unrecognized operation kind: '" + op.getKind() + "' for operation " + name);
    }
    opd.setCode(op.getName());
    opd.setComment(preProcessMarkdown(op.getFooter(), "Operation Comments"));
    opd.setSystem(op.isSystem());
    opd.addResource(resourceName);
    opd.setType(op.isType());
    opd.setInstance(op.isInstance());
    if (op.getIdempotent() == null) {
        throw new Error("Operation " + opd.getId() + " is not marked as Idempotent or not");
    } else {
        opd.setAffectsState(!op.getIdempotent());
    }
    for (OperationParameter p : op.getParameters()) {
        produceOpParam(op.getName(), opd.getParameter(), p, null);
    }
    OperationDefinitionRenderer opr = new OperationDefinitionRenderer(rc);
    opr.render(opd);
    return opd;
}
Also used : OperationDefinitionRenderer(org.hl7.fhir.r5.renderers.OperationDefinitionRenderer) OperationParameter(org.hl7.fhir.definitions.model.OperationParameter) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException)

Aggregations

URISyntaxException (java.net.URISyntaxException)1 OperationParameter (org.hl7.fhir.definitions.model.OperationParameter)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)1 OperationDefinition (org.hl7.fhir.r5.model.OperationDefinition)1 OperationDefinitionRenderer (org.hl7.fhir.r5.renderers.OperationDefinitionRenderer)1