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..39f6967 100644 --- a/src/hooks/hookResources.ts +++ b/src/hooks/hookResources.ts @@ -297,13 +297,18 @@ export function createSmartLink( appContext: string | null, request: MedicationRequest | undefined ) { + let 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=${ - request?.insurance?.[0].reference - }` + appContext: `${appContext}&order=${order}&coverage=${request?.insurance?.[0].reference}` }; return newLink; }