40.0.1JavaScript Execution Environment

 

This section describes the standard objects available to JavaScript callbacks executing in the Smile CDR JavaScript execution environment.

40.0.1.1Callbacks

Here is the current list of JavaScript callbacks available in Smile CDR.

Module Configuration Functions
CDA Exchange N/A
N/A
generateCdaExchangeComposition(...)
CDA Exchange cda_processing_script.text
cda_processing_script.file
onPostImportCDA(...)
onPreImportCDA(...)
onPostExportCDA(...)
CDA Exchange+ cda_processing_script.text
cda_processing_script.file
onPostImportCDA(...)
onPreImportCDA(...)
onPostExportCDA(...)
Channel Import etl_script.text
etl_script.file
handleChannelImportJsonPayload(...)
handleChannelImportStringPayload(...)
ETL Importer mapping.script
mapping.script.file
handleEtlImportRow(...)
ETL Importer parallelism.hashing.script
parallelism.hashing.script.file
hashEtlImportRow(...)
FHIR REST Endpoint (All FHIR Versions) consent_service.script.text
consent_service.script.file
consentStartOperation(...)
consentCanSeeResource(...)
consentWillSeeResource(...)
completeOperationSuccess(...)
completeOperationFailure(...)
FHIR Storage callback_script.text
callback_script.file
fhirResourceCreated(...)
fhirResourceDeleted(...)
fhirResourcePreCreate(...)
fhirResourcePreDelete(...)
fhirResourcePreUpdate(...)
fhirResourceUpdated(...)
FHIR Storage consent_service.script.text
consent_service.script.file
consentStartOperation(...)
consentCanSeeResource(...)
consentWillSeeResource(...)
completeOperationSuccess(...)
completeOperationFailure(...)
FHIR Storage javascript_repository_validation.script.text
javascript_repository_validation.script.file
repositoryValidationProvideRules(...)
FHIR Storage livebundle_service.script.text
livebundle_service.script.file
buildLiveBundleRuleSet(...)
HL7 v2.x Listening Endpoint listener_script.text
listener_script.file
onPreConvertHl7V2ToFhir(...)
onPostConvertHl7V2ToFhir(...)
HL7 v2.x Listening Endpoint (Deprecated) listener_script.text
listener_script.file
onPreConvertHl7V2ToFhir(...)
onPostConvertHl7V2ToFhir(...)
HL7 v2.x Sending Endpoint mapper_script.text
mapper_script.file
onPostConvertFhirToHl7V2(...)
Local Inbound Security callback_script.text
callback_script.file
authenticate(...)
onAuthenticateSuccess(...)
getUserName(...)
onSmartScopeAuthorityNarrowing(...)
Local Inbound Security user_self_registration.create_script.text
user_self_registration.create_script.file
onUserSelfRegistrationRequest(...)
MDM key_interceptor_script.text
key_interceptor_script.file
mdmGenerateMessageKey(...)
MDM survivorship_script.text
survivorship_script.file
SMART Outbound Security codap.auth_script.text
codap.auth_script.file
authenticate(...)
SMART Outbound Security post_authorize_script.text
post_authorize_script.file
onAuthenticateSuccessClientCredentials(...)
onPostAuthorize(...)
onTokenGenerated(...)
onTokenGenerating(...)
onSmartLoginPreContextSelection(...)
onSmartLoginPostContextSelection(...)
onSmartScopeAuthorityNarrowing(...)
Scripted Inbound Security script.text
script.file
authenticate(...)
authenticateAnonymous(...)
System to System Data Exchange rule_interceptor_script.text
rule_interceptor_script.file
matchPatient(...)

40.0.1.2Testing Scripts in Development

Normally, configuration changes are only applied when a module is restarted. This applies to scripts, and other settings. However, in a development environment if you are running a single standalone instance of Smile CDR, you can enable reload_scripts_on_save (in the Smile CDR properties file) to reload scripts automatically in that server process when module configuration changes are saved. This can be useful for quickly testing script changes. These changes will NOT apply to an entire cluster, and is this is not appropriate for use in production.

module.clustermgr.config.reload_scripts_on_save =true

40.0.2Change Log

 

40.0.2.0.1Smile CDR 2023.08

40.0.2.0.2Smile CDR 2022.05

40.0.2.0.3Smile CDR 2020.08

  • Javascript engine upgraded to ECMAScript 2020.
  • JavaScript engine upgraded from nashorn to graal-js. The nashorn JavaScript engine is no longer supported. Oracle has deprecated nashorn and will remove it from a future release of the JDK.
  • The graal-js JavaScript engine supports ECMAScript 2020. This means that many ECMAScript features that were not available in previous versions of Smile CDR are now supported. However, it also means that you may need to make some changes to your Smile CDR JavaScript code. Here are some known changes you need to make:
    • When working with resource elements that have cardinality, indexes are now required: replace patient.name.family with patient.name[0].family
    • replace string.contains('foo') with string.includes('foo')
    • replace string.replaceAll('foo', 'bar') with string.split('foo').join('bar')
    • replace string.regionMatches(true, 0, 'foo', 0, 3) with .substring(0, 3).toUpperCase() === ' foo'
    • when comparing strings, change == to ===