skalarsystems / fhirzeug

A Python FHIR specification parser and class generator
Apache License 2.0
17 stars 1 forks source link

GitHub license CI Codecov

FHIR Zeug - A FHIR Spec Compiler

(forked from https://github.com/smart-on-fhir/fhir-parser)

Why a fork?

The original project seemed to abandoned and its structure was not quite pythonic. The work which has been done was great and we wanted to continue development here. We wanted to have a more self-contained project, which already has the definitions for the languages on board.

Our main support goals are Python (3.8) with pydantic and FHIR R4.

This work is licensed under the APACHE license. FHIR® is the registered trademark of HL7 and is used with the permission of HL7.

Usage

The fhir_zeug.cli module is the central CLI utility included. In an installed environment it can be called with

Make sure you have the ouput not in the project directory otherwise you will run into issues with poetry.

poetry run fhirzeug  --output-directory ../pydantic-fhir --generator python_pydantic

It will:

Technical explanations

About ValueSets and CodeSystems

Article to understand the difference in FHIR between a ValueSets and a CodeSystems : https://fhir-drills.github.io/ValueSet-And-CodeSystem.html .

FHIR Specification provides different ways to define a ValueSet. At the moment, FHIRzeug implementation only handle a few cases :

Note : when no specific validation is implemented, the attribute has the generic type FHIRCode which is a constrained string with the very permissive regex [^\s]+(\s[^\s]+)*.

How are property names determined?

Every “property” of a class, meaning every element in a profile snapshot, is represented as a FHIRStructureDefinitionElement instance. If an element itself defines a class, e.g. Patient.animal, calling the instance's as_properties() method returns a list of FHIRClassProperty instances – usually only one – that indicates a class was found in the profile. The class of this property is derived from element.type, which is expected to only contain one entry, in this matter:


Maintained by:

BlackTusk

and

Skalar Systems