Skip to content

Python bindings for the CDA R2 document format (French ANS variant)

License

Notifications You must be signed in to change notification settings

ipsosante/cda-bindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CDA bindings

Python bindings for the CDA R2 document format.

The bindings are generated using tefra/xsdata, based on the ANS variant of the CDA spec.

Using the bindings

Add the following to your requirements.txt file :

git+https://github.com/ipsosante/cda-bindings.git

Re-generating the bindings

Start by creating a Python virtualenv, and install the dependencies:

pip install .[cli]

Then you'll need to clone https://github.com/ansforge/TestContenuCDA-3-0 somewhere.

git clone https://github.com/ansforge/TestContenuCDA-3-0.git

Come back to the cda-bindings directory, then run :

./regen.sh /path/to/ansforge/TestContenuCDA-3-0

This will regenerate the full bindings in ./cdabindings.

Validating the generated XML files with the XSD

brew install java
# Follow the brew instructions after installation, e.g.
# sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
git clone https://github.com/amouat/xsd-validator
cd xsd-validator
./xsdv.sh /path/to/ansforge/TestContenuCDA-3-0/infrastructure/cda/CDA_extended.xsd /path/to/generated/vsm_doc.xml

Patches

patches/xsd/remove_cd_qualifier.patch

Removes the qualifier property from de CD element (instead of declaring it with maxOccurs="0"). It is not supported by the spec :

Les éléments de type "CV", "CE" ou "CD" doivent respecter les contraintes suivantes : [...] l'élément qualifier n'est pas utilisé car non supporté par la version ultérieure des types de données HL7 V3;

patches/xsd/remove_cd_qualifier.patch

Make the maxOccurs property of the translation attributes of the CE element unbounded intead of 0.

I've seen no reason if the spec to limit the usage of translation at the CE level. It also makes the generated CV class unusable because xsdata will generate a dataclass with a translation field with init=False.

patches/generated_code/cs_init.patch

This is related to the patch patches/xsd/remove_cd_qualifier.patch. To make the generated CS class initializable, we need to manually declare its initializer to work around most of its field being re-declared with init=False.

patches/generated_code/duplicated_classes_names.patch

Because we are removing the PocdMt000040 prefix to all classes (using <Substitution> in .xsdata.xml), the generated code ends up with some classes with the same name declared with the same module. We manually rename each of them to fix the resulting ambiguity.

About

Python bindings for the CDA R2 document format (French ANS variant)

Resources

License

Stars

Watchers

Forks

Packages

No packages published