key
from mcgpy.key import (encode, decode)
Functions sumarry
| Functions | Description |
|---|---|
| encode(patient_name, gender, birth_date) | Encode personal name, birthday, and gender |
| decode(name) | Decode personal information from the encrypted string |
The key.encode
def mcgpy.key.encode(patient_name, gender, birth_date, *args, **kwargs)
encode patient name, gender, birth date information
Parameters
-
patient_name :
strpatient's name
-
gender :
strpatient's gender
-
birth_date :
strpatient's bith date
Raise
-
ValueError
- if the input gender argument is no valid string, "man", "woman", "male", "female", 0, or 1
- if the input birth_data argument does not match to valid format,
%Y-%m-%d %H:%M:%S
Return : tuple
-
fianlencoded name :
stroutput of encoded information
-
folder name :
stroutput of encoded information with current date
Examples
>>> from mcgpy.key import encode
>>> encode("phil", "male", "2222-02-22 22:22:22")
("a7576ae32B2566A8F16F", "a7F76ae32B2566A8F165_22221223'")
The key.decode
def mcgpy.key.decode(name, *args, **kwargs)
decode an encoded string
Parameters
-
name :
strencoded string
Raise
-
NameError
if the input string is no valid name
Warning
OverflowError
The error was reported in some environments if the time module tries to convert the timestamp before the Unix epoch standard to the datetime.datetime format.
Return : dict
dict{"patient name" : # decoded patient's name from an input string
"gender" : # decoded patient's gender from an input string
"birth date" : # decoded patient's birth date from an input string as "datetime.datetime"
}
Examples
>>> from mcgpy.key import decode
>>> decode("a7576ae32B2566A8F16F")
{'patient name': 'phil',
'gender': 'Male',
'birth date': datetime.datetime(2222, 2, 22, 22, 22, 22)}