Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/tx/designations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand All @@ -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
Expand Down
45 changes: 26 additions & 19 deletions tx/library/designations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions tx/workers/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions tx/workers/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Loading