SPHN (SPHN Data Model)

raw JSON →
0.2.1 verified Fri May 01 auth: no python

A Python library for working with the SPHN (Swiss Personalized Health Network) data model. Version 0.2.1. Enables creation, validation, and serialization of SPHN-compliant RDF data. Currently in early development with frequent releases.

pip install sphn
error ModuleNotFoundError: No module named 'sphn'
cause The library is not installed or is installed in a different environment.
fix
Run 'pip install sphn' in your current environment.
error AttributeError: module 'sphn' has no attribute 'SPHNProject'
cause Attempting to import a non-existent class or outdated version.
fix
Update the library: 'pip install --upgrade sphn'. Then use 'from sphn import SPHNProject'.
gotcha The library is in early development (v0.2.1). API may change drastically between versions. Pin your dependency to a specific version.
fix Use 'sphn==0.2.1' in requirements.txt.
gotcha The 'sphn' package name on PyPI is very short and could be confused with other projects. Ensure you are installing the correct package.
fix Always install via 'pip install sphn' and verify version >=0.2.0.

Create a new SPHN project, add a patient, and serialize as RDF/Turtle.

from sphn import SPHNProject
from datetime import datetime
project = SPHNProject()
patient = project.create_patient(patient_id='P001', birth_date=datetime(1990, 4, 23))
project.add_patient(patient)
rdf = project.to_rdf()
print(rdf.serialize(format='turtle'))