Skip to content
Open
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
7 changes: 0 additions & 7 deletions FhirValidator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,4 @@ describe('FhirValidator Integration Tests', () => {

expect(result).toHaveProperty('resourceType', 'OperationOutcome');
});

test('should load additional IGs', async () => {
if (skipIntegration) return;

const result = await validator.loadIG('hl7.fhir.uv.ips', '1.1.0');
expect(result).toHaveProperty('resourceType', 'OperationOutcome');
});
});
57 changes: 0 additions & 57 deletions fhir-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,63 +272,6 @@ class FhirValidator {
return this.validate(resourceObject, options);
}

/**
* Load an Implementation Guide
* @param {string} packageId - The package ID (e.g., "hl7.fhir.us.core")
* @param {string} version - The version (e.g., "6.0.0")
* @returns {Promise<Object>} - The OperationOutcome as a JavaScript object
*/
async loadIG(packageId, version) {
if (!this.isReady) {
throw new Error('Validator service is not ready');
}

const queryParams = new URLSearchParams();
queryParams.set('packageId', packageId);
queryParams.set('version', version);

const url = `${this.baseUrl}/loadIG?${queryParams.toString()}`;

return new Promise((resolve, reject) => {
const parsedUrl = new URL(url);
const requestOptions = {
hostname: parsedUrl.hostname,
port: parsedUrl.port,
path: parsedUrl.pathname + parsedUrl.search,
method: 'POST',
headers: {
'Accept': 'application/fhir+json'
}
};

const req = http.request(requestOptions, (res) => {
let data = '';

res.on('data', (chunk) => {
data += chunk;
});

res.on('end', () => {
try {
const result = JSON.parse(data);
resolve(result);
} catch (error) {
reject(new Error(`Failed to parse response: ${error.message}\nResponse: ${data}`));
}
});
});

req.on('error', reject);

req.setTimeout(30000, () => {
req.destroy();
reject(new Error('Load IG request timeout'));
});

req.end();
});
}

/**
* Stop the validator service
* @returns {Promise<void>}
Expand Down