diff --git a/projects/ngx-formentry/src/form-entry/helpers/historical-expression-helper-service.ts b/projects/ngx-formentry/src/form-entry/helpers/historical-expression-helper-service.ts index 05429b4d..68e72fa5 100644 --- a/projects/ngx-formentry/src/form-entry/helpers/historical-expression-helper-service.ts +++ b/projects/ngx-formentry/src/form-entry/helpers/historical-expression-helper-service.ts @@ -14,19 +14,22 @@ export class HistoricalHelperService { public evaluate( expr: string, - dataSources: any, - additionalScopevalues: any - ): any { + dataSources: Record, + additionalScopeValues: Record | null, + ) { const HD = new HistoricalEncounterDataService(); HD.registerEncounters('prevEnc', dataSources['rawPrevEnc']); - const deps: any = { - HD: HD - }; + if (dataSources.hasOwnProperty('rawPrevObs')) { + HD.registerEncounters('prevObs', dataSources['rawPrevObs']); + } + + const deps = { HD }; - if (additionalScopevalues) { - for (const o in additionalScopevalues) { - if (additionalScopevalues[o]) { - deps[o] = additionalScopevalues[o]; + if (additionalScopeValues) { + for (const o in additionalScopeValues) { + const value = additionalScopeValues[o]; + if (typeof value !== 'undefined' && value !== null) { + deps[o] = value; } } }