This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
messages.py
146 lines (105 loc) · 4.19 KB
/
messages.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
"""ProtoRPC message definition for a CCDA document."""
from protorpc import message_types
from protorpc import messages
class Code(messages.Message):
name = messages.StringField(1)
code = messages.StringField(2)
code_system = messages.StringField(3)
code_system_name = messages.StringField(4)
class DateRange(messages.Message):
start = message_types.DateTimeField(1)
end = message_types.DateTimeField(2)
class Allergy(messages.Message):
code = messages.MessageField(Code, 1)
date_range = messages.MessageField(DateRange, 2)
severity = messages.StringField(3)
reaction = messages.MessageField(Code, 4)
reaction_type = messages.MessageField(Code, 5)
allergen = messages.MessageField(Code, 6)
class Address(messages.Message):
# TODO: street.
city = messages.StringField(1)
state = messages.StringField(2)
postal_code = messages.StringField(3)
country = messages.StringField(4)
class Guardian(messages.Message):
# TODO: name, phone.
address = messages.MessageField(Address, 1)
relationship = messages.StringField(2)
class Demographic(messages.Message):
# TODO: name, phone.
dob = message_types.DateTimeField(1)
gender = messages.MessageField(Code, 2)
marital_status = messages.MessageField(Code, 3)
language = messages.StringField(4)
race = messages.MessageField(Code, 5)
ethnicity = messages.MessageField(Code, 6)
religion = messages.MessageField(Code, 7)
birthplace = messages.MessageField(Address, 8)
class Provider(messages.Message):
organization = messages.StringField(1)
address = messages.MessageField(Address, 2)
# TODO: phone.
class Encounter(messages.Message):
# TODO: Implement me.
pass
class Product(messages.Message):
code = messages.MessageField(Code, 1)
# TODO: translation, route, instructions, education_type.
class Immunization(messages.Message):
date = message_types.DateTimeField(1)
product = messages.MessageField(Product, 2)
class LabResult(messages.Message):
date = message_types.DateTimeField(1)
code = messages.MessageField(Code, 2)
value = messages.IntegerField(3)
unit = messages.StringField(4)
# TODO: reference.
class Lab(messages.Message):
code = messages.MessageField(Code, 1)
result = messages.MessageField(LabResult, 2)
class Quantity(messages.Message):
value = messages.StringField(1)
unit = messages.StringField(2)
class Prescriber(messages.Message):
organization = messages.StringField(1)
person = messages.StringField(2)
class Medication(messages.Message):
date_range = messages.MessageField(DateRange, 1)
product = messages.MessageField(Product, 2)
dose_quantity = messages.MessageField(Quantity, 3)
rate_quantity = messages.MessageField(Quantity, 4)
precondition = messages.MessageField(Code, 5)
reason = messages.MessageField(Code, 6)
route = messages.MessageField(Code, 7)
vehicle = messages.MessageField(Code, 8)
administration = messages.MessageField(Code, 9)
prescriber = messages.MessageField(Prescriber, 10)
class Problem(messages.Message):
code = messages.MessageField(Code, 1)
status = messages.StringField(2)
age = messages.IntegerField(3)
date_range = messages.MessageField(DateRange, 4)
class Procedure(messages.Message):
date = message_types.DateTimeField(1)
code = messages.MessageField(Code, 2)
specimen = messages.MessageField(Code, 3)
device = messages.MessageField(Code, 4)
performer = messages.MessageField(Provider, 5)
class VitalResult(messages.Message):
code = messages.MessageField(Code, 1)
value = messages.IntegerField(2)
unit = messages.StringField(3)
class Vital(messages.Message):
date = message_types.DateTimeField(1)
results = messages.MessageField(VitalResult, 2, repeated=True)
class CcdaDocument(messages.Message):
allergies = messages.MessageField(Allergy, 1, repeated=True)
demographics = messages.MessageField(Demographic, 2)
# TODO: encounters.
immunizations = messages.MessageField(Immunization, 3, repeated=True)
labs = messages.MessageField(Lab, 4, repeated=True)
medications = messages.MessageField(Medication, 5, repeated=True)
problems = messages.MessageField(Problem, 6, repeated=True)
procedures = messages.MessageField(Procedure, 7, repeated=True)
vitals = messages.MessageField(Vital, 8, repeated=True)