Skip to content

Commit

Permalink
Remove sandboxes and clean up #52, #51
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Jun 10, 2021
1 parent dd86826 commit 5d8b3d6
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 165 deletions.
1 change: 0 additions & 1 deletion env/development.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
NODE_ENV=development
LOG_TIMES=0
DISABLE_SANDBOXES=1
DISABLE_BACKEND_SERVICES=0
FHIR_SERVER_R2="https://r2.smarthealthit.org"
FHIR_SERVER_R3="https://r3.smarthealthit.org"
Expand Down
1 change: 0 additions & 1 deletion env/test.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
NODE_ENV = test
LOG_TIMES = 0
DISABLE_SANDBOXES = 1
DISABLE_BACKEND_SERVICES = 0
FHIR_SERVER_R2 = "https://r2.smarthealthit.org"
FHIR_SERVER_R3 = "https://r3.smarthealthit.org"
Expand Down
24 changes: 4 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const bodyParser = require('body-parser');
const fs = require("fs");
const base64url = require("base64-url");
const smartAuth = require("./smart-auth");
const reverseProxy = require("./reverse-proxy");
const simpleProxy = require("./simple-proxy");
const config = require("./config");
const generator = require("./generator");
Expand Down Expand Up @@ -97,8 +96,6 @@ app.get("/keys", (req, res) => {

const buildRoutePermutations = (lastSegment) => {
return [
"/v/:fhir_release/sb/:sandbox/sim/:sim" + lastSegment,
"/v/:fhir_release/sb/:sandbox" + lastSegment,
"/v/:fhir_release/sim/:sim" + lastSegment,
"/v/:fhir_release" + lastSegment
];
Expand Down Expand Up @@ -147,17 +144,6 @@ app.post(buildRoutePermutations("/fhir/_services/smart/launch"), bodyParser.json
});
});

// fhir request using sandboxes (tags)
app.use(
[
`/v/:fhir_release/sb/:sandbox/sim/:sim${config.fhirBaseUrl}`,
`/v/:fhir_release/sb/:sandbox${config.fhirBaseUrl}`
],
bodyParser.text({ type: "*/*", limit: 1e6 }),
handleParseError,
reverseProxy
);

// fhir request - no sandboxes - fast streaming proxy
app.use(
[
Expand All @@ -174,17 +160,15 @@ app.use("/generator", generator);

app.use("/env.js", (req, res) => {
const out = {
DISABLE_SANDBOXES: true, // No sandbox support by default
PICKER_ORIGIN : "https://patient-browser.smarthealthit.org",
STU2_ENABLED : true,
STU3_ENABLED : true,
STU4_ENABLED : true
PICKER_ORIGIN: "https://patient-browser.smarthealthit.org",
STU2_ENABLED : true,
STU3_ENABLED : true,
STU4_ENABLED : true
};

const whitelist = {
"NODE_ENV" : String,
"LOG_TIMES" : lib.bool,
"DISABLE_SANDBOXES" : lib.bool,
"DISABLE_BACKEND_SERVICES": lib.bool,
"GOOGLE_ANALYTICS_ID" : String,
"CDS_SANDBOX_URL" : String,
Expand Down
131 changes: 5 additions & 126 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,48 +106,6 @@ <h5 class="modal-title">Private Key</h5>
<button type="submit" style="position: fixed; top: -100px">Submit</button>
<div class="container" id="content" style="display:none;">

<!-- Sandboxes ================================================= -->
<div class="panel panel-info alert-info sandbox-panel" style="display:none">
<div class="panel-heading">
<b class="text-primary">My Sandbox</b>
</div>
<div class="panel-body navbar-default" style="padding-bottom: 0">
<div class="form-group col-sm-6">
<label for="sb">Name</label>
<input type="text" id="sb" class="form-control">
<p class="help-block small">
Launch with this randomly generated sandbox name,
or enter a previously used name to use an existing
sandbox.
</p>
</div>

<div class="form-group col-sm-6">
<label for="fhir-version-1">Version</label>
<select id="fhir-version-1" class="form-control fhir-version"></select>
<p class="help-block small">&nbsp;</p>
</div>

<br clear="all" />
<div class="form-group col-sm-6">
<p><label>Also include read access to these pre-defined datasets</label></p>
<div class="fhir-tags"></div>
</div>

<div class="form-group col-sm-6">
<a href="#" target="_blank" class="btn btn-sm btn-default pull-right open-url-preview" style="padding: 2px 3em;margin: -5px 0 0">Test</a>
<label for="open-url">
Open FHIR Server Endpoint
</label>
<div class="alert alert-info" style="margin: 0">
<div>
<a class="form-control-static open-url"></a>
</div>
</div>
</div>
</div>
</div>

<br />

<div class="panel panel-default">
Expand Down Expand Up @@ -381,7 +339,7 @@ <h5 class="modal-title">Private Key</h5>
<br class="hidden-sm"/>
</div>
<div class="col-sm-6">
<label for="sb">Simulate Authentication Error for Testing</label>
<label for="auth-error">Simulate Authentication Error for Testing</label>
<select id="auth-error" class="form-control"></select>
<br/>
</div>
Expand Down Expand Up @@ -556,36 +514,13 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(

// Getters ---------------------------------------------------------
function getFhirVersion() {
return $(ENV.DISABLE_SANDBOXES ?
"#fhir-version-2" :
"#fhir-version-1"
).val() || CONFIG.fhirVersions[0].name;
}

function getSandboxName() {
return !ENV.DISABLE_SANDBOXES ?
$("#sb").val() || "public" :
"public";
return $("#fhir-version-2").val() || CONFIG.fhirVersions[0].name;
}

function getLaunchType() {
return $("input[name=launch-type]:checked").attr("id");
}

function getTags() {
var tags = [], sb = getSandboxName();
if (!ENV.DISABLE_SANDBOXES) {
tags = $(".sb :checked").filter(":visible").map(
function () { return $(this).val() }
).get();

if (sb) {
tags.unshift(sb);
}
}
return tags;
}

function getLaunchUrl() {
return $.trim($("#launch-url").val());
}
Expand Down Expand Up @@ -626,28 +561,6 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
$(".disabled-server-stu3").show();
}

// Build the FHIR tag checkboxes
if (!ENV.DISABLE_SANDBOXES) {
$(".sandbox-panel").show();
$("#fhir-version-2").closest(".col-sm-6").remove();
$(".fhir-tags").html(
$.map(CONFIG.fhirVersions, function(v) {
return v.tags && v.tags.length ?
$.map(v.tags, function(t) {
return '<div class="checkbox sb ' + v.name + '">' +
'<label>' +
'<input class="tag" type="checkbox" id="' + t.id + '" value="' + t.value +
'"' + (t.selected ? ' checked' : '') + '>' +
'<b>' + t.displayName + '</b> <small class="text-muted">(' +
t.description + ')</small>' +
'</label>' +
'</div>';
}).join("") :
'<span class="text-muted">No tags defined on the selected server</span>';
}).join("")
);
}

if (ENV.CDS_SANDBOX_URL) {
$(".visible-if-cds").removeClass("hidden");
}
Expand Down Expand Up @@ -736,32 +649,13 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
server: {
url : getBaseUrl() + "/fhir",
type: fhirVersion
},
hideTagSelector: !ENV.DISABLE_SANDBOXES
}
};

if (!fhirServer) {
pickerSettings.server.conditions = []
}

if (!ENV.DISABLE_SANDBOXES) {
tags = $("input:checkbox.tag:checked:visible").map(function(i, cb) {
return {
key : cb.value,
label: $(cb).parent().text(),
selected: true
};
}).get();

tags.unshift({
key: $("#sb").val(),
label: "My Own Data",
selected: true
});

pickerSettings.server.tags = tags
}

Lib.selectPatients(input.val(), {
pickerSettings: pickerSettings
}, fhirServer).then(function(sel) {
Expand Down Expand Up @@ -837,13 +731,7 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
}

function getBaseUrl() {
var baseUrl = window.location.href.split("?")[0].replace(/index\.html/, "");
var sandboxes = getTags();
baseUrl += "v/" + getFhirVersion();
if (sandboxes.length) {
baseUrl += "/sb/" + sandboxes.join(",");
}
return baseUrl;
return window.location.href.split("?")[0].replace(/index\.html/, "") + "v/" + getFhirVersion();
}

function bookmark() {
Expand Down Expand Up @@ -1029,10 +917,6 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
toggles.filter("." + launchType + ":not(:visible)").show();
}

if (!ENV.DISABLE_SANDBOXES) {
$(".sb").hide().filter(".sb." + getFhirVersion()).show();
}

switch (launchType) {
case "launch-ehr":
$("#sim-ehr-label").appendTo("#launch-ehr-radio")
Expand Down Expand Up @@ -1091,9 +975,7 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
}

$(function init() {
$("body")
.toggleClass("no-sandboxes", ENV.DISABLE_SANDBOXES)
.toggleClass("no-backend-services", ENV.DISABLE_BACKEND_SERVICES);
$("body").toggleClass("no-backend-services", ENV.DISABLE_BACKEND_SERVICES);

if (ENV.DISABLE_BACKEND_SERVICES) {
$("#launch-bs-radio").hide();
Expand All @@ -1103,9 +985,6 @@ <h3 class="glyphicon glyphicon-info-sign pull-left" style="margin:0;color: rgba(
$("#content").show();
buildForm();
Lib.qsToForm();
if (!ENV.DISABLE_SANDBOXES && !$("#sb").val()) {
$("#sb").val(Lib.generateUID());
}
bindEventHandlers();
// if (!$("#launch-url").val()) {
// $("#launch-url").val(
Expand Down
2 changes: 1 addition & 1 deletion static/sample-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h4>Standalone Launch Parameters</h4>
<tr>
<th style="text-align:right">aud:</th>
<td colspan="3">
<input type="text" name="aud" id="aud" value="https://sb-fhir-stu3.smarthealthit.org/smartstu3/data">
<input type="text" name="aud" id="aud">
</td>
<td rowspan="2" style="border-right:1px solid #DDD"></td>
<td rowspan="2" style="border-left:1px solid #FFF"></td>
Expand Down
13 changes: 4 additions & 9 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,13 @@ function buildRoutePermutations(suffix = "", fhirVersion) {

if (ENABLE_FHIR_VERSION_3 && (!fhirVersion || fhirVersion == 3)) {
out.push(
`/v/r3/sb/abc/sim/whatever/${suffix}`,
`/v/r3/sb/abc/${suffix}`,
`/v/r3/sim/whatever/${suffix}`,
`/v/r3/${suffix}`
);
}

if (ENABLE_FHIR_VERSION_2 && (!fhirVersion || fhirVersion == 2)) {
out.push(
`/v/r2/sb/abc/sim/whatever/${suffix}`,
`/v/r2/sb/abc/${suffix}`,
`/v/r2/sim/whatever/${suffix}`,
`/v/r2/${suffix}`
);
Expand Down Expand Up @@ -390,11 +386,10 @@ describe('Proxy', function() {
.expect(401, done);
});

it ("Can simulate custom token errors", null);
it ("Keeps protected data-sets read-only", null);
it ("Inject sandbox tag into POST and PUT requests", null);
it ("Make urls conditional and if exists, change /id to ?_id=", null);
it ("Apply patient scope to GET requests", null);
it ("Can simulate custom token errors");
it ("Keeps protected data-sets read-only");
it ("Make urls conditional and if exists, change /id to ?_id=");
it ("Apply patient scope to GET requests");

it ("Adjust urls in the fhir response", done => {
request(app)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/spec/login-screen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const CFG = require("../config.js");
const BASE = `${CFG.PICKER_URL}/v/r3/sb/a6yzhl,smart-7-2017/login`;
const BASE = `${CFG.PICKER_URL}/v/r3/login`;

// ?client_id=growth_chart
// &response_type=code
Expand Down
5 changes: 0 additions & 5 deletions tests/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,13 @@ function buildRoutePermutations(suffix = "", fhirVersion) {

if (ENABLE_FHIR_VERSION_3 && (!fhirVersion || fhirVersion == 3)) {
out.push(
`/v/r3/sb/abc/sim/whatever/${suffix}`,
`/v/r3/sb/abc/${suffix}`,
`/v/r3/sim/whatever/${suffix}`,
`/v/r3/${suffix}`
);
}

if (ENABLE_FHIR_VERSION_2 && (!fhirVersion || fhirVersion == 2)) {
out.push(
`/v/r2/sb/abc/sim/whatever/${suffix}`,
`/v/r2/sb/abc/${suffix}`,
`/v/r2/sim/whatever/${suffix}`,
`/v/r2/${suffix}`
);
Expand Down Expand Up @@ -372,7 +368,6 @@ describe('Proxy', function() {

it ("Can simulate custom token errors");
it ("Keeps protected data-sets read-only");
it ("Inject sandbox tag into POST and PUT requests");
it ("Make urls conditional and if exists, change /id to ?_id=");
it ("Apply patient scope to GET requests");

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/spec/login-screen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const CFG = require("../config.js");
const BASE = `${CFG.PICKER_URL}/v/r3/sb/a6yzhl,smart-7-2017/login`;
const BASE = `${CFG.PICKER_URL}/v/r3/login`;

// ?client_id=growth_chart
// &response_type=code
Expand Down

0 comments on commit 5d8b3d6

Please sign in to comment.