-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
52 lines (41 loc) · 1.67 KB
/
models.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
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, Date
from sqlalchemy.orm import relationship
from enum import Enum
from .database import Base
class BiologicalGender(Enum):
woman = 1
man = 2
unknown = 3
class InsuranceCompany(Base):
__tablename__ = "insurance_company"
id = Column(Integer, primary_key=True, index=True)
official_id = Column(Integer, unique=True)
name = Column(String)
class Citizen(Base):
__tablename__ = "citizen"
id = Column(Integer, primary_key=True, index=True)
citizen_id = Column(Integer, unique=True, index=True)
insurance_company = Column(Integer, ForeignKey("insurance_company.id"))
first_name = Column(String)
last_name = Column(String)
street = Column(String)
postcode = Column(String)
city = Column(String)
birthday = Column(Date, index=True)
biological_gender = Column(Enum(BiologicalGender))
test_cases = relationship("TestCase", back_populates="patient")
class TestMethod(Base):
__tablename__ = "test_method"
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
reliability_score = Column(Integer)
test_cases = relationship("TestCase", back_populates="test_method")
class TestCase(Base):
__tablename__ = "test_case"
id = Column(Integer, primary_key=True, index=True)
patient_id = Column(Integer, ForeignKey("citizen.id"))
patient = relationship("Citizen", back_populates="test_cases")
date_of_test Column(Date, index=True)
result_positve = Colum(Boolean, index=True)
test_method_id = Column(Integer, ForeignKey("test_method.id"))
test_method = relationship("TestMethod", back_populates="test_cases")