-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
154 lines (135 loc) · 6.3 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
#System Administrator Role
class System_Administrator(models.Model):
Date = models.DateTimeField('Date')
username = models.ForeignKey(User, blank=True, null=True)
def __str__(self):
return str(self.username)
#Doctor Role
class Doctor(models.Model):
Practice_Name = models.CharField(max_length=200)
Practice_Address = models.CharField(max_length=200)
Recovery_Phrase = models.CharField(max_length=200)
#Username = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True,)
username = models.ForeignKey(User, blank=True, null=True)
#created_by = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return self.Practice_Name
#Nurse Role
class Nurse(models.Model):
Practice_Name = models.CharField(max_length=200)
Practice_Address = models.CharField(max_length=200)
Associated_Doctors = models.ManyToManyField(Doctor)
username = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return self.Practice_Name
#Medical Administrator Role
class Medical_Administrator(models.Model):
Practice_Name = models.CharField(max_length=200)
Practice_Address = models.CharField(max_length=200)
Associated_Doctors = models.ManyToManyField(Doctor)
Associated_Nurses = models.ManyToManyField(Nurse)
username = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return self.Practice_Name
#Insurance Administrator Role
class Insurance_Administrator(models.Model):
Company_Name = models.CharField(max_length=200)
Company_Address = models.CharField(max_length=200)
username = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return self.Company_Name
#Patient Role
class Patient(models.Model):
SSN = models.CharField(max_length=200)
Address = models.CharField(max_length=200)
DOB = models.DateTimeField('Date')
username = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return self.SSN
#Record
class Record(models.Model):
Record_ID = models.AutoField(primary_key=True)
lst = ['Doctor Exam','Test Result','Diagnosis','Insurance Claim','Patient Doctor Correspondence','Raw']
options = [(str(i), str(i)) for i in lst]
Record_Type = models.CharField(max_length=200, choices=options, default='Doctor Exam')
Record_Date = models.DateTimeField('Record_Date', auto_now=True)
Owner = models.ForeignKey(User, blank=True, null=True, related_name='Owner')
Patient = models.ForeignKey(User, blank=True, null=True, related_name='Patient')
Edit_Permissions = models.ManyToManyField(User, related_name='Edit_Permissions')
View_Permissions = models.ManyToManyField(User, related_name='View_Permissions')
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.Record_ID)
#Doctor Exam Record
class Doctor_Exam_Record(models.Model):
Date = models.DateTimeField('Date of exam', auto_now=True)
Doctor = models.ForeignKey(User, blank=True, null=True)
Notes = models.CharField(max_length=200)
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Diagnosis Record
class Diagnosis_Record(models.Model):
Date = models.DateTimeField('Date of exam', auto_now=True)
Doctor = models.ForeignKey(User, blank=True, null=True)
Diagnosis = models.CharField(max_length=200)
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Test Results Record
class Test_Results_Record(models.Model):
Date = models.DateTimeField('Date of exam', auto_now=True)
Doctor = models.ForeignKey(User, blank=True, null=True)
Lab = models.CharField(max_length=200)
Notes = models.CharField(max_length=200)
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Insurance Claim Record
class Insurance_Claim_Record(models.Model):
Date = models.DateTimeField('Date of exam', auto_now=True)
Medical_Administrator = models.ForeignKey(User, blank=True, null=True, related_name='Medical_Administrator_handling_claim_for_doctor')
Amount = models.FloatField(default=0.0) # models.FloatField(null=True, blank=True, default=None)
Status_Options = (('Filed', 'Filed'), ('Examining', 'Examining'), ('Rejected', 'Rejected'),('Accepted', 'Accepted'), ( 'Paid', 'Paid'))
Status = models.CharField(max_length=200, choices=Status_Options)
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Patient_Doctor_Correspondence_Record
class Patient_Doctor_Correspondence_Record(models.Model):
Doctor = models.ForeignKey(User, blank=True, null=True, related_name='Doctor')
Notes = models.ManyToManyField('Note')
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Raw Record
class Raw_Record(models.Model):
Description = models.CharField(max_length=200)
File = models.FileField(upload_to='documents')
Record = models.ForeignKey(Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)
#Note
class Note(models.Model):
Date = models.DateTimeField('Note Date', auto_now=True)
Text = models.CharField(max_length=200)
Patient_Doctor_Correspondence = models.ForeignKey(Patient_Doctor_Correspondence_Record, blank=True, null=True)
created_at = models.DateTimeField('Date', auto_now=True)
def __str__(self):
return str(self.id)