fhir: map primitive elements#1678
Conversation
Signed-off-by: Hunter Achieng <achienghunter@gmail.com>
Signed-off-by: Hunter Achieng <achienghunter@gmail.com>
josephjclark
left a comment
There was a problem hiding this comment.
Maybe a bit of confusion over whether we're handling primitve types or primitive extensions? I'm expecting that primitive types work already, and we're just adding support for extensions here
| import type * as FHIR from "../fhir"; | ||
| type MaybeArray<T> = T | T[]; | ||
|
|
||
| export type Observation_SzVitalSigns_Props = { |
There was a problem hiding this comment.
Nervous about this diff! This looks unrelated to the work. And I think all the types here are actually broken?
There was a problem hiding this comment.
@josephjclark I used this command to regenerate the schema pnpm generate-fhir fhir-eswatini --respec could this be the cause of the changes? Because I got this error when testing and I had to export it from builders in fhir-4
TypeError: dt.ensureConceptText is not a function
There was a problem hiding this comment.
Strange 🤔
When I rebuild from the root I also get strange type errors and wierd syntax. When I go into the adaptor folder and do pnpm build:src --respec, I get different output.
The two commands really should be aliases of each other. I fear some path has gotten misaligned and is doing wierd things.
if you go to main and run pnpm build:src --respec from inside the adaptor folder, what happens?
There was a problem hiding this comment.
@josephjclark It is only this that is updated "adaptorGeneratedDate": "2026-05-27T13:18:19.262Z",
There was a problem hiding this comment.
That's what I get too.
So I think we have a bug when generating from the repo root. Or maybe it's a bug when generating inside the folder. Either way that needs investigating.
Maybe you can run pnpm build:src --respec on this branch and commit the changes - that should resolve some of the issues I see on this PR.
There was a problem hiding this comment.
You mean the primitive extension no longer gets added? The test fails?
There was a problem hiding this comment.
It is not added, and the tests fail. I had to skip them
There was a problem hiding this comment.
Don't skip them - if tests are failing its because something is broken. They should fail in CI until we fix the problem.
Something seems very messed up here. I'll try and take a look tomorrow but if I can't, it'll be Monday before I can investigate.
npm generate-fhir fhir-eswatini --respec and pnpm build:src --respec should be exactly the same command. I'm really nervous that we seem to be getting different behaviours. Can you try and investigate what might be different when running the commands?
There's no magic here, just code. All the answers are in this repo .
I suspect something is wrong on main, and we need to update fhir-eswatini on a branch off main first, and then rebase your work here onto that branch. That would help me understand what's wrong on main, and what you've added on this PR. That will make my review a lot easier.
There was a problem hiding this comment.
@josephjclark using npm generate-fhir fhir-eswatini --respec does not work. It flags that npm error Missing script: "generate-fhir"
When I try with pnpm when inside fhir-eswatini, I get these changes

| declare const setValues: (url: any, values: any, type?: string) => void; | ||
| declare const value: (value: any, system: any, ...extra: any[]) => any; | ||
|
|
||
| import "./values"; |
There was a problem hiding this comment.
Quite nervous about this cahnge too
Signed-off-by: Hunter Achieng <achienghunter@gmail.com>
Signed-off-by: Hunter Achieng <achienghunter@gmail.com>
Summary
Add ability to map primitive elements in
fhirby focusing on elements starting with an_.Regenerated
fhir-eswatiniwith tests to check behaviorgenerate-schemathen mapped by checking if the parent has an extension.AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to
know!):
You can read more details in our
Responsible AI Policy
Review Checklist
Before merging, the reviewer should check the following items:
production? Is it safe to release?
dev only changes don't need a changeset.