A module to read german health insurance cards with python
Project description
This package aims to provide a simple way to read smart cards (healthcards from) the German health insurance system.
It is based off of this repo: https://github.com/asdil12/python-egk/
Installation
Simply install the package via pip:
pip install python-healthcard
Usage
HealthCardReader
The usage a pretty straightforward.
from healthcard.reader import HealthCardReader
reader = HealthCardReader()
healthcard = reader.get_health_card()
print(healthcard.patient.first_name)
Max
The HealthCardReader object is automatically looking for a card reader. If there are multiple card readers available it uses the first one be default. This behavior can be changed however:
# change the index of the used reader
reader = HealthCardReader(index=1)
# or instantiate a cardservice yourself
from smartcard.CardType import ATRCardType
from smartcard.CardRequest import CardRequest
from smartcard.util import toHexString, toBytes
cardtype = ATRCardType( toBytes( "3B 16 94 20 02 01 00 00 0D" ) ) # just an example APDU
cardrequest = CardRequest( timeout=1, cardType=cardtype )
cardservice = cardrequest.waitforcard()
# This example code is taken from https://pyscard.sourceforge.io/user-guide.html
reader = HealthCardReader(cardservice=cardservice)
There are currently 3 versions of healthcards defined: G1, G1plus and G2.
The package automatically detects the version and reads the data accordingly.
HealthCard
The HealthCard object provides a simple interface to access insurance and patient data:
healthcard.patient # Patient object
healthcard.insurance # Insurance object
healthcard.version # G1, G1plus or G2
It provides 2 JSON formatted outputs - a flattened as well as a hierarchical one:
healthcard.to_json()
# and
healthcard.to_flattened_json()
Patient
The Patient object contains the personal data of the healthcard:
patient.first_name
patient.insurant_id
patient.birthdate
patient.first_name
patient.last_name
patient.gender
patient.prefix
patient.name_addition
patient.title
# depends on version
patient.postal_address
# or
patient.residential_address
PostalAddress
address.city
address.zip_code
address.country_code
address.zip_code
address.mailbox
ResidenceAddress
address.city
address.zip_code
address.country_code
address.city
address.street
address.street_number
address.address_addition
Insurance
This object only contains the name of the insurance.
insurance.insurance_name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-healthcard-1.0.5.tar.gz
.
File metadata
- Download URL: python-healthcard-1.0.5.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 905c06d4ea7e1238587df1bcf73e26489139f37db9e02242bcac7a120f13ce95 |
|
MD5 | 990f897a7ba85bd150595a90c149004c |
|
BLAKE2b-256 | 49dc9460e9bb1f1da9e5ade026e934d83e92c2b360568ed30c0a681e8062a9ad |
File details
Details for the file python_healthcard-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: python_healthcard-1.0.5-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a34666ffb19c6ade9cc384f78b6613d3d53629b474b99971805c480fcf4b03c6 |
|
MD5 | b0980267154f90dfbb5255861fe188fb |
|
BLAKE2b-256 | 6eb1a8592cda933f656768e929c608a6b1b21aa22a982f6160e105aa5597d438 |