Releases: luisfabib/fhircraft
v0.8.3
v0.8.2
Fixed
- Fixed construction of resources where resolution could miss inherited type information or slicing metadata when an intermediate definition had no complete snapshot (#347)
- Fixed missing propagation of constrained children (including extension slicing use cases) for type-choice values in generated models (#348)
- Fixed model assembly path for profiles that constrain children on typed type-choice branches (#348)
- Fixed the FHIRPath
getValue()fucntion to correctly unwrap thevalueattribute from FHIR primitive objects before returning, ensuring the function returns the actual primitive value rather than the wrapper object (#349)
v0.8.1
Fixed
- Ensured that elements (e.g.
Extension.url) defined with FHIRPath-typed elements (which should not have extensions or ids) are not built using the new primitive classes (that can hold extensions and ids) but rather using Python native types (#342) - Ensured generated FHIR resource models use lowercase primitive type aliases prefixed with a
fhirmodule alias (e.g.fhir.string,fhir.integer) instead of importing and referencing the primitive classes directly (e.g.String,Integer) (#343) - Ensured primitive type-alias coercion correctly handles primitive model instances (including compatible parent primitive instances), so alias validation behaves consistently for both native Python inputs and class-based primitive values. (#344, fixed #341)
- Added a
pyright: reportIncompatibleVariableOverride=falsedirective at the top of the generated source code to disable incompatible variable override warnings from Pyright that are commonly raised in v0.8.0 due to narrowing of type annotations in FHIR model elements (a limitation of Python's type system, but compatible with Pydantic) (#345)
v0.8.0
Added
- Introduced class-based FHIR primitive type implementations (
String,Boolean,Integer,Decimal,Date,DateTime,Instant,Time,Code,Uri,Url,Canonical,Base64Binary,Oid,Id,Markdown,Uuid,Xhtml,PositiveInt,UnsignedInt, andInteger64for R5) as dedicated modules under versionedprimitive/packages for R4, R4B, and R5. - Added a new base model
FHIRPrimitiveModelto support operations and subclasssing of primitive classes. - Added support for serializing and deserializing FHIR primitive placeholder fields (e.g.
_fieldNameextension containers) in the resource base model. - Added
DefinitionIndexexclusion of slice child nodes from path queries to avoid false positives in element lookups.
Changed
- Replaced
TypeAliasType-based primitive definitions inTypeRegistryand the olddatatypes/primitives.pymodule with the new class-based primitive implementations (#339) - Updated all built-in models to use the new primitive definitions and removed all old placeholder elements (
{fieldname}_ext) throughout (#339) - Updated the model factory to no longer create primitive extension placeholder elements and to resolve the new primitive types (#339)
- Updated the FHIRPath engine (string functions, math operations, type conversions, equality, boolean logic, and literals) to operate correctly on
FHIRPrimitivemodel instances rather than raw Python scalars (#339) - Updated the FHIR mapper engine (transforms, parser, rules, and source/target handlers) to consume the new primitive type classes (#339)
- Updated type utility functions to use the new primitive classes throughout (#339)
- Updated the documentation to reflect the class-based primitive model and shadow-field serialization behaviour (#339)
Fixed
- Fixed
SnapshotResolverto remove an unnecessary complex-type guard, allowing primitive type nodes to be constructed during snapshot resolution, fixing construction of resources with primitive-type extensions. (#339, fixes #336)
Removed
- Removed the
fhircraft.fhir.resources.datatypes.primitivesmodule (replaced by per-version, per-type class modules) (#339)
v0.7.1
Added
- Added
skip_invalidparameter toStructureDefinitionRegistry.download_packageandFHIRModelFactory.register_packageto gracefully skipStructureDefinitionresources that fail validation, issuing a warning instead of raising an error (#327) - Added
include_dependenciesparameter toStructureDefinitionRegistry.download_packageandFHIRModelFactory.register_packageto control whether package dependencies are automatically downloaded and registered alongside the requested package (#327)
Fixed
- Fixed
toDate()/convertsToDate(),toDateTime()/convertsToDateTime(), andtoTime()/convertsToTime()to supportdate,datetime,time,System.Date,System.DateTime, andSystem.Timetypes rather than returning empty lists (#320, fixes #328) - Updated the regular expression in
toDecimalandconvertsToDecimalto correctly recognize numbers with a leading plus sign, enabling support for strings like "+14" and "+14.5" in conversion functions (#321, fixes #309) - Ensured that the FHIRPath
now()function always returns a time-zone awareDateTime(fixed to the UTC offset) as required by the FHIRPath specification (#322, fixes #312) - Fixed the propagation of any UTC offset from timezone-aware Python
datetime/timeobjects into the FHIRPathDateTime.hour_shift/DateTime.minute_shiftfields, preserving timezone information through serialization and comparison (#322) - Fixed the FHIRPath
DateTime/Timeliterals string parsing to ensure theZsuffix (UTC shorthand) is parsedashour_shift = 0/minute_shift = 0(#322)
- Fixed spelling errors in the FHIRPath lexer calendar duration tokens list by replacing "miliseond" and "miliseconds" with the correct "millisecond" and "milliseconds" (#323, fixes #313)
- Introduced
TypePrecisionErrorto signal that a comparison cannot be performed between FHIRPath values with different levels of precision, allowing equality operators to propagate an empty collection per the FHIRPath spec (#324) - Refactored FHIRPath
TimeandDateTimeliterals to store seconds asfloat(combining seconds and milliseconds) instead of separatesecondandmillisecondinteger fields, improving sub-second precision handling (#324) - Fixed
to_time()andto_datetime()conversion methods to propagate timezone offset (hour_shift/minute_shift) into the returned Pythontime/datetimeobjects. (#324) - Fixed
TimeandDateTimeliterals string parsers to accept 1–3 digit millisecond values and correctly combine them with the seconds field as a float (#324) - Fixed
NotEquals(!=) operator to return an empty collection when the operands are empty or of incompatible types, instead of incorrectly inverting a non-boolean result (#324, fixes #305) - Fixed
Equivalent(~) string comparison to normalize internal whitespace (collapsing runs of whitespace to a single space) in addition to trimming and lowercasing. (#324, fixes #311) - Fixed
Equals(=) andEquivalent(~) to return an empty collection when aTypePrecisionErroris raised during comparison of values with differing precision levels (#324) - Refactored
All.evaluate()to use.single()for criteria evaluation so
that single-item results are correctly unwrapped (#324) - Update
validate_FHIR_element_pattern()to useis_dict_subset(_pattern, _element)instead ofmerge_dicts(_element, _pattern) == _elementto ensure that pattern containment is properly executed (#325, fixes #317) - Ensured that extension placeholder fields for primitive type-choice variants (e.g.
value[x]) are now named after the concrete typed field (valueString_ext,valueBoolean_ext, …) rather than the polymorphic base name (value_ext) (#330, fixes #329) - Fixed factory to preserve base-type cardinality through differential merging such that profiled models no longer silently change array-fields into singleton ones (#337, fixes #331)
- Prevented
SlicedFieldBuilderfrom emitting a redundant serialization alias when the field name was not renamed (#337, fixes #332) - Fixed backbone field builder to short-circuit
build()and return the original specific backbone type directly when the differential has no children, instead of generating an empty subclass (#337, fixes #333) - Fixed
SnapshotResolverto correctly resolve all base elements when an intermediate profile in thebaseDefinitionchain has no snapshot (#337, fixes #334) - Ensured that extensions on complex type fields are correctly accounted for and generated by the model factory (#337, fixes #335)
- Implemented handling of prohibited fields (
0..0) to be set asNone-typed fields in the builder (#337) - Updated
ElementNode.documentationretrieval to skip non-alphanumeric-only content in theshort,definitionandcomment(#337) - Fixed
max_cardinalitytype annotation to allowNonein generated source code (#337) - Ensured that multiple type codes on an element definition are supported in the factory resolver (#337)
v0.7.0
Added
-
Implemented a new modular factory architecture (#296)
- Added a new
factorypackage with dedicated sub-modules:element_node,index,resolver,context,assembler,core, andexceptionsreplacing the previous monolithicfactory.py. - Added Specialised field builders
BaseFieldBuilder,SimpleFieldBuilder,BackboneFieldBuilder,SlicedFieldBuilder, andTypeChoiceFieldBuilder, each responsible for compiling field information for a specific class of FHIR element. - Implemented a new
StructureDefinitionRegistrydedicated registry for loading, storing, and resolving FHIRStructureDefinitionresources, including dependency resolution via FHIR packages. - Cleaned and streamlined the public API for
FHIRModelFactoryfor long-term stability- Renamed
construct_resource_modeltobuild - Renamed
load_packagetoregister_package - Renamed
add_structure_definitiontoregister - Renamed
clear_cachetoreset_cache - Added new methods
get_registered_definition,has_registered_definition,unregister,list_registered_definitions,rebuild,is_built,list_built,evict
- Renamed
- Added a new
-
Implemented a
FHIRTypeRegistrycentralised registry for resolving FHIR type names and canonical URLs across all FHIR releases (R4, R4B, R5) (#296) -
Added support for to correctly handle slicing rules, particularly
closedslicing (#296) -
Introduced FHIRPath expression parse caching so that identical expressions (common for FHIR invariant constraints) are compiled by PLY only once per process lifetime rather than on every constraint evaluation significantly reducing computation times (#299)
Added aStructureMapRegistrythat operates offline by default. StructureMaps must be registered before execution; the engine raises a clear error if an imported URL is not found. An optional internet fallback can be enabled to resolve canonical URLs at runtime (#300) -
Added support for the
importclause: the engine now resolves canonical URLs declared in a StructureMap'simportsection, making groups defined in those maps available during execution. Wildcard URLs (e.g.http://example.org/maps/*) are supported and matched against all registered maps (#300, fixes #37) -
Added support for the
extendsclause, including: multi-level inheritance chains and cross-map inheritance (#300, fixes #33) -
Added a specific FHIR Mapping Language parser error message for the common scenario when a rule was not closed with a semicolon, providing a clear hint (#302)
-
Added support the FHIRPath
Systemtype namespace (#303)
Changed
- Consolidated the FHIR type utilities; all type lookups now go through a single
get_fhir_typefunction backed byFHIRTypeRegistry(#296) - Set the
ElementDefinition.idfield set as aStringprimitive rather than anIdprimitive to avoid the inconsistency between theIdprimitive regex constraints and the functional meaning for theElementDefinition(namely the use of colon:) (#296) - The resource factory no longer injects
meta.profilewith default values into constructed models (#296) -
- Renamed several of the configuration parameters for clarity and precision (#298)
- Renamed
disable_warningstodisable_validation_warnings - Renamed
disable_warning_severitytodisable_fhir_warnings - Renamed
disable_errorstodisable_fhir_errors - Renamed
disabled_constraintstodisabled_fhir_constraints
- Renamed
- Renamed several of the configuration parameters for clarity and precision (#298)
- Renamed
with_config()context manager tooverride_config()for clarity and consistency (#298) - Froze
FhircraftConfigto raise an error upon direct attribute mutation (#298) - Extended all constraint, pattern, fixed-value, type-choice, and cardinality validators to respect configuration
mode = 'skip'by returning immediately (#299) - Extended all assert-based validators (pattern, fixed-value, type-choice, cardinality) to respect configuration
mode = 'lenient'by issuing warnings instead of raising errors, consistent with how FHIRPath constraint validators already behaved (#299) - Switched resource context computation in FHIR models and lists to be lazy, deferring work until the context is actually accessed rather than computing it at construction time (#299)
- Renamed the
repositoryattribute onFHIRMappingEnginetostructure_definition_registryto better reflect its purpose and distinguish it from the newstructure_map_registry(#300) - Introduced
FHIRStructureMapperas the new public interface for the FHIR Mapping Language. The oldFHIRMapperis replaced byFHIRStructureMapper(#318)
Fixed
- Enhanced the factory builder type resolver to detect elements with primitive FHIRPath-types and, consequently, to not generate extension placeholder elements (
*_ext) and to use thestructuredefiniton-fhir-typeto determine the proper FHIR-native primitive type to use. (#296, fixes #290) - Removed primitive extension placeholder elements from built-in model fields with FHIRPath types (
Element.id_ext,Extension.url_ext,Xhtml.value_ext, and all downstream models) and updated their type ofExtension.url(StringtoUri) and ofElement.id(StringtoId) across all releases (R4, R4B , R5) (#296, fixes #288) - Ensured that sliced field type unions and their referenced slice models use concrete base element types (e.g.
ObservationComponent) rather than base types (e.g.BackboneElement) when constructing sliced elements in differential mode (#296, fixes #292 and #293) - Fixed sliced field construction to correctly inherit slices already defined on the parent model's field when constructing sliced in differential mode (#296, fixes #294)
- Fixed multiple issues related to differential resolution including (#296)
- Ensured that intermediate-node path lookups not defined in the differential are accounted.
- Fixed the resolution so that a differential is always resolved agains a snapshot and not against a partially resolved differential.
- Enabled support for recursive resolution against a sequence of base definitions.
- Fixed
Dosage.doseAndRate(R4, R4B, R5) polymorphic fields (doseQuantity,rateQuantity) to now correctly referenceQuantityinstead ofSimpleQuantityin the validator and correctly validate values (#296) - Fixed the
validate_slicing_cardinalitiesvalidator to correctly handleNonevalues in themaxcardinality (#296) - Updated the slice cardinality validator to only validate cardinalities when at least one slice instance is present, consistent with how element cardinalities are handled and avoiding false violations when a discriminator cannot be evaluated (e.g. value-set binding slices) (#296, fixes #295)
- Replaced
**kwargsinconfigure()andoverride_config()with explicit keyword-only typed parameters; unrecognized arguments now raiseTypeErrorat call time (#298, fixes #208) - Fixed parser to allow declarations in any order within FHIR Mapping Language scripts, rather than requiring a strict fixed sequence. (#302, fixes #301).
- Updated the parser to raise
FhirMappingLanguageParserErrorwhen themapstatement appears more than once in a single script (#302)
Removed
- Replaced the monolithic
factory.py(2,200+ lines) by the newfactory/package (#296) - Replaced the
StructureDefinitionRepositorymodule and its associated tests, now superseded byStructureDefinitionRegistry(#296) - Removed
ValidationConfigdataclass and merged its fields directly intoFhircraftConfig(#298)
v.0.6.5
Added
- Added an "AI Tools and Human Attribution" info box to the contributing guidelines, outlining acceptable and unacceptable types of AI-assisted contributions, and emphasizing the requirement for human review and responsibility (286)
- Implemented a manifest-based FHIR resource
StructureDefinitionlookup system for factory model construction based on canonical URL and name for performance and stability (281)
Changed
- Splited the
definitions/R{x}/profiles-resources.jsonanddefinitions/R{x}/profiles-types.jsonfiles into individual files containing just the bundledStructureDefinitionresources, largely decreasing the overall package size (281)
Fixed
- Added support for the logic that allows correctly creating models for slices of primitive types with extension placeholders, improving compatibility with FHIR extension patterns (#276)
- Fixed errors in factory methods when trying to load structure definitions of complex-type resources (#281)
- Fixed the differential element merging to recursively merge parent elements in the element path hierarchy. This ensures all intervening elements are created and properly merged with base definitions (#278, fixes #279)
- Fixed an issue with the differential merging to ensure that it succeeds even if the base definition has a different base name as the derived resource (#278)
- Ensured that when constructing differential mode profiles, specialized BackboneElement subclasses from the base model are used as bases instead of generic BackboneElement, allowing proper inheritance of backbone element structure (#283, fixes #277)
- Prevented identical inherited properties from being in generated source code of derived classes, while still generating properties that are new or have different implementations (#285)
v0.6.4
Fixed
- Ensured that profiled complex types with pattern or fixed values result in the correct default type when set (#269, fixes #111)
- Sanitized StructureDefinition.name values to ensure valid Python class identifiers (#269, fixes #264)
- Fixed cardinality resolution to fall back to base model when not resolved in structure definition (#269)
- Fixed the construction of slice models by passing the correct base class for constructing its element fields (#269)
- Changed the representation of fixed-value constraints from
EnumandLiteralto proper Pydantic field validators to ensure correct functionality even for complex values (#269, fixes #263) - Enabled polymorphic deserialization for profile models to accept instances of their parent classes, matching the behavior of dictionary deserialization. Profile fields now properly validate and adopt parent class instances while preserving all data (#270, fixes #262)
- Ensured FHIR Pydantic fields are always nullable independently of default value (#269)
- Updated the model source code generation logic and template (#272, #271)
- Removed hardcoded import statements in favor of dynamically generated imports, ensuring that only the required modules and objects are imported for each generated resource (#272, fixes #261)
- Removed the
model_rebuild()calls to avoid unnecessary model rebuilds (#271, fixes #261) - Avoided setting field descriptions when explicitly set as
Noneor empty strings (#269)
- Prevented the resource factory of creating empty slice models if there are no fields and no validators specified for the slice (#273, fixes #265)
v0.6.3
Fixed
- Improve code generator to reduce boilerplate and repetitive code in auto-generated model definitions source code (#256)
- Updated the code generator to serialize and include non-built-in bases in generated code, enabling proper handling of custom base classes
- Fixed the factory method for differential elements resolution to ensure properties such as constraints are not reintroduced if not specified by the differential definition
- Fixed the code generator to also check in ancestor bases of the requested models for inherited validators
- Prevented unnecessary class variable definitions from being inherited from parent classes to avoid duplicate
- Resolve bug in factory when dealing with differentials that slice an element within a complex or backbone type. When profiling
Observation.code.coding:slice, the slice cannot be resolved against the base becauseObservation.code.codingis implicitly derived fromObservation.code's type rather than explicitly defined in the snapshot. This causes the sliced element to lose type information and be omitted from code generation (#257, fixes #255) - Ensured that when merging the differential element definitions, if the sliced element's ID is present in the base snapshot, then it is resolved against it with fallback to resolution against the path (#257)
- Pattern and fixed-value constraints on slices are now enforced. When a slice definition includes pattern values such as
patternCodeableConcept, the generated model will validate slice instances against the specified pattern and include appropriate default values. (#259, fixes #258) - Limited polymorphic deserialization to abstract FHIR resource classes (
_abstract=True) to avoid pollution of deserialization of other classes after creating new resource models (#258)
v0.6.2
Added
- Added support to the FHIRPath
resolve()function for resolution of internal references when the%resourceenvironment variable is available (#252) - Added support for implicit FHIRPath evaluation context to the
evaluatetransform during mapping (#246, fixes #39 and #217) - Added support for implicit type casting to the
casttransform during mapping (#246, fixes #38) - Added support for implicit system detection to the
cptransform during mapping (#246, fixes #40)
Changed
- Updated the FHIR Mapping Language parser to no longer strip quotes from FHIRPath expressions, ensuring that string FHIRPaths within the mappings (e.g. constants) retain their quotes during parsing (#251, fixes #213 and #216)
- Removed support to the FHIRPath
resolve()function for attempting resolution of URL references using the reference as absolute URL for security reasons, now warning instead (#252)
Fixed
- Fixed resolution of FHIRPaths within source context scopes for the
whereandcheckstatements (#246, fixes #215) - Fixed documentation mapping examples not returning the correct results (#246, fixes #220)
- Fixed transforms to allow variables to be passed as arguments (#246, fixes #218)
- Expanded the FHIR Mapper parser grammar to allow reserved words (e.g.
group,import,source, etc.) to be used as identifiers both in mapping rules and its FHIRPath expressions (#250, fixes #214) - Modified the FHIRPath
Literalclass so that the string represenations of date, datetime, and time values are represented with an@prefix (e.g.,@2014-01-01), aligning with FHIRPath conventions (#249, fixes #247) - Fixed the string representation of FHIRPath index invocations (e.g.,
a[2]), which was previously represented with a dot (#249, fixes #248) - Ensured that
resource_urlcannot be evaluated toNonewithin the FHIRPathresolve()function, which was leading toAttributeError(#252, fixes #240) - Fixed XML serialization to wrap contained/nested resources in their respective resource type tags during XML serialization (#253, fixes #219)