-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc9f510
commit 62af206
Showing
3 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from dataclasses import dataclass, field | ||
|
||
@dataclass | ||
class Patient: | ||
source : str | ||
name : str | ||
birth_date : str | ||
cpf : str | ||
cns : str = "" | ||
gender : str = "unknow" | ||
active : bool = True | ||
address : list = field(default_factory=list) | ||
birth_city : str = "" | ||
birth_country : str = "01" | ||
deceased : bool = True | ||
nationality : str = "" | ||
naturalization : str = "" | ||
mother : str = "" | ||
father : str = "" | ||
protected_person : bool = False | ||
race: str = "" | ||
ethnicity : str = "" | ||
register_quality : float = 0 | ||
telecom : list = field(default_factory=list) | ||
|
||
elements_required = ["active", "birthCountry", "birthDate", "gender", "identifier", "name"] | ||
def __post_init__(self): | ||
self.name = self.name.title() | ||
# verifica validade da pk | ||
|
||
def __init__(self, patient: dict, source: str): | ||
# verifica presença dos campos obrigatórios | ||
|
||
#verify | ||
|
||
# verify if all required elements are in patient | ||
elements_required_missing = [] | ||
for key in elements_required: | ||
if key not in patient: | ||
elements_required_missing.append(key) | ||
if len(elements_required_missing) > 0: | ||
raise f"Missing required element(s): {elements_required_missing}" | ||
#def compliance_check | ||
|
||
#def padroniza textos | ||
|
||
self.source = source | ||
self.active = None | ||
self.address = None | ||
self.birth_city = None | ||
self.birth_country = None | ||
self.birth_date = None | ||
self.deceased = None | ||
self.gender = None | ||
self.identifier = None | ||
self.name = None | ||
self.nationality = None | ||
self.naturalization = None | ||
self.parents = None | ||
self.protected_person = None | ||
self.race_ethnicity = None | ||
self.register_quality = None | ||
self.telecom = None | ||
|
||
#def dicarcad_incomplinat | ||
|
||
#def to_fhir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
from fhir_utils.utils import json_to_dict | ||
from fhir_utils.fhir.patient.parsers import fhir_to_dict | ||
from fhir_utils.fhir.patient.resource import Patient | ||
|
||
patient = json_to_dict("/home/thiagotrabach/tmp/patient_sample.json") | ||
patient_json = json_to_dict("/home/thiagotrabach/tmp/patient_sample.json") | ||
|
||
patient_clean = fhir_to_dict(patient, "vitacare") | ||
patient = fhir_to_dict(patient_json, "vitacare") | ||
|
||
print(patient_clean) | ||
gabriela = Patient(name = patient["data"]["name"], | ||
cpf = patient["data"]["identifiers"]["tax"], | ||
birth_date = patient["data"]["birth_date"], | ||
source ="vitai" ) | ||
|
||
print(gabriela) | ||
|
||
|