Search in sources :

Example 21 with Code

use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.

the class FhirMetadataController method initCache.

private Holder initCache() {
    final Holder holder = new Holder();
    // XXX: we know that the subclass is instantiated (in SnowOwlApiConfig)
    final OpenAPI openAPI = ((SnowOwlOpenApiWebMvcResource) openApiWebMvcResource).getOpenApi();
    final Collection<Resource> resources = collectResources(openAPI);
    final Collection<OperationDefinition> operationDefinitions = collectOperationDefinitions(openAPI);
    final Rest.Builder restBuilder = Rest.builder().mode(RestfulCapabilityMode.SERVER).resources(resources);
    holder.operationMap = newHashMap();
    for (final OperationDefinition operationDefinition : operationDefinitions) {
        for (final Code code : operationDefinition.getResources()) {
            final String key = code.getCodeValue() + operationDefinition.getName();
            holder.operationMap.put(key, operationDefinition);
            restBuilder.addOperation(com.b2international.snowowl.fhir.core.model.capabilitystatement.Operation.builder().name(operationDefinition.getName()).definition(buildOperationUrl(code, operationDefinition)).build());
        }
    }
    final String serverVersion = Platform.getBundle(CoreActivator.PLUGIN_ID).getVersion().toString();
    String description = ApplicationContext.getServiceForClass(SnowOwlConfiguration.class).getDescription();
    holder.capabilityStatement = CapabilityStatement.builder().name("FHIR Capability statement for Snow Owl© Terminology Server").status(PublicationStatus.ACTIVE).experimental(false).kind(CapabilityStatementKind.INSTANCE.getCode()).fhirVersion("4.0.1").addInstantiate(new Uri("http://hl7.org/fhir/CapabilityStatement/terminology-server")).software(Software.builder().name("Snow Owl©").version(serverVersion).build()).implementation(Implementation.builder().url("https://b2i.sg").description(description).build()).addFormat(new Code(AbstractFhirController.APPLICATION_FHIR_JSON)).addRest(restBuilder.build()).build();
    return holder;
}
Also used : SnowOwlOpenApiWebMvcResource(com.b2international.snowowl.core.rest.SnowOwlOpenApiWebMvcResource) OpenApiWebMvcResource(org.springdoc.webmvc.api.OpenApiWebMvcResource) SnowOwlOpenApiWebMvcResource(com.b2international.snowowl.core.rest.SnowOwlOpenApiWebMvcResource) Code(com.b2international.snowowl.fhir.core.model.dt.Code) Uri(com.b2international.snowowl.fhir.core.model.dt.Uri) OpenAPI(io.swagger.v3.oas.models.OpenAPI) OperationDefinition(com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition) SnowOwlConfiguration(com.b2international.snowowl.core.config.SnowOwlConfiguration)

Example 22 with Code

use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.

the class FhirParametersRequestEntryProcessor method doProcess.

@Override
public void doProcess(ArrayNode arrayNode, HttpServletRequest request) throws JsonMappingException, JsonProcessingException {
    BatchRequest batchRequest = requestEntry.getRequest();
    Code requestMethod = batchRequest.getMethod();
    if (!requestMethod.equals(HttpVerb.POST.getCode())) {
        createInvalidMethodResponse(arrayNode, requestMethod);
        return;
    }
    HttpHeaders headers = getHeaders(request);
    RestTemplate restTemplate = getRestTemplate();
    StringBuilder uriBuilder = new StringBuilder(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getLocalPort()).append(request.getRequestURI()).append(batchRequest.getUrl().getUriValue());
    // TODO: change the RequestEntry to accommodate resources for non-operation bulk support
    HttpEntity<?> httpEntity = new HttpEntity<>(requestEntry.getRequestResource(), headers);
    ResponseEntity<String> response = restTemplate.exchange(uriBuilder.toString(), HttpMethod.POST, httpEntity, String.class);
    String json = response.getBody();
    ObjectNode resourceNode = (ObjectNode) objectMapper.readTree(json);
    addResponse(arrayNode, resourceNode, String.valueOf(response.getStatusCode().value()));
}
Also used : BatchRequest(com.b2international.snowowl.fhir.core.model.BatchRequest) HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) RestTemplate(org.springframework.web.client.RestTemplate) Code(com.b2international.snowowl.fhir.core.model.dt.Code)

Aggregations

Code (com.b2international.snowowl.fhir.core.model.dt.Code)22 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)13 Test (org.junit.Test)13 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)11 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)4 BatchRequest (com.b2international.snowowl.fhir.core.model.BatchRequest)3 SimpleQuantity (com.b2international.snowowl.fhir.core.model.dt.SimpleQuantity)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 HttpEntity (org.springframework.http.HttpEntity)3 HttpHeaders (org.springframework.http.HttpHeaders)3 RestTemplate (org.springframework.web.client.RestTemplate)3 SnowOwlConfiguration (com.b2international.snowowl.core.config.SnowOwlConfiguration)2 SnowOwlOpenApiWebMvcResource (com.b2international.snowowl.core.rest.SnowOwlOpenApiWebMvcResource)2 Designation (com.b2international.snowowl.fhir.core.model.Designation)2 OperationDefinition (com.b2international.snowowl.fhir.core.model.operationdefinition.OperationDefinition)2 StringUtils (com.b2international.commons.StringUtils)1 NotFoundException (com.b2international.commons.exceptions.NotFoundException)1 ApplicationContext (com.b2international.snowowl.core.ApplicationContext)1 CoreActivator (com.b2international.snowowl.core.CoreActivator)1 FhirApiConfig (com.b2international.snowowl.core.rest.FhirApiConfig)1