Skip to content

atomic-ehr-codegen-python-us-core-profiles: doc fix + regenerate fhir_types (codegen canary)#37

Merged
ryukzak merged 9 commits into
mainfrom
fix/codegen-python-client-fhirpy-docs
Jul 2, 2026
Merged

atomic-ehr-codegen-python-us-core-profiles: doc fix + regenerate fhir_types (codegen canary)#37
ryukzak merged 9 commits into
mainfrom
fix/codegen-python-client-fhirpy-docs

Conversation

@ryukzak

@ryukzak ryukzak commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Changes to developer-experience/atomic-ehr-codegen-python-us-core-profiles:

1. Docs: correct the codegen option name

The README and post.py docstring referenced fhirpyClient: true, but the current @atomic-ehr/codegen API — and this example's own generate.ts — use client: "fhirpy". Fixed the three stale references.

2. Bump codegen to the profile-typing fix + regenerate fhir_types/

Pinned @atomic-ehr/codegen to 0.0.16-canary.20260702151019.bdf8485 — the build that includes the profile type-checking fix (atomic-ehr/codegen#192) — and regenerated fhir_types/. The generated profile layer now type-checks under strict mypy:

  • slice setters wrap the input into the element model under a fresh variable (no dict→model rebind);
  • extension setters narrow the flat-dict else branch with a runtime-validating assert is_record(value) / assert not isinstance(value, Extension);
  • single-value extension setters are typed as the value's own model (e.g. Coding) instead of Any;
  • is_record is a TypeGuard[MutableMapping[str, Any]].

(Also carries the earlier regeneration changes: concrete resources type resourceType as str with the value still pattern-fixed; abstract base types no longer carry a resourceType default; FhirpyBaseModel guards against PydanticUndefined.)

Pin is exact, not a caret. ^0.0.16-canary... resolves to the older stable 0.0.16 (a release outranks its prereleases in semver), which lacks the fix. Swap to a stable release once one ships with it.

3. Drop mypy suppressions

mypy.ini is now plain strict = True + the pydantic plugin. Previously the generated fhir_types/ tripped ~36 strict-mode errors that were masked with disable_error_code (plus strict_optional = False); the codegen fix makes both unnecessary. Optional access in the demo/tests uses ordinary None-guards.

Verification (after regeneration)

  • mypy .Success, no issues (35 source files) — strict, no suppressions
  • python load.py → writes bundle.json (10 entries)
  • python avg.pyAvg BP: 125.2/82.0 mmHg (n=5)
  • python post.py → transaction committed against a local Aidbox, observations read back as typed Observation resources

ryukzak added 2 commits June 26, 2026 14:53
…ion name to client: "fhirpy"

The README and post.py docstring referenced `fhirpyClient: true`, but the
current @atomic-ehr/codegen API (and this example`s generate.ts) use
`client: "fhirpy"`. Update the three references to match.
…pes with @atomic-ehr/codegen canary

Regenerated with @atomic-ehr/codegen@0.0.16-canary.20260626094300.e87ff88.
Canary changes: concrete resources type resourceType as `str` (pattern still
fixes the value) instead of `Literal[...]`, abstract base types (Resource,
DomainResource) no longer carry a resourceType default, and FhirpyBaseModel
guards against PydanticUndefined so it does not register a class-level
resourceType for those abstract types.

Verified: mypy clean (35 files), load.py / avg.py run, and post.py round-trips
a transaction against a local Aidbox with typed read-back.
@ryukzak ryukzak changed the title docs: correct @atomic-ehr/codegen option name to client: "fhirpy" atomic-ehr-codegen-python-us-core-profiles: doc fix + regenerate fhir_types (codegen canary) Jun 26, 2026
ryukzak added 5 commits July 2, 2026 17:31
…ofile-typing fix, drop mypy suppressions

Pin @atomic-ehr/codegen to 0.0.16-canary.20260702151019.bdf8485 (atomic-ehr/codegen#192),
which makes the generated profile layer type-check under strict mypy. mypy.ini is now
plain 'strict = True' + pydantic plugin -- the disable_error_code and strict_optional = False
suppressions are no longer needed.

Exact pin (no caret): '^0.0.16-canary...' resolves to the older stable 0.0.16, which lacks the fix.
…pes with the profile-typing fix

Slice setters use a fresh element variable, extension setters narrow the else branch with
assert is_record(value) / assert not isinstance(value, Extension), single-value extension
setters are typed as the value model instead of Any, and is_record is a TypeGuard.
…mples

For each example: regenerate types from the @atomic-ehr/codegen canary, fail
on committed-output drift, typecheck, run the scripts and check their output,
then POST the bundle to a licensed Aidbox service container and read it back.
Trigger only on changes under the example path or its own workflow file.
…r-types with @atomic-ehr/codegen canary and pin it
…ep install so codegen works on npm 10 (CI)

The canonical manager copies the local structure-definitions folder into
node_modules then runs npm install for each declared dependency; on npm 10
that prunes the just-copied local package as extraneous, failing with
'Package example.folder.structures not found'. Set FCM_SKIP_LOCAL_DEP_INSTALL=1
to skip the redundant install (hl7.fhir.r4.core comes from hl7.fhir.us.core).
@ryukzak ryukzak force-pushed the fix/codegen-python-client-fhirpy-docs branch from 350af93 to e636c28 Compare July 2, 2026 17:42
ryukzak added 2 commits July 2, 2026 22:25
… us.core instead of re-installing it

Use a relative path for the local structure-definitions folder and drop the
explicit hl7.fhir.r4.core dependency. It is already provided by
fromPackage("hl7.fhir.us.core"); re-declaring it made the canonical manager
run `npm install hl7.fhir.r4.core`, which on npm 10 (CI) pruned the just-copied
local package and failed with 'Package example.folder.structures not found'.
Generated types are unchanged; only the README duplicate-count report shifts.
…to 0.0.17

0.0.17 is the stable release of the canary the examples were generated with;
regenerated output is identical. CI installs @0.0.17 instead of @canary.
@ryukzak ryukzak merged commit 6e92f6c into main Jul 2, 2026
2 checks passed
@ryukzak ryukzak deleted the fix/codegen-python-client-fhirpy-docs branch July 2, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant