diff --git a/tests/tx/designations.test.js b/tests/tx/designations.test.js index d8861b51..c459a354 100644 --- a/tests/tx/designations.test.js +++ b/tests/tx/designations.test.js @@ -165,6 +165,7 @@ describe('Designations', () => { test('should respect quality values', () => { const langList = Languages.fromAcceptLanguage('fr;q=0.1,en;q=0.9'); + designations.designations[0].status = 'active'; const preferred = designations.preferredDesignation(langList); // Should prefer English due to higher quality @@ -289,6 +290,8 @@ describe('Designations', () => { test('should prefer base over display for exact match', () => { const langList = Languages.fromAcceptLanguage('en-US'); + designations.designations[0].status = 'active'; + designations.designations[2].status = 'active'; const preferred = designations.preferredDesignation(langList); expect(preferred.display).toBe('Base US English'); @@ -297,6 +300,7 @@ describe('Designations', () => { test('should fall back to language-region match', () => { const langList = Languages.fromAcceptLanguage('en-AU'); // Australian English not in designations + designations.designations[0].status = 'active'; const preferred = designations.preferredDesignation(langList); // Should fall back to base English diff --git a/tx/library/designations.js b/tx/library/designations.js index ccdc1e56..8d4bbb41 100644 --- a/tx/library/designations.js +++ b/tx/library/designations.js @@ -610,35 +610,42 @@ class Designations { const matchTypes = [LangMatchType.FULL, LangMatchType.LANG_REGION, LangMatchType.LANG]; - for (const matchType of matchTypes) { - for (const cd of this.designations) { - if (this._langMatches(lang, cd.language, matchType) && this.isDisplay(cd)) { - if (supplements && cd.source) { - supplements.add(cd.source); + for (const activeOnly of [true, false]) { + for (const matchType of matchTypes) { + for (const cd of this.designations) { + if (this._langMatches(lang, cd.language, matchType) && this.isDisplay(cd) && (!activeOnly || cd.isActive())) { + if (supplements && cd.source) { + supplements.add(cd.source); + } + return cd; } - return cd; } - } - for (const cd of this.designations) { - if (this._langMatches(lang, cd.language, matchType) && this._isPreferred(cd)) { - if (supplements && cd.source) { - supplements.add(cd.source); + for (const cd of this.designations) { + if (this._langMatches(lang, cd.language, matchType) && this._isPreferred(cd)&& (!activeOnly || cd.isActive())) { + if (supplements && cd.source) { + supplements.add(cd.source); + } + return cd; } - return cd; } - } - for (const cd of this.designations) { - if (this._langMatches(lang, cd.language, matchType)) { - if (supplements && cd.source) { - supplements.add(cd.source); + for (const cd of this.designations) { + if (this._langMatches(lang, cd.language, matchType) && (!activeOnly || cd.isActive())) { + if (supplements && cd.source) { + supplements.add(cd.source); + } + return cd; } - return cd; } } } } for (const cd of this.designations) { - if (!cd.language && this.isDisplay(cd)) { + if (!cd.language && this.isDisplay(cd) && cd.isActive()) { + if (supplements && cd.source) { + supplements.add(cd.source); + } + return cd; + } if (!cd.language && this.isDisplay(cd)) { if (supplements && cd.source) { supplements.add(cd.source); } diff --git a/tx/workers/lookup.js b/tx/workers/lookup.js index 6d52a4d6..6766a0ed 100644 --- a/tx/workers/lookup.js +++ b/tx/workers/lookup.js @@ -374,6 +374,12 @@ class LookupWorker extends TerminologyWorker { }); } + if (designation.status && designation.status !== 'active') { + designationParts.push({ + name: 'status', + valueCode: designation.status + }); + } designationParts.push({ name: 'value', valueString: designation.value diff --git a/tx/workers/validate.js b/tx/workers/validate.js index 40c5210e..8391df0e 100644 --- a/tx/workers/validate.js +++ b/tx/workers/validate.js @@ -1350,14 +1350,18 @@ class ValueSetChecker { if (vstatus.value && vstatus.value !== 'inactive') { result.addParamCode('status', vstatus.value); } + let mpath = inactive.path; + if (!mpath) { + mpath = 'code'; + } if (!['inactive', 'DISCOURAGED'].includes(vstatus.value)) { let m = this.worker.i18n.translate('INACTIVE_CONCEPT_FOUND', this.params.HTTPLanguages, ['inactive', tcode]); msg(m); - op.addIssue(new Issue('warning', 'business-rule', inactive.path, 'INACTIVE_CONCEPT_FOUND', m, 'code-comment')); + op.addIssue(new Issue('warning', 'business-rule', mpath, 'INACTIVE_CONCEPT_FOUND', m, 'code-comment')); } let m = this.worker.i18n.translate('INACTIVE_CONCEPT_FOUND', this.params.HTTPLanguages, [vstatus.value, tcode]); msg(m); - op.addIssue(new Issue('warning', 'business-rule', inactive.path, 'INACTIVE_CONCEPT_FOUND', m, 'code-comment')); + op.addIssue(new Issue('warning', 'business-rule', mpath, 'INACTIVE_CONCEPT_FOUND', m, 'code-comment')); } else if (vstatus.value && vstatus.value.toLowerCase() === 'deprecated') { result.addParamCode('status', 'deprecated'); let m = this.worker.i18n.translate('DEPRECATED_CONCEPT_FOUND', this.params.HTTPLanguages, [vstatus.value, tcode]);