Search in sources :

Example 91 with Package

use of org.hl7.fhir.utilities.graphql.Package in project CRD by HL7-DaVinci.

the class FhirController method questionnaireForOrderOperation.

/**
 * FHIR Operation to retrieve all of the Questionnaires and CQL files associated with a given request.
 * @param fhirVersion (converted to uppercase)
 * @return FHIR Bundle
 * @throws IOException
 */
@PostMapping(path = "/fhir/{fhirVersion}/Questionnaire/$questionnaire-package", consumes = { MediaType.APPLICATION_JSON_VALUE, "application/fhir+json" })
public ResponseEntity<String> questionnaireForOrderOperation(HttpServletRequest request, HttpEntity<String> entity, @PathVariable String fhirVersion) {
    fhirVersion = fhirVersion.toUpperCase();
    String baseUrl = Utils.getApplicationBaseUrl(request).toString() + "/";
    logger.info("POST /fhir/" + fhirVersion + "/Questionnaire/$Questionnaire-package");
    String resource = null;
    if (fhirVersion.equalsIgnoreCase("R4")) {
        QuestionnairePackageOperation operation = new QuestionnairePackageOperation(fileStore, baseUrl);
        resource = operation.execute(entity.getBody());
        if (resource == null) {
            logger.warning("bad parameters");
            HttpStatus status = HttpStatus.BAD_REQUEST;
            MediaType contentType = MediaType.TEXT_PLAIN;
            return ResponseEntity.status(status).contentType(contentType).body("Bad Parameters");
        }
    } else {
        logger.warning("unsupported FHIR version: " + fhirVersion + ", not storing");
        HttpStatus status = HttpStatus.BAD_REQUEST;
        MediaType contentType = MediaType.TEXT_PLAIN;
        return ResponseEntity.status(status).contentType(contentType).body("Bad Request");
    }
    return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(resource);
}
Also used : HttpStatus(org.springframework.http.HttpStatus) MediaType(org.springframework.http.MediaType) QuestionnairePackageOperation(org.hl7.davinci.endpoint.fhir.r4.QuestionnairePackageOperation)

Example 92 with Package

use of org.hl7.fhir.utilities.graphql.Package in project CRD by HL7-DaVinci.

the class Metadata method buildCapabilityStatement.

/**
 * Builds the CapabilityStatement describing the Coverage Requirements Discovery Reference
 * Implementation.
 *
 * @return CapabilityStatement - the CapabilityStatement.
 */
private CapabilityStatement buildCapabilityStatement(String baseUrl) {
    CapabilityStatement metadata = new CapabilityStatement();
    metadata.setTitle("Da Vinci Coverage Requirements Discovery (CRD) Reference Implementation");
    metadata.setStatus(PublicationStatus.DRAFT);
    metadata.setExperimental(true);
    Calendar calendar = Calendar.getInstance();
    calendar.set(2019, 4, 28, 0, 0, 0);
    metadata.setDate(calendar.getTime());
    metadata.setPublisher("Da Vinci");
    metadata.setKind(CapabilityStatementKind.INSTANCE);
    CapabilityStatementSoftwareComponent software = new CapabilityStatementSoftwareComponent();
    software.setName("https://github.com/HL7-DaVinci/CRD");
    metadata.setSoftware(software);
    CapabilityStatementImplementationComponent implementation = new CapabilityStatementImplementationComponent();
    implementation.setDescription(metadata.getTitle());
    implementation.setUrl(baseUrl + "metadata");
    metadata.setImplementation(implementation);
    metadata.setFhirVersion(FHIRVersion._4_0_1);
    metadata.addFormat("json");
    metadata.addExtension("http://hl7.org/fhir/StructureDefinition/capabilitystatement-websocket", new StringType("/fhir/r4"));
    metadata.addImplementationGuide("https://build.fhir.org/ig/HL7/davinci-crd/index.html");
    CapabilityStatementRestComponent rest = new CapabilityStatementRestComponent();
    rest.setMode(RestfulCapabilityMode.SERVER);
    CapabilityStatementRestSecurityComponent security = new CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    rest.setSecurity(security);
    // Library Resource
    CapabilityStatementRestResourceComponent library = new CapabilityStatementRestResourceComponent();
    library.setType("Library");
    library.addInteraction().setCode(TypeRestfulInteraction.READ);
    library.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
    library.addInteraction().setCode(TypeRestfulInteraction.CREATE);
    rest.addResource(library);
    // Questionnaire Resource
    CapabilityStatementRestResourceComponent questionnaire = new CapabilityStatementRestResourceComponent();
    questionnaire.setType("Questionnaire");
    questionnaire.addInteraction().setCode(TypeRestfulInteraction.READ);
    questionnaire.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
    questionnaire.addInteraction().setCode(TypeRestfulInteraction.CREATE);
    CapabilityStatementRestResourceOperationComponent questionnairePackageOperation = new CapabilityStatementRestResourceOperationComponent();
    questionnairePackageOperation.setName("questionnaire-package");
    questionnairePackageOperation.setDefinition("http://hl7.org/fhir/us/davinci-dtr/OperationDefinition/Questionnaire-package");
    questionnairePackageOperation.setDocumentation("Retrieve the Questionnaire(s), Libraries, and Valuesets for a given order and coverage. This operation is to support HL7 DaVinci DTR.");
    questionnaire.addOperation(questionnairePackageOperation);
    rest.addResource(questionnaire);
    // QuestionnaireResponse Resource
    CapabilityStatementRestResourceComponent questionnaireResponse = new CapabilityStatementRestResourceComponent();
    questionnaireResponse.setType("QuestionnaireResponse");
    questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.READ);
    questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
    questionnaireResponse.addInteraction().setCode(TypeRestfulInteraction.CREATE);
    rest.addResource(questionnaireResponse);
    // ValueSet Resource
    CapabilityStatementRestResourceComponent valueset = new CapabilityStatementRestResourceComponent();
    valueset.setType("ValueSet");
    valueset.addInteraction().setCode(TypeRestfulInteraction.READ);
    valueset.addInteraction().setCode(TypeRestfulInteraction.SEARCHTYPE);
    valueset.addInteraction().setCode(TypeRestfulInteraction.CREATE);
    // ValueSet $expand Operator
    CapabilityStatementRestResourceOperationComponent expandOperator = new CapabilityStatementRestResourceOperationComponent();
    expandOperator.setName("expand");
    expandOperator.setDefinition("http://hl7.org/fhir/OperationDefinition/ValueSet-expand");
    expandOperator.setDocumentation("Only works at the ValueSet type level with a 'url' query parameter. Will only return expansions that are pre-cached on this server.");
    valueset.addOperation(expandOperator);
    rest.addResource(valueset);
    metadata.addRest(rest);
    return metadata;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) CapabilityStatementImplementationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementImplementationComponent) CapabilityStatementRestSecurityComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestSecurityComponent) Calendar(java.util.Calendar) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) CapabilityStatementSoftwareComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementSoftwareComponent) CapabilityStatementRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent) CapabilityStatementRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent) CapabilityStatementRestResourceOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent)

Aggregations

File (java.io.File)25 FHIRException (org.hl7.fhir.exceptions.FHIRException)22 TextFile (org.hl7.fhir.utilities.TextFile)22 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)15 JsonObject (com.google.gson.JsonObject)12 FileNotFoundException (java.io.FileNotFoundException)11 FileInputStream (java.io.FileInputStream)9 IniFile (org.hl7.fhir.utilities.IniFile)9 FilesystemPackageCacheManager (org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager)9 ParseException (java.text.ParseException)8 HashMap (java.util.HashMap)7 Gson (com.google.gson.Gson)6 GsonBuilder (com.google.gson.GsonBuilder)6 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)6 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)6 JsonElement (com.google.gson.JsonElement)5 FileOutputStream (java.io.FileOutputStream)5 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 CSFile (org.hl7.fhir.utilities.CSFile)5