Commit 6a464d7
committed
fix(generator): give complex sub-extensions a valid, unfrozen date default
The two latent defects the previous commit recorded but left alone.
complexExtValueDefault supplies the value[x] default for a sub-extension of a
complex extension:
- dateTime, instant and date fell through to `default: value`, emitting
valueDateTime: "value", which is not a valid FHIR dateTime.
- Period interpolated a generation-time new Date(), freezing the wall clock into
the emitted source — the same defect just removed from getTypePlaceholder.
Both now use the __DATE_EXPR__ / __DATE10_EXPR__ placeholders that the class
emitter resolves into randomDate(), so the value is valid and fresh per call.
The risk that held this back is cleared. The result becomes fixedValue on the
extension child, and a placeholder leaking into a validator comparison would emit
a check against the literal "__DATE_EXPR__". Every validator consumer of
fixedValue guards on typeof string/number/boolean, and buildFixedValueValidations
emits nothing for any other shape, so an array-of-objects fixedValue never reaches
a comparison. Only the class emitter renders it, and objectToCodeExpression
resolves the placeholder in a nested object value — checked by executing it, not by
reading it.
Verified on us-core@9.0.0: zero baked timestamps, zero unresolved placeholders in
the emitted output, and HL7 parity unchanged at 54/54 random and 54/54 empty.
Tests written first; 4 of 5 failed for the intended reasons before the change.1 parent cab82f1 commit 6a464d7
2 files changed
Lines changed: 75 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
0 commit comments