Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveregger committed Sep 13, 2024
1 parent 1604f77 commit 4da8ce6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@
},
{
"type": "java",
"name": "Launch Matchbox-Server (test)",
"name": "Launch Matchbox-Server (test r4)",
"request": "launch",
"mainClass": "ca.uhn.fhir.jpa.starter.Application",
"projectName": "matchbox-server",
"vmArgs": "-Dspring.config.additional-location=file:/Users/oegger/Documents/github/matchbox/matchbox-server/target/test-classes/application-test-r5onr4.yaml",
"vmArgs": "-Dspring.config.additional-location=file:/Users/oegger/Documents/github/matchbox/matchbox-server/target/test-classes/application-test-r4.yaml",
"cwd": "${workspaceFolder}/matchbox-server"
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2024/09/ Release 3.9.x
2024/09/ Release 3.9.1
- Make CORS configurable, default not activated make cors configurable (now activated) [#271](https://github.com/ahdis/matchbox/issues/271)
- server API FML transforms between different FHIR versions (R4, R4B, R5) [#265](https://github.com/ahdis/matchbox/issues/265), set flag xVersion

2024/09/10 Release 3.9.0

Expand Down
3 changes: 1 addition & 2 deletions matchbox-server/api.http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@host = http://localhost:8082/matchboxv3
@host = http://localhost:8080/matchboxv3
### @host = https://test.ahdis.ch/matchbox
### @host = https://test.ahdis.ch/matchboxv3

Expand All @@ -23,6 +23,5 @@ Accept: application/fhir+json
GET {{host}}/fhir/OperationDefinition/-s-validate HTTP/1.1
Accept: application/fhir+json


### $validate OperationDefinition
GET {{host}}/tx-reg/resolve HTTP/1.1
1 change: 0 additions & 1 deletion matchbox-server/fml.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
### returns metadata configuration for server, verify that you have in implementation description "Development Mode"
GET {{host}}/metadata HTTP/1.1
Accept: application/fhir+xml;fhirVersion=4.0
Origin: http://localhost


### Convert Textual representation of a FHIR Mapping Language to StructureMap resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ public void manualInputAndOutput(HttpServletRequest theServletRequest, HttpServl
if (map == null) {
throw new UnprocessableEntityException("Map not available with canonical url "+source[0]);
}
for (StructureMapStructureComponent component : map.getStructure()) {
if (component.getUrl() != null && matchboxEngine.getStructureDefinitionR5(component.getUrl()) == null) {
throw new UnprocessableEntityException("matchbox engine could not be initialized with canonical url required for transform for "+source[0]+ " component "+component.getUrl());
}
}
transform(map, theServletRequest, theServletResponse, matchboxEngine);
} else {
throw new UnprocessableEntityException("No source parameter provided");
Expand All @@ -147,24 +142,13 @@ public void transform(org.hl7.fhir.r5.model.StructureMap map, HttpServletRequest
if (highestRankedAcceptValues.contains(Constants.CT_FHIR_JSON)) {
responseContentType = Constants.CT_FHIR_JSON_NEW;
}
String result = matchboxEngine.transform(new String(theServletRequest.getInputStream().readAllBytes()), contentType.contains("json"), map.getUrl(), responseContentType.contains("json"));

org.hl7.fhir.r5.elementmodel.Element r = matchboxEngine.transform(ByteProvider.forBytes(theServletRequest.getInputStream().readAllBytes()), contentType.contains("xml") ? FhirFormat.XML : FhirFormat.JSON, map.getUrl());

theServletResponse.setContentType(responseContentType);
theServletResponse.setCharacterEncoding("UTF-8");

ServletOutputStream output = theServletResponse.getOutputStream();
try {
if (output != null) {
if (responseContentType.equals(Constants.CT_FHIR_JSON_NEW))
new org.hl7.fhir.r5.elementmodel.JsonParser(matchboxEngine.getContext()).compose(r, output, OutputStyle.PRETTY, null);
else
new org.hl7.fhir.r5.elementmodel.XmlParser(matchboxEngine.getContext()).compose(r, output, OutputStyle.PRETTY, null);
}
} catch(org.hl7.fhir.exceptions.FHIRException e) {
log.error("Transform exception", e);
output.write("Exception during Transform".getBytes());
}
output.write(result.getBytes("UTF-8"));
theServletResponse.getOutputStream().close();
}

Expand Down
5 changes: 5 additions & 0 deletions matchbox-server/src/test/resources/application-test-r4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ hapi:
name: matchbox.health.test.ig.r4
version: 0.1.0
url: classpath:/matchbox.health.test.ig.r4-0.1.0.tgz
xver:
name: hl7.fhir.uv.xver
version: 0.1.0
url: classpath:/hl7.fhir.uv.xver#[email protected]
matchbox:
fhir:
context:
Expand All @@ -29,6 +33,7 @@ matchbox:
hl7.fhir.r4.core#4.0.1:
- "Constraint failed: dom-6:"
- "regex:Entry '(.+)' isn't reachable by traversing forwards from the Composition"
xVersion: true
spring:
datasource:
url: "jdbc:h2:mem:test-r4"
21 changes: 21 additions & 0 deletions matchbox-server/xver.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@host = http://localhost:8081/matchboxv3/fhir
### @host = https://test.ahdis.ch/matchbox/fhir

### returns metadata configuration for server, verify that you have in implementation description "Development Mode"
GET {{host}}/metadata HTTP/1.1
Accept: application/fhir+xml;fhirVersion=4.0

### transform the r4 provided medication to r5 medication
POST {{host}}/StructureMap/$transform?source=http://hl7.org/fhir/uv/xver/StructureMap/Medication4to5
Accept: application/fhir+json
Content-Type: application/fhir+json

< ./matchbox-engine/src/test/resources/xvers/medication-r4-med0301.json


### ### transform the r5 medication to r4 medication
POST {{host}}/StructureMap/$transform?source=http://hl7.org/fhir/uv/xver/StructureMap/Medication5to4
Accept: application/fhir+json
Content-Type: application/fhir+json

< ./matchbox-engine/src/test/resources/xvers/medication-r5-med0301.json

0 comments on commit 4da8ce6

Please sign in to comment.