diff --git a/packages/demo/public/catalogues/catalogue-dktk.json b/packages/demo/public/catalogues/catalogue-dktk.json index 1a279666..397aa323 100644 --- a/packages/demo/public/catalogues/catalogue-dktk.json +++ b/packages/demo/public/catalogues/catalogue-dktk.json @@ -4808,7 +4808,7 @@ [ { "value": "diagnosis", - "name": "C91.1" + "name": "C91.1%" } ], [ diff --git a/packages/lib/src/cql-translator-service/ast-to-cql-translator.ts b/packages/lib/src/cql-translator-service/ast-to-cql-translator.ts index 494be428..52054c8e 100644 --- a/packages/lib/src/cql-translator-service/ast-to-cql-translator.ts +++ b/packages/lib/src/cql-translator-service/ast-to-cql-translator.ts @@ -143,7 +143,10 @@ const getSingleton = (criterion: AstBottomLayerValue): string => { case "TNMc": { if (typeof criterion.value === "string") { // TODO: Check if we really need to do this or we can somehow tell cql to do that expansion it self - if (criterion.value.slice(-1) === "%") { + if ( + criterion.value.slice(-1) === "%" && + criterion.value.length == 5 + ) { const mykey = criterion.value.slice(0, -2); if (criteria != undefined) { const expandedValues = criteria.filter( @@ -156,6 +159,22 @@ const getSingleton = (criterion: AstBottomLayerValue): string => { value: expandedValues, }); } + } else if ( + criterion.value.slice(-1) === "%" && + criterion.value.length == 6 + ) { + const mykey = criterion.value.slice(0, -1); + if (criteria != undefined) { + const expandedValues = criteria.filter( + (value) => value.startsWith(mykey), + ); + expression += getSingleton({ + key: criterion.key, + type: criterion.type, + system: criterion.system, + value: expandedValues, + }); + } } else { expression += substituteCQLExpression( criterion.key,