From fafdc74fc797aaae3f3aeece04d9c089e2c1ff9e Mon Sep 17 00:00:00 2001 From: Patrick LaRocque Date: Fri, 10 Jan 2025 00:22:49 -0500 Subject: [PATCH 1/2] Include only a reference to the order (MedicationRequest) if configured. --- .env | 3 ++- README.md | 1 + src/config.ts | 3 ++- src/hooks/hookResources.ts | 9 ++++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.env b/.env index fe09fe6..cfe7782 100644 --- a/.env +++ b/.env @@ -11,10 +11,11 @@ USE_HTTPS = false VSAC_API_KEY = changeMe WHITELIST = http://localhost, http://localhost:3005 SERVER_NAME = CodeX REMS Administrator Prototype +FULL_RESOURCE_IN_APP_CONTEXT = false #Frontend Vars FRONTEND_PORT=9090 VITE_REALM = ClientFhirServer VITE_AUTH = http://localhost:8180 VITE_CLIENT = app-login -VITE_SCOPE_ID = rems-admin \ No newline at end of file +VITE_SCOPE_ID = rems-admin diff --git a/README.md b/README.md index 1d8cc90..84cdb6b 100644 --- a/README.md +++ b/README.md @@ -117,4 +117,5 @@ Following are a list of modifiable paths: | VSAC_API_KEY | `changeMe` | Replace with VSAC API key for pulling down ValueSets. Request an API Key from the [VSAC website](https://vsac.nlm.nih.gov/) | | WHITELIST | `http://localhost, http://localhost:3005` | List of valid URLs for CORS. Should include any URLs the server accesses for resources. | | SERVER_NAME | `CodeX REMS Administrator Prototype` | Name of the server that is returned in the card source. | +| FULL_RESOURCE_IN_APP_CONTEXT | 'false' | If true, the entire order resource will be included in the appContext, otherwise only a reference will be. | | FRONTEND_PORT | `9080` | Port that the frontend server should run on, change if there are conflicts with port usage. | \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 69fa1a4..58745c6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -23,7 +23,8 @@ export default { }, general: { resourcePath: 'src/cds-library/CRD-DTR', - VsacApiKey: env.get('VSAC_API_KEY').required().asString() + VsacApiKey: env.get('VSAC_API_KEY').required().asString(), + fullResourceInAppContext: env.get('FULL_RESOURCE_IN_APP_CONTEXT').required().asBool() }, database: { selected: 'mongo', diff --git a/src/hooks/hookResources.ts b/src/hooks/hookResources.ts index 1dd98db..9e462ca 100644 --- a/src/hooks/hookResources.ts +++ b/src/hooks/hookResources.ts @@ -297,11 +297,18 @@ export function createSmartLink( appContext: string | null, request: MedicationRequest | undefined ) { + var order; + if (config.general.fullResourceInAppContext) { + order = JSON.stringify(request); + } else { + order = request?.resourceType + '/' + request?.id; + } + const newLink: Link = { label: requirementName + ' Form', url: new URL(config.smart.endpoint), type: 'smart', - appContext: `${appContext}&order=${JSON.stringify(request)}&coverage=${ + appContext: `${appContext}&order=${order}&coverage=${ request?.insurance?.[0].reference }` }; From c38e684da2c67782706affc5909ad490a252402c Mon Sep 17 00:00:00 2001 From: Patrick LaRocque Date: Fri, 10 Jan 2025 09:56:01 -0500 Subject: [PATCH 2/2] fix lint and prettier errors --- src/hooks/hookResources.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hooks/hookResources.ts b/src/hooks/hookResources.ts index 9e462ca..39f6967 100644 --- a/src/hooks/hookResources.ts +++ b/src/hooks/hookResources.ts @@ -297,20 +297,18 @@ export function createSmartLink( appContext: string | null, request: MedicationRequest | undefined ) { - var order; + let order; if (config.general.fullResourceInAppContext) { order = JSON.stringify(request); } else { - order = request?.resourceType + '/' + request?.id; + order = request?.resourceType + '/' + request?.id; } const newLink: Link = { label: requirementName + ' Form', url: new URL(config.smart.endpoint), type: 'smart', - appContext: `${appContext}&order=${order}&coverage=${ - request?.insurance?.[0].reference - }` + appContext: `${appContext}&order=${order}&coverage=${request?.insurance?.[0].reference}` }; return newLink; }