-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvet.py
75 lines (71 loc) · 2.38 KB
/
vet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from bson.errors import InvalidId
from pymongo import MongoClient
import docker
from bson.objectid import ObjectId
erro_value = 'Valor indevido inserido'
erro_type = 'Tipo indevido de dado inserido'
erro_index = 'Erro ao adicionar definição do valor'
erro_key = 'Erro ao adicionar valor'
def check_consult_date(id_paciente):
try:
client = docker.DockerClient()
container = client.containers.get('pet_health_mongodb')
ip_add = container.attrs['NetworkSettings']['IPAddress']
client_mongo = MongoClient(ip_add)
petdatabase = client_mongo["petdatabase"]
petconsult = petdatabase["petconsult"]
consulta = {"_id": ObjectId(id_paciente)}
try:
print(petconsult.find_one())
for x in petconsult.find(consulta):
for coluna, valor in x.items():
print(coluna + ":", valor)
except ValueError:
print(erro_value)
except TypeError:
print(erro_type)
except IndexError:
print(erro_index)
except KeyError:
print(erro_key)
except InvalidId:
print(erro_value)
except ValueError:
print(erro_value)
except TypeError:
print(erro_type)
except IndexError:
print(erro_index)
except KeyError:
print(erro_key)
def remenber_consult(id_paciente):
try:
client = docker.DockerClient()
consult_date = check_consult_date(id_paciente)
if consult_date:
container = client.containers.get('pet_health_mongodb')
ip_add = container.attrs['NetworkSettings']['IPAddress']
client_mongo = MongoClient(ip_add) #Porta padrão para o biomics
petdatabase = client_mongo["petdatabase"]
petconsult = petdatabase["petconsult"]
consulta = {"date": consult_date}
try:
petconsult.find(consulta)
except ValueError:
print(erro_value)
except TypeError:
print(erro_type)
except IndexError:
print(erro_index)
except KeyError:
print(erro_key)
except InvalidId:
print(erro_value)
except ValueError:
print(erro_value)
except TypeError:
print(erro_type)
except IndexError:
print(erro_index)
except KeyError:
print(erro_key)