awacke1's picture
Update app.py
250dfd3
import streamlit as st
import hl7
import definitions
from enum import Enum
class AdtEvents(Enum):
"""ADT events for MSH segment"""
Patient_Admit = 'A01'
Patient_Transfer = 'A02'
Patient_Discharge = 'A03'
Patient_Registration = 'A04'
Patient_Pre_Admission = 'A05'
Patient_Information_Update = 'A08'
Cancel_Patient_Admit = 'A11'
Cancel_Patient_Transfer = 'A12'
Cancel_Patient_Discharge = 'A13'
Pending_Admit = 'A14'
Pending_Transfer = 'A15'
Pending_Discharge = 'A16'
def is_match(self, event) -> bool:
return self.value == event
@staticmethod
def get_label(event_type: str) -> str:
try:
enum_val = AdtEvents(event_type)
label = enum_val.name.replace('_', ' ')
except IndexError:
label = 'Unknown {}'.format(event_type)
return label
class DiagnosisType(Enum):
"""Diagnosis type for DG1 segment"""
A = "Admitting"
AD = 'admitting diagnosis'
BD = 'treating diagnosis'
ED = 'referral diagnosis'
EL = 'discharge/transfer diagnosis'
F = "Final"
ND = 'diagnosis'
NO = 'diagnosis operation'
NU = 'follow-up diagnosis that has justified the incapacity to work'
UD = 'referral diagnosis'
VO = 'preoperative diagnosis'
W = 'Waiting'
ZD = 'ZD'
class PatientClass(Enum):
E = 'EMERGENCY'
I = 'INPATIENT'
O = 'OUTPATIENT'
P = 'PREADMIT'
R = 'RECURRING PATIENT'
B = 'OBSTETRICS'
C = 'COMMERCIAL ACCOUNT'
N = 'NOT APPLICABLE'
U = 'UNKNOWN'
NO_MATCH = 'UNKNOWN'
class CleanPatientClass(Enum):
ER = 'E'
IP = 'I'
class PatientClassText(Enum):
EMERGENCY = 'E'
INPATIENT = 'I'
OUTPATIENT = 'O'
PREADMIT = 'P'
RECURRING_PATIENT = 'R'
OBSTETRICS = 'B'
COMMERCIAL_ACCOUNT = 'C'
NOT_APPLICABLE = 'N'
UNKNOWN = 'U'
class AdmitSource(Enum):
Physician_Referral = '1'
PR = '1'
Clinic_Referral = '2'
HMO_Referral = '3'
HMO = '3'
Transfer_From_Hospital = '4'
Transfer_From_Skilled_Nursing_Facility = '5'
SNF = '5'
Transfer_From_Another_Health_Care_Facility = '6'
Emergency_Room = '7'
ER = '7'
Court_or_Law_Enforcement = '8'
Information_Not_Available = '9'
Transfer_From_Critical_Access_Hospital = 'A'
Transfer_From_Another_Home_Health_Agency = 'B'
Readmission_to_Same_Home_Health_Agency = 'C'
Transfer_from_Hospital_Inpatient_In_Same_Facility = 'D'
@staticmethod
def get_value(attribute: str) -> str:
try:
return AdmitSource[attribute].value
except KeyError:
hl7tools_logger.warning("No match found for Admit Source '{}', returning 0.".format(attribute))
return '0'
class DiagnosisPriority(Enum):
"""Diagnosis priority for DG1 segment"""
DP_1 = '1 The primary diagnosis'
DP_1_1 = '1.1 main diagnosis (primary)'
DP_1_2 = '1.2 main diagnosis (secondary)'
class MshSegment(Enum):
"""Message Header"""
Sending_Application_Name = 'MSH{}.F3.R1.C1'
Sending_Application_Universal_ID = 'MSH{}.F3.R1.C2'
Sending_Application_Universal_ID_Type = 'MSH{}.F3.R1.C3'
Sending_Facility_Name = 'MSH{}.F4.R1.C1'
Sending_Facility_Universal_ID = 'MSH{}.F4.R1.C2'
Sending_Facility_Universal_ID_Type = 'MSH{}.F4.R1.C3'
Receiving_Application_Name = 'MSH{}.F5.R1.C1'
Receiving_Application_Universal_ID = 'MSH{}.F5.R1.C2'
Receiving_Application_Universal_ID_Type = 'MSH{}.F5.R1.C3'
Receiving_Facility_Name = 'MSH{}.F6.R1.C1'
Receiving_Facility_Universal_ID = 'MSH{}.F6.R1.C2'
Receiving_Facility_Universal_ID_Type = 'MSH{}.F6.R1.C3'
Msg_Timestamp = 'MSH{}.F7.R1.C1'
Security = 'MSH{}.F8'
Msg_Type = 'MSH{}.F9.R1.C1'
Msg_Trigger_Event = 'MSH{}.F9.R1.C2'
Msg_Structure_ID = 'MSH{}.F9.R1.C3'
Msg_control_ID = 'MSH{}.F10.R1.C1'
Processing_ID = 'MSH{}.F11.R1.C1'
Processing_Mode_ID = 'MSH{}.F11.R1.C2'
Version_ID = 'MSH{}.F12.R1.C1'
Version_Internationalization_Code = 'MSH{}.F12.R1.C2'
Version_Internationalization_Version = 'MSH{}.F12.R1.C3'
Sequence_Number = 'MSH{}.F13'
Accept_Ack_Type = 'MSH{}.F15'
Application_Ack_Type = 'MSH{}.F16'
Country_Code = 'MSH{}.F17'
Character_Set = 'MSH{}.F18'
ODX_Id = 'MSH{}.F21'
@staticmethod
def get_segment_name() -> str:
return 'MSH'
@staticmethod
def get_segment_title() -> str:
return 'Message Header'
class EvnSegment(Enum):
"""Event"""
Event_Type_Code = 'EVN{}.F1'
Recorded_Date_Time = 'EVN{}.F2.R1.C1'
Recorded_Date_Time_Degree_of_Precision = 'EVN{}.F2.R1.C2'
Date_Time_Planned_Event_Time = 'EVN{}.F3.R1.C1'
Date_Time_Planned_Degree_of_Precision = 'EVN{}.F3.R1.C2'
Event_Reason_Code = 'EVN{}.F4'
Operator_ID_Number = 'EVN{}.F5.R1.C1'
Operator_ID_Family_Name_Surname = 'EVN{}.F5.R1.C2.S1'
Operator_ID_Family_Name_Own_Surname_Prefix = 'EVN{}.F5.R1.C2.S2'
Operator_ID_Given_Name = 'EVN{}.F5.R1.C3'
Operator_ID_Middle_Initial = 'EVN{}.F5.R1.C4'
Operator_ID_Suffix = 'EVN{}.F5.R1.C5'
Operator_ID_Prefix = 'EVN{}.F5.R1.C6'
Operator_ID_Degree = 'EVN{}.F5.R1.C7'
Operator_ID_Source_Table = 'EVN{}.F5.R1.C8'
Operator_ID_Assigning_Authority = 'EVN{}.F5.R1.C9'
Operator_ID_Name_Type_Code = 'EVN{}.F5.R1.C10'
Operator_ID_Identifier_Check_Digit = 'EVN{}.F5.R1.C11'
Operator_ID_Check_Digit_Scheme = 'EVN{}.F5.R1.C12'
Operator_ID_Identifier_Type_Code = 'EVN{}.F5.R1.C13'
Operator_ID_Assigning_Facility = 'EVN{}.F5.R1.C14'
Operator_ID_Name_Representation_Code = 'EVN{}.F5.R1.C15'
Operator_ID_Name_Context = 'EVN{}.F5.R1.C16'
Operator_ID_Name_Validity_Range = 'EVN{}.F5.R1.C17'
Operator_ID_Name_Assembly_Order = 'EVN{}.F5.R1.C18'
Operator_ID_Effective_Date = 'EVN{}.F5.R1.C19'
Operator_ID_Expiration_Date = 'EVN{}.F5.R1.C20'
Operator_ID_Professional_Suffix = 'EVN{}.F5.R1.C21'
Operator_ID_Assigning_Jurisdiction = 'EVN{}.F5.R1.C22'
Operator_ID_Assigning_Agency_or_Department = 'EVN{}.F5.R1.C23'
Event_Occurred_Time = 'EVN{}.F6.R1.C1'
Event_Occurred_Degree_of_Precision = 'EVN{}.F6.R1.C2'
Event_Facility_Namespace_ID = 'EVN{}.F7.R1.C1'
Event_Facility_Universal_ID = 'EVN{}.F7.R1.C2'
Event_Facility_Universal_ID_Type = 'EVN{}.F7.R1.C3'
@staticmethod
def get_segment_name() -> str:
return 'EVN'
@staticmethod
def get_segment_title() -> str:
return 'Event'
class PidSegment(Enum):
"""Patient Identification"""
Patient_ID = 'PID{}.F2.R1.C1'
Patient_ID_Assigning_Auth = 'PID{}.F2.R1.C4'
Patient_ID_Type_Code = 'PID{}.F2.R1.C5'
Patient_ID_List = 'PID{}.F3.R1.C1'
Patient_ID_List_Assigning_Auth = 'PID{}.F3.R1.C4'
Patient_ID_List_Type_Code = 'PID{}.F3.R1.C5'
Patient_ID_Alt = 'PID{}.F4.R1.C1'
Patient_ID_Alt_Assigning_Auth = 'PID{}.F4.R1.C4'
Patient_ID_Alt_Type_Code = 'PID{}.F4.R1.C5'
Patient_Last_Name = 'PID{}.F5.R1.C1'
Patient_First_Name = 'PID{}.F5.R1.C2'
Patient_Middle_Name = 'PID{}.F5.R1.C3'
Patient_DOB = 'PID{}.F7'
Patient_Gender = 'PID{}.F8'
Patient_Address_Street_1 = 'PID{}.F11.R1.C1'
Patient_Address_Street_2 = 'PID{}.F11.R1.C2'
Patient_Address_City = 'PID{}.F11.R1.C3'
Patient_Address_State = 'PID{}.F11.R1.C4'
Patient_Address_Zip = 'PID{}.F11.R1.C5'
Patient_Phone_Number_Home = 'PID{}.F13.R1.C1'
Marital_Status = 'PID{}.F16'
Patient_Account_Number = 'PID{}.F18.R1.C1'
Patient_SSN = 'PID{}.F19'
@staticmethod
def get_segment_name() -> str:
return 'PID'
@staticmethod
def get_segment_title() -> str:
return 'Patient ID'
class Pd1Segment(Enum):
"""Patient Additional Demographic"""
Living_Dependency = 'PD1{}.F1'
Living_Arrangement = 'PD1{}.F2'
Patient_Primary_Facility_Org_Name = 'PD1{}.F3.R1.C1'
Patient_Primary_Facility_Org_Name_Type_Code = 'PD1{}.F3.R1.C2'
Patient_Primary_Facility_Org_ID_Number = 'PD1{}.F3.R1.C3'
Patient_Primary_Facility_Org_Check_Digit = 'PD1{}.F3.R1.C4'
Patient_Primary_Facility_Org_Check_Digit_Scheme = 'PD1{}.F3.R1.C5'
Patient_Primary_Facility_Org_Assigning_Authority = 'PD1{}.F3.R1.C6'
Patient_Primary_Facility_Org_Identifier_Type_Code = 'PD1{}.F3.R1.C7'
Patient_Primary_Facility_Org_Assigning_Facility = 'PD1{}.F3.R1.C8'
Patient_Primary_Facility_Org_Name_Representation_Code = 'PD1{}.F3.R1.C9'
Patient_Primary_Facility_Org_Name_Organization_Identifier = 'PD1{}.F3.R1.C10'
Patient_PCP_ID_Number = 'PD1{}.F4.R1.C1'
Patient_PCP_ID_Family_Name = 'PD1{}.F4.R1.C2'
Patient_PCP_ID_Given_Name = 'PD1{}.F4.R1.C3'
Patient_PCP_ID_Middle_Initial = 'PD1{}.F4.R1.C4'
Patient_PCP_ID_Suffix = 'PD1{}.F4.R1.C5'
Patient_PCP_ID_Prefix = 'PD1{}.F4.R1.C6'
Patient_PCP_ID_Degree = 'PD1{}.F4.R1.C7'
Patient_PCP_ID_Source_Table = 'PD1{}.F4.R1.C8'
Patient_PCP_ID_Assigning_Authority = 'PD1{}.F4.R1.C9'
Patient_PCP_ID_Name_Type_Code = 'PD1{}.F4.R1.C10'
Patient_PCP_ID_Identifier_Check_Digit = 'PD1{}.F4.R1.C11'
Patient_PCP_ID_Check_Digit_Scheme = 'PD1{}.F4.R1.C12'
Patient_PCP_ID_Identifier_Type_Code = 'PD1{}.F4.R1.C13'
Patient_PCP_ID_Assigning_Facility = 'PD1{}.F4.R1.C14'
Patient_PCP_ID_Name_Representation_Code = 'PD1{}.F4.R1.C15'
Patient_PCP_ID_Name_Context = 'PD1{}.F4.R1.C16'
Patient_PCP_ID_Name_Validity_Range = 'PD1{}.F4.R1.C17'
Patient_PCP_ID_Name_Assembly_Order = 'PD1{}.F4.R1.C18'
Patient_PCP_ID_Effective_Date = 'PD1{}.F4.R1.C19'
Patient_PCP_ID_Expiration_Date = 'PD1{}.F4.R1.C20'
Patient_PCP_ID_Professional_Suffix = 'PD1{}.F4.R1.C21'
Patient_PCP_ID_Assigning_Jurisdiction = 'PD1{}.F4.R1.C22'
Patient_PCP_ID_Assigning_Agency_or_Dept = 'PD1{}.F4.R1.C23'
Student_Indicator = 'PD1{}.F5'
Handicap = 'PD1{}.F6'
Living_Will_Code = 'PD1{}.F7'
Organ_Donor_Code = 'PD1{}.F8'
Separate_Bill = 'PD1{}.F9'
Duplicate_Patient_ID_Number = 'PD1{}.F10.R1.C1'
Duplicate_Patient_Check_Digit = 'PD1{}.F10.R1.C2'
Duplicate_Patient_Check_Digit_Scheme = 'PD1{}.F10.R1.C3'
Duplicate_Patient_Assigning_Authority = 'PD1{}.F10.R1.C4'
Duplicate_Patient_Identifier_Type_Code = 'PD1{}.F10.R1.C5'
Duplicate_Patient_Assigning_Facility = 'PD1{}.F10.R1.C6'
Duplicate_Patient_Effective_Date = 'PD1{}.F10.R1.C7'
Duplicate_Patient_Expiration_Date = 'PD1{}.F10.R1.C8'
Duplicate_Patient_Assigning_Jurisdiction = 'PD1{}.F10.R1.C9'
Duplicate_Patient_Assigning_Agency_or_Dept = 'PD1{}.F10.R1.C10'
Publicity_Code = 'PD1{}.F11'
Protection_Indicator = 'PD1{}.F12'
Protection_Indicator_Effective_Date = 'PD1{}.F13'
Place_of_Worship_Organization_Name = 'PD1{}.F14.R1.C1'
Place_of_Worship_Organization_Name_Type_Code = 'PD1{}.F14.R1.C2'
Place_of_Worship_ID_Number = 'PD1{}.F14.R1.C3'
Place_of_Worship_Check_Digit = 'PD1{}.F14.R1.C4'
Place_of_Worship_Check_Digit_Scheme = 'PD1{}.F14.R1.C5'
Place_of_Worship_Assigning_Authority = 'PD1{}.F14.R1.C6'
Place_of_Worship_Identifier_Type_Code = 'PD1{}.F14.R1.C7'
Place_of_Worship_Assigning_Facility = 'PD1{}.F14.R1.C8'
Place_of_Worship_Name_Representation_Code = 'PD1{}.F14.R1.C9'
Place_of_Worship_Organization_Identifier = 'PD1{}.F14.R1.C10'
Advance_Directive_Code_Identifier = 'PD1{}.F15.R1.C1'
Advance_Directive_Code_Text = 'PD1{}.F15.R1.C2'
Advance_Directive_Code_Name_of_Coding_System = 'PD1{}.F15.R1.C3'
Advance_Directive_Code_Alternate_Identifier = 'PD1{}.F15.R1.C4'
Advance_Directive_Code_Alternate_Text = 'PD1{}.F15.R1.C5'
Advance_Directive_Code_Name_of_Alternate_Coding_System = 'PD1{}.F15.R1.C6'
Immunization_Registry_Status = 'PD1{}.F16'
Immunization_Registry_Status_Effective_Date = 'PD1{}.F17'
Publicity_Code_Effective_Date = 'PD1{}.F18'
Military_Branch = 'PD1{}.F19'
Military_Rank_Grade = 'PD1{}.F20'
Military_Status = 'PD1{}.F21'
@staticmethod
def get_segment_name() -> str:
return 'PD1'
@staticmethod
def get_segment_title() -> str:
return 'Patient Additional Demographic'
class RolSegment(Enum):
Role_Instance_ID = 'ROL{}.F1'
Action_Code = 'ROL{}.F2'
Role_ROL = 'ROL{}.F3'
Role_Person = 'ROL{}.F4'
Role_Begin_Date_Time = 'ROL{}.F5'
Role_End_Date_Time = 'ROL{}.F6'
Role_Duration = 'ROL{}.F7'
Role_Action_Reason = 'ROL{}.F8'
Provider_Type = 'ROL{}.F9'
Organization_Unit_Type = 'ROL{}.F10'
Office_Home_Address_Birthplace = 'ROL{}.F11'
Phone = 'ROL{}.F12'
Persons_Location = 'ROL{}.F13'
Organization = 'ROL{}.F14'
@staticmethod
def get_segment_name() -> str:
return 'ROL'
@staticmethod
def get_segment_title() -> str:
return 'Role'
class Pv1Segment(Enum):
Set_ID = 'PV1{}.F1'
Patient_Class_ID = 'PV1{}.F2.R1.C1'
Patient_Class_Text = 'PV1{}.F2.R1.C2' # inpatient, outpatient, etc
Patient_Class_Name_of_Coding_System = 'PV1{}.F2.R1.C3'
Patient_Class_Alt_ID = 'PV1{}.F2.R1.C4'
Patient_Class_Alt_Text = 'PV1{}.F2.R1.C5'
Patient_Class_2nd_Alt_ID = 'PV1{}.F2.R1.C10'
Patient_Class_2nd_Alt_Text = 'PV1{}.F2.R1.C11'
Patient_Loc_Point_of_Care = 'PV1{}.F3.R1.C1'
Patient_Loc_Room = 'PV1{}.F3.R1.C2'
Patient_Loc_Bed = 'PV1{}.F3.R1.C3'
Patient_Loc_Facility = 'PV1{}.F3.R1.C4'
Patient_Loc_Location_Status = 'PV1{}.F3.R1.C5'
Patient_Loc_Assigning_Authority = 'PV1{}.F3.R1.C11'
Admission_Type_ID = 'PV1{}.F4.R1.C1'
Admission_Type_Text = 'PV1{}.F4.R1.C2'
Admission_Type_Alt_ID = 'PV1{}.F4.R1.C4'
Admission_Type_Alt_Text = 'PV1{}.F4.R1.C5'
Admission_Type_2nd_Alt_ID = 'PV1{}.F4.R1.C10'
Admission_Type_2nd_Alt_Text = 'PV1{}.F4.R1.C11'
Attending_Doctor = 'PV1{}.F7'
Attending_Doctor_Person_ID = 'PV1{}.F7.R1.C1'
Attending_Doctor_Family_Name = 'PV1{}.F7.R1.C2.S1'
Attending_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F7.R1.C2.S2'
Attending_Doctor_Given_Name = 'PV1{}.F7.R1.C3'
Attending_Doctor_Middle_Initial = 'PV1{}.F7.R1.C4'
Attending_Doctor_Suffix = 'PV1{}.F7.R1.C5'
Attending_Doctor_Prefix = 'PV1{}.F7.R1.C6'
Attending_Doctor_Degree = 'PV1{}.F7.R1.C7'
Attending_Doctor_Source_Table = 'PV1{}.F7.R1.C8'
Attending_Doctor_Assigning_Authority = 'PV1{}.F7.R1.C9'
Attending_Doctor_Name_Type_Code = 'PV1{}.F7.R1.C10'
Attending_Doctor_Identifier_Check_Digit = 'PV1{}.F7.R1.C11'
Attending_Doctor_Check_Digit_Scheme = 'PV1{}.F7.R1.C12'
Attending_Doctor_Identifier_Type_Code = 'PV1{}.F7.R1.C13'
Attending_Doctor_Assigning_Facility = 'PV1{}.F7.R1.C14'
Attending_Doctor_Name_Representation_Code = 'PV1{}.F7.R1.C15'
Attending_Doctor_Name_Context = 'PV1{}.F7.R1.C16'
Attending_Doctor_Name_Validity_Range = 'PV1{}.F7.R1.C17'
Attending_Doctor_Name_Assembly_Order = 'PV1{}.F7.R1.C18'
Attending_Doctor_Effective_Date = 'PV1{}.F7.R1.C19'
Attending_Doctor_Expiration_Date = 'PV1{}.F7.R1.C20'
Attending_Doctor_Professional_Suffix = 'PV1{}.F7.R1.C21'
Attending_Doctor_Assigning_Jurisdiction = 'PV1{}.F7.R1.C22'
Attending_Doctor_Assigning_Agency_or_Department = 'PV1{}.F7.R1.C23'
Referring_Doctor = 'PV1{}.F8'
Referring_Doctor_Person_ID = 'PV1{}.F8.R1.C1'
Referring_Doctor_Family_Name = 'PV1{}.F8.R1.C2.S1'
Referring_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F8.R1.C2.S2'
Referring_Doctor_Given_Name = 'PV1{}.F8.R1.C3'
Referring_Doctor_Middle_Initial = 'PV1{}.F8.R1.C4'
Referring_Doctor_Suffix = 'PV1{}.F8.R1.C5'
Referring_Doctor_Prefix = 'PV1{}.F8.R1.C6'
Referring_Doctor_Degree = 'PV1{}.F8.R1.C7'
Referring_Doctor_Source_Table = 'PV1{}.F8.R1.C8'
Referring_Doctor_Assigning_Authority = 'PV1{}.F8.R1.C9'
Referring_Doctor_Name_Type_Code = 'PV1{}.F8.R1.C10'
Referring_Doctor_Identifier_Check_Digit = 'PV1{}.F8.R1.C11'
Referring_Doctor_Check_Digit_Scheme = 'PV1{}.F8.R1.C12'
Referring_Doctor_Identifier_Type_Code = 'PV1{}.F8.R1.C13'
Referring_Doctor_Assigning_Facility = 'PV1{}.F8.R1.C14'
Referring_Doctor_Name_Representation_Code = 'PV1{}.F8.R1.C15'
Referring_Doctor_Name_Context = 'PV1{}.F8.R1.C16'
Referring_Doctor_Name_Validity_Range = 'PV1{}.F8.R1.C17'
Referring_Doctor_Name_Assembly_Order = 'PV1{}.F8.R1.C18'
Referring_Doctor_Effective_Date = 'PV1{}.F8.R1.C19'
Referring_Doctor_Expiration_Date = 'PV1{}.F8.R1.C20'
Referring_Doctor_Professional_Suffix = 'PV1{}.F8.R1.C21'
Referring_Doctor_Assigning_Jurisdiction = 'PV1{}.F8.R1.C22'
Referring_Doctor_Assigning_Agency_or_Department = 'PV1{}.F8.R1.C23'
Consulting_Doctor = 'PV1{}.F9'
Consulting_Doctor_Person_ID = 'PV1{}.F9.R1.C1'
Consulting_Doctor_Family_Name = 'PV1{}.F9.R1.C2.S1'
Consulting_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F9.R1.C2.S2'
Consulting_Doctor_Given_Name = 'PV1{}.F9.R1.C3'
Consulting_Doctor_Middle_Initial = 'PV1{}.F9.R1.C4'
Consulting_Doctor_Suffix = 'PV1{}.F9.R1.C5'
Consulting_Doctor_Prefix = 'PV1{}.F9.R1.C6'
Consulting_Doctor_Degree = 'PV1{}.F9.R1.C7'
Consulting_Doctor_Source_Table = 'PV1{}.F9.R1.C8'
Consulting_Doctor_Assigning_Authority = 'PV1{}.F9.R1.C9'
Consulting_Doctor_Name_Type_Code = 'PV1{}.F9.R1.C10'
Consulting_Doctor_Identifier_Check_Digit = 'PV1{}.F9.R1.C11'
Consulting_Doctor_Check_Digit_Scheme = 'PV1{}.F9.R1.C12'
Consulting_Doctor_Identifier_Type_Code = 'PV1{}.F9.R1.C13'
Consulting_Doctor_Assigning_Facility = 'PV1{}.F9.R1.C14'
Consulting_Doctor_Name_Representation_Code = 'PV1{}.F9.R1.C15'
Consulting_Doctor_Name_Context = 'PV1{}.F9.R1.C16'
Consulting_Doctor_Name_Validity_Range = 'PV1{}.F9.R1.C17'
Consulting_Doctor_Name_Assembly_Order = 'PV1{}.F9.R1.C18'
Consulting_Doctor_Effective_Date = 'PV1{}.F9.R1.C19'
Consulting_Doctor_Expiration_Date = 'PV1{}.F9.R1.C20'
Consulting_Doctor_Professional_Suffix = 'PV1{}.F9.R1.C21'
Consulting_Doctor_Assigning_Jurisdiction = 'PV1{}.F9.R1.C22'
Consulting_Doctor_Assigning_Agency_or_Department = 'PV1{}.F9.R1.C23'
Hospital_Service = 'PV1{}.F10'
Hospital_Service_Identifier = 'PV1{}.F10.R1.C1'
Hospital_Service_Text = 'PV1{}.F10.R1.C2'
Readmission_Indicator = 'PV1{}.F13'
Admit_Source = 'PV1{}.F14'
Admit_Source_ID = 'PV1{}.F14.R1.C1'
Admit_Source_Text = 'PV1{}.F14.R1.C2'
Admitting_Doctor = 'PV1{}.F17'
Admitting_Doctor_Person_ID = 'PV1{}.F17.R1.C1'
Admitting_Doctor_Family_Name = 'PV1{}.F17.R1.C2.S1'
Admitting_Doctor_Family_Name_Own_Surname_Prefix = 'PV1{}.F17.R1.C2.S2'
Admitting_Doctor_Given_Name = 'PV1{}.F17.R1.C3'
Admitting_Doctor_Middle_Initial = 'PV1{}.F17.R1.C4'
Admitting_Doctor_Suffix = 'PV1{}.F17.R1.C5'
Admitting_Doctor_Prefix = 'PV1{}.F17.R1.C6'
Admitting_Doctor_Degree = 'PV1{}.F17.R1.C7'
Admitting_Doctor_Source_Table = 'PV1{}.F17.R1.C8'
Admitting_Doctor_Assigning_Authority = 'PV1{}.F17.R1.C9'
Admitting_Doctor_Name_Type_Code = 'PV1{}.F17.R1.C10'
Admitting_Doctor_Identifier_Check_Digit = 'PV1{}.F17.R1.C11'
Admitting_Doctor_Check_Digit_Scheme = 'PV1{}.F17.R1.C12'
Admitting_Doctor_Identifier_Type_Code = 'PV1{}.F17.R1.C13'
Admitting_Doctor_Assigning_Facility = 'PV1{}.F17.R1.C14'
Admitting_Doctor_Name_Representation_Code = 'PV1{}.F17.R1.C15'
Admitting_Doctor_Name_Context = 'PV1{}.F17.R1.C16'
Admitting_Doctor_Name_Validity_Range = 'PV1{}.F17.R1.C17'
Admitting_Doctor_Name_Assembly_Order = 'PV1{}.F17.R1.C18'
Admitting_Doctor_Effective_Date = 'PV1{}.F17.R1.C19'
Admitting_Doctor_Expiration_Date = 'PV1{}.F17.R1.C20'
Admitting_Doctor_Professional_Suffix = 'PV1{}.F17.R1.C21'
Admitting_Doctor_Assigning_Jurisdiction = 'PV1{}.F17.R1.C22'
Admitting_Doctor_Assigning_Agency_or_Department = 'PV1{}.F17.R1.C23'
Patient_Type_ID = 'PV1{}.F18.R1.C1'
Patient_Type_Text = 'PV1{}.F18.R1.C2'
Patient_Type_Alt_ID = 'PV1{}.F18.R1.C4'
Patient_Type_Alt_Text = 'PV1{}.F18.R1.C5'
Visit_Number = 'PV1{}.F19.R1.C1'
Discharge_Disposition = 'PV1{}.F36.R1.C1'
Discharge_Disposition_Text = 'PV1{}.F36.R1.C2'
Discharge_Disposition_Coding = 'PV1{}.F36.R1.C3'
Discharge_Disposition_Alt = 'PV1{}.F36.R1.C4'
Discharge_Disposition_Text_Alt = 'PV1{}.F36.R1.C5'
Discharge_Disposition_Coding_Alt = 'PV1{}.F36.R1.C6'
Discharge_Disposition_Original_Text = 'PV1{}.F36.R1.C9'
Discharge_Disposition_Alt2 = 'PV1{}.F36.R1.C10'
Discharge_Disposition_Text_Alt2 = 'PV1{}.F36.R1.C11'
Discharge_Disposition_Coding_Alt2 = 'PV1{}.F36.R1.C12'
Discharge_to_Location = 'PV1{}.F37'
# Some records come in with Servicing Facility as a multi-part field.
# First part might be NPI. The next could be facility name.
Servicing_Facility = 'PV1{}.F39'
Servicing_Facility_Name = 'PV1{}.F39.R1.C2'
Admit_Date_Time = 'PV1{}.F44'
Discharge_Date_Time = 'PV1{}.F45'
Current_Patient_Balance = 'PV1{}.F45'
Total_Charges = 'PV1{}.F47'
Visit_Ind = 'PV1{}.F51'
Other_HealthCare_Provider = 'PV1{}.F52'
Service_Episode_Description = 'PV1{}.F53'
@staticmethod
def get_segment_name() -> str:
return 'PV1'
@staticmethod
def get_segment_title() -> str:
return 'Patient Visit'
# PV2||Routine|^Medicine Refill|||||||||103|||||||||n|N||||||||||N||||||Public Trans
class Pv2Segment(Enum):
Prior_Pending_Location = 'PV2{}.F1'
Prior_Pending_Location_Point_of_Care = 'PV2{}.F1.R1.C1'
Prior_Pending_Location_Room = 'PV2{}.F1.R1.C2'
Prior_Pending_Location_Bed = 'PV2{}.F1.R1.C3'
Prior_Pending_Location_Facility = 'PV2{}.F1.R1.C4'
Prior_Pending_Location_Location_Status = 'PV2{}.F1.R1.C5'
Accommodation_Code = 'PV2{}.F2'
Admit_Reason = 'PV2{}.F3'
Transfer_Reason_ID = 'PV2{}.F4.R1.C1'
Transfer_Reason_Text = 'PV2{}.F4.R1.C2'
Transfer_Reason_Alt_ID = 'PV2{}.F4.R1.C4'
Transfer_Reason_Alt_Text = 'PV2{}.F4.R1.C5'
Transfer_Reason_2nd_Alt_ID = 'PV2{}.F4.R1.C10'
Transfer_Reason_2nd_Alt_Text = 'PV2{}.F4.R1.C11'
Patient_Valuables = 'PV2{}.F5'
Patient_Valuables_Location = 'PV2{}.F6'
Visit_User_Code = 'PV2{}.F7'
Expected_Admit_DateTime = 'PV2{}.F8'
Expected_Discharge_DateTime = 'PV2{}.F9'
Estimated_Length_of_Inpatient_Stay = 'PV2{}.F10'
Visit_Description = 'PV2{}.F12'
Referral_Source_Code = 'PV2{}.F13'
Previous_Service_Date = 'PV2{}.F14'
Retention_Indicator = 'PV2{}.F19'
Previous_Treatment_Date = 'PV2{}.F26'
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.
Military_NonAvailability_Code = 'PV2{}.F35' # N - the patient does not have permissions to use a non-military healthcare facility
Mode_of_Arrival = 'PV2{}.F38'
Admission_Level_of_Care_Text = 'PV2{}.F40.R1.C2'
Patient_Condition_Code = 'PV2{}.F42'
@staticmethod
def get_segment_name() -> str:
return 'PV2'
@staticmethod
def get_segment_title() -> str:
return 'Patient Visit Part 2'
class Al1Segment(Enum):
"""Patient Allergy Information"""
Set_ID = 'AL1{}.F1'
Allergen_Type_Code_Identifier = 'AL1{}.F2.R1.C1'
Allergen_Type_Code_Name_of_Coding_System = 'AL1{}.F2.R1.C2'
Allergen_Type_Code_Text = 'AL1{}.F2.R1.C3'
Allergen_Type_Code_Alternate_Identifier = 'AL1{}.F2.R1.C4'
Allergen_Type_Code_Alternate_Text = 'AL1{}.F2.R1.C5'
Allergen_Type_Code_Name_of_Alternate_Coding_System = 'AL1{}.F2.R1.C6'
Allergen_Code_Mnemonic_Desc_Identifier = 'AL1{}.F3.R1.C1'
Allergen_Code_Mnemonic_Desc_Text = 'AL1{}.F3.R1.C2'
Allergen_Code_Mnemonic_Desc_Name_of_Coding_System = 'AL1{}.F3.R1.C3'
Allergen_Code_Mnemonic_Desc_Alternate_Identifier = 'AL1{}.F3.R1.C4'
Allergen_Code_Mnemonic_Desc_Alternate_Text = 'AL1{}.F3.R1.C5'
Allergen_Code_Mnemonic_Desc_Name_of_Alternate_Coding_System = 'AL1{}.F3.R1.C6'
Allergy_Reaction_Code = 'AL1{}.F5'
Identification_Date = 'AL1{}.F6'
@staticmethod
def get_segment_name() -> str:
return 'AL1'
@staticmethod
def get_segment_title() -> str:
return 'Patient Allergy'
class Dg1Segment(Enum):
Set_ID = 'DG1{}.F1'
Diagnosis_Coding_Method = 'DG1{}.F2'
Diagnosis_Code_ID = 'DG1{}.F3.R1.C1'
Diagnosis_Code_Desc = 'DG1{}.F3.R1.C2'
Diagnosis_Code_Code_System = 'DG1{}.F3.R1.C3'
Diagnosis_Description = 'DG1{}.F4'
# Diagnosis_Date_Time
Diagnosis_Type = 'DG1{}.F6'
# Major_Diagnostic_Category
# Diagnostic_Related_Group
# DRG_Approval_Indicator
# DRG_Grouper_Review_Code
# Outlier_Type
# Outlier_Days
# Outlier_Cost
# Grouper_Version_And_Type
# Diagnosis_Priority
# Diagnosing_Clinician
# Diagnosis_Classification
# Confidential_Indicator
# Attestation_Date_Time
# Diagnosis_Identifier
# Diagnosis_Action_Code
@staticmethod
def get_segment_name() -> str:
return 'DG1'
@staticmethod
def get_segment_title() -> str:
return 'Diagnosis'
class Pr1Segment(Enum):
"""Procedures"""
Set_ID = 'PR1{}.F1'
Procedure_Coding_Method = 'PR1{}.F2'
Procedure_Code_Identifier = 'PR1{}.F3.R1.C1'
Procedure_Code_Text = 'PR1{}.F3.R1.C2'
Procedure_Code_Name_of_Coding_System = 'PR1{}.F3.R1.C3'
Procedure_Code_Alternate_Identifier = 'PR1{}.F3.R1.C4'
Procedure_Code_Alternate_Text = 'PR1{}.F3.R1.C5'
Procedure_Code_Name_of_Alternate_Coding_System = 'PR1{}.F3.R1.C6'
Procedure_Description = 'PR1{}.F4'
Procedure_Time = 'PR1{}.F5.R1.C1'
Procedure_Functional_Type = 'PR1{}.F6'
Procedure_Minutes = 'PR1{}.F7'
Anesthesiologist_ID_Number = 'PR1{}.F8.R1.C1'
Anesthesiologist_Family_Name = 'PR1{}.F8.R1.C2'
Anesthesiologist_Given_Name = 'PR1{}.F8.R1.C3'
Anesthesiologist_Middle_Initial = 'PR1{}.F8.R1.C4'
Anesthesiologist_Suffix = 'PR1{}.F8.R1.C5'
Anesthesiologist_Prefix = 'PR1{}.F8.R1.C6'
Anesthesiologist_Source_Table = 'PR1{}.F8.R1.C8'
Anesthesiologist_Assigning_Authority = 'PR1{}.F8.R1.C9'
Anesthesiologist_Name_Type_Code = 'PR1{}.F8.R1.C10'
Anesthesiologist_Identifier_Check_Digit = 'PR1{}.F8.R1.C11'
Anesthesiologist_Check_Digit_Scheme = 'PR1{}.F8.R1.C12'
Anesthesiologist_Identifier_Type_Code = 'PR1{}.F8.R1.C13'
Anesthesiologist_Assigning_Facility = 'PR1{}.F8.R1.C14'
Anesthesiologist_Name_Representation_Code = 'PR1{}.F8.R1.C15'
Anesthesiologist_Name_Context = 'PR1{}.F8.R1.C16'
Anesthesiologist_Name_Assembly_Order = 'PR1{}.F8.R1.C18'
Anesthesiologist_Effective_Date = 'PR1{}.F8.R1.C19'
Anesthesiologist_Expiration_Date = 'PR1{}.F8.R1.C20'
Anesthesiologist_Professional_Suffix = 'PR1{}.F8.R1.C21'
Anesthesiologist_Assigning_Jurisdiction = 'PR1{}.F8.R1.C22'
Anesthesiologist_Assigning_Agency_or_Dept = 'PR1{}.F8.R1.C23'
Anesthesia_Code = 'PR1{}.F9'
Anesthesia_Minutes = 'PR1{}.F10'
Surgeon_ID_Number = 'PR1{}.F11.R1.C1'
Surgeon_Family_Name = 'PR1{}.F11.R1.C2'
Surgeon_Given_Name = 'PR1{}.F1.R1.C3'
Surgeon_Middle_Initial = 'PR1{}.F11.R1.C4'
Surgeon_Suffix = 'PR1{}.F11.R1.C5'
Surgeon_Prefix = 'PR1{}.F11.R1.C6'
Surgeon_Source_Table = 'PR1{}.F11.R1.C8'
Surgeon_Assigning_Authority = 'PR1{}.F11.R1.C9'
Surgeon_Name_Type_Code = 'PR1{}.F11.R1.C10'
Surgeon_Identifier_Check_Digit = 'PR1{}.F11.R1.C11'
Surgeon_Check_Digit_Scheme = 'PR1{}.F11.R1.C12'
Surgeon_Identifier_Type_Code = 'PR1{}.F11.R1.C13'
Surgeon_Assigning_Facility = 'PR1{}.F11.R1.C14'
Surgeon_Name_Representation_Code = 'PR1{}.F11.R1.C15'
Surgeon_Name_Context = 'PR1{}.F11.R1.C16'
Surgeon_Name_Assembly_Order = 'PR1{}.F11.R1.C18'
Surgeon_Effective_Date = 'PR1{}.F11.R1.C19'
Surgeon_Expiration_Date = 'PR1{}.F11.R1.C20'
Surgeon_Professional_Suffix = 'PR1{}.F11.R1.C21'
Surgeon_Assigning_Jurisdiction = 'PR1{}.F11.R1.C22'
Surgeon_Assigning_Agency_or_Dept = 'PR1{}.F11.R1.C23'
Procedure_Practitioner_ID_Number = 'PR1{}.F12.R1.C1'
Procedure_Practitioner_Family_Name = 'PR1{}.F12.R1.C2'
Procedure_Practitioner_Given_Name = 'PR1{}.F12.R1.C3'
Procedure_Practitioner_Middle_Initial = 'PR1{}.F12.R1.C4'
Procedure_Practitioner_Suffix = 'PR1{}.F12.R1.C5'
Procedure_Practitioner_Prefix = 'PR1{}.F12.R1.C6'
Procedure_Practitioner_Source_Table = 'PR1{}.F12.R1.C8'
Procedure_Practitioner_Assigning_Authority = 'PR1{}.F12.R1.C9'
Procedure_Practitioner_Name_Type_Code = 'PR1{}.F12.R1.C10'
Procedure_Practitioner_Identifier_Check_Digit = 'PR1{}.F12.R1.C11'
Procedure_Practitioner_Check_Digit_Scheme = 'PR1{}.F12.R1.C12'
Procedure_Practitioner_Identifier_Type_Code = 'PR1{}.F12.R1.C13'
Procedure_Practitioner_Assigning_Facility = 'PR1{}.F12.R1.C14'
Procedure_Practitioner_Name_Representation_Code = 'PR1{}.F12.R1.C15'
Procedure_Practitioner_Name_Context = 'PR1{}.F12.R1.C16'
Procedure_Practitioner_Name_Assembly_Order = 'PR1{}.F12.R1.C18'
Procedure_Practitioner_Effective_Date = 'PR1{}.F12.R1.C19'
Procedure_Practitioner_Expiration_Date = 'PR1{}.F12.R1.C20'
Procedure_Practitioner_Professional_Suffix = 'PR1{}.F12.R1.C21'
Procedure_Practitioner_Assigning_Jurisdiction = 'PR1{}.F12.R1.C22'
Procedure_Practitioner_Assigning_Agency_or_Dept = 'PR1{}.F12.R1.C23'
Consent_Code_Identifier = 'PR1{}.F13.R1.C1'
Consent_Code_Text = 'PR1{}.F13.R1.C2'
Consent_Code_Name_of_Coding_System = 'PR1{}.F13.R1.C3'
Consent_Code_Alternate_Identifier = 'PR1{}.F13.R1.C4'
Consent_Code_Alternate_Text = 'PR1{}.F13.R1.C5'
Consent_Code_Name_of_Alternate_Coding_System = 'PR1{}.F13.R1.C6'
Procedure_Priority = 'PR1{}.F14'
Associated_Diag_Code_Identifier = 'PR1{}.F15.R1.C1'
Associated_Diag_Code_Text = 'PR1{}.F15.R1.C2'
Associated_Diag_Code_Name_of_Coding_System = 'PR1{}.F15.R1.C3'
Associated_Diag_Code_Alternate_Identifier = 'PR1{}.F15.R1.C4'
Associated_Diag_Code_Alternate_Text = 'PR1{}.F15.R1.C5'
Associated_Diag_Code_Name_of_Alternate_Coding_System = 'PR1{}.F15.R1.C6'
Proc_Code_Mod_Identifier = 'PR1{}.F16.R1.C1'
Proc_Code_Mod_Text = 'PR1{}.F16.R1.C2'
Proc_Code_Mod_Name_of_Coding_System = 'PR1{}.F16.R1.C3'
Proc_Code_Mod_Alternate_Identifier = 'PR1{}.F16.R1.C4'
Proc_Code_Mod_Alternate_Text = 'PR1{}.F16.R1.C5'
Proc_Code_Mod_Name_of_Alternate_Coding_System = 'PR1{}.F16.R1.C6'
Procedure_DRG_Type = 'PR1{}.F17'
Tissue_Type_Code_Identifier = 'PR1{}.F18.R1.C1'
Tissue_Type_Code_Text = 'PR1{}.F18.R1.C2'
Tissue_Type_Code_Name_of_Coding_System = 'PR1{}.F18.R1.C3'
Tissue_Type_Code_Alternate_Identifier = 'PR1{}.F18.R1.C4'
Tissue_Type_Code_Alternate_Text = 'PR1{}.F18.R1.C5'
Tissue_Type_Code_Name_of_Alternate_Coding_System = 'PR1{}.F18.R1.C6'
Procedure_Identifier_Entity_Identifier = 'PR1{}.F19.R1.C1'
Procedure_Identifier_Namespace_ID = 'PR1{}.F19.R1.C2'
Procedure_Identifier_Universal_ID = 'PR1{}.F19.R1.C3'
Procedure_Identifier_Universal_ID_Type = 'PR1{}.F19.R1.C4'
Procedure_Action_Code = 'PR1{}.F20'
@staticmethod
def get_segment_name() -> str:
return 'PR1'
@staticmethod
def get_segment_title() -> str:
return 'Procedures'
class In1Segment(Enum):
"""Insurance Company Info"""
Set_ID = 'IN1{}.F1'
Health_Plan_ID = 'IN1{}.F2.R1.C1'
Health_Plan_Text = 'IN1{}.F2.R1.C2'
Health_Plan_Coding = 'IN1{}.F2.R1.C3'
Health_Plan_Alt_ID = 'IN1{}.F2.R1.C4'
Health_Plan_Alt_Text = 'IN1{}.F2.R1.C5'
Health_Plan_Alt_Coding = 'IN1{}.F2.R1.C6'
Health_Plan_Coding_System_Version = 'IN1{}.F2.R1.C7'
Health_Plan_Alt_Coding_System_Version = 'IN1{}.F2.R1.C8'
Original_Text = 'IN1{}.F2.R1.C9'
Insurance_Company_ID_Number = 'IN1{}.F3.R1.C1'
Insurance_Company_ID_Assigning_Facility = 'IN1{}.F3.R1.C6'
Insurance_Company_ID_Effective_Date = 'IN1{}.F3.R1.C7'
Insurance_Company_ID_Expiration_Date = 'IN1{}.F3.R1.C8'
Insurance_Company_ID_Assigning_Jurisdiction = 'IN1{}.F3.R1.C9'
Insurance_Company_Organization_Name = 'IN1{}.F4.R1.C1'
Insurance_Company_Organization_Name_Code = 'IN1{}.F4.R1.C2'
Insurance_Company_Street_Address = 'IN1{}.F5.R1.C1'
Insurance_Company_Other_Designation = 'IN1{}.F5.R1.C2'
Insurance_Company_City = 'IN1{}.F5.R1.C3'
Insurance_Company_State_or_Province = 'IN1{}.F5.R1.C4'
Insurance_Company_Zip_or_Postal_Code = 'IN1{}.F5.R1.C5'
Insurance_Company_Country = 'IN1{}.F5.R1.C6'
Insurance_Company_Address_Type = 'IN1{}.F5.R1.C7'
Insurance_Company_Phone_Number_Area_Code = 'IN1{}.F7.R1.C6'
Insurance_Company_Phone_Number_Local_Number = 'IN1{}.F7.R1.C7'
Insurance_Company_Phone_Number_Ext = 'IN1{}.F7.R1.C8'
Insurance_Company_Phone_Number_Any_Text = 'IN1{}.F7.R1.C9'
Insurance_Company_Phone_Number_Ext_Prefix = 'IN1{}.F7.R1.C10'
Insurance_Company_Phone_Number_Unformatted = 'IN1{}.F7.R1.C12'
Group_Number = 'IN1{}.F8'
Group_Name = 'IN1{}.F9'
Insured_Group_Emp_ID_Number = 'IN1{}.F10.R1.C1'
Insured_Group_Emp_Name = 'IN1{}.F11.R1.C1'
Plan_Effective_Date = 'IN1{}.F12'
Plan_Expiration_Date = 'IN1{}.F13'
Name_of_Insured_Family_Name = 'IN1{}.F16.R1.C1.S1'
Name_of_Insured_Family_Name_Surname = 'IN1{}.F16.R1.C1.S2'
Name_of_Insured_Family_Own_Surname_Prefix = 'IN1{}.F16.R1.C1.S3'
Name_of_Insured_Given_Name = 'IN1{}.F16.R1.C2'
Name_of_Insured_Other_Given_Names = 'IN1{}.F16.R1.C3'
Name_of_Insured_Suffix = 'IN1{}.F16.R1.C4'
Name_of_Insured_Prefix = 'IN1{}.F16.R1.C5'
Policy_Number = 'IN1{}.F36'
Coverage_Type = 'IN1{}.F47'
Subscriber_ID = 'IN1{}.F49'
@staticmethod
def get_segment_name() -> str:
return 'IN1'
@staticmethod
def get_segment_title() -> str:
return 'Insurance Company Info'
class In2Segment(Enum):
"""Additional Insurance Info"""
Insureds_Employee_ID = 'IN2{}.F1'
Insureds_Social_Security_Number = 'IN2{}.F2'
Insureds_Employers_Name_and_ID = 'IN2{}.F3'
Employer_Information_Data = 'IN2{}.F4'
Medicare_Health_Ins_Card_Number = 'IN2{}.F6'
Non_Covered_Insurance_Code = 'IN2{}.F24'
@staticmethod
def get_segment_name() -> str:
return 'IN2'
@staticmethod
def get_segment_title() -> str:
return 'Insurance Company Additional Info'
class NteSegment(Enum):
Set_ID = 'NTE{}.F1'
Source_Of_Comment = 'NTE{}.F2'
Comment = 'NTE{}.F3'
Comment_Type = 'NTE{}.F4'
@staticmethod
def get_segment_name() -> str:
return 'NTE'
@staticmethod
def get_segment_title() -> str:
return 'Note'
class OvrSegment(Enum):
"""Business Rule Overide"""
BRO_Type_ID = 'OVR{}.F1.R1.C1'
BRO_Type_Text = 'OVR{}.F1.R1.C2'
BRO_Type_Name_of_Coding_System = 'OVR{}.F1.R1.C3'
BRO_Type_Alt_ID = 'OVR{}.F1.R1.C4'
BRO_Type_Alt_Text = 'OVR{}.F1.R1.C5'
BRO_Type_Alt_Name_of_Coding_System = 'OVR{}.F1.R1.C6'
BRO_Type_Coding_System_Version = 'OVR{}.F1.R1.C7'
BRO_Type_Coding_System_Version_Alt = 'OVR{}.F1.R1.C8'
BRO_Type_Original_Text = 'OVR{}.F1.R1.C9'
BRO_Code_ID = 'OVR{}.21.R1.C1'
BRO_Code_Text = 'OVR{}.F2.R1.C2'
BRO_Code_Name_of_Coding_System = 'OVR{}.F2.R1.C3'
BRO_Code_Alt_ID = 'OVR{}.F2.R1.C4'
BRO_Code_Alt_Text = 'OVR{}.F2.R1.C5'
BRO_Code_Alt_Name_of_Coding_System = 'OVR{}.F2.R1.C6'
BRO_Code_Coding_System_Version = 'OVR{}.F2.R1.C7'
BRO_Code_Coding_System_Version_Alt = 'OVR{}.F2.R1.C8'
BRO_Code_Original_Text = 'OVR{}.F2.R1.C9'
Override_Comments = 'OVR{}.F3'
@staticmethod
def get_segment_name() -> str:
return 'OVR'
@staticmethod
def get_segment_title() -> str:
return 'Business Rule Override'
class Gt1Segment(Enum):
"""Guarantor Segment"""
Guarantor_Name = 'GT1{}.F3'
@staticmethod
def get_segment_name() -> str:
return 'GT1'
@staticmethod
def get_segment_title() -> str:
return 'Guarantor'
class Rf1Segment(Enum):
"""Referral Information Segment"""
Process_Date = 'RF1{}.F9'
@staticmethod
def get_segment_name() -> str:
return 'RF1'
@staticmethod
def get_segment_title() -> str:
return 'Referral Information'
class IvcSegment(Enum):
Provider_Tax_Id = 'IVC{}.F26'
@staticmethod
def get_segment_name() -> str:
return 'IVC'
@staticmethod
def get_segment_title() -> str:
return 'Invoice'
class OruSegment(Enum):
Set_ID = 'ORU.F1'
@staticmethod
def get_segment_name() -> str:
return 'ORU'
@staticmethod
def get_segment_title() -> str:
return 'ORU'
class OrnSegment(Enum):
Set_ID = 'ORN.F1'
@staticmethod
def get_segment_name() -> str:
return 'ORN'
@staticmethod
def get_segment_title() -> str:
return 'ORN'
class ZonSegment(Enum):
Zon_Flag = 'ZON.F1'
@staticmethod
def get_segment_name() -> str:
return 'ZON'
@staticmethod
def get_segment_title() -> str:
return 'ZON'
def parse_hl7(message):
# Parse the HL7 message using the hl7 library
parsed_message = hl7.parse(message)
# Loop through the segments in the message
for segment in parsed_message:
# Get the segment type
segment_type = segment[0]
# Get the field names for the segment type
field_names = get_segment_fields(segment_type)
# Loop through the fields in the segment
for i, field in enumerate(segment):
# Label the field with its corresponding field name
if i < len(field_names):
st.write(f"{field_names[i]}: {field}")
else:
st.write(f"Unknown field: {field}")
# Define the Streamlit app
def app():
# Add a text input field for the HL7 message
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")
# Parse the HL7 message and display the labeled fields
if hl7_message:
parse_hl7(hl7_message)
# if __name__ == "__main__":
if __name__ == '__main__':
app()
print(AdmitSource['PR'].value)
print(AdmitSource['HMO'].value)
for i in range(1, 10):
print(AdmitSource.get_value(str(i)))
print(AdmitSource.get_value('PR'))
print(AdmitSource.get_value('Emergency_Room'))