Skip to content

Commit bc20f07

Browse files
committed
refactor: use distinct error messages for bundle vs contained ref validation
- Bundle refs: 'Bundle reference not found: <ref>' - Contained refs: 'Contained reference not found: #id' - Update parity classifier to match both old HL7 and new internal messages - Update test assertions to match new message format
1 parent 50c940e commit bc20f07

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/generator/emitters/validator/validatorTemplates.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function generateBundleRefValidation(baseResourceType: string | undefined
3030
const ref = rec.reference as string;
3131
if (ref.startsWith('urn:uuid:') || ref.startsWith('urn:oid:')) {
3232
if (!_fullUrls.has(ref)) {
33-
errors.push('Bundled or contained reference not found within the bundle/resource ' + ref);
33+
errors.push('Bundle reference not found: ' + ref);
3434
}
3535
} else if (/^[A-Za-z]+\\//.test(ref)) {
3636
if (!_resIds.has(ref)) {
@@ -39,7 +39,7 @@ export function generateBundleRefValidation(baseResourceType: string | undefined
3939
if (_fu.endsWith('/' + ref) || _fu.endsWith(ref)) { _found = true; break; }
4040
}
4141
if (!_found) {
42-
errors.push('Bundled or contained reference not found within the bundle/resource ' + ref);
42+
errors.push('Bundle reference not found: ' + ref);
4343
}
4444
}
4545
}
@@ -83,7 +83,7 @@ export function generateContainedRefValidation(baseResourceType: string | undefi
8383
if (_ref.startsWith('#')) {
8484
const _id = _ref.substring(1);
8585
if (_id && !_containedIds.has(_id)) {
86-
errors.push('Bundled or contained reference not found within the bundle/resource ' + _ref);
86+
errors.push('Contained reference not found: ' + _ref);
8787
}
8888
}
8989
}

src/test/parity/parityHelpers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,10 @@ export function extractFieldFromMessage(msg: string): FieldIssue | null {
396396
return { field: 'constraint', type: 'constraint', message: msg };
397397
}
398398

399-
// HL7 bundled/contained reference resolution errors
400-
// e.g., "Bundled or contained reference not found within the bundle/resource Encounter/id-xxx"
401-
if (msg_lower.includes('reference not found within the bundle') || msg_lower.includes('contained reference not found')) {
399+
// Bundled/contained reference resolution errors
400+
// HL7: "Bundled or contained reference not found within the bundle/resource Encounter/id-xxx"
401+
// Internal: "Bundle reference not found: urn:uuid:..." / "Contained reference not found: #id"
402+
if (msg_lower.includes('reference not found within the bundle') || msg_lower.includes('contained reference not found') || msg_lower.includes('bundle reference not found')) {
402403
return { field: 'constraint', type: 'constraint', message: msg };
403404
}
404405

src/test/validatorGaps.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('validatorGenerator gaps', () => {
467467
];
468468
const code = generateCode('TestBundle', fields, { baseResourceType: 'Bundle' });
469469

470-
expect(code).toContain('Bundled or contained reference not found');
470+
expect(code).toContain('Bundle reference not found');
471471
});
472472

473473
it('does NOT emit bundle reference resolution for non-Bundle base type', () => {

0 commit comments

Comments
 (0)