babelfhir-ts 1.5.12 → 1.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -451,10 +451,18 @@ export function handleFlatField(args) {
451
451
  addTypeImport(fieldType);
452
452
  }
453
453
  }
454
+ // Capture primitiveness BEFORE applyBindingConstraint rewrites CodeableConcept
455
+ // fields into an intersection string like `CodeableConcept & { coding: Array<{
456
+ // code: X; system: "..." }> }`. That string contains quotes, so the post-
457
+ // constraint isPrimitiveType() heuristic (/['"]/ in createRules) misfires and
458
+ // the code-union path below would clobber the CodeableConcept with a bare code
459
+ // union (regression from bae9e64). Only genuine primitive `code` fields should
460
+ // take that path, so gate it on the pre-constraint type.
461
+ const isPrimitiveCodeField = isPrimitiveType(fieldType);
454
462
  // Apply ValueSet binding constraints for CodeableConcept types
455
463
  fieldType = applyBindingConstraint(fieldType, field, fields);
456
464
  // Apply ValueSet binding constraints for primitive code fields (generates union literal type)
457
- if (isPrimitiveType(fieldType) && hasNarrowingBinding && field.binding?.codes) {
465
+ if (isPrimitiveCodeField && hasNarrowingBinding && field.binding?.codes) {
458
466
  const vsUri = field.binding.uri?.split('|')[0];
459
467
  const vs = vsUri && valueSets ? (valueSets.get(vsUri) || valueSets.get(field.binding.uri)) : undefined;
460
468
  if (vs && vs.isSmall && vs.concepts.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babelfhir-ts",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "BabelFHIR-TS: generate TypeScript interfaces, validators, and helper classes from FHIR R4/R4B/R5 StructureDefinitions (profiles) directly inside package archives.",
5
5
  "type": "module",
6
6
  "main": "out/src/main.js",