use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.
the class ConceptTest method build.
@Test
public void build() throws Exception {
assertEquals(new Code("conceptCode"), concept.getCode());
ConceptProperty conceptProperty = concept.getProperties().iterator().next();
assertTrue(conceptProperty instanceof CodeConceptProperty);
}
use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.
the class FhirMetadataController method collectResources.
private Collection<Resource> collectResources(final OpenAPI openAPI) {
final Paths paths = openAPI.getPaths();
final List<io.swagger.v3.oas.models.tags.Tag> tags = openAPI.getTags();
return tags.stream().filter(t -> t.getExtensions() != null && t.getExtensions().containsKey(B2I_OPENAPI_X_NAME)).map(t -> {
final Map<?, ?> nameExtensionMap = (Map<?, ?>) t.getExtensions().get(B2I_OPENAPI_X_NAME);
final String profile = (String) nameExtensionMap.get(B2I_OPENAPI_PROFILE);
final Resource.Builder resourceBuilder = Resource.builder().type(t.getName()).profile(profile);
// Collect the operations that belong to the same tagged class resource
paths.values().stream().flatMap(pi -> pi.readOperations().stream()).filter(o -> o.getTags().contains(t.getName()) && o.getExtensions() != null && o.getExtensions().containsKey(B2I_OPENAPI_X_INTERACTION)).forEachOrdered(op -> {
final Map<String, Object> operationExtensionMap = op.getExtensions();
final Map<?, ?> interactionMap = (Map<?, ?>) operationExtensionMap.get(B2I_OPENAPI_X_INTERACTION);
interactionMap.entrySet().forEach(e -> {
final Interaction.Builder interactionBuilder = Interaction.builder().code((String) e.getKey());
final String value = (String) e.getValue();
if (!StringUtils.isEmpty(value)) {
interactionBuilder.documentation((String) value);
}
resourceBuilder.addInteraction(interactionBuilder.build());
});
});
return resourceBuilder.build();
}).sorted(Comparator.comparing(r -> r.getType().getCodeValue())).collect(Collectors.toList());
}
use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.
the class FhirRequestEntryProcessor method doProcess.
@Override
public void doProcess(ArrayNode arrayNode, HttpServletRequest request) throws Exception {
BatchRequest batchRequest = requestEntry.getRequest();
Code requestMethod = batchRequest.getMethod();
if (!requestMethod.equals(HttpVerb.GET.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());
HttpEntity<String> httpEntity = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange(uriBuilder.toString(), HttpMethod.GET, httpEntity, String.class);
String json = response.getBody();
ObjectNode resourceNode = (ObjectNode) objectMapper.readTree(json);
addResponse(arrayNode, resourceNode, String.valueOf(response.getStatusCode().value()));
}
use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.
the class FhirResourceRequestEntryProcessor 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());
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()));
}
use of com.b2international.snowowl.fhir.core.model.dt.Code in project snow-owl by b2ihealthcare.
the class QuantityTest method deserialize.
@Test
public void deserialize() throws Exception {
Quantity readQuantity = objectMapper.readValue(objectMapper.writeValueAsString(quantity), Quantity.class);
assertEquals(Double.valueOf(12.3), readQuantity.getValue());
assertEquals("mg", readQuantity.getUnit());
assertEquals(new Uri("uri:LOINC"), readQuantity.getSystem());
assertEquals(new Code("code"), readQuantity.getCode());
assertEquals(QuantityComparator.GREATER_OR_EQUAL_TO.getCode(), readQuantity.getComparator());
}
Aggregations