awacke1 commited on
Commit
250dfd3
·
1 Parent(s): b2c35ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +950 -3
app.py CHANGED
@@ -1,6 +1,944 @@
1
  import streamlit as st
2
  import hl7
3
- #from hl7tools.segment_def_enums import *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  def parse_hl7(message):
6
  # Parse the HL7 message using the hl7 library
@@ -25,11 +963,20 @@ def parse_hl7(message):
25
  # Define the Streamlit app
26
  def app():
27
  # Add a text input field for the HL7 message
28
- hl7_message = st.text_area("Enter HL7 message here", value="MSH|^~\&|ANYSHARE^2.16.840.1.113883.1.2966.500.1.1.17.1.312.1|ABCCHHH|AnyCompanyHIE|CDX|20190408235621||ADT^A03|183000519^248647541|P|2.5.1\r")
29
 
30
  # Parse the HL7 message and display the labeled fields
31
  if hl7_message:
32
  parse_hl7(hl7_message)
33
 
34
- if __name__ == "__main__":
 
 
 
35
  app()
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import hl7
3
+ import definitions
4
+ from enum import Enum
5
+
6
+ class AdtEvents(Enum):
7
+ """ADT events for MSH segment"""
8
+ Patient_Admit = 'A01'
9
+ Patient_Transfer = 'A02'
10
+ Patient_Discharge = 'A03'
11
+ Patient_Registration = 'A04'
12
+ Patient_Pre_Admission = 'A05'
13
+ Patient_Information_Update = 'A08'
14
+ Cancel_Patient_Admit = 'A11'
15
+ Cancel_Patient_Transfer = 'A12'
16
+ Cancel_Patient_Discharge = 'A13'
17
+ Pending_Admit = 'A14'
18
+ Pending_Transfer = 'A15'
19
+ Pending_Discharge = 'A16'
20
+
21
+ def is_match(self, event) -> bool:
22
+ return self.value == event
23
+
24
+ @staticmethod
25
+ def get_label(event_type: str) -> str:
26
+ try:
27
+ enum_val = AdtEvents(event_type)
28
+ label = enum_val.name.replace('_', ' ')
29
+ except IndexError:
30
+ label = 'Unknown {}'.format(event_type)
31
+ return label
32
+
33
+
34
+ class DiagnosisType(Enum):
35
+ """Diagnosis type for DG1 segment"""
36
+ A = "Admitting"
37
+ AD = 'admitting diagnosis'
38
+ BD = 'treating diagnosis'
39
+ ED = 'referral diagnosis'
40
+ EL = 'discharge/transfer diagnosis'
41
+ F = "Final"
42
+ ND = 'diagnosis'
43
+ NO = 'diagnosis operation'
44
+ NU = 'follow-up diagnosis that has justified the incapacity to work'
45
+ UD = 'referral diagnosis'
46
+ VO = 'preoperative diagnosis'
47
+ W = 'Waiting'
48
+ ZD = 'ZD'
49
+
50
+
51
+ class PatientClass(Enum):
52
+ E = 'EMERGENCY'
53
+ I = 'INPATIENT'
54
+ O = 'OUTPATIENT'
55
+ P = 'PREADMIT'
56
+ R = 'RECURRING PATIENT'
57
+ B = 'OBSTETRICS'
58
+ C = 'COMMERCIAL ACCOUNT'
59
+ N = 'NOT APPLICABLE'
60
+ U = 'UNKNOWN'
61
+ NO_MATCH = 'UNKNOWN'
62
+
63
+
64
+ class CleanPatientClass(Enum):
65
+ ER = 'E'
66
+ IP = 'I'
67
+
68
+
69
+ class PatientClassText(Enum):
70
+ EMERGENCY = 'E'
71
+ INPATIENT = 'I'
72
+ OUTPATIENT = 'O'
73
+ PREADMIT = 'P'
74
+ RECURRING_PATIENT = 'R'
75
+ OBSTETRICS = 'B'
76
+ COMMERCIAL_ACCOUNT = 'C'
77
+ NOT_APPLICABLE = 'N'
78
+ UNKNOWN = 'U'
79
+
80
+
81
+ class AdmitSource(Enum):
82
+ Physician_Referral = '1'
83
+ PR = '1'
84
+ Clinic_Referral = '2'
85
+ HMO_Referral = '3'
86
+ HMO = '3'
87
+ Transfer_From_Hospital = '4'
88
+ Transfer_From_Skilled_Nursing_Facility = '5'
89
+ SNF = '5'
90
+ Transfer_From_Another_Health_Care_Facility = '6'
91
+ Emergency_Room = '7'
92
+ ER = '7'
93
+ Court_or_Law_Enforcement = '8'
94
+ Information_Not_Available = '9'
95
+ Transfer_From_Critical_Access_Hospital = 'A'
96
+ Transfer_From_Another_Home_Health_Agency = 'B'
97
+ Readmission_to_Same_Home_Health_Agency = 'C'
98
+ Transfer_from_Hospital_Inpatient_In_Same_Facility = 'D'
99
+
100
+ @staticmethod
101
+ def get_value(attribute: str) -> str:
102
+ try:
103
+ return AdmitSource[attribute].value
104
+ except KeyError:
105
+ hl7tools_logger.warning("No match found for Admit Source '{}', returning 0.".format(attribute))
106
+ return '0'
107
+
108
+
109
+ class DiagnosisPriority(Enum):
110
+ """Diagnosis priority for DG1 segment"""
111
+ DP_1 = '1 The primary diagnosis'
112
+ DP_1_1 = '1.1 main diagnosis (primary)'
113
+ DP_1_2 = '1.2 main diagnosis (secondary)'
114
+
115
+
116
+ class MshSegment(Enum):
117
+ """Message Header"""
118
+ Sending_Application_Name = 'MSH{}.F3.R1.C1'
119
+ Sending_Application_Universal_ID = 'MSH{}.F3.R1.C2'
120
+ Sending_Application_Universal_ID_Type = 'MSH{}.F3.R1.C3'
121
+ Sending_Facility_Name = 'MSH{}.F4.R1.C1'
122
+ Sending_Facility_Universal_ID = 'MSH{}.F4.R1.C2'
123
+ Sending_Facility_Universal_ID_Type = 'MSH{}.F4.R1.C3'
124
+ Receiving_Application_Name = 'MSH{}.F5.R1.C1'
125
+ Receiving_Application_Universal_ID = 'MSH{}.F5.R1.C2'
126
+ Receiving_Application_Universal_ID_Type = 'MSH{}.F5.R1.C3'
127
+ Receiving_Facility_Name = 'MSH{}.F6.R1.C1'
128
+ Receiving_Facility_Universal_ID = 'MSH{}.F6.R1.C2'
129
+ Receiving_Facility_Universal_ID_Type = 'MSH{}.F6.R1.C3'
130
+ Msg_Timestamp = 'MSH{}.F7.R1.C1'
131
+ Security = 'MSH{}.F8'
132
+ Msg_Type = 'MSH{}.F9.R1.C1'
133
+ Msg_Trigger_Event = 'MSH{}.F9.R1.C2'
134
+ Msg_Structure_ID = 'MSH{}.F9.R1.C3'
135
+ Msg_control_ID = 'MSH{}.F10.R1.C1'
136
+ Processing_ID = 'MSH{}.F11.R1.C1'
137
+ Processing_Mode_ID = 'MSH{}.F11.R1.C2'
138
+ Version_ID = 'MSH{}.F12.R1.C1'
139
+ Version_Internationalization_Code = 'MSH{}.F12.R1.C2'
140
+ Version_Internationalization_Version = 'MSH{}.F12.R1.C3'
141
+ Sequence_Number = 'MSH{}.F13'
142
+ Accept_Ack_Type = 'MSH{}.F15'
143
+ Application_Ack_Type = 'MSH{}.F16'
144
+ Country_Code = 'MSH{}.F17'
145
+ Character_Set = 'MSH{}.F18'
146
+ ODX_Id = 'MSH{}.F21'
147
+
148
+ @staticmethod
149
+ def get_segment_name() -> str:
150
+ return 'MSH'
151
+
152
+ @staticmethod
153
+ def get_segment_title() -> str:
154
+ return 'Message Header'
155
+
156
+
157
+ class EvnSegment(Enum):
158
+ """Event"""
159
+ Event_Type_Code = 'EVN{}.F1'
160
+ Recorded_Date_Time = 'EVN{}.F2.R1.C1'
161
+ Recorded_Date_Time_Degree_of_Precision = 'EVN{}.F2.R1.C2'
162
+ Date_Time_Planned_Event_Time = 'EVN{}.F3.R1.C1'
163
+ Date_Time_Planned_Degree_of_Precision = 'EVN{}.F3.R1.C2'
164
+ Event_Reason_Code = 'EVN{}.F4'
165
+ Operator_ID_Number = 'EVN{}.F5.R1.C1'
166
+ Operator_ID_Family_Name_Surname = 'EVN{}.F5.R1.C2.S1'
167
+ Operator_ID_Family_Name_Own_Surname_Prefix = 'EVN{}.F5.R1.C2.S2'
168
+ Operator_ID_Given_Name = 'EVN{}.F5.R1.C3'
169
+ Operator_ID_Middle_Initial = 'EVN{}.F5.R1.C4'
170
+ Operator_ID_Suffix = 'EVN{}.F5.R1.C5'
171
+ Operator_ID_Prefix = 'EVN{}.F5.R1.C6'
172
+ Operator_ID_Degree = 'EVN{}.F5.R1.C7'
173
+ Operator_ID_Source_Table = 'EVN{}.F5.R1.C8'
174
+ Operator_ID_Assigning_Authority = 'EVN{}.F5.R1.C9'
175
+ Operator_ID_Name_Type_Code = 'EVN{}.F5.R1.C10'
176
+ Operator_ID_Identifier_Check_Digit = 'EVN{}.F5.R1.C11'
177
+ Operator_ID_Check_Digit_Scheme = 'EVN{}.F5.R1.C12'
178
+ Operator_ID_Identifier_Type_Code = 'EVN{}.F5.R1.C13'
179
+ Operator_ID_Assigning_Facility = 'EVN{}.F5.R1.C14'
180
+ Operator_ID_Name_Representation_Code = 'EVN{}.F5.R1.C15'
181
+ Operator_ID_Name_Context = 'EVN{}.F5.R1.C16'
182
+ Operator_ID_Name_Validity_Range = 'EVN{}.F5.R1.C17'
183
+ Operator_ID_Name_Assembly_Order = 'EVN{}.F5.R1.C18'
184
+ Operator_ID_Effective_Date = 'EVN{}.F5.R1.C19'
185
+ Operator_ID_Expiration_Date = 'EVN{}.F5.R1.C20'
186
+ Operator_ID_Professional_Suffix = 'EVN{}.F5.R1.C21'
187
+ Operator_ID_Assigning_Jurisdiction = 'EVN{}.F5.R1.C22'
188
+ Operator_ID_Assigning_Agency_or_Department = 'EVN{}.F5.R1.C23'
189
+ Event_Occurred_Time = 'EVN{}.F6.R1.C1'
190
+ Event_Occurred_Degree_of_Precision = 'EVN{}.F6.R1.C2'
191
+ Event_Facility_Namespace_ID = 'EVN{}.F7.R1.C1'
192
+ Event_Facility_Universal_ID = 'EVN{}.F7.R1.C2'
193
+ Event_Facility_Universal_ID_Type = 'EVN{}.F7.R1.C3'
194
+
195
+ @staticmethod
196
+ def get_segment_name() -> str:
197
+ return 'EVN'
198
+
199
+ @staticmethod
200
+ def get_segment_title() -> str:
201
+ return 'Event'
202
+
203
+
204
+ class PidSegment(Enum):
205
+ """Patient Identification"""
206
+ Patient_ID = 'PID{}.F2.R1.C1'
207
+ Patient_ID_Assigning_Auth = 'PID{}.F2.R1.C4'
208
+ Patient_ID_Type_Code = 'PID{}.F2.R1.C5'
209
+ Patient_ID_List = 'PID{}.F3.R1.C1'
210
+ Patient_ID_List_Assigning_Auth = 'PID{}.F3.R1.C4'
211
+ Patient_ID_List_Type_Code = 'PID{}.F3.R1.C5'
212
+ Patient_ID_Alt = 'PID{}.F4.R1.C1'
213
+ Patient_ID_Alt_Assigning_Auth = 'PID{}.F4.R1.C4'
214
+ Patient_ID_Alt_Type_Code = 'PID{}.F4.R1.C5'
215
+ Patient_Last_Name = 'PID{}.F5.R1.C1'
216
+ Patient_First_Name = 'PID{}.F5.R1.C2'
217
+ Patient_Middle_Name = 'PID{}.F5.R1.C3'
218
+ Patient_DOB = 'PID{}.F7'
219
+ Patient_Gender = 'PID{}.F8'
220
+ Patient_Address_Street_1 = 'PID{}.F11.R1.C1'
221
+ Patient_Address_Street_2 = 'PID{}.F11.R1.C2'
222
+ Patient_Address_City = 'PID{}.F11.R1.C3'
223
+ Patient_Address_State = 'PID{}.F11.R1.C4'
224
+ Patient_Address_Zip = 'PID{}.F11.R1.C5'
225
+ Patient_Phone_Number_Home = 'PID{}.F13.R1.C1'
226
+ Marital_Status = 'PID{}.F16'
227
+ Patient_Account_Number = 'PID{}.F18.R1.C1'
228
+ Patient_SSN = 'PID{}.F19'
229
+
230
+ @staticmethod
231
+ def get_segment_name() -> str:
232
+ return 'PID'
233
+
234
+ @staticmethod
235
+ def get_segment_title() -> str:
236
+ return 'Patient ID'
237
+
238
+
239
+ class Pd1Segment(Enum):
240
+ """Patient Additional Demographic"""
241
+ Living_Dependency = 'PD1{}.F1'
242
+ Living_Arrangement = 'PD1{}.F2'
243
+ Patient_Primary_Facility_Org_Name = 'PD1{}.F3.R1.C1'
244
+ Patient_Primary_Facility_Org_Name_Type_Code = 'PD1{}.F3.R1.C2'
245
+ Patient_Primary_Facility_Org_ID_Number = 'PD1{}.F3.R1.C3'
246
+ Patient_Primary_Facility_Org_Check_Digit = 'PD1{}.F3.R1.C4'
247
+ Patient_Primary_Facility_Org_Check_Digit_Scheme = 'PD1{}.F3.R1.C5'
248
+ Patient_Primary_Facility_Org_Assigning_Authority = 'PD1{}.F3.R1.C6'
249
+ Patient_Primary_Facility_Org_Identifier_Type_Code = 'PD1{}.F3.R1.C7'
250
+ Patient_Primary_Facility_Org_Assigning_Facility = 'PD1{}.F3.R1.C8'
251
+ Patient_Primary_Facility_Org_Name_Representation_Code = 'PD1{}.F3.R1.C9'
252
+ Patient_Primary_Facility_Org_Name_Organization_Identifier = 'PD1{}.F3.R1.C10'
253
+ Patient_PCP_ID_Number = 'PD1{}.F4.R1.C1'
254
+ Patient_PCP_ID_Family_Name = 'PD1{}.F4.R1.C2'
255
+ Patient_PCP_ID_Given_Name = 'PD1{}.F4.R1.C3'
256
+ Patient_PCP_ID_Middle_Initial = 'PD1{}.F4.R1.C4'
257
+ Patient_PCP_ID_Suffix = 'PD1{}.F4.R1.C5'
258
+ Patient_PCP_ID_Prefix = 'PD1{}.F4.R1.C6'
259
+ Patient_PCP_ID_Degree = 'PD1{}.F4.R1.C7'
260
+ Patient_PCP_ID_Source_Table = 'PD1{}.F4.R1.C8'
261
+ Patient_PCP_ID_Assigning_Authority = 'PD1{}.F4.R1.C9'
262
+ Patient_PCP_ID_Name_Type_Code = 'PD1{}.F4.R1.C10'
263
+ Patient_PCP_ID_Identifier_Check_Digit = 'PD1{}.F4.R1.C11'
264
+ Patient_PCP_ID_Check_Digit_Scheme = 'PD1{}.F4.R1.C12'
265
+ Patient_PCP_ID_Identifier_Type_Code = 'PD1{}.F4.R1.C13'
266
+ Patient_PCP_ID_Assigning_Facility = 'PD1{}.F4.R1.C14'
267
+ Patient_PCP_ID_Name_Representation_Code = 'PD1{}.F4.R1.C15'
268
+ Patient_PCP_ID_Name_Context = 'PD1{}.F4.R1.C16'
269
+ Patient_PCP_ID_Name_Validity_Range = 'PD1{}.F4.R1.C17'
270
+ Patient_PCP_ID_Name_Assembly_Order = 'PD1{}.F4.R1.C18'
271
+ Patient_PCP_ID_Effective_Date = 'PD1{}.F4.R1.C19'
272
+ Patient_PCP_ID_Expiration_Date = 'PD1{}.F4.R1.C20'
273
+ Patient_PCP_ID_Professional_Suffix = 'PD1{}.F4.R1.C21'
274
+ Patient_PCP_ID_Assigning_Jurisdiction = 'PD1{}.F4.R1.C22'
275
+ Patient_PCP_ID_Assigning_Agency_or_Dept = 'PD1{}.F4.R1.C23'
276
+ Student_Indicator = 'PD1{}.F5'
277
+ Handicap = 'PD1{}.F6'
278
+ Living_Will_Code = 'PD1{}.F7'
279
+ Organ_Donor_Code = 'PD1{}.F8'
280
+ Separate_Bill = 'PD1{}.F9'
281
+ Duplicate_Patient_ID_Number = 'PD1{}.F10.R1.C1'
282
+ Duplicate_Patient_Check_Digit = 'PD1{}.F10.R1.C2'
283
+ Duplicate_Patient_Check_Digit_Scheme = 'PD1{}.F10.R1.C3'
284
+ Duplicate_Patient_Assigning_Authority = 'PD1{}.F10.R1.C4'
285
+ Duplicate_Patient_Identifier_Type_Code = 'PD1{}.F10.R1.C5'
286
+ Duplicate_Patient_Assigning_Facility = 'PD1{}.F10.R1.C6'
287
+ Duplicate_Patient_Effective_Date = 'PD1{}.F10.R1.C7'
288
+ Duplicate_Patient_Expiration_Date = 'PD1{}.F10.R1.C8'
289
+ Duplicate_Patient_Assigning_Jurisdiction = 'PD1{}.F10.R1.C9'
290
+ Duplicate_Patient_Assigning_Agency_or_Dept = 'PD1{}.F10.R1.C10'
291
+ Publicity_Code = 'PD1{}.F11'
292
+ Protection_Indicator = 'PD1{}.F12'
293
+ Protection_Indicator_Effective_Date = 'PD1{}.F13'
294
+ Place_of_Worship_Organization_Name = 'PD1{}.F14.R1.C1'
295
+ Place_of_Worship_Organization_Name_Type_Code = 'PD1{}.F14.R1.C2'
296
+ Place_of_Worship_ID_Number = 'PD1{}.F14.R1.C3'
297
+ Place_of_Worship_Check_Digit = 'PD1{}.F14.R1.C4'
298
+ Place_of_Worship_Check_Digit_Scheme = 'PD1{}.F14.R1.C5'
299
+ Place_of_Worship_Assigning_Authority = 'PD1{}.F14.R1.C6'
300
+ Place_of_Worship_Identifier_Type_Code = 'PD1{}.F14.R1.C7'
301
+ Place_of_Worship_Assigning_Facility = 'PD1{}.F14.R1.C8'
302
+ Place_of_Worship_Name_Representation_Code = 'PD1{}.F14.R1.C9'
303
+ Place_of_Worship_Organization_Identifier = 'PD1{}.F14.R1.C10'
304
+ Advance_Directive_Code_Identifier = 'PD1{}.F15.R1.C1'
305
+ Advance_Directive_Code_Text = 'PD1{}.F15.R1.C2'
306
+ Advance_Directive_Code_Name_of_Coding_System = 'PD1{}.F15.R1.C3'
307
+ Advance_Directive_Code_Alternate_Identifier = 'PD1{}.F15.R1.C4'
308
+ Advance_Directive_Code_Alternate_Text = 'PD1{}.F15.R1.C5'
309
+ Advance_Directive_Code_Name_of_Alternate_Coding_System = 'PD1{}.F15.R1.C6'
310
+ Immunization_Registry_Status = 'PD1{}.F16'
311
+ Immunization_Registry_Status_Effective_Date = 'PD1{}.F17'
312
+ Publicity_Code_Effective_Date = 'PD1{}.F18'
313
+ Military_Branch = 'PD1{}.F19'
314
+ Military_Rank_Grade = 'PD1{}.F20'
315
+ Military_Status = 'PD1{}.F21'
316
+
317
+ @staticmethod
318
+ def get_segment_name() -> str:
319
+ return 'PD1'
320
+
321
+ @staticmethod
322
+ def get_segment_title() -> str:
323
+ return 'Patient Additional Demographic'
324
+
325
+
326
+ class RolSegment(Enum):
327
+ Role_Instance_ID = 'ROL{}.F1'
328
+ Action_Code = 'ROL{}.F2'
329
+ Role_ROL = 'ROL{}.F3'
330
+ Role_Person = 'ROL{}.F4'
331
+ Role_Begin_Date_Time = 'ROL{}.F5'
332
+ Role_End_Date_Time = 'ROL{}.F6'
333
+ Role_Duration = 'ROL{}.F7'
334
+ Role_Action_Reason = 'ROL{}.F8'
335
+ Provider_Type = 'ROL{}.F9'
336
+ Organization_Unit_Type = 'ROL{}.F10'
337
+ Office_Home_Address_Birthplace = 'ROL{}.F11'
338
+ Phone = 'ROL{}.F12'
339
+ Persons_Location = 'ROL{}.F13'
340
+ Organization = 'ROL{}.F14'
341
+
342
+ @staticmethod
343
+ def get_segment_name() -> str:
344
+ return 'ROL'
345
+
346
+ @staticmethod
347
+ def get_segment_title() -> str:
348
+ return 'Role'
349
+
350
+
351
+ class Pv1Segment(Enum):
352
+ Set_ID = 'PV1{}.F1'
353
+ Patient_Class_ID = 'PV1{}.F2.R1.C1'
354
+ Patient_Class_Text = 'PV1{}.F2.R1.C2' # inpatient, outpatient, etc
355
+ Patient_Class_Name_of_Coding_System = 'PV1{}.F2.R1.C3'
356
+ Patient_Class_Alt_ID = 'PV1{}.F2.R1.C4'
357
+ Patient_Class_Alt_Text = 'PV1{}.F2.R1.C5'
358
+ Patient_Class_2nd_Alt_ID = 'PV1{}.F2.R1.C10'
359
+ Patient_Class_2nd_Alt_Text = 'PV1{}.F2.R1.C11'
360
+ Patient_Loc_Point_of_Care = 'PV1{}.F3.R1.C1'
361
+ Patient_Loc_Room = 'PV1{}.F3.R1.C2'
362
+ Patient_Loc_Bed = 'PV1{}.F3.R1.C3'
363
+ Patient_Loc_Facility = 'PV1{}.F3.R1.C4'
364
+ Patient_Loc_Location_Status = 'PV1{}.F3.R1.C5'
365
+ Patient_Loc_Assigning_Authority = 'PV1{}.F3.R1.C11'
366
+ Admission_Type_ID = 'PV1{}.F4.R1.C1'
367
+ Admission_Type_Text = 'PV1{}.F4.R1.C2'
368
+ Admission_Type_Alt_ID = 'PV1{}.F4.R1.C4'
369
+ Admission_Type_Alt_Text = 'PV1{}.F4.R1.C5'
370
+ Admission_Type_2nd_Alt_ID = 'PV1{}.F4.R1.C10'
371
+ Admission_Type_2nd_Alt_Text = 'PV1{}.F4.R1.C11'
372
+ Attending_Doctor = 'PV1{}.F7'
373
+ Attending_Doctor_Person_ID = 'PV1{}.F7.R1.C1'
374
+ Attending_Doctor_Family_Name = 'PV1{}.F7.R1.C2.S1'
375
+ Attending_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F7.R1.C2.S2'
376
+ Attending_Doctor_Given_Name = 'PV1{}.F7.R1.C3'
377
+ Attending_Doctor_Middle_Initial = 'PV1{}.F7.R1.C4'
378
+ Attending_Doctor_Suffix = 'PV1{}.F7.R1.C5'
379
+ Attending_Doctor_Prefix = 'PV1{}.F7.R1.C6'
380
+ Attending_Doctor_Degree = 'PV1{}.F7.R1.C7'
381
+ Attending_Doctor_Source_Table = 'PV1{}.F7.R1.C8'
382
+ Attending_Doctor_Assigning_Authority = 'PV1{}.F7.R1.C9'
383
+ Attending_Doctor_Name_Type_Code = 'PV1{}.F7.R1.C10'
384
+ Attending_Doctor_Identifier_Check_Digit = 'PV1{}.F7.R1.C11'
385
+ Attending_Doctor_Check_Digit_Scheme = 'PV1{}.F7.R1.C12'
386
+ Attending_Doctor_Identifier_Type_Code = 'PV1{}.F7.R1.C13'
387
+ Attending_Doctor_Assigning_Facility = 'PV1{}.F7.R1.C14'
388
+ Attending_Doctor_Name_Representation_Code = 'PV1{}.F7.R1.C15'
389
+ Attending_Doctor_Name_Context = 'PV1{}.F7.R1.C16'
390
+ Attending_Doctor_Name_Validity_Range = 'PV1{}.F7.R1.C17'
391
+ Attending_Doctor_Name_Assembly_Order = 'PV1{}.F7.R1.C18'
392
+ Attending_Doctor_Effective_Date = 'PV1{}.F7.R1.C19'
393
+ Attending_Doctor_Expiration_Date = 'PV1{}.F7.R1.C20'
394
+ Attending_Doctor_Professional_Suffix = 'PV1{}.F7.R1.C21'
395
+ Attending_Doctor_Assigning_Jurisdiction = 'PV1{}.F7.R1.C22'
396
+ Attending_Doctor_Assigning_Agency_or_Department = 'PV1{}.F7.R1.C23'
397
+ Referring_Doctor = 'PV1{}.F8'
398
+ Referring_Doctor_Person_ID = 'PV1{}.F8.R1.C1'
399
+ Referring_Doctor_Family_Name = 'PV1{}.F8.R1.C2.S1'
400
+ Referring_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F8.R1.C2.S2'
401
+ Referring_Doctor_Given_Name = 'PV1{}.F8.R1.C3'
402
+ Referring_Doctor_Middle_Initial = 'PV1{}.F8.R1.C4'
403
+ Referring_Doctor_Suffix = 'PV1{}.F8.R1.C5'
404
+ Referring_Doctor_Prefix = 'PV1{}.F8.R1.C6'
405
+ Referring_Doctor_Degree = 'PV1{}.F8.R1.C7'
406
+ Referring_Doctor_Source_Table = 'PV1{}.F8.R1.C8'
407
+ Referring_Doctor_Assigning_Authority = 'PV1{}.F8.R1.C9'
408
+ Referring_Doctor_Name_Type_Code = 'PV1{}.F8.R1.C10'
409
+ Referring_Doctor_Identifier_Check_Digit = 'PV1{}.F8.R1.C11'
410
+ Referring_Doctor_Check_Digit_Scheme = 'PV1{}.F8.R1.C12'
411
+ Referring_Doctor_Identifier_Type_Code = 'PV1{}.F8.R1.C13'
412
+ Referring_Doctor_Assigning_Facility = 'PV1{}.F8.R1.C14'
413
+ Referring_Doctor_Name_Representation_Code = 'PV1{}.F8.R1.C15'
414
+ Referring_Doctor_Name_Context = 'PV1{}.F8.R1.C16'
415
+ Referring_Doctor_Name_Validity_Range = 'PV1{}.F8.R1.C17'
416
+ Referring_Doctor_Name_Assembly_Order = 'PV1{}.F8.R1.C18'
417
+ Referring_Doctor_Effective_Date = 'PV1{}.F8.R1.C19'
418
+ Referring_Doctor_Expiration_Date = 'PV1{}.F8.R1.C20'
419
+ Referring_Doctor_Professional_Suffix = 'PV1{}.F8.R1.C21'
420
+ Referring_Doctor_Assigning_Jurisdiction = 'PV1{}.F8.R1.C22'
421
+ Referring_Doctor_Assigning_Agency_or_Department = 'PV1{}.F8.R1.C23'
422
+ Consulting_Doctor = 'PV1{}.F9'
423
+ Consulting_Doctor_Person_ID = 'PV1{}.F9.R1.C1'
424
+ Consulting_Doctor_Family_Name = 'PV1{}.F9.R1.C2.S1'
425
+ Consulting_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F9.R1.C2.S2'
426
+ Consulting_Doctor_Given_Name = 'PV1{}.F9.R1.C3'
427
+ Consulting_Doctor_Middle_Initial = 'PV1{}.F9.R1.C4'
428
+ Consulting_Doctor_Suffix = 'PV1{}.F9.R1.C5'
429
+ Consulting_Doctor_Prefix = 'PV1{}.F9.R1.C6'
430
+ Consulting_Doctor_Degree = 'PV1{}.F9.R1.C7'
431
+ Consulting_Doctor_Source_Table = 'PV1{}.F9.R1.C8'
432
+ Consulting_Doctor_Assigning_Authority = 'PV1{}.F9.R1.C9'
433
+ Consulting_Doctor_Name_Type_Code = 'PV1{}.F9.R1.C10'
434
+ Consulting_Doctor_Identifier_Check_Digit = 'PV1{}.F9.R1.C11'
435
+ Consulting_Doctor_Check_Digit_Scheme = 'PV1{}.F9.R1.C12'
436
+ Consulting_Doctor_Identifier_Type_Code = 'PV1{}.F9.R1.C13'
437
+ Consulting_Doctor_Assigning_Facility = 'PV1{}.F9.R1.C14'
438
+ Consulting_Doctor_Name_Representation_Code = 'PV1{}.F9.R1.C15'
439
+ Consulting_Doctor_Name_Context = 'PV1{}.F9.R1.C16'
440
+ Consulting_Doctor_Name_Validity_Range = 'PV1{}.F9.R1.C17'
441
+ Consulting_Doctor_Name_Assembly_Order = 'PV1{}.F9.R1.C18'
442
+ Consulting_Doctor_Effective_Date = 'PV1{}.F9.R1.C19'
443
+ Consulting_Doctor_Expiration_Date = 'PV1{}.F9.R1.C20'
444
+ Consulting_Doctor_Professional_Suffix = 'PV1{}.F9.R1.C21'
445
+ Consulting_Doctor_Assigning_Jurisdiction = 'PV1{}.F9.R1.C22'
446
+ Consulting_Doctor_Assigning_Agency_or_Department = 'PV1{}.F9.R1.C23'
447
+ Hospital_Service = 'PV1{}.F10'
448
+ Hospital_Service_Identifier = 'PV1{}.F10.R1.C1'
449
+ Hospital_Service_Text = 'PV1{}.F10.R1.C2'
450
+ Readmission_Indicator = 'PV1{}.F13'
451
+ Admit_Source = 'PV1{}.F14'
452
+ Admit_Source_ID = 'PV1{}.F14.R1.C1'
453
+ Admit_Source_Text = 'PV1{}.F14.R1.C2'
454
+ Admitting_Doctor = 'PV1{}.F17'
455
+ Admitting_Doctor_Person_ID = 'PV1{}.F17.R1.C1'
456
+ Admitting_Doctor_Family_Name = 'PV1{}.F17.R1.C2.S1'
457
+ Admitting_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F17.R1.C2.S2'
458
+ Admitting_Doctor_Given_Name = 'PV1{}.F17.R1.C3'
459
+ Admitting_Doctor_Middle_Initial = 'PV1{}.F17.R1.C4'
460
+ Admitting_Doctor_Suffix = 'PV1{}.F17.R1.C5'
461
+ Admitting_Doctor_Prefix = 'PV1{}.F17.R1.C6'
462
+ Admitting_Doctor_Degree = 'PV1{}.F17.R1.C7'
463
+ Admitting_Doctor_Source_Table = 'PV1{}.F17.R1.C8'
464
+ Admitting_Doctor_Assigning_Authority = 'PV1{}.F17.R1.C9'
465
+ Admitting_Doctor_Name_Type_Code = 'PV1{}.F17.R1.C10'
466
+ Admitting_Doctor_Identifier_Check_Digit = 'PV1{}.F17.R1.C11'
467
+ Admitting_Doctor_Check_Digit_Scheme = 'PV1{}.F17.R1.C12'
468
+ Admitting_Doctor_Identifier_Type_Code = 'PV1{}.F17.R1.C13'
469
+ Admitting_Doctor_Assigning_Facility = 'PV1{}.F17.R1.C14'
470
+ Admitting_Doctor_Name_Representation_Code = 'PV1{}.F17.R1.C15'
471
+ Admitting_Doctor_Name_Context = 'PV1{}.F17.R1.C16'
472
+ Admitting_Doctor_Name_Validity_Range = 'PV1{}.F17.R1.C17'
473
+ Admitting_Doctor_Name_Assembly_Order = 'PV1{}.F17.R1.C18'
474
+ Admitting_Doctor_Effective_Date = 'PV1{}.F17.R1.C19'
475
+ Admitting_Doctor_Expiration_Date = 'PV1{}.F17.R1.C20'
476
+ Admitting_Doctor_Professional_Suffix = 'PV1{}.F17.R1.C21'
477
+ Admitting_Doctor_Assigning_Jurisdiction = 'PV1{}.F17.R1.C22'
478
+ Admitting_Doctor_Assigning_Agency_or_Department = 'PV1{}.F17.R1.C23'
479
+ Patient_Type_ID = 'PV1{}.F18.R1.C1'
480
+ Patient_Type_Text = 'PV1{}.F18.R1.C2'
481
+ Patient_Type_Alt_ID = 'PV1{}.F18.R1.C4'
482
+ Patient_Type_Alt_Text = 'PV1{}.F18.R1.C5'
483
+ Visit_Number = 'PV1{}.F19.R1.C1'
484
+ Discharge_Disposition = 'PV1{}.F36.R1.C1'
485
+ Discharge_Disposition_Text = 'PV1{}.F36.R1.C2'
486
+ Discharge_Disposition_Coding = 'PV1{}.F36.R1.C3'
487
+ Discharge_Disposition_Alt = 'PV1{}.F36.R1.C4'
488
+ Discharge_Disposition_Text_Alt = 'PV1{}.F36.R1.C5'
489
+ Discharge_Disposition_Coding_Alt = 'PV1{}.F36.R1.C6'
490
+ Discharge_Disposition_Original_Text = 'PV1{}.F36.R1.C9'
491
+ Discharge_Disposition_Alt2 = 'PV1{}.F36.R1.C10'
492
+ Discharge_Disposition_Text_Alt2 = 'PV1{}.F36.R1.C11'
493
+ Discharge_Disposition_Coding_Alt2 = 'PV1{}.F36.R1.C12'
494
+ Discharge_to_Location = 'PV1{}.F37'
495
+ # Some records come in with Servicing Facility as a multi-part field.
496
+ # First part might be NPI. The next could be facility name.
497
+ Servicing_Facility = 'PV1{}.F39'
498
+ Servicing_Facility_Name = 'PV1{}.F39.R1.C2'
499
+ Admit_Date_Time = 'PV1{}.F44'
500
+ Discharge_Date_Time = 'PV1{}.F45'
501
+ Current_Patient_Balance = 'PV1{}.F45'
502
+ Total_Charges = 'PV1{}.F47'
503
+ Visit_Ind = 'PV1{}.F51'
504
+ Other_HealthCare_Provider = 'PV1{}.F52'
505
+ Service_Episode_Description = 'PV1{}.F53'
506
+
507
+ @staticmethod
508
+ def get_segment_name() -> str:
509
+ return 'PV1'
510
+
511
+ @staticmethod
512
+ def get_segment_title() -> str:
513
+ return 'Patient Visit'
514
+
515
+
516
+ # PV2||Routine|^Medicine Refill|||||||||103|||||||||n|N||||||||||N||||||Public Trans
517
+ class Pv2Segment(Enum):
518
+ Prior_Pending_Location = 'PV2{}.F1'
519
+ Prior_Pending_Location_Point_of_Care = 'PV2{}.F1.R1.C1'
520
+ Prior_Pending_Location_Room = 'PV2{}.F1.R1.C2'
521
+ Prior_Pending_Location_Bed = 'PV2{}.F1.R1.C3'
522
+ Prior_Pending_Location_Facility = 'PV2{}.F1.R1.C4'
523
+ Prior_Pending_Location_Location_Status = 'PV2{}.F1.R1.C5'
524
+ Accommodation_Code = 'PV2{}.F2'
525
+ Admit_Reason = 'PV2{}.F3'
526
+ Transfer_Reason_ID = 'PV2{}.F4.R1.C1'
527
+ Transfer_Reason_Text = 'PV2{}.F4.R1.C2'
528
+ Transfer_Reason_Alt_ID = 'PV2{}.F4.R1.C4'
529
+ Transfer_Reason_Alt_Text = 'PV2{}.F4.R1.C5'
530
+ Transfer_Reason_2nd_Alt_ID = 'PV2{}.F4.R1.C10'
531
+ Transfer_Reason_2nd_Alt_Text = 'PV2{}.F4.R1.C11'
532
+ Patient_Valuables = 'PV2{}.F5'
533
+ Patient_Valuables_Location = 'PV2{}.F6'
534
+ Visit_User_Code = 'PV2{}.F7'
535
+ Expected_Admit_DateTime = 'PV2{}.F8'
536
+ Expected_Discharge_DateTime = 'PV2{}.F9'
537
+ Estimated_Length_of_Inpatient_Stay = 'PV2{}.F10'
538
+ Visit_Description = 'PV2{}.F12'
539
+ Referral_Source_Code = 'PV2{}.F13'
540
+ Previous_Service_Date = 'PV2{}.F14'
541
+ Retention_Indicator = 'PV2{}.F19'
542
+ Previous_Treatment_Date = 'PV2{}.F26'
543
+ Military_Partnership_Code = 'PV2{}.F34' # indicates that a military healthcare facility has contracted with a non-military healthcare facility for the use of its services.
544
+ Military_NonAvailability_Code = 'PV2{}.F35' # N - the patient does not have permissions to use a non-military healthcare facility
545
+ Mode_of_Arrival = 'PV2{}.F38'
546
+ Admission_Level_of_Care_Text = 'PV2{}.F40.R1.C2'
547
+ Patient_Condition_Code = 'PV2{}.F42'
548
+
549
+ @staticmethod
550
+ def get_segment_name() -> str:
551
+ return 'PV2'
552
+
553
+ @staticmethod
554
+ def get_segment_title() -> str:
555
+ return 'Patient Visit Part 2'
556
+
557
+
558
+ class Al1Segment(Enum):
559
+ """Patient Allergy Information"""
560
+ Set_ID = 'AL1{}.F1'
561
+ Allergen_Type_Code_Identifier = 'AL1{}.F2.R1.C1'
562
+ Allergen_Type_Code_Name_of_Coding_System = 'AL1{}.F2.R1.C2'
563
+ Allergen_Type_Code_Text = 'AL1{}.F2.R1.C3'
564
+ Allergen_Type_Code_Alternate_Identifier = 'AL1{}.F2.R1.C4'
565
+ Allergen_Type_Code_Alternate_Text = 'AL1{}.F2.R1.C5'
566
+ Allergen_Type_Code_Name_of_Alternate_Coding_System = 'AL1{}.F2.R1.C6'
567
+
568
+ Allergen_Code_Mnemonic_Desc_Identifier = 'AL1{}.F3.R1.C1'
569
+ Allergen_Code_Mnemonic_Desc_Text = 'AL1{}.F3.R1.C2'
570
+ Allergen_Code_Mnemonic_Desc_Name_of_Coding_System = 'AL1{}.F3.R1.C3'
571
+ Allergen_Code_Mnemonic_Desc_Alternate_Identifier = 'AL1{}.F3.R1.C4'
572
+ Allergen_Code_Mnemonic_Desc_Alternate_Text = 'AL1{}.F3.R1.C5'
573
+ Allergen_Code_Mnemonic_Desc_Name_of_Alternate_Coding_System = 'AL1{}.F3.R1.C6'
574
+ Allergy_Reaction_Code = 'AL1{}.F5'
575
+ Identification_Date = 'AL1{}.F6'
576
+
577
+ @staticmethod
578
+ def get_segment_name() -> str:
579
+ return 'AL1'
580
+
581
+ @staticmethod
582
+ def get_segment_title() -> str:
583
+ return 'Patient Allergy'
584
+
585
+
586
+ class Dg1Segment(Enum):
587
+ Set_ID = 'DG1{}.F1'
588
+ Diagnosis_Coding_Method = 'DG1{}.F2'
589
+ Diagnosis_Code_ID = 'DG1{}.F3.R1.C1'
590
+ Diagnosis_Code_Desc = 'DG1{}.F3.R1.C2'
591
+ Diagnosis_Code_Code_System = 'DG1{}.F3.R1.C3'
592
+ Diagnosis_Description = 'DG1{}.F4'
593
+ # Diagnosis_Date_Time
594
+ Diagnosis_Type = 'DG1{}.F6'
595
+
596
+ # Major_Diagnostic_Category
597
+ # Diagnostic_Related_Group
598
+ # DRG_Approval_Indicator
599
+ # DRG_Grouper_Review_Code
600
+ # Outlier_Type
601
+ # Outlier_Days
602
+ # Outlier_Cost
603
+ # Grouper_Version_And_Type
604
+ # Diagnosis_Priority
605
+ # Diagnosing_Clinician
606
+ # Diagnosis_Classification
607
+ # Confidential_Indicator
608
+ # Attestation_Date_Time
609
+ # Diagnosis_Identifier
610
+ # Diagnosis_Action_Code
611
+
612
+ @staticmethod
613
+ def get_segment_name() -> str:
614
+ return 'DG1'
615
+
616
+ @staticmethod
617
+ def get_segment_title() -> str:
618
+ return 'Diagnosis'
619
+
620
+
621
+ class Pr1Segment(Enum):
622
+ """Procedures"""
623
+ Set_ID = 'PR1{}.F1'
624
+ Procedure_Coding_Method = 'PR1{}.F2'
625
+ Procedure_Code_Identifier = 'PR1{}.F3.R1.C1'
626
+ Procedure_Code_Text = 'PR1{}.F3.R1.C2'
627
+ Procedure_Code_Name_of_Coding_System = 'PR1{}.F3.R1.C3'
628
+ Procedure_Code_Alternate_Identifier = 'PR1{}.F3.R1.C4'
629
+ Procedure_Code_Alternate_Text = 'PR1{}.F3.R1.C5'
630
+ Procedure_Code_Name_of_Alternate_Coding_System = 'PR1{}.F3.R1.C6'
631
+ Procedure_Description = 'PR1{}.F4'
632
+ Procedure_Time = 'PR1{}.F5.R1.C1'
633
+ Procedure_Functional_Type = 'PR1{}.F6'
634
+ Procedure_Minutes = 'PR1{}.F7'
635
+ Anesthesiologist_ID_Number = 'PR1{}.F8.R1.C1'
636
+ Anesthesiologist_Family_Name = 'PR1{}.F8.R1.C2'
637
+ Anesthesiologist_Given_Name = 'PR1{}.F8.R1.C3'
638
+ Anesthesiologist_Middle_Initial = 'PR1{}.F8.R1.C4'
639
+ Anesthesiologist_Suffix = 'PR1{}.F8.R1.C5'
640
+ Anesthesiologist_Prefix = 'PR1{}.F8.R1.C6'
641
+ Anesthesiologist_Source_Table = 'PR1{}.F8.R1.C8'
642
+ Anesthesiologist_Assigning_Authority = 'PR1{}.F8.R1.C9'
643
+ Anesthesiologist_Name_Type_Code = 'PR1{}.F8.R1.C10'
644
+ Anesthesiologist_Identifier_Check_Digit = 'PR1{}.F8.R1.C11'
645
+ Anesthesiologist_Check_Digit_Scheme = 'PR1{}.F8.R1.C12'
646
+ Anesthesiologist_Identifier_Type_Code = 'PR1{}.F8.R1.C13'
647
+ Anesthesiologist_Assigning_Facility = 'PR1{}.F8.R1.C14'
648
+ Anesthesiologist_Name_Representation_Code = 'PR1{}.F8.R1.C15'
649
+ Anesthesiologist_Name_Context = 'PR1{}.F8.R1.C16'
650
+ Anesthesiologist_Name_Assembly_Order = 'PR1{}.F8.R1.C18'
651
+ Anesthesiologist_Effective_Date = 'PR1{}.F8.R1.C19'
652
+ Anesthesiologist_Expiration_Date = 'PR1{}.F8.R1.C20'
653
+ Anesthesiologist_Professional_Suffix = 'PR1{}.F8.R1.C21'
654
+ Anesthesiologist_Assigning_Jurisdiction = 'PR1{}.F8.R1.C22'
655
+ Anesthesiologist_Assigning_Agency_or_Dept = 'PR1{}.F8.R1.C23'
656
+ Anesthesia_Code = 'PR1{}.F9'
657
+ Anesthesia_Minutes = 'PR1{}.F10'
658
+ Surgeon_ID_Number = 'PR1{}.F11.R1.C1'
659
+ Surgeon_Family_Name = 'PR1{}.F11.R1.C2'
660
+ Surgeon_Given_Name = 'PR1{}.F1.R1.C3'
661
+ Surgeon_Middle_Initial = 'PR1{}.F11.R1.C4'
662
+ Surgeon_Suffix = 'PR1{}.F11.R1.C5'
663
+ Surgeon_Prefix = 'PR1{}.F11.R1.C6'
664
+ Surgeon_Source_Table = 'PR1{}.F11.R1.C8'
665
+ Surgeon_Assigning_Authority = 'PR1{}.F11.R1.C9'
666
+ Surgeon_Name_Type_Code = 'PR1{}.F11.R1.C10'
667
+ Surgeon_Identifier_Check_Digit = 'PR1{}.F11.R1.C11'
668
+ Surgeon_Check_Digit_Scheme = 'PR1{}.F11.R1.C12'
669
+ Surgeon_Identifier_Type_Code = 'PR1{}.F11.R1.C13'
670
+ Surgeon_Assigning_Facility = 'PR1{}.F11.R1.C14'
671
+ Surgeon_Name_Representation_Code = 'PR1{}.F11.R1.C15'
672
+ Surgeon_Name_Context = 'PR1{}.F11.R1.C16'
673
+ Surgeon_Name_Assembly_Order = 'PR1{}.F11.R1.C18'
674
+ Surgeon_Effective_Date = 'PR1{}.F11.R1.C19'
675
+ Surgeon_Expiration_Date = 'PR1{}.F11.R1.C20'
676
+ Surgeon_Professional_Suffix = 'PR1{}.F11.R1.C21'
677
+ Surgeon_Assigning_Jurisdiction = 'PR1{}.F11.R1.C22'
678
+ Surgeon_Assigning_Agency_or_Dept = 'PR1{}.F11.R1.C23'
679
+ Procedure_Practitioner_ID_Number = 'PR1{}.F12.R1.C1'
680
+ Procedure_Practitioner_Family_Name = 'PR1{}.F12.R1.C2'
681
+ Procedure_Practitioner_Given_Name = 'PR1{}.F12.R1.C3'
682
+ Procedure_Practitioner_Middle_Initial = 'PR1{}.F12.R1.C4'
683
+ Procedure_Practitioner_Suffix = 'PR1{}.F12.R1.C5'
684
+ Procedure_Practitioner_Prefix = 'PR1{}.F12.R1.C6'
685
+ Procedure_Practitioner_Source_Table = 'PR1{}.F12.R1.C8'
686
+ Procedure_Practitioner_Assigning_Authority = 'PR1{}.F12.R1.C9'
687
+ Procedure_Practitioner_Name_Type_Code = 'PR1{}.F12.R1.C10'
688
+ Procedure_Practitioner_Identifier_Check_Digit = 'PR1{}.F12.R1.C11'
689
+ Procedure_Practitioner_Check_Digit_Scheme = 'PR1{}.F12.R1.C12'
690
+ Procedure_Practitioner_Identifier_Type_Code = 'PR1{}.F12.R1.C13'
691
+ Procedure_Practitioner_Assigning_Facility = 'PR1{}.F12.R1.C14'
692
+ Procedure_Practitioner_Name_Representation_Code = 'PR1{}.F12.R1.C15'
693
+ Procedure_Practitioner_Name_Context = 'PR1{}.F12.R1.C16'
694
+ Procedure_Practitioner_Name_Assembly_Order = 'PR1{}.F12.R1.C18'
695
+ Procedure_Practitioner_Effective_Date = 'PR1{}.F12.R1.C19'
696
+ Procedure_Practitioner_Expiration_Date = 'PR1{}.F12.R1.C20'
697
+ Procedure_Practitioner_Professional_Suffix = 'PR1{}.F12.R1.C21'
698
+ Procedure_Practitioner_Assigning_Jurisdiction = 'PR1{}.F12.R1.C22'
699
+ Procedure_Practitioner_Assigning_Agency_or_Dept = 'PR1{}.F12.R1.C23'
700
+ Consent_Code_Identifier = 'PR1{}.F13.R1.C1'
701
+ Consent_Code_Text = 'PR1{}.F13.R1.C2'
702
+ Consent_Code_Name_of_Coding_System = 'PR1{}.F13.R1.C3'
703
+ Consent_Code_Alternate_Identifier = 'PR1{}.F13.R1.C4'
704
+ Consent_Code_Alternate_Text = 'PR1{}.F13.R1.C5'
705
+ Consent_Code_Name_of_Alternate_Coding_System = 'PR1{}.F13.R1.C6'
706
+ Procedure_Priority = 'PR1{}.F14'
707
+ Associated_Diag_Code_Identifier = 'PR1{}.F15.R1.C1'
708
+ Associated_Diag_Code_Text = 'PR1{}.F15.R1.C2'
709
+ Associated_Diag_Code_Name_of_Coding_System = 'PR1{}.F15.R1.C3'
710
+ Associated_Diag_Code_Alternate_Identifier = 'PR1{}.F15.R1.C4'
711
+ Associated_Diag_Code_Alternate_Text = 'PR1{}.F15.R1.C5'
712
+ Associated_Diag_Code_Name_of_Alternate_Coding_System = 'PR1{}.F15.R1.C6'
713
+ Proc_Code_Mod_Identifier = 'PR1{}.F16.R1.C1'
714
+ Proc_Code_Mod_Text = 'PR1{}.F16.R1.C2'
715
+ Proc_Code_Mod_Name_of_Coding_System = 'PR1{}.F16.R1.C3'
716
+ Proc_Code_Mod_Alternate_Identifier = 'PR1{}.F16.R1.C4'
717
+ Proc_Code_Mod_Alternate_Text = 'PR1{}.F16.R1.C5'
718
+ Proc_Code_Mod_Name_of_Alternate_Coding_System = 'PR1{}.F16.R1.C6'
719
+ Procedure_DRG_Type = 'PR1{}.F17'
720
+ Tissue_Type_Code_Identifier = 'PR1{}.F18.R1.C1'
721
+ Tissue_Type_Code_Text = 'PR1{}.F18.R1.C2'
722
+ Tissue_Type_Code_Name_of_Coding_System = 'PR1{}.F18.R1.C3'
723
+ Tissue_Type_Code_Alternate_Identifier = 'PR1{}.F18.R1.C4'
724
+ Tissue_Type_Code_Alternate_Text = 'PR1{}.F18.R1.C5'
725
+ Tissue_Type_Code_Name_of_Alternate_Coding_System = 'PR1{}.F18.R1.C6'
726
+ Procedure_Identifier_Entity_Identifier = 'PR1{}.F19.R1.C1'
727
+ Procedure_Identifier_Namespace_ID = 'PR1{}.F19.R1.C2'
728
+ Procedure_Identifier_Universal_ID = 'PR1{}.F19.R1.C3'
729
+ Procedure_Identifier_Universal_ID_Type = 'PR1{}.F19.R1.C4'
730
+ Procedure_Action_Code = 'PR1{}.F20'
731
+
732
+ @staticmethod
733
+ def get_segment_name() -> str:
734
+ return 'PR1'
735
+
736
+ @staticmethod
737
+ def get_segment_title() -> str:
738
+ return 'Procedures'
739
+
740
+
741
+ class In1Segment(Enum):
742
+ """Insurance Company Info"""
743
+ Set_ID = 'IN1{}.F1'
744
+ Health_Plan_ID = 'IN1{}.F2.R1.C1'
745
+ Health_Plan_Text = 'IN1{}.F2.R1.C2'
746
+ Health_Plan_Coding = 'IN1{}.F2.R1.C3'
747
+ Health_Plan_Alt_ID = 'IN1{}.F2.R1.C4'
748
+ Health_Plan_Alt_Text = 'IN1{}.F2.R1.C5'
749
+ Health_Plan_Alt_Coding = 'IN1{}.F2.R1.C6'
750
+ Health_Plan_Coding_System_Version = 'IN1{}.F2.R1.C7'
751
+ Health_Plan_Alt_Coding_System_Version = 'IN1{}.F2.R1.C8'
752
+ Original_Text = 'IN1{}.F2.R1.C9'
753
+
754
+ Insurance_Company_ID_Number = 'IN1{}.F3.R1.C1'
755
+ Insurance_Company_ID_Assigning_Facility = 'IN1{}.F3.R1.C6'
756
+ Insurance_Company_ID_Effective_Date = 'IN1{}.F3.R1.C7'
757
+ Insurance_Company_ID_Expiration_Date = 'IN1{}.F3.R1.C8'
758
+ Insurance_Company_ID_Assigning_Jurisdiction = 'IN1{}.F3.R1.C9'
759
+
760
+ Insurance_Company_Organization_Name = 'IN1{}.F4.R1.C1'
761
+ Insurance_Company_Organization_Name_Code = 'IN1{}.F4.R1.C2'
762
+
763
+ Insurance_Company_Street_Address = 'IN1{}.F5.R1.C1'
764
+ Insurance_Company_Other_Designation = 'IN1{}.F5.R1.C2'
765
+ Insurance_Company_City = 'IN1{}.F5.R1.C3'
766
+ Insurance_Company_State_or_Province = 'IN1{}.F5.R1.C4'
767
+ Insurance_Company_Zip_or_Postal_Code = 'IN1{}.F5.R1.C5'
768
+ Insurance_Company_Country = 'IN1{}.F5.R1.C6'
769
+ Insurance_Company_Address_Type = 'IN1{}.F5.R1.C7'
770
+
771
+ Insurance_Company_Phone_Number_Area_Code = 'IN1{}.F7.R1.C6'
772
+ Insurance_Company_Phone_Number_Local_Number = 'IN1{}.F7.R1.C7'
773
+ Insurance_Company_Phone_Number_Ext = 'IN1{}.F7.R1.C8'
774
+ Insurance_Company_Phone_Number_Any_Text = 'IN1{}.F7.R1.C9'
775
+ Insurance_Company_Phone_Number_Ext_Prefix = 'IN1{}.F7.R1.C10'
776
+ Insurance_Company_Phone_Number_Unformatted = 'IN1{}.F7.R1.C12'
777
+
778
+ Group_Number = 'IN1{}.F8'
779
+ Group_Name = 'IN1{}.F9'
780
+ Insured_Group_Emp_ID_Number = 'IN1{}.F10.R1.C1'
781
+ Insured_Group_Emp_Name = 'IN1{}.F11.R1.C1'
782
+ Plan_Effective_Date = 'IN1{}.F12'
783
+ Plan_Expiration_Date = 'IN1{}.F13'
784
+
785
+ Name_of_Insured_Family_Name = 'IN1{}.F16.R1.C1.S1'
786
+ Name_of_Insured_Family_Name_Surname = 'IN1{}.F16.R1.C1.S2'
787
+ Name_of_Insured_Family_Own_Surname_Prefix = 'IN1{}.F16.R1.C1.S3'
788
+ Name_of_Insured_Given_Name = 'IN1{}.F16.R1.C2'
789
+ Name_of_Insured_Other_Given_Names = 'IN1{}.F16.R1.C3'
790
+ Name_of_Insured_Suffix = 'IN1{}.F16.R1.C4'
791
+ Name_of_Insured_Prefix = 'IN1{}.F16.R1.C5'
792
+
793
+ Policy_Number = 'IN1{}.F36'
794
+ Coverage_Type = 'IN1{}.F47'
795
+ Subscriber_ID = 'IN1{}.F49'
796
+
797
+ @staticmethod
798
+ def get_segment_name() -> str:
799
+ return 'IN1'
800
+
801
+ @staticmethod
802
+ def get_segment_title() -> str:
803
+ return 'Insurance Company Info'
804
+
805
+
806
+ class In2Segment(Enum):
807
+ """Additional Insurance Info"""
808
+ Insureds_Employee_ID = 'IN2{}.F1'
809
+ Insureds_Social_Security_Number = 'IN2{}.F2'
810
+ Insureds_Employers_Name_and_ID = 'IN2{}.F3'
811
+ Employer_Information_Data = 'IN2{}.F4'
812
+ Medicare_Health_Ins_Card_Number = 'IN2{}.F6'
813
+ Non_Covered_Insurance_Code = 'IN2{}.F24'
814
+
815
+ @staticmethod
816
+ def get_segment_name() -> str:
817
+ return 'IN2'
818
+
819
+ @staticmethod
820
+ def get_segment_title() -> str:
821
+ return 'Insurance Company Additional Info'
822
+
823
+
824
+ class NteSegment(Enum):
825
+ Set_ID = 'NTE{}.F1'
826
+ Source_Of_Comment = 'NTE{}.F2'
827
+ Comment = 'NTE{}.F3'
828
+ Comment_Type = 'NTE{}.F4'
829
+
830
+ @staticmethod
831
+ def get_segment_name() -> str:
832
+ return 'NTE'
833
+
834
+ @staticmethod
835
+ def get_segment_title() -> str:
836
+ return 'Note'
837
+
838
+
839
+ class OvrSegment(Enum):
840
+ """Business Rule Overide"""
841
+ BRO_Type_ID = 'OVR{}.F1.R1.C1'
842
+ BRO_Type_Text = 'OVR{}.F1.R1.C2'
843
+ BRO_Type_Name_of_Coding_System = 'OVR{}.F1.R1.C3'
844
+ BRO_Type_Alt_ID = 'OVR{}.F1.R1.C4'
845
+ BRO_Type_Alt_Text = 'OVR{}.F1.R1.C5'
846
+ BRO_Type_Alt_Name_of_Coding_System = 'OVR{}.F1.R1.C6'
847
+ BRO_Type_Coding_System_Version = 'OVR{}.F1.R1.C7'
848
+ BRO_Type_Coding_System_Version_Alt = 'OVR{}.F1.R1.C8'
849
+ BRO_Type_Original_Text = 'OVR{}.F1.R1.C9'
850
+ BRO_Code_ID = 'OVR{}.21.R1.C1'
851
+ BRO_Code_Text = 'OVR{}.F2.R1.C2'
852
+ BRO_Code_Name_of_Coding_System = 'OVR{}.F2.R1.C3'
853
+ BRO_Code_Alt_ID = 'OVR{}.F2.R1.C4'
854
+ BRO_Code_Alt_Text = 'OVR{}.F2.R1.C5'
855
+ BRO_Code_Alt_Name_of_Coding_System = 'OVR{}.F2.R1.C6'
856
+ BRO_Code_Coding_System_Version = 'OVR{}.F2.R1.C7'
857
+ BRO_Code_Coding_System_Version_Alt = 'OVR{}.F2.R1.C8'
858
+ BRO_Code_Original_Text = 'OVR{}.F2.R1.C9'
859
+ Override_Comments = 'OVR{}.F3'
860
+
861
+ @staticmethod
862
+ def get_segment_name() -> str:
863
+ return 'OVR'
864
+
865
+ @staticmethod
866
+ def get_segment_title() -> str:
867
+ return 'Business Rule Override'
868
+
869
+
870
+ class Gt1Segment(Enum):
871
+ """Guarantor Segment"""
872
+ Guarantor_Name = 'GT1{}.F3'
873
+
874
+ @staticmethod
875
+ def get_segment_name() -> str:
876
+ return 'GT1'
877
+
878
+ @staticmethod
879
+ def get_segment_title() -> str:
880
+ return 'Guarantor'
881
+
882
+
883
+ class Rf1Segment(Enum):
884
+ """Referral Information Segment"""
885
+ Process_Date = 'RF1{}.F9'
886
+
887
+ @staticmethod
888
+ def get_segment_name() -> str:
889
+ return 'RF1'
890
+
891
+ @staticmethod
892
+ def get_segment_title() -> str:
893
+ return 'Referral Information'
894
+
895
+
896
+ class IvcSegment(Enum):
897
+ Provider_Tax_Id = 'IVC{}.F26'
898
+
899
+ @staticmethod
900
+ def get_segment_name() -> str:
901
+ return 'IVC'
902
+
903
+ @staticmethod
904
+ def get_segment_title() -> str:
905
+ return 'Invoice'
906
+
907
+
908
+ class OruSegment(Enum):
909
+ Set_ID = 'ORU.F1'
910
+
911
+ @staticmethod
912
+ def get_segment_name() -> str:
913
+ return 'ORU'
914
+
915
+ @staticmethod
916
+ def get_segment_title() -> str:
917
+ return 'ORU'
918
+
919
+
920
+ class OrnSegment(Enum):
921
+ Set_ID = 'ORN.F1'
922
+
923
+ @staticmethod
924
+ def get_segment_name() -> str:
925
+ return 'ORN'
926
+
927
+ @staticmethod
928
+ def get_segment_title() -> str:
929
+ return 'ORN'
930
+
931
+
932
+ class ZonSegment(Enum):
933
+ Zon_Flag = 'ZON.F1'
934
+
935
+ @staticmethod
936
+ def get_segment_name() -> str:
937
+ return 'ZON'
938
+
939
+ @staticmethod
940
+ def get_segment_title() -> str:
941
+ return 'ZON'
942
 
943
  def parse_hl7(message):
944
  # Parse the HL7 message using the hl7 library
 
963
  # Define the Streamlit app
964
  def app():
965
  # Add a text input field for the HL7 message
966
+ hl7_message = st.text_area("Enter HL7 message here", value="MSH|^~\&|ANYSHARE^2.16.840.1.113883.1.2966.500.1.1.17.1.312.1|ABCCHHH|AnyCompanyHIE|ADX|20190408235621||ADT^A03|183000519^248647541|P|2.5.1\r")
967
 
968
  # Parse the HL7 message and display the labeled fields
969
  if hl7_message:
970
  parse_hl7(hl7_message)
971
 
972
+ # if __name__ == "__main__":
973
+
974
+
975
+ if __name__ == '__main__':
976
  app()
977
+ print(AdmitSource['PR'].value)
978
+ print(AdmitSource['HMO'].value)
979
+ for i in range(1, 10):
980
+ print(AdmitSource.get_value(str(i)))
981
+ print(AdmitSource.get_value('PR'))
982
+ print(AdmitSource.get_value('Emergency_Room'))