Search in sources :

Example 6 with OperationExample

use of org.hl7.fhir.definitions.model.Operation.OperationExample in project kindling by HL7.

the class ResourceParser method convertOperation.

private Operation convertOperation(OperationDefinition src) throws FileNotFoundException, FHIRException, IOException, Exception {
    List<OperationExample> examples = new ArrayList<>();
    List<OperationExample> examples2 = new ArrayList<>();
    for (Extension ex : src.getExtensionsByUrl(BuildExtensions.EXT_OP_EXAMPLE)) {
        if ("2".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))) {
            processExample(examples2, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
        } else {
            processExample(examples, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
        }
    }
    Operation op = new Operation(src.getName(), src.getSystem(), src.getType(), src.getInstance(), src.getKind().toCode(), src.getTitle(), src.getDescription(), BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER), examples, !src.getAffectsState());
    op.getExamples2().addAll(examples2);
    op.setResource(src);
    op.setStandardsStatus(StandardsStatus.fromCode(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_STANDARDS_STATUS)));
    op.setFmm(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FMM_LEVEL));
    op.setFooter2(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER2));
    for (OperationDefinitionParameterComponent psrc : src.getParameter()) {
        op.getParameters().add(convertOperationParameter(psrc, false));
    }
    return op;
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ArrayList(java.util.ArrayList) Operation(org.hl7.fhir.definitions.model.Operation) OperationDefinitionParameterComponent(org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)

Aggregations

OperationExample (org.hl7.fhir.definitions.model.Operation.OperationExample)6 Operation (org.hl7.fhir.definitions.model.Operation)3 OperationParameter (org.hl7.fhir.definitions.model.OperationParameter)2 Extension (org.hl7.fhir.r5.model.Extension)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Example (org.hl7.fhir.definitions.model.Example)1 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)1 FHIRException (org.hl7.fhir.exceptions.FHIRException)1 XmlParser (org.hl7.fhir.r5.formats.XmlParser)1 BooleanType (org.hl7.fhir.r5.model.BooleanType)1 IntegerType (org.hl7.fhir.r5.model.IntegerType)1 MarkdownType (org.hl7.fhir.r5.model.MarkdownType)1 OperationDefinition (org.hl7.fhir.r5.model.OperationDefinition)1 OperationDefinitionParameterComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)1 StringType (org.hl7.fhir.r5.model.StringType)1 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)1