class tblS7PreventionProgram3Description_ChangeHistory(BaseRMPModel): preventionprogram3descchangehistoryid = CopyFromIntegerField( primary_key=True, source_column='PreventionProgram3DescChangeHistoryID', ) facilitychangehistoryid = CopyFromIntegerField( source_column='FacilityChangeHistoryID', ) cdxcorrectioncode = CopyFromCharField( max_length=1, source_column='CDXCorrectionCode', ) preventionprogram3id = CopyFromForeignKey( 'tblS7PreventionProgram3', on_delete=models.PROTECT, source_column='PreventionProgram3ID', ) description = CopyFromTextField( source_column='Description', blank=True, ) olddescription = CopyFromTextField( source_column='OldDescription', blank=True, ) seqnum = CopyFromIntegerField(source_column='SeqNum', )
class tblS7PreventionProgram3Description_ChangeHistory(BaseRMPModel): PreventionProgram3DescChangeHistoryID = CopyFromIntegerField( primary_key=True, ) FacilityChangeHistoryID = CopyFromIntegerField() CDXCorrectionCode = CopyFromCharField(max_length=1, ) PreventionProgram3ID = CopyFromForeignKey( 'tblS7PreventionProgram3', db_column='PreventionProgram3ID', on_delete=models.PROTECT, ) Description = CopyFromTextField(blank=True, ) OldDescription = CopyFromTextField(blank=True, ) SeqNum = CopyFromIntegerField()
class tblExecutiveSummaries(BaseRMPModel): ESSeqNum = CopyFromIntegerField( verbose_name='Executive Summary Sequence Number', help_text='Unique sequence number for the executive summary.', ) FacilityID = CopyFromForeignKey( 'tblS1Facilities', db_column='FacilityID', on_delete=models.PROTECT, verbose_name='Facility ID', help_text='Unique identifier for all RMPs submitted by a specific ' 'facility (assigned by Reporting Center for first-time ' 'submission). * After this number is assigned to the first ' 'submission for a facility, subsequent submissions for the ' 'same facility must include this identifier.', ) SummaryText = CopyFromTextField( verbose_name='Executive Summary', blank=True, help_text='The Executive Summary includes a brief description of the ' "facility's risk management program.", ) source_file = 'tblExecutiveSummaries' class Meta: db_table = 'tblExecutiveSummaries'
class tblRMPError(BaseRMPModel): FacilityID = CopyFromForeignKey( 'tblFacility', on_delete=models.PROTECT, source_column='FacilityID', verbose_name='Facility ID', help_text='Unique identifier for all RMPs submitted by a specific ' 'facility (assigned by Reporting Center for first-time ' 'submission). * After this number is assigned to the first ' 'submission for a facility, subsequent submissions for the ' 'same facility must include this identifier.', ) SequenceNumber = CopyFromIntegerField( source_column='SequenceNumber', verbose_name='Sequence Number', help_text='Unique sequence number.', ) ErrorText = CopyFromTextField( source_column='ErrorText', verbose_name='Error Text', help_text='Error message text.', ) class Meta: verbose_name = 'RMP ValidationError' verbose_name_plural = 'RMP ValidationErrors'
class ExecutiveSummary(BaseRMPModel): id = CopyFromIntegerField( primary_key=True, source_column='rmp_id', ) summary_text = CopyFromTextField( source_column='execsum', blank=True, ) @classmethod def get_transform_queryset(self): qs = raw_models.tblExecutiveSummaries.objects.filter( ESSeqNum=Subquery( raw_models.tblExecutiveSummaries.objects.filter( FacilityID=OuterRef('FacilityID'), ).values('FacilityID_id').annotate( max_seqnum=Max('ESSeqNum') ).values('max_seqnum')[:1] ) ).annotate( rmp_id=F('FacilityID'), execsum=F('SummaryText') ) return qs
class Prev3Text(BaseRMPModel): prevent_3 = CopyFromOneToOneField( 'PreventionProgram3', primary_key=True, on_delete=models.CASCADE, source_column='prevent_3_id', ) desctext = CopyFromTextField() source_file = 'rmp_prev3text'
class ExecutiveSummary(BaseRMPModel): #rmp_execsum id = CopyFromIntegerField( primary_key=True, source_column='rmp_id', ) summary_text = CopyFromTextField( source_column='execsum', blank=True, ) source_file = 'rmp_execsum'
class ExecutiveSummary(BaseRMPModel): id = CopyFromIntegerField( primary_key=True, source_column='rmp_id', ) summary_text = CopyFromTextField( source_column='execsum', blank=True, ) @classmethod def get_transform_queryset(self): qs = raw_models.tblExecutiveSummaries.objects.values( 'FacilityID', ).annotate(rmp_id=F("FacilityID"), execsum=StringAgg( 'SummaryText', '\n', ordering=('ESSeqNum', ))) return qs
class tblRMPTrack(BaseRMPModel): TrackID = CopyFromBigIntegerField( primary_key=True, verbose_name='Track ID', help_text='Unique number used to identify each RMP Tracking record.', ) EPAFacilityID = CopyFromForeignKey( 'tblFacility', db_column='EPAFacilityID', on_delete=models.PROTECT, null=True, verbose_name='EPA Facility ID', help_text='Unique identifier for all RMPs submitted by a specific ' 'facility (assigned by Reporting Center for first-time ' 'submission). * After this number is assigned to the first ' 'submission for a facility, subsequent submissions for the ' 'same facility must include this identifier.', ) ReceiptDate = CopyFromDateTimeField( verbose_name='Receipt Date', help_text='The date the diskettes or paper submission was received by ' 'the Records Center.', ) PostmarkDate = CopyFromDateTimeField( verbose_name='Postmark Date', help_text='The postmark date of the RMP received material.', ) FacilityName1 = CopyFromCharField( max_length=50, verbose_name='Facility Name 1', help_text='The first line of the facility name.', ) FacilityName2 = CopyFromCharField( max_length=50, blank=True, verbose_name='Facility Name 2', help_text='The second line of the facility name.', ) FacilityStreet1 = CopyFromCharField( max_length=35, verbose_name='Facility Street 1', help_text='The text which contains the first line of the mailing ' 'address of the facility.', ) FacilityStreet2 = CopyFromCharField( max_length=35, blank=True, verbose_name='Facility Street 2', help_text='The text which contains the second line of the mailing ' 'address of the facility.', ) FacilityCity = CopyFromCharField( max_length=20, verbose_name='Facility City', help_text='The name of the city in which the facility is located.', ) FacilityState = CopyFromForeignKey( 'tlkpStateFIPSCodes', db_column='FacilityState', on_delete=models.PROTECT, verbose_name='Facility State', help_text='The two-character FIPS abbreviation for the state in which ' 'the facility is located.', ) FacilityZip = CopyFromCharField( max_length=5, verbose_name='Facility Zip', help_text='The code which represents the Zoning Improvement Plan (ZIP)' ' zone of the facility mailing address.', ) FacilityZip4 = CopyFromCharField( max_length=4, blank=True, verbose_name='Facility Zip4', help_text='The code which represents the Zoning Improve Plan (ZIP) ' 'Geographic Segment of the facility mailing address.', ) DocumentHandle = CopyFromForeignKey( 'tlkpDocHandle', db_column='DocumentHandle', on_delete=models.PROTECT, blank=True, verbose_name='Document Handle', help_text='The code which represents the method of handling used for ' 'the RMP submission.', ) Comments = CopyFromTextField( verbose_name='Comments', blank=True, help_text='The text which contains comments about the RMP submission.', ) DocumentType = CopyFromForeignKey( 'tlkpDocType', db_column='DocumentType', on_delete=models.PROTECT, blank=True, verbose_name='Document Type', help_text='The code which represents the type of the document to which' ' the RMP Tracking record applies.', ) RejectionReason = CopyFromForeignKey( 'tlkpRejectReason', db_column='RejectionReason', on_delete=models.PROTECT, verbose_name='Rejection Reason', help_text='The code which represents the reason the RMP submission ' 'could not be processed.', ) ResolutionDate = CopyFromDateTimeField( null=True, verbose_name='Resolution Date', help_text='The date on which the problems which prevented the RMP from' ' being processed were finally resolved.', ) InsertDate = CopyFromDateTimeField(null=True, ) class Meta: verbose_name = 'RMP Tracking' verbose_name_plural = 'RMP Tracking'
class tblS8PreventionProgram2(BaseRMPModel): preventionprogram2id = CopyFromIntegerField( source_column='PreventionProgram2ID', primary_key=True, ) process_naics_id = CopyFromForeignKey( 'tblS1ProcessNAICS', source_column='Process_NAICS_ID', on_delete=models.PROTECT, ) safetyreviewdate = CopyFromDateTimeField( source_column='SafetyReviewDate', null=True, ) fr_nfpa58 = CopyFromBooleanField(source_column='FR_NFPA58', ) fr_osha = CopyFromBooleanField(source_column='FR_OSHA', ) fr_astm = CopyFromBooleanField(source_column='FR_ASTM', ) fr_ansi = CopyFromBooleanField(source_column='FR_ANSI', ) fr_asme = CopyFromBooleanField(source_column='FR_ASME', ) fr_none = CopyFromBooleanField(source_column='FR_None', ) fr_othertype = CopyFromCharField( source_column='FR_OtherType', max_length=200, blank=True, ) fr_comments = CopyFromCharField( source_column='FR_Comments', max_length=200, blank=True, ) hazardreviewdate = CopyFromDateTimeField( source_column='HazardReviewDate', null=True, ) changecompletiondate = CopyFromDateTimeField( source_column='ChangeCompletionDate', null=True, ) mh_toxicrelease = CopyFromBooleanField(source_column='MH_ToxicRelease', ) mh_fire = CopyFromBooleanField(source_column='MH_Fire', ) mh_explosion = CopyFromBooleanField(source_column='MH_Explosion', ) mh_runawayreaction = CopyFromBooleanField( source_column='MH_RunawayReaction', ) mh_polymerization = CopyFromBooleanField( source_column='MH_Polymerization', ) mh_overpressurization = CopyFromBooleanField( source_column='MH_Overpressurization', ) mh_corrosion = CopyFromBooleanField(source_column='MH_Corrosion', ) mh_overfilling = CopyFromBooleanField(source_column='MH_Overfilling', ) mh_contamination = CopyFromBooleanField(source_column='MH_Contamination', ) mh_equipmentfailure = CopyFromBooleanField( source_column='MH_EquipmentFailure', ) mh_coolingloss = CopyFromBooleanField(source_column='MH_CoolingLoss', ) mh_earthquake = CopyFromBooleanField(source_column='MH_Earthquake', ) mh_floods = CopyFromBooleanField(source_column='MH_Floods', ) mh_tornado = CopyFromBooleanField(source_column='MH_Tornado', ) mh_hurricanes = CopyFromBooleanField(source_column='MH_Hurricanes', ) mh_othertype = CopyFromCharField( source_column='MH_OtherType', max_length=200, blank=True, ) pc_vents = CopyFromBooleanField(source_column='PC_Vents', ) pc_reliefvalves = CopyFromBooleanField(source_column='PC_ReliefValves', ) pc_checkvalves = CopyFromBooleanField(source_column='PC_CheckValves', ) pc_scrubbers = CopyFromBooleanField(source_column='PC_Scrubbers', ) pc_flares = CopyFromBooleanField(source_column='PC_Flares', ) pc_manualshutoffs = CopyFromBooleanField( source_column='PC_ManualShutoffs', ) pc_automaticshutoffs = CopyFromBooleanField( source_column='PC_AutomaticShutoffs', ) pc_interlocks = CopyFromBooleanField(source_column='PC_Interlocks', ) pc_alarms = CopyFromBooleanField(source_column='PC_Alarms', ) pc_keyedbypass = CopyFromBooleanField(source_column='PC_KeyedBypass', ) pc_emergencyairsupply = CopyFromBooleanField( source_column='PC_EmergencyAirSupply', ) pc_emergencypower = CopyFromBooleanField( source_column='PC_EmergencyPower', ) pc_backuppump = CopyFromBooleanField(source_column='PC_BackupPump', ) pc_groundingequipment = CopyFromBooleanField( source_column='PC_GroundingEquipment', ) pc_inhibitoraddition = CopyFromBooleanField( source_column='PC_InhibitorAddition', ) pc_rupturedisks = CopyFromBooleanField(source_column='PC_RuptureDisks', ) pc_excessflowdevice = CopyFromBooleanField( source_column='PC_ExcessFlowDevice', ) pc_quenchsystem = CopyFromBooleanField(source_column='PC_QuenchSystem', ) pc_purgesystem = CopyFromBooleanField(source_column='PC_PurgeSystem', ) pc_none = CopyFromBooleanField(source_column='PC_None', ) pc_othertype = CopyFromCharField( source_column='PC_OtherType', max_length=200, blank=True, ) ms_sprinklersystem = CopyFromBooleanField( source_column='MS_SprinklerSystem', ) ms_dikes = CopyFromBooleanField(source_column='MS_Dikes', ) ms_firewalls = CopyFromBooleanField(source_column='MS_FireWalls', ) ms_blastwalls = CopyFromBooleanField(source_column='MS_BlastWalls', ) ms_delugesystem = CopyFromBooleanField(source_column='MS_DelugeSystem', ) ms_watercurtain = CopyFromBooleanField(source_column='MS_WaterCurtain', ) ms_enclosure = CopyFromBooleanField(source_column='MS_Enclosure', ) ms_neutralization = CopyFromBooleanField( source_column='MS_Neutralization', ) ms_none = CopyFromBooleanField(source_column='MS_None', ) ms_othertype = CopyFromCharField( source_column='MS_OtherType', max_length=200, blank=True, ) md_processareadetectors = CopyFromBooleanField( source_column='MD_ProcessAreaDetectors', ) md_perimetermonitors = CopyFromBooleanField( source_column='MD_PerimeterMonitors', ) md_none = CopyFromBooleanField(source_column='MD_None', ) md_othertype = CopyFromCharField( source_column='MD_OtherType', max_length=200, blank=True, ) ch_chemicalreduction = CopyFromBooleanField( source_column='CH_ChemicalReduction', ) ch_chemicalincrease = CopyFromBooleanField( source_column='CH_ChemicalIncrease', ) ch_changeprocessparameters = CopyFromBooleanField( source_column='CH_ChangeProcessParameters', ) ch_installprocesscontrols = CopyFromBooleanField( source_column='CH_InstallProcessControls', ) ch_installprocessdetection = CopyFromBooleanField( source_column='CH_InstallProcessDetection', ) ch_installperimetermonitoring = CopyFromBooleanField( source_column='CH_InstallPerimeterMonitoring', ) ch_installmitigationsystems = CopyFromBooleanField( source_column='CH_InstallMitigationSystems', ) ch_nonerequired = CopyFromBooleanField(source_column='CH_NoneRequired', ) ch_none = CopyFromBooleanField(source_column='CH_None', ) ch_otherchanges = CopyFromCharField( source_column='CH_OtherChanges', max_length=200, blank=True, ) opproceduresreviewdate = CopyFromDateTimeField( source_column='OpProceduresReviewDate', null=True, ) trainingreviewdate = CopyFromDateTimeField( source_column='TrainingReviewDate', null=True, ) tr_classroom = CopyFromBooleanField(source_column='TR_Classroom', ) tr_onthejob = CopyFromBooleanField(source_column='TR_OnTheJob', ) tr_othertype = CopyFromCharField( source_column='TR_OtherType', max_length=200, blank=True, ) ct_writtentest = CopyFromBooleanField(source_column='CT_WrittenTest', ) ct_oraltest = CopyFromBooleanField(source_column='CT_OralTest', ) ct_demonstration = CopyFromBooleanField(source_column='CT_Demonstration', ) ct_observation = CopyFromBooleanField(source_column='CT_Observation', ) ct_othertype = CopyFromCharField( source_column='CT_OtherType', max_length=200, blank=True, ) maintenancereviewdate = CopyFromDateTimeField( source_column='MaintenanceReviewDate', null=True, ) equipmentinspectiondate = CopyFromDateTimeField( source_column='EquipmentInspectionDate', null=True, ) equipmenttested = CopyFromCharField( source_column='EquipmentTested', max_length=200, blank=True, ) complianceauditdate = CopyFromDateTimeField( source_column='ComplianceAuditDate', null=True, ) auditcompletiondate = CopyFromDateTimeField( source_column='AuditCompletionDate', null=True, ) incidentinvestigationdate = CopyFromDateTimeField( source_column='IncidentInvestigationDate', null=True, ) investigationchangedate = CopyFromDateTimeField( source_column='InvestigationChangeDate', null=True, ) mostrecentchangedate = CopyFromDateTimeField( source_column='MostRecentChangeDate', null=True, ) cbi_flag = CopyFromBooleanField(source_column='CBI_Flag', ) description = CopyFromTextField( source_column='Description', blank=True, ) class Meta: verbose_name = 'Prevention Program: Program Level 2' verbose_name_plural = 'Prevention Program: Program Level 2'
class tblS7PreventionProgram3(BaseRMPModel): PreventionProgram3ID = CopyFromIntegerField( primary_key=True, ) Process_NAICS_ID = CopyFromForeignKey( 'tblS1Process_NAICS', db_column='Process_NAICS_ID', on_delete=models.PROTECT, ) SafetyReviewDate = CopyFromDateTimeField( null=True, ) PHA_Date = CopyFromDateTimeField( null=True, ) PHA_WhatIf = CopyFromBooleanField( ) PHA_Checklist = CopyFromBooleanField( ) PHA_WhatIfChecklist = CopyFromBooleanField( ) PHA_HAZOP = CopyFromBooleanField( ) PHA_FMEA = CopyFromBooleanField( ) PHA_FTA = CopyFromBooleanField( ) PHA_OtherTechnique = CopyFromCharField( max_length=200, blank=True, ) PHACompletionDate = CopyFromDateTimeField( null=True, ) MH_ToxicRelease = CopyFromBooleanField( ) MH_Fire = CopyFromBooleanField( ) MH_Explosion = CopyFromBooleanField( ) MH_RunawayReaction = CopyFromBooleanField( ) MH_Polymerization = CopyFromBooleanField( ) MH_Overpressurization = CopyFromBooleanField( ) MH_Corrosion = CopyFromBooleanField( ) MH_Overfilling = CopyFromBooleanField( ) MH_Contamination = CopyFromBooleanField( ) MH_EquipmentFailure = CopyFromBooleanField( ) MH_CoolingLoss = CopyFromBooleanField( ) MH_Earthquake = CopyFromBooleanField( ) MH_Floods = CopyFromBooleanField( ) MH_Tornado = CopyFromBooleanField( ) MH_Hurricanes = CopyFromBooleanField( ) MH_OtherType = CopyFromCharField( max_length=200, blank=True, ) PC_Vents = CopyFromBooleanField( ) PC_ReliefValves = CopyFromBooleanField( ) PC_CheckValves = CopyFromBooleanField( ) PC_Scrubbers = CopyFromBooleanField( ) PC_Flares = CopyFromBooleanField( ) PC_ManualShutoffs = CopyFromBooleanField( ) PC_AutomaticShutoffs = CopyFromBooleanField( ) PC_Interlocks = CopyFromBooleanField( ) PC_Alarms = CopyFromBooleanField( ) PC_KeyedBypass = CopyFromBooleanField( ) PC_EmergencyAirSupply = CopyFromBooleanField( ) PC_EmergencyPower = CopyFromBooleanField( ) PC_BackupPump = CopyFromBooleanField( ) PC_GroundingEquipment = CopyFromBooleanField( ) PC_InhibitorAddition = CopyFromBooleanField( ) PC_RuptureDisks = CopyFromBooleanField( ) PC_ExcessFlowDevice = CopyFromBooleanField( ) PC_QuenchSystem = CopyFromBooleanField( ) PC_PurgeSystem = CopyFromBooleanField( ) PC_None = CopyFromBooleanField( ) PC_OtherType = CopyFromCharField( max_length=200, blank=True, ) MS_SprinklerSystem = CopyFromBooleanField( ) MS_Dikes = CopyFromBooleanField( ) MS_FireWalls = CopyFromBooleanField( ) MS_BlastWalls = CopyFromBooleanField( ) MS_DelugeSystem = CopyFromBooleanField( ) MS_WaterCurtain = CopyFromBooleanField( ) MS_Enclosure = CopyFromBooleanField( ) MS_Neutralization = CopyFromBooleanField( ) MS_None = CopyFromBooleanField( ) MS_OtherType = CopyFromCharField( max_length=200, blank=True, ) MD_ProcessAreaDetectors = CopyFromBooleanField( ) MD_PerimeterMonitors = CopyFromBooleanField( ) MD_None = CopyFromBooleanField( ) MD_OtherType = CopyFromCharField( max_length=200, blank=True, ) CH_ChemicalReduction = CopyFromBooleanField( ) CH_ChemicalIncrease = CopyFromBooleanField( ) CH_ChangeProcessParameters = CopyFromBooleanField( ) CH_InstallProcessControls = CopyFromBooleanField( ) CH_InstallProcessDetection = CopyFromBooleanField( ) CH_InstallPerimeterMonitoring = CopyFromBooleanField( ) CH_InstallMitigationSystems = CopyFromBooleanField( ) CH_NoneRequired = CopyFromBooleanField( ) CH_None = CopyFromBooleanField( ) CH_OtherChanges = CopyFromCharField( max_length=200, blank=True, ) OpProceduresReviewDate = CopyFromDateTimeField( null=True, ) TrainingReviewDate = CopyFromDateTimeField( null=True, ) TR_Classroom = CopyFromBooleanField( ) TR_OnTheJob = CopyFromBooleanField( ) TR_OtherType = CopyFromCharField( max_length=200, blank=True, ) CT_WrittenTest = CopyFromBooleanField( ) CT_OralTest = CopyFromBooleanField( ) CT_Demonstration = CopyFromBooleanField( ) CT_Observation = CopyFromBooleanField( ) CT_OtherType = CopyFromCharField( max_length=200, blank=True ) MaintenanceReviewDate = CopyFromDateTimeField( null=True, ) EquipmentInspectionDate = CopyFromDateTimeField( null=True, ) EquipmentTested = CopyFromCharField( max_length=200, blank=True, ) ChangeMgmtDate = CopyFromDateTimeField( null=True, ) ChangeMgmtReviewDate = CopyFromDateTimeField( null=True, ) PreStartupReviewDate = CopyFromDateTimeField( null=True, ) ComplianceAuditDate = CopyFromDateTimeField( null=True, ) AuditCompletionDate = CopyFromDateTimeField( null=True, ) IncidentInvestigationDate = CopyFromDateTimeField( null=True, ) InvestigationChangeDate = CopyFromDateTimeField( null=True, ) ParticipationPlansReviewDate = CopyFromDateTimeField( null=True, ) HotWorkPermitReviewDate = CopyFromDateTimeField( null=True, ) ContractorSafetyReviewDate = CopyFromDateTimeField( null=True, ) ContractorSafetyEvalDate = CopyFromDateTimeField( null=True, ) CBI_Flag = CopyFromBooleanField( ) Description = CopyFromTextField( blank=True, ) # TODO to rmp_prev3text with prevention programID class Meta: verbose_name = 'Prevention Program: Program Level 3' verbose_name_plural = 'Prevention Programs: Program Level 3'