From aa3848dd56c42eb538aa2ff0e17ac59ec1a95a71 Mon Sep 17 00:00:00 2001 From: Malte Sussdorff Date: Mon, 11 May 2026 18:34:03 +0200 Subject: [PATCH 1/2] test(typeschema): give shared-URL fixtures explicit package_meta The fixtures string.fs.json and coding.fs.json reproduce real FHIR R4 primitive/complex type definitions using canonical URLs that collide with the hl7.fhir.r4.core@4.0.1 entries pre-loaded via mkR4Register. Without an explicit package_meta, the registerFs test helper defaulted them to mypackage@0.0.0, so testAppendFs inserted these schemas into the shared r4 register under that fake package id. Subsequent tests that resolved primitive type references (e.g. "string") from a mypackage context hit the resolveFs fallback at register.ts:190 which returns any fhirSchemas entry whose package_meta.name matches the caller's package name. Result: primitive type identifiers in the "with cardinality", "with resource with string", "with resource with nested type", and "with resource with nested type 2" snapshots were silently attributed to mypackage@0.0.0 instead of hl7.fhir.r4.core on platforms whose Object.values iteration order surfaced the polluted entry first (notably macOS arm64). The same pollution path also baked an incorrect mypackage attribution into the previously-passing Custom resource > TutorNotification* and Real world examples snapshots, where primitive string references were recorded under mypackage instead of hl7.fhir.r4.core. Setting an explicit package_meta of realworld.test@1.0.0 on the two shared-URL fixtures breaks the URL collision: the schemas land in their own pkgIndex, so the mypackage-name fallback no longer matches them and the canonical resolution path returns the genuine R4 entry. The fixture intent is preserved (these are still treated as externally-defined primitives), and the test names continue to make semantic sense. --- test/assets/fhir-schemas/coding.fs.json | 1 + test/assets/fhir-schemas/string.fs.json | 1 + 2 files changed, 2 insertions(+) diff --git a/test/assets/fhir-schemas/coding.fs.json b/test/assets/fhir-schemas/coding.fs.json index fed5190b0..f0d6b8b30 100644 --- a/test/assets/fhir-schemas/coding.fs.json +++ b/test/assets/fhir-schemas/coding.fs.json @@ -1,4 +1,5 @@ { + "package_meta" : { "name" : "realworld.test", "version" : "1.0.0" }, "description" : "Base StructureDefinition for Coding Type: A reference to a code defined by a terminology system.", "derivation" : "specialization", "name" : "Coding", diff --git a/test/assets/fhir-schemas/string.fs.json b/test/assets/fhir-schemas/string.fs.json index 18e9bbd7f..6e4ccf1f2 100644 --- a/test/assets/fhir-schemas/string.fs.json +++ b/test/assets/fhir-schemas/string.fs.json @@ -1,4 +1,5 @@ { + "package_meta" : { "name" : "realworld.test", "version" : "1.0.0" }, "description" : "Base StructureDefinition for string Type: A sequence of Unicode characters", "derivation" : "specialization", "name" : "string", From a135574b95d4dcd63c164dc13ed2aa0747154869 Mon Sep 17 00:00:00 2001 From: Malte Sussdorff Date: Mon, 11 May 2026 18:34:11 +0200 Subject: [PATCH 2/2] test(typeschema): regenerate snapshot.test.ts.snap after pollution fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regenerated snapshots reflect two distinct changes from the previous commit: 1. Identifier flip in "Real world examples" snapshots — the coding and string primitive type fixtures now report their own realworld.test@1.0.0 package on the identifier, matching their newly explicit package_meta. 2. Correction of primitive type attribution in "Custom resource" TutorNotification* snapshots and in the previously-failing "with cardinality", "with resource with string", "with resource with nested type", and "with resource with nested type 2" snapshots — primitive string references now correctly resolve to hl7.fhir.r4.core@4.0.1 (the canonical FHIR R4 source) instead of the leaked mypackage@0.0.0 attribution that was previously baked in by the register pollution. Verified by counting "mypackage" occurrences in the snapshot file: 30 before, 22 after — exactly 8 changes, accounting for 2 identifier flips and 6 primitive type/dependency corrections. The remaining 22 mypackage references are all legitimate (test resource identifiers, bindings, and reference targets that do belong to mypackage). All 14 snapshot.test.ts tests now pass on macOS arm64; the broader test suite remains green (257/257). --- .../__snapshots__/snapshot.test.ts.snap | 1368 ++++++++--------- 1 file changed, 684 insertions(+), 684 deletions(-) diff --git a/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap b/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap index bf7645ce9..66fd94366 100644 --- a/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap +++ b/test/unit/typeschema/__snapshots__/snapshot.test.ts.snap @@ -1,4 +1,4 @@ -// Bun Snapshot v1, https://bun.sh/docs/test/snapshots +// Bun Snapshot v1, https://goo.gl/fbAQLP exports[`ValueSet to Type Schema (snapshot) administrative-gender 1`] = ` "{ @@ -124,15 +124,15 @@ exports[`ValueSet to Type Schema (snapshot) marital-status 1`] = ` }" `; -exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) Real world examples coding primitive type 1`] = ` "[ { "identifier": { "kind": "complex-type", - "package": "mypackage", - "version": "0.0.0", - "name": "Cardinality", - "url": "http://hl7.org/fhir/StructureDefinition/Cardinality" + "package": "realworld.test", + "version": "1.0.0", + "name": "Coding", + "url": "http://hl7.org/fhir/StructureDefinition/Coding" }, "base": { "kind": "complex-type", @@ -142,21 +142,19 @@ exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` "url": "http://hl7.org/fhir/StructureDefinition/Element" }, "fields": { - "zero_or_one": { + "system": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "uri", + "url": "http://hl7.org/fhir/StructureDefinition/uri" }, "required": false, "excluded": false, - "array": true, - "min": 0, - "max": 1 + "array": false }, - "one": { + "version": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", @@ -166,25 +164,21 @@ exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` }, "required": false, "excluded": false, - "array": true, - "min": 1, - "max": 1 + "array": false }, - "many": { + "code": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "code", + "url": "http://hl7.org/fhir/StructureDefinition/code" }, "required": false, "excluded": false, - "array": true, - "min": 42, - "max": 42 + "array": false }, - "one_or_many": { + "display": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", @@ -194,24 +188,37 @@ exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` }, "required": false, "excluded": false, - "array": true, - "min": 1 + "array": false }, - "zero_or_many": { + "userSelected": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "boolean", + "url": "http://hl7.org/fhir/StructureDefinition/boolean" }, "required": false, "excluded": false, - "array": true + "array": false } }, "description": "Base StructureDefinition for Coding Type: A reference to a code defined by a terminology system.", "dependencies": [ + { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "boolean", + "url": "http://hl7.org/fhir/StructureDefinition/boolean" + }, + { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "code", + "url": "http://hl7.org/fhir/StructureDefinition/code" + }, { "kind": "complex-type", "package": "hl7.fhir.r4.core", @@ -225,21 +232,59 @@ exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` "version": "4.0.1", "name": "string", "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "uri", + "url": "http://hl7.org/fhir/StructureDefinition/uri" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) with resource with string 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) Real world examples string primitive type 1`] = ` +"[ + { + "identifier": { + "kind": "primitive-type", + "package": "realworld.test", + "version": "1.0.0", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "description": "Base StructureDefinition for string Type: A sequence of Unicode characters", + "base": { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Element", + "url": "http://hl7.org/fhir/StructureDefinition/Element" + }, + "dependencies": [ + { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Element", + "url": "http://hl7.org/fhir/StructureDefinition/Element" + } + ] + } +]" +`; + +exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotificationTemplate 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "WithPrimitiveString", - "url": "http://example.io/fhir/WithPrimitiveString" + "name": "TutorNotificationTemplate", + "url": "http://example.com/aidbox-sms-tutor/TutorNotificationTemplate" }, "base": { "kind": "resource", @@ -249,7 +294,7 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with string 1`] = ` "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "someString": { + "template": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", @@ -262,7 +307,6 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with string 1`] = ` "array": false } }, - "description": "description", "dependencies": [ { "kind": "resource", @@ -283,15 +327,15 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with string 1`] = ` ]" `; -exports[`FHIR Schema to Type Schema (snapshot) with resource with code 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "WithCode", - "url": "http://example.io/fhir/WithCode" + "name": "TutorNotification", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification" }, "base": { "kind": "resource", @@ -301,160 +345,161 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with code 1`] = ` "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "gender": { + "type": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "code", - "url": "http://hl7.org/fhir/StructureDefinition/code" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" }, - "required": false, + "required": true, "excluded": false, "array": false, "binding": { "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "AdministrativeGender", - "url": "urn:fhir:binding:AdministrativeGender" + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.type_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" }, "enum": { "isOpen": false, "values": [ - "male", - "female", - "other", - "unknown" + "phone", + "fax", + "email", + "pager", + "url", + "sms", + "other" ] } - } - }, - "description": "description", - "dependencies": [ - { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "code", - "url": "http://hl7.org/fhir/StructureDefinition/code" - }, - { - "kind": "resource", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "DomainResource", - "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, - { - "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "AdministrativeGender", - "url": "urn:fhir:binding:AdministrativeGender" - } - ] - }, - { - "identifier": { - "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "AdministrativeGender", - "url": "urn:fhir:binding:AdministrativeGender" - }, - "valueset": { - "kind": "value-set", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "AdministrativeGender", - "url": "http://hl7.org/fhir/ValueSet/administrative-gender" - }, - "strength": "required", - "enum": { - "isOpen": false, - "values": [ - "male", - "female", - "other", - "unknown" - ] - }, - "dependencies": [ - { - "kind": "value-set", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "AdministrativeGender", - "url": "http://hl7.org/fhir/ValueSet/administrative-gender" - } - ] - } -]" -`; - -exports[`FHIR Schema to Type Schema (snapshot) with resource with codable concept 1`] = ` -"[ - { - "identifier": { - "kind": "resource", - "package": "mypackage", - "version": "0.0.0", - "name": "WithCodableConcept", - "url": "http://example.io/fhir/WithCodableConcept" - }, - "base": { - "kind": "resource", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "DomainResource", - "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" - }, - "fields": { - "maritalStatus": { + "status": { "type": { - "kind": "complex-type", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "CodeableConcept", - "url": "http://hl7.org/fhir/StructureDefinition/CodeableConcept" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" }, - "required": false, + "required": true, "excluded": false, "array": false, "binding": { "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "MaritalStatus", - "url": "urn:fhir:binding:MaritalStatus" + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.status_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" }, "enum": { - "isOpen": true, + "isOpen": false, "values": [ - "A", - "D", - "I", - "L", - "M", - "P", - "S", - "T", - "U", - "W", - "UNK" - ] - } + "draft", + "requested", + "received", + "accepted", + "rejected", + "ready", + "cancelled", + "in-progress", + "on-hold", + "failed", + "completed", + "entered-in-error" + ] + } + }, + "template": { + "type": { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Reference", + "url": "http://hl7.org/fhir/StructureDefinition/Reference" + }, + "required": true, + "excluded": false, + "reference": [ + { + "kind": "resource", + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotificationTemplate", + "url": "http://example.com/aidbox-sms-tutor/TutorNotificationTemplate" + } + ], + "array": false + }, + "message": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "required": false, + "excluded": false, + "array": false + }, + "sendAfter": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "dateTime", + "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + }, + "required": true, + "excluded": false, + "array": false + }, + "subject": { + "type": { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Reference", + "url": "http://hl7.org/fhir/StructureDefinition/Reference" + }, + "required": true, + "excluded": false, + "reference": [ + { + "kind": "resource", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Patient", + "url": "http://hl7.org/fhir/StructureDefinition/Patient" + } + ], + "array": false } }, - "description": "description", "dependencies": [ { - "kind": "complex-type", + "kind": "binding", + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.status_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" + }, + { + "kind": "binding", + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.type_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" + }, + { + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "CodeableConcept", - "url": "http://hl7.org/fhir/StructureDefinition/CodeableConcept" + "name": "dateTime", + "url": "http://hl7.org/fhir/StructureDefinition/dateTime" }, { "kind": "resource", @@ -464,44 +509,52 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with codable concep "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, { - "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "MaritalStatus", - "url": "urn:fhir:binding:MaritalStatus" + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "Reference", + "url": "http://hl7.org/fhir/StructureDefinition/Reference" + }, + { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" } ] }, { "identifier": { "kind": "binding", - "package": "shared", - "version": "1.0.0", - "name": "MaritalStatus", - "url": "urn:fhir:binding:MaritalStatus" + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.status_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" }, "valueset": { "kind": "value-set", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "MaritalStatus", - "url": "http://hl7.org/fhir/ValueSet/marital-status" + "name": "TaskStatus", + "url": "http://hl7.org/fhir/ValueSet/task-status" }, - "strength": "extensible", + "strength": "required", "enum": { - "isOpen": true, + "isOpen": false, "values": [ - "A", - "D", - "I", - "L", - "M", - "P", - "S", - "T", - "U", - "W", - "UNK" + "draft", + "requested", + "received", + "accepted", + "rejected", + "ready", + "cancelled", + "in-progress", + "on-hold", + "failed", + "completed", + "entered-in-error" ] }, "dependencies": [ @@ -509,105 +562,168 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with codable concep "kind": "value-set", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "MaritalStatus", - "url": "http://hl7.org/fhir/ValueSet/marital-status" + "name": "TaskStatus", + "url": "http://hl7.org/fhir/ValueSet/task-status" + } + ] + }, + { + "identifier": { + "kind": "binding", + "package": "mypackage", + "version": "0.0.0", + "name": "TutorNotification.type_binding", + "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" + }, + "valueset": { + "kind": "value-set", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "ContactPointSystem", + "url": "http://hl7.org/fhir/ValueSet/contact-point-system" + }, + "strength": "required", + "enum": { + "isOpen": false, + "values": [ + "phone", + "fax", + "email", + "pager", + "url", + "sms", + "other" + ] + }, + "dependencies": [ + { + "kind": "value-set", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "ContactPointSystem", + "url": "http://hl7.org/fhir/ValueSet/contact-point-system" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) with resource with choice 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with cardinality 1`] = ` "[ { "identifier": { - "kind": "resource", + "kind": "complex-type", "package": "mypackage", "version": "0.0.0", - "name": "WithChoice", - "url": "http://example.io/fhir/WithChoice" + "name": "Cardinality", + "url": "http://hl7.org/fhir/StructureDefinition/Cardinality" }, "base": { - "kind": "resource", + "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "DomainResource", - "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" + "name": "Element", + "url": "http://hl7.org/fhir/StructureDefinition/Element" }, "fields": { - "deceasedDateTime": { + "zero_or_one": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "dateTime", - "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" }, "required": false, "excluded": false, - "array": false, - "choiceOf": "deceased" + "array": true, + "min": 0, + "max": 1 }, - "deceasedBoolean": { + "one": { "type": { "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "boolean", - "url": "http://hl7.org/fhir/StructureDefinition/boolean" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" }, "required": false, "excluded": false, - "array": false, - "choiceOf": "deceased" + "array": true, + "min": 1, + "max": 1 }, - "deceased": { + "many": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, "required": false, "excluded": false, - "array": false, - "choices": [ - "deceasedBoolean", - "deceasedDateTime" - ] - } - }, - "description": "description", - "dependencies": [ - { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "boolean", - "url": "http://hl7.org/fhir/StructureDefinition/boolean" + "array": true, + "min": 42, + "max": 42 + }, + "one_or_many": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "required": false, + "excluded": false, + "array": true, + "min": 1 }, + "zero_or_many": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "required": false, + "excluded": false, + "array": true + } + }, + "description": "Base StructureDefinition for Coding Type: A reference to a code defined by a terminology system.", + "dependencies": [ { - "kind": "primitive-type", + "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "dateTime", - "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + "name": "Element", + "url": "http://hl7.org/fhir/StructureDefinition/Element" }, { - "kind": "resource", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "DomainResource", - "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with resource with string 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "WithNestedType", - "url": "http://example.io/fhir/WithNestedType" + "name": "WithPrimitiveString", + "url": "http://example.io/fhir/WithPrimitiveString" }, "base": { "kind": "resource", @@ -617,60 +733,21 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 1` "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "link": { + "someString": { "type": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "link", - "url": "http://example.io/fhir/WithNestedType#link" - }, - "array": true, - "required": false, - "excluded": false - } - }, - "nested": [ - { - "identifier": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "link", - "url": "http://example.io/fhir/WithNestedType#link" - }, - "base": { - "kind": "complex-type", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "BackboneElement", - "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" }, - "fields": { - "someString": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" - }, - "required": true, - "excluded": false, - "array": false - } - } + "required": true, + "excluded": false, + "array": false } - ], - "description": "some description", + }, + "description": "description", "dependencies": [ - { - "kind": "complex-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "BackboneElement", - "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" - }, { "kind": "resource", "package": "hl7.fhir.r4.core", @@ -690,15 +767,15 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 1` ]" `; -exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 2 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with resource with code 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "Root", - "url": "http://example.io/fhir/Root" + "name": "WithCode", + "url": "http://example.io/fhir/WithCode" }, "base": { "kind": "resource", @@ -708,89 +785,43 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 2 "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "field": { + "gender": { "type": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "field", - "url": "http://example.io/fhir/Root#field" - }, - "array": true, - "required": false, - "excluded": false - } - }, - "nested": [ - { - "identifier": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "field", - "url": "http://example.io/fhir/Root#field" - }, - "base": { - "kind": "complex-type", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "BackboneElement", - "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" - }, - "fields": { - "subfield": { - "type": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "field.subfield", - "url": "http://example.io/fhir/Root#field.subfield" - }, - "array": true, - "required": false, - "excluded": false - } - } - }, - { - "identifier": { - "kind": "nested", - "package": "mypackage", - "version": "0.0.0", - "name": "field.subfield", - "url": "http://example.io/fhir/Root#field.subfield" + "name": "code", + "url": "http://hl7.org/fhir/StructureDefinition/code" }, - "base": { - "kind": "complex-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "BackboneElement", - "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + "required": false, + "excluded": false, + "array": false, + "binding": { + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "AdministrativeGender", + "url": "urn:fhir:binding:AdministrativeGender" }, - "fields": { - "subsubfield": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" - }, - "required": false, - "excluded": false, - "array": false - } + "enum": { + "isOpen": false, + "values": [ + "male", + "female", + "other", + "unknown" + ] } } - ], - "description": "some description", + }, + "description": "description", "dependencies": [ { - "kind": "complex-type", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "BackboneElement", - "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + "name": "code", + "url": "http://hl7.org/fhir/StructureDefinition/code" }, { "kind": "resource", @@ -800,178 +831,185 @@ exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 2 "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, { - "kind": "primitive-type", + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "AdministrativeGender", + "url": "urn:fhir:binding:AdministrativeGender" + } + ] + }, + { + "identifier": { + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "AdministrativeGender", + "url": "urn:fhir:binding:AdministrativeGender" + }, + "valueset": { + "kind": "value-set", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "AdministrativeGender", + "url": "http://hl7.org/fhir/ValueSet/administrative-gender" + }, + "strength": "required", + "enum": { + "isOpen": false, + "values": [ + "male", + "female", + "other", + "unknown" + ] + }, + "dependencies": [ + { + "kind": "value-set", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "AdministrativeGender", + "url": "http://hl7.org/fhir/ValueSet/administrative-gender" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) Real world examples coding primitive type 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with resource with codable concept 1`] = ` "[ { "identifier": { - "kind": "complex-type", + "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "Coding", - "url": "http://hl7.org/fhir/StructureDefinition/Coding" + "name": "WithCodableConcept", + "url": "http://example.io/fhir/WithCodableConcept" }, "base": { - "kind": "complex-type", + "kind": "resource", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Element", - "url": "http://hl7.org/fhir/StructureDefinition/Element" + "name": "DomainResource", + "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "system": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "uri", - "url": "http://hl7.org/fhir/StructureDefinition/uri" - }, - "required": false, - "excluded": false, - "array": false - }, - "version": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" - }, - "required": false, - "excluded": false, - "array": false - }, - "code": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "code", - "url": "http://hl7.org/fhir/StructureDefinition/code" - }, - "required": false, - "excluded": false, - "array": false - }, - "display": { + "maritalStatus": { "type": { - "kind": "primitive-type", + "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "CodeableConcept", + "url": "http://hl7.org/fhir/StructureDefinition/CodeableConcept" }, "required": false, "excluded": false, - "array": false - }, - "userSelected": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "boolean", - "url": "http://hl7.org/fhir/StructureDefinition/boolean" + "array": false, + "binding": { + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "MaritalStatus", + "url": "urn:fhir:binding:MaritalStatus" }, - "required": false, - "excluded": false, - "array": false + "enum": { + "isOpen": true, + "values": [ + "A", + "D", + "I", + "L", + "M", + "P", + "S", + "T", + "U", + "W", + "UNK" + ] + } } }, - "description": "Base StructureDefinition for Coding Type: A reference to a code defined by a terminology system.", + "description": "description", "dependencies": [ - { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "boolean", - "url": "http://hl7.org/fhir/StructureDefinition/boolean" - }, - { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "code", - "url": "http://hl7.org/fhir/StructureDefinition/code" - }, { "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Element", - "url": "http://hl7.org/fhir/StructureDefinition/Element" + "name": "CodeableConcept", + "url": "http://hl7.org/fhir/StructureDefinition/CodeableConcept" }, { - "kind": "primitive-type", + "kind": "resource", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "DomainResource", + "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "uri", - "url": "http://hl7.org/fhir/StructureDefinition/uri" + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "MaritalStatus", + "url": "urn:fhir:binding:MaritalStatus" } ] - } -]" -`; - -exports[`FHIR Schema to Type Schema (snapshot) Real world examples string primitive type 1`] = ` -"[ + }, { "identifier": { - "kind": "primitive-type", - "package": "mypackage", - "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "kind": "binding", + "package": "shared", + "version": "1.0.0", + "name": "MaritalStatus", + "url": "urn:fhir:binding:MaritalStatus" }, - "description": "Base StructureDefinition for string Type: A sequence of Unicode characters", - "base": { - "kind": "complex-type", + "valueset": { + "kind": "value-set", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Element", - "url": "http://hl7.org/fhir/StructureDefinition/Element" + "name": "MaritalStatus", + "url": "http://hl7.org/fhir/ValueSet/marital-status" + }, + "strength": "extensible", + "enum": { + "isOpen": true, + "values": [ + "A", + "D", + "I", + "L", + "M", + "P", + "S", + "T", + "U", + "W", + "UNK" + ] }, "dependencies": [ { - "kind": "complex-type", + "kind": "value-set", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Element", - "url": "http://hl7.org/fhir/StructureDefinition/Element" + "name": "MaritalStatus", + "url": "http://hl7.org/fhir/ValueSet/marital-status" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotificationTemplate 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with resource with choice 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "TutorNotificationTemplate", - "url": "http://example.com/aidbox-sms-tutor/TutorNotificationTemplate" + "name": "WithChoice", + "url": "http://example.io/fhir/WithChoice" }, "base": { "kind": "resource", @@ -981,48 +1019,79 @@ exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "template": { + "deceasedDateTime": { "type": { "kind": "primitive-type", - "package": "mypackage", - "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "dateTime", + "url": "http://hl7.org/fhir/StructureDefinition/dateTime" }, - "required": true, + "required": false, "excluded": false, - "array": false + "array": false, + "choiceOf": "deceased" + }, + "deceasedBoolean": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "boolean", + "url": "http://hl7.org/fhir/StructureDefinition/boolean" + }, + "required": false, + "excluded": false, + "array": false, + "choiceOf": "deceased" + }, + "deceased": { + "required": false, + "excluded": false, + "array": false, + "choices": [ + "deceasedBoolean", + "deceasedDateTime" + ] } }, + "description": "description", "dependencies": [ { - "kind": "resource", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "DomainResource", - "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" + "name": "boolean", + "url": "http://hl7.org/fhir/StructureDefinition/boolean" }, { "kind": "primitive-type", - "package": "mypackage", - "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "dateTime", + "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + }, + { + "kind": "resource", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "DomainResource", + "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" } ] } ]" `; -exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification 1`] = ` +exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 1`] = ` "[ { "identifier": { "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "TutorNotification", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification" + "name": "WithNestedType", + "url": "http://example.io/fhir/WithNestedType" }, "base": { "kind": "resource", @@ -1032,161 +1101,59 @@ exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, "fields": { - "type": { + "link": { "type": { - "kind": "primitive-type", + "kind": "nested", "package": "mypackage", "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" + "name": "link", + "url": "http://example.io/fhir/WithNestedType#link" }, - "required": true, - "excluded": false, - "array": false, - "binding": { - "kind": "binding", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotification.type_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" - }, - "enum": { - "isOpen": false, - "values": [ - "phone", - "fax", - "email", - "pager", - "url", - "sms", - "other" - ] - } - }, - "status": { - "type": { - "kind": "primitive-type", - "package": "mypackage", - "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" - }, - "required": true, - "excluded": false, - "array": false, - "binding": { - "kind": "binding", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotification.status_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" - }, - "enum": { - "isOpen": false, - "values": [ - "draft", - "requested", - "received", - "accepted", - "rejected", - "ready", - "cancelled", - "in-progress", - "on-hold", - "failed", - "completed", - "entered-in-error" - ] - } - }, - "template": { - "type": { - "kind": "complex-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "Reference", - "url": "http://hl7.org/fhir/StructureDefinition/Reference" - }, - "required": true, - "excluded": false, - "reference": [ - { - "kind": "resource", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotificationTemplate", - "url": "http://example.com/aidbox-sms-tutor/TutorNotificationTemplate" - } - ], - "array": false - }, - "message": { - "type": { - "kind": "primitive-type", + "array": true, + "required": false, + "excluded": false + } + }, + "nested": [ + { + "identifier": { + "kind": "nested", "package": "mypackage", "version": "0.0.0", - "name": "string", - "url": "http://hl7.org/fhir/StructureDefinition/string" - }, - "required": false, - "excluded": false, - "array": false - }, - "sendAfter": { - "type": { - "kind": "primitive-type", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "dateTime", - "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + "name": "link", + "url": "http://example.io/fhir/WithNestedType#link" }, - "required": true, - "excluded": false, - "array": false - }, - "subject": { - "type": { + "base": { "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Reference", - "url": "http://hl7.org/fhir/StructureDefinition/Reference" + "name": "BackboneElement", + "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" }, - "required": true, - "excluded": false, - "reference": [ - { - "kind": "resource", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "Patient", - "url": "http://hl7.org/fhir/StructureDefinition/Patient" + "fields": { + "someString": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "required": true, + "excluded": false, + "array": false } - ], - "array": false + } } - }, + ], + "description": "some description", "dependencies": [ { - "kind": "binding", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotification.status_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" - }, - { - "kind": "binding", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotification.type_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" - }, - { - "kind": "primitive-type", + "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "dateTime", - "url": "http://hl7.org/fhir/StructureDefinition/dateTime" + "name": "BackboneElement", + "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" }, { "kind": "resource", @@ -1196,99 +1163,132 @@ exports[`FHIR Schema to Type Schema (snapshot) Custom resource TutorNotification "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, { - "kind": "complex-type", + "kind": "primitive-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "Reference", - "url": "http://hl7.org/fhir/StructureDefinition/Reference" - }, - { - "kind": "primitive-type", - "package": "mypackage", - "version": "0.0.0", "name": "string", "url": "http://hl7.org/fhir/StructureDefinition/string" } ] - }, + } +]" +`; + +exports[`FHIR Schema to Type Schema (snapshot) with resource with nested type 2 1`] = ` +"[ { "identifier": { - "kind": "binding", + "kind": "resource", "package": "mypackage", "version": "0.0.0", - "name": "TutorNotification.status_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#status_binding" + "name": "Root", + "url": "http://example.io/fhir/Root" }, - "valueset": { - "kind": "value-set", + "base": { + "kind": "resource", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "TaskStatus", - "url": "http://hl7.org/fhir/ValueSet/task-status" + "name": "DomainResource", + "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" }, - "strength": "required", - "enum": { - "isOpen": false, - "values": [ - "draft", - "requested", - "received", - "accepted", - "rejected", - "ready", - "cancelled", - "in-progress", - "on-hold", - "failed", - "completed", - "entered-in-error" - ] + "fields": { + "field": { + "type": { + "kind": "nested", + "package": "mypackage", + "version": "0.0.0", + "name": "field", + "url": "http://example.io/fhir/Root#field" + }, + "array": true, + "required": false, + "excluded": false + } }, + "nested": [ + { + "identifier": { + "kind": "nested", + "package": "mypackage", + "version": "0.0.0", + "name": "field", + "url": "http://example.io/fhir/Root#field" + }, + "base": { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "BackboneElement", + "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + }, + "fields": { + "subfield": { + "type": { + "kind": "nested", + "package": "mypackage", + "version": "0.0.0", + "name": "field.subfield", + "url": "http://example.io/fhir/Root#field.subfield" + }, + "array": true, + "required": false, + "excluded": false + } + } + }, + { + "identifier": { + "kind": "nested", + "package": "mypackage", + "version": "0.0.0", + "name": "field.subfield", + "url": "http://example.io/fhir/Root#field.subfield" + }, + "base": { + "kind": "complex-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "BackboneElement", + "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + }, + "fields": { + "subsubfield": { + "type": { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" + }, + "required": false, + "excluded": false, + "array": false + } + } + } + ], + "description": "some description", "dependencies": [ { - "kind": "value-set", + "kind": "complex-type", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "TaskStatus", - "url": "http://hl7.org/fhir/ValueSet/task-status" - } - ] - }, - { - "identifier": { - "kind": "binding", - "package": "mypackage", - "version": "0.0.0", - "name": "TutorNotification.type_binding", - "url": "http://example.com/aidbox-sms-tutor/TutorNotification#type_binding" - }, - "valueset": { - "kind": "value-set", - "package": "hl7.fhir.r4.core", - "version": "4.0.1", - "name": "ContactPointSystem", - "url": "http://hl7.org/fhir/ValueSet/contact-point-system" - }, - "strength": "required", - "enum": { - "isOpen": false, - "values": [ - "phone", - "fax", - "email", - "pager", - "url", - "sms", - "other" - ] - }, - "dependencies": [ + "name": "BackboneElement", + "url": "http://hl7.org/fhir/StructureDefinition/BackboneElement" + }, { - "kind": "value-set", + "kind": "resource", "package": "hl7.fhir.r4.core", "version": "4.0.1", - "name": "ContactPointSystem", - "url": "http://hl7.org/fhir/ValueSet/contact-point-system" + "name": "DomainResource", + "url": "http://hl7.org/fhir/StructureDefinition/DomainResource" + }, + { + "kind": "primitive-type", + "package": "hl7.fhir.r4.core", + "version": "4.0.1", + "name": "string", + "url": "http://hl7.org/fhir/StructureDefinition/string" } ] }