Skip to content

Commit

Permalink
Remove /FHIR/R4
Browse files Browse the repository at this point in the history
  • Loading branch information
JackPlowman committed Apr 18, 2024
1 parent 15724e5 commit 591b512
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions proxies/live/apiproxy/policies/javascript.RemoveFHIRPath.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="javascript.RemoveFHIRPath">
<DisplayName>javascript.RemoveFHIRPath</DisplayName>
<Properties/>
<ResourceURL>jsc://RemoveFHIRPath.js</ResourceURL>
</Javascript>
15 changes: 15 additions & 0 deletions proxies/live/apiproxy/resources/jsc/RemoveFHIRPath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Get current proxy URL
var proxyUrl = context.getVariable("proxy.url");

// Check if the proxy URL contains '/FHIR/R4/' string
if (proxyUrl.includes('/FHIR/R4/')) {
// Disable copy path
context.setVariable("target.copy.pathsuffix", false);

// Replace string in incoming proxy URL path
var proxyUrlReplaced = proxyUrl.replace('/FHIR/R4/', '/');
print("Replaced: " + proxyUrlReplaced)

// Replace outgoing url
context.setVariable("target.url", proxyUrlReplaced);
}
3 changes: 3 additions & 0 deletions proxies/live/apiproxy/targets/target.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<Step>
<Name>AddUserNHSNumber</Name>
</Step>
<Step>
<Name>javascript.RemoveFHIRPath</Name>
</Step>
</Request>
</PreFlow>
<FaultRules>
Expand Down
3 changes: 2 additions & 1 deletion proxies/sandbox/apiproxy/targets/sandbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
<Response/>
</PostFlow>
<PreFlow name="PreFlow">
<Request/>
<Request>
<Step>
<Name>FlowCallout.ApplyRateLimiting</Name>
</Step>
</Request>
<Response>
<Step>
<Name>AssignMessage.AddCors</Name>
Expand Down
2 changes: 1 addition & 1 deletion sandbox/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def health() -> dict:
}


@app.route("/FHIR/R4/RelatedPerson", methods=["GET"])
@app.route("/RelatedPerson", methods=["GET"])
def get_related_persons() -> Union[dict, tuple]:
"""Sandbox API for GET /RelatedPerson
Expand Down

0 comments on commit 591b512

Please sign in to comment.