Python bindings for the CDA R2 document format.
The bindings are generated using tefra/xsdata, based on the ANS variant of the CDA spec.
Add the following to your requirements.txt file :
git+https://github.com/ipsosante/cda-bindings.git
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.gitCome back to the cda-bindings directory, then run :
./regen.sh /path/to/ansforge/TestContenuCDA-3-0This will regenerate the full bindings in ./cdabindings.
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.jdkgit 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.xmlRemoves 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;
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.
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.
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.