@@ -152,47 +152,53 @@ export function transformFhirSchema(register: Register, fhirSchema: RichFHIRSche
152152
153153 const fields = mkFields ( register , fhirSchema , [ ] , fhirSchema . elements , logger ) ;
154154 const nested = mkNestedTypes ( register , fhirSchema , logger ) ;
155+ const bindingSchemas = collectBindingSchemas ( register , fhirSchema , logger ) ;
155156
156- let typeSchema : TypeSchema ;
157157 if ( fhirSchema . derivation === "constraint" ) {
158158 const identifier = mkIdentifier ( fhirSchema ) ;
159159 if ( ! base ) throw new Error ( `Profile ${ fhirSchema . url } must have a base type` ) ;
160160 const extensions = extractProfileExtensions ( register , fhirSchema , logger ) ;
161161 const extensionDeps = extensions ?. flatMap ( extractExtensionDeps ) ;
162162 const rawDeps = extractProfileDependencies ( identifier , base , fields , nested ) ;
163- typeSchema = {
164- identifier,
165- base,
166- fields,
167- nested,
168- description : fhirSchema . description ,
169- dependencies : concatIdentifiers ( rawDeps , extensionDeps ) ,
170- extensions,
171- } ;
172- } else if ( fhirSchema . kind === "primitive-type" ) {
163+ return [
164+ {
165+ identifier,
166+ base,
167+ fields,
168+ nested,
169+ description : fhirSchema . description ,
170+ dependencies : concatIdentifiers ( rawDeps , extensionDeps ) ,
171+ extensions,
172+ } ,
173+ ...bindingSchemas ,
174+ ] ;
175+ }
176+
177+ if ( fhirSchema . kind === "primitive-type" ) {
173178 const identifier = mkIdentifier ( fhirSchema ) ;
174- const rawDeps = extractDependencies ( identifier , base , fields , nested ) ;
175179 assert ( base , `Primitive type ${ fhirSchema . url } must have a base type` ) ;
176- typeSchema = {
177- identifier,
178- description : fhirSchema . description ,
179- base,
180- dependencies : rawDeps ,
181- } ;
182- } else {
183- const identifier = mkIdentifier ( fhirSchema ) ;
184- const rawDeps = extractDependencies ( identifier , base , fields , nested ) ;
185- typeSchema = {
180+ return [
181+ {
182+ identifier,
183+ description : fhirSchema . description ,
184+ base,
185+ dependencies : extractDependencies ( identifier , base , fields , nested ) ,
186+ } ,
187+ ...bindingSchemas ,
188+ ] ;
189+ }
190+
191+ const identifier = mkIdentifier ( fhirSchema ) ;
192+ return [
193+ {
186194 identifier,
187195 base,
188196 fields,
189197 nested,
190198 description : fhirSchema . description ,
191- dependencies : rawDeps ,
192- typeFamily : undefined , // NOTE: should be populateTypeFamily later.
193- } ;
194- }
195-
196- const bindingSchemas = collectBindingSchemas ( register , fhirSchema , logger ) ;
197- return [ typeSchema , ...bindingSchemas ] ;
199+ dependencies : extractDependencies ( identifier , base , fields , nested ) ,
200+ typeFamily : undefined ,
201+ } ,
202+ ...bindingSchemas ,
203+ ] ;
198204}
0 commit comments