Skip to content
13 changes: 13 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,19 @@ async function startServer() {
if (modules.packages && config.modules.packages.enabled) {
modules.packages.startInitialCrawler();
}
// Run usage tracker in background after startup
if (modules.tx && modules.tx.library) {
setImmediate(async () => {
try {
serverLog.info('Starting ConceptUsageTracker scan...');
let count = await modules.tx.usageTracker.scanValueSets(modules.tx.library);
serverLog.info(`ConceptUsageTracker scan complete: ${count} valuesets list codes`);
} catch (err) {
console.log(err);
serverLog.error('ConceptUsageTracker scan failed:', err);
}
});
}
} catch (error) {
console.error('FATAL - Failed to start server:', error);
serverLog.error('FATAL - Failed to start server:', error);
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-areacode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ describe('AreaCodeServices', () => {
test('should throw error for search filter', async () => {
await expect(
provider.searchFilter(await provider.getPrepContext(false), 'test', false)
).rejects.toThrow('not implemented');
).rejects.toThrow('Text Search is not supported');
});

});
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-country.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ describe('CountryCodeServices', () => {
test('should throw error for search filter', async () => {
await expect(
provider.searchFilter(await provider.getPrepContext(false), 'test', false)
).rejects.toThrow('not implemented');
).rejects.toThrow('Text Search is not supported');
});

});
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-cpt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ describe('CPT Provider', () => {

await expect(
provider.searchFilter(filterContext, 'test', false)
).rejects.toThrow('not implemented');
).rejects.toThrow('Text Search is not supported');
});
});
});
16 changes: 8 additions & 8 deletions tests/cs/cs-cs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {CodeSystem} = require('../../tx/library/codesystem');
const {FhirCodeSystemFactory, FhirCodeSystemProvider, FhirCodeSystemProviderContext} = require('../../tx/cs/cs-cs');
const {Languages, Language} = require('../../library/languages');
const {OperationContext} = require("../../tx/operation-context");
const {Designations} = require("../../tx/library/designations");
const {Designations, SearchFilterText} = require("../../tx/library/designations");
const {TestUtilities} = require("../test-utilities");

describe('FHIR CodeSystem Provider', () => {
Expand Down Expand Up @@ -1416,7 +1416,7 @@ describe('FHIR CodeSystem Provider', () => {

describe('Search Filter', () => {
test('should find concepts by exact code match', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'code1', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('code1'), true);
expect(results.size()).toBeGreaterThan(0);

const concept = results.findConceptByCode('code1');
Expand All @@ -1425,30 +1425,30 @@ describe('FHIR CodeSystem Provider', () => {
});

test('should find concepts by display text match', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'Display 1', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('Display 1'), true);
expect(results.size()).toBeGreaterThan(0);

const concept = results.findConceptByCode('code1');
expect(concept).toBeDefined();
});

test('should find concepts by partial match', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'Display', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('Display'), true);
expect(results.size()).toBeGreaterThan(1); // Should find multiple concepts
});

test('should find concepts by definition match', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'first', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('first'), true);
expect(results.size()).toBeGreaterThan(0);
});

test('should return empty results for non-matching search', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'nonexistent', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('nonexistent'), true);
expect(results.size()).toBe(0);
});

test('should sort results by relevance when requested', async () => {
const results = await simpleProvider.searchFilter(filterContext, 'code', true);
const results = await simpleProvider.searchFilter(filterContext, new SearchFilterText('code'), true);
expect(results.size()).toBeGreaterThan(1);

// Results should be sorted by rating (exact matches first)
Expand Down Expand Up @@ -1683,7 +1683,7 @@ describe('FHIR CodeSystem Provider', () => {

describe('Complex Filter Scenarios', () => {
test('should work with German CodeSystem', async () => {
const results = await deProvider.searchFilter(filterContext, 'Anzeige', true);
const results = await deProvider.searchFilter(filterContext, new SearchFilterText('Anzeige'), true);
expect(results.size()).toBeGreaterThan(0);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-currency.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('Iso4217Services', () => {
const ctxt = await provider.getPrepContext(false);
await expect(
provider.searchFilter(ctxt, 'dollar', false)
).rejects.toThrow('not implemented');
).rejects.toThrow('Text Search is not supported');
});

test('should throw error for unsupported filter', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-hgvs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('HGVS Provider', () => {

test('should throw errors for filter operations', async () => {
await expect(provider.getPrepContext(true)).rejects.toThrow('not supported for HGVS');
await expect(provider.searchFilter(null, 'filter', false)).rejects.toThrow('not supported for HGVS');
await expect(provider.searchFilter(null, 'filter', false)).rejects.toThrow('Text Search is not supported');
await expect(provider.filter(null, 'prop', 'equal', 'value')).rejects.toThrow('not supported for HGVS');
await expect(provider.prepare(null)).rejects.toThrow('not supported for HGVS');
await expect(provider.executeFilters(null)).rejects.toThrow('not supported for HGVS');
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-lang.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('IETF Language CodeSystem Provider', () => {
test('should not support text search', async () => {
await expect(
provider.searchFilter(new FilterExecutionContext(), 'english', false)
).rejects.toThrow('Text search not supported');
).rejects.toThrow('Text Search is not supported');
});

test('should indicate filters are not closed', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/cs/cs-omop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ describe('OMOP Provider', () => {

await expect(
provider.searchFilter(filterContext, 'test', false)
).rejects.toThrow('not implemented');
).rejects.toThrow('Text Search is not supported');
});
});

Expand Down
Loading
Loading