Skip to content
Merged
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
56 changes: 6 additions & 50 deletions .github/workflows/sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
exit 1
fi

test-typescript-sdk-r4:
test-typescript-r4-us-core-example:
runs-on: ubuntu-latest

steps:
Expand All @@ -55,65 +55,21 @@ jobs:
run: bun install --frozen-lockfile

- name: Run tests
run: make test-typescript-r4-example
run: make test-typescript-r4-us-core-example

- name: Repository contains actual typescript-sdk version
run: |
diff_result=$(git diff --exit-code --name-only examples/typescript-r4 || true)
diff_result=$(git diff --exit-code --name-only examples/typescript-r4-us-core || true)

if [ -z "$diff_result" ]; then
echo "✅ Generated SDK is identical to the one stored in repository."
else
echo "❌ Generated SDK differs from the one stored in repository."
echo "Differences:"
git diff examples/typescript-r4
git diff examples/typescript-r4-us-core
exit 1
fi

test-typescript-us-core-example:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Run tests
run: make test-typescript-us-core-example

# TODO: enable git diff check after fixing non-deterministic generation output
# - name: Repository contains actual typescript-us-core version
# run: |
# diff_result=$(git diff --exit-code --name-only examples/typescript-us-core || true)
#
# if [ -z "$diff_result" ]; then
# echo "✅ Generated SDK is identical to the one stored in repository."
# else
# echo "❌ Generated SDK differs from the one stored in repository."
# echo "Differences:"
# git diff examples/typescript-us-core
# exit 1
# fi

test-typescript-ccda-example:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Run tests
run: make test-typescript-ccda-example

test-python-sdk:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -201,7 +157,7 @@ jobs:
- name: Run tests
run: make test-python-us-core-example

test-local-package-folder-example:
test-typescript-custom-packages-example:
runs-on: ubuntu-latest

steps:
Expand All @@ -214,7 +170,7 @@ jobs:
run: bun install --frozen-lockfile

- name: Run tests
run: make test-local-package-folder-example
run: make test-typescript-custom-packages-example

test-on-the-fly-example:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .zed/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"command": "make test"
},
{
"label": "test-ts-r4-example",
"command": "make test-typescript-r4-example"
"label": "test-ts-r4-us-core-example",
"command": "make test-typescript-r4-us-core-example"
},
{
"label": "test-ts-ccda-example",
"command": "make test-typescript-ccda-example"
"command": "make test-on-the-fly-ccda"
}
]
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Example test files in `examples/` follow a two-tier structure:

2. **Regression tests** follow — concise, focused tests for edge cases and mechanics not covered by demos (e.g. factory equivalence, slice replacement, choice type independence). Keep these minimal; don't duplicate what demos already prove.

Reference example: `examples/typescript-r4/profile-bodyweight.test.ts`
Reference example: `examples/typescript-r4-us-core/profile-r4-bodyweight.test.ts`

### Key Dependencies
- `@atomic-ehr/fhir-canonical-manager`: FHIR package management
Expand Down
57 changes: 21 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ VERSION = $(shell cat package.json | grep version | sed -E 's/ *"version": "//'
.PHONY: all generate-types lint lint-fix lint-unsafe typecheck \
test test-multi-package \
prepare-aidbox-runme test-all-example-generation test-other-example-generation \
test-on-the-fly-example test-on-the-fly-norge-r4 test-on-the-fly-kbv-r4 \
test-typescript-r4-example test-typescript-us-core-example test-typescript-sql-on-fhir-example \
test-typescript-ccda-example test-local-package-folder-example test-mustache-java-r4-example \
test-on-the-fly-example test-on-the-fly-norge-r4 test-on-the-fly-kbv-r4 test-on-the-fly-ccda \
test-typescript-r4-us-core-example test-typescript-custom-packages-example \
test-mustache-java-r4-example \
test-csharp-sdk generate-python-sdk generate-python-sdk-fhirpy generate-python-us-core-sdk \
python-test-setup python-fhirpy-test-setup python-us-core-test-setup \
test-python-sdk test-python-fhirpy-sdk test-python-us-core-example

all: test test-multi-package test-typescript-r4-example test-typescript-us-core-example test-typescript-ccda-example test-typescript-sql-on-fhir-example test-local-package-folder-example lint-unsafe test-all-example-generation
all: test test-multi-package test-typescript-r4-us-core-example test-typescript-custom-packages-example lint-unsafe test-all-example-generation

generate-types:
bun run scripts/generate-types.ts
Expand Down Expand Up @@ -54,19 +54,16 @@ prepare-aidbox-runme:

test-all-example-generation: test-other-example-generation
bun run examples/csharp/generate.ts
bun run examples/local-package-folder/generate.ts
bun run examples/typescript-custom-packages/generate.ts
bun run examples/mustache/mustache-java-r4-gen.ts
bun run examples/python-r4/generate.ts
bun run examples/python-fhirpy/generate.ts
bun run examples/python-us-core/generate.ts
bun run examples/typescript-ccda/generate.ts
bun run examples/typescript-r4/generate.ts
bun run examples/typescript-sql-on-fhir/generate.ts
bun run examples/typescript-us-core/generate.ts
bun run examples/typescript-r4-us-core/generate.ts

test-other-example-generation: test-on-the-fly-example

test-on-the-fly-example: test-on-the-fly-norge-r4 test-on-the-fly-kbv-r4
test-on-the-fly-example: test-on-the-fly-norge-r4 test-on-the-fly-kbv-r4 test-on-the-fly-ccda

test-on-the-fly-norge-r4: typecheck
bun run examples/on-the-fly/norge-r4/generate.ts
Expand All @@ -78,32 +75,20 @@ test-on-the-fly-kbv-r4: typecheck
$(TYPECHECK) --project examples/on-the-fly/kbv-r4/tsconfig.json
bun test ./examples/on-the-fly/kbv-r4/

test-typescript-r4-example: typecheck
bun run examples/typescript-r4/generate.ts
$(TYPECHECK) --project examples/typescript-r4/tsconfig.json
bun test ./examples/typescript-r4/

test-typescript-us-core-example: typecheck
bun run examples/typescript-us-core/generate.ts
$(TYPECHECK) --project examples/typescript-us-core/tsconfig.json
bun test ./examples/typescript-us-core/

test-typescript-sql-on-fhir-example: typecheck
bun run examples/typescript-sql-on-fhir/generate.ts
$(TYPECHECK) --project examples/typescript-sql-on-fhir/tsconfig.json

test-typescript-ccda-example: typecheck
bun test test/unit/typeschema/transformer/ccda.test.ts
bun run examples/typescript-ccda/generate.ts
$(TYPECHECK) --project examples/typescript-ccda/tsconfig.json
bun test --project examples/typescript-ccda/tsconfig.json \
./examples/typescript-ccda/demo-cda.test.ts \
./examples/typescript-ccda/demo-ccda.test.ts

test-local-package-folder-example: typecheck
bun run examples/local-package-folder/generate.ts
$(TYPECHECK) --project examples/local-package-folder/tsconfig.json
bun test ./examples/local-package-folder/
test-on-the-fly-ccda: typecheck
bun run examples/on-the-fly/ccda/generate.ts
$(TYPECHECK) --project examples/on-the-fly/ccda/tsconfig.json
bun test ./examples/on-the-fly/ccda/

test-typescript-r4-us-core-example: typecheck
bun run examples/typescript-r4-us-core/generate.ts
$(TYPECHECK) --project examples/typescript-r4-us-core/tsconfig.json
bun test ./examples/typescript-r4-us-core/

test-typescript-custom-packages-example: typecheck
bun run examples/typescript-custom-packages/generate.ts
$(TYPECHECK) --project examples/typescript-custom-packages/tsconfig.json
bun test ./examples/typescript-custom-packages/

test-mustache-java-r4-example: typecheck
bun run examples/mustache/mustache-java-r4-gen.ts
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ A powerful, extensible code generation toolkit for FHIR ([Fast Healthcare Intero

## Features

- [x] **Multi-Package Support** — Load packages from the [FHIR registry](examples/typescript-r4/), [remote TGZ files](examples/typescript-sql-on-fhir/), or a [local folder with custom StructureDefinitions](examples/local-package-folder/)
- [x] **Multi-Package Support** — Load packages from the [FHIR registry](examples/typescript-r4-us-core/), [remote TGZ files](examples/typescript-custom-packages/), or a [local folder with custom StructureDefinitions](examples/typescript-custom-packages/)
- Tested with hl7.fhir.r4.core, US Core, C-CDA, SQL on FHIR, etc.
- [x] **Resources & Complex Types** — Generates typed definitions with proper inheritance
- [x] **Value Set Bindings** — Strongly-typed enums from FHIR terminology bindings
- [x] **Profiles** — Factory methods with auto-populated fixed values and required slices ([R4 profiles](examples/typescript-r4/profile-bp.test.ts), [US Core](examples/typescript-us-core/))
- Extensions — flat typed accessors (e.g. `setRace()` on US Core Patient), [standalone extension profiles](examples/typescript-r4/extension-profile.test.ts)
- [x] **Profiles** — Factory methods with auto-populated fixed values and required slices ([R4 profiles](examples/typescript-r4-us-core/profile-r4-bp.test.ts), [US Core](examples/typescript-r4-us-core/profile-us-core-patient.test.ts))
- Extensions — flat typed accessors (e.g. `setRace()` on US Core Patient), [standalone extension profiles](examples/typescript-r4-us-core/profile-r4-extension.test.ts)
- Slicing — typed get/set accessors with discriminator matching
- Validation — runtime `validate()` for required fields, fixed values, slice cardinality, enums, references
- [x] **Extensible Architecture** — Three-stage pipeline: FHIR packages → [TypeSchema](https://www.health-samurai.io/articles/type-schema-a-pragmatic-approach-to-build-fhir-sdk) IR → code generation
Expand Down Expand Up @@ -99,7 +99,7 @@ yarn add @atomic-ehr/codegen
const builder = new APIBuilder()
.fromPackage("hl7.fhir.r4.core", "4.0.1")
.typescript({})
.outputTo("./examples/typescript-r4/fhir-types")
.outputTo("./examples/typescript-r4-us-core/fhir-types")
.introspection({ typeTree: "./type-tree.yaml" });

const report = await builder.generate();
Expand All @@ -116,14 +116,13 @@ yarn add @atomic-ehr/codegen

See the [examples/](examples/) directory for working demonstrations:

- **[typescript-r4/](examples/typescript-r4/)** - FHIR R4 type generation with resource creation demo and profile usage
- **[typescript-ccda/](examples/typescript-ccda/)** - C-CDA on FHIR type generation
- **[typescript-sql-on-fhir/](examples/typescript-sql-on-fhir/)** - SQL on FHIR ViewDefinition with tree shaking
- **[typescript-r4-us-core/](examples/typescript-r4-us-core/)** - FHIR R4 core + US Core type generation with resource creation, profiles, and extensions
- **[on-the-fly/ccda/](examples/on-the-fly/ccda/)** - C-CDA on FHIR type generation (logical models, generated on the fly)
- **[python/](examples/python/)** - Python/Pydantic model generation with simple requests-based client
- **[python-fhirpy/](examples/python-fhirpy/)** - Python/Pydantic model generation with fhirpy async client
- **[csharp/](examples/csharp/)** - C# class generation with namespace configuration
- **[mustache/](examples/mustache/)** - Java generation with Mustache templates and post-generation hooks
- **[local-package-folder/](examples/local-package-folder/)** - Loading unpublished local FHIR packages
- **[typescript-custom-packages/](examples/typescript-custom-packages/)** - Loading packages from local folders or remote TGZ URLs (SQL-on-FHIR)

For detailed documentation, see [examples/README.md](examples/README.md).

Expand Down Expand Up @@ -423,7 +422,7 @@ const errors = bp.validate();
// ["effective: at least one of effectiveDateTime, effectivePeriod is required"]
```

See [examples/typescript-r4/](examples/typescript-r4/) for R4 profile tests and [examples/typescript-us-core/](examples/typescript-us-core/) for US Core profile examples.
See [examples/typescript-r4-us-core/](examples/typescript-r4-us-core/) for R4 and US Core profile tests.

## Support

Expand Down
2 changes: 1 addition & 1 deletion docs/design/profiles.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FHIR Profiles Representation

Status: Implemented (TypeScript). See `examples/typescript-r4/` and `examples/typescript-us-core/` for working examples.
Status: Implemented (TypeScript). See `examples/typescript-r4-us-core/` for working R4 and US Core examples.

This document covers the representation of FHIR profiles in generated code: resource profiles, extension profiles, and their relationship to base resources.

Expand Down
2 changes: 1 addition & 1 deletion docs/design/slices.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FHIR Slices Representation

Status: Implemented (TypeScript, Lens level). See `examples/typescript-r4/` for working examples.
Status: Implemented (TypeScript, Lens level). See `examples/typescript-r4-us-core/` for working examples.

Working issue: [#24](https://github.com/atomic-ehr/codegen/issues/24)

Expand Down
Loading
Loading