-- Streamline Risk Assessment wizard

UPDATE forms
SET elements = $json$[{"label":"Type","field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":4,"options_table":"risk_assessment_types","options_label_column":"name","options_value_column":"id","order_index":1},{"label":"Location","field_name":"location","data_column":"location","type_id":4,"options_table":"locations","options_label_column":"name","options_value_column":"name","order_index":2}]$json$
WHERE id = 75;

UPDATE table_views
SET columns='["risk_assessment_type_id","location"]',
    sort_by='risk_assessment_type_id',
    sort_dir='ASC'
WHERE form_id = 75 AND name='Default';

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"Chemical Used","field_name":"chemical","json_column":"form_data","type_id":1,"order_index":9},{"label":"Hazard Identified","field_name":"hazard","json_column":"form_data","type_id":7,"order_index":10},{"label":"Risk Rating","field_name":"risk_rating","json_column":"form_data","type_id":2,"order_index":11},{"label":"Control Measures","field_name":"controls","json_column":"form_data","type_id":7,"order_index":12}]$json$
WHERE id = 85;

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"Pipe Segment","field_name":"pipe_segment","json_column":"form_data","type_id":1,"order_index":9},{"label":"Material Type","field_name":"material","json_column":"form_data","type_id":1,"order_index":10},{"label":"Identified Risk","field_name":"risk","json_column":"form_data","type_id":7,"order_index":11},{"label":"Failure Likelihood","field_name":"likelihood","json_column":"form_data","type_id":2,"order_index":12},{"label":"Mitigation Action","field_name":"action","json_column":"form_data","type_id":7,"order_index":13}]$json$
WHERE id = 86;

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"Area Assessed","field_name":"area","json_column":"form_data","type_id":1,"order_index":9},{"label":"Environmental Risk","field_name":"env_risk","json_column":"form_data","type_id":7,"order_index":10},{"label":"Climate Trigger","field_name":"trigger","json_column":"form_data","type_id":1,"order_index":11},{"label":"Severity","field_name":"severity","json_column":"form_data","type_id":2,"order_index":12},{"label":"Control Plan","field_name":"plan","json_column":"form_data","type_id":7,"order_index":13}]$json$
WHERE id = 87;

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"Job Task","field_name":"task","json_column":"form_data","type_id":1,"order_index":9},{"label":"Identified Hazard","field_name":"hazard","json_column":"form_data","type_id":7,"order_index":10},{"label":"Risk Level","field_name":"risk_level","json_column":"form_data","type_id":2,"order_index":11},{"label":"PPE Required","field_name":"ppe","json_column":"form_data","type_id":1,"order_index":12},{"label":"First Aid Measures","field_name":"first_aid","json_column":"form_data","type_id":7,"order_index":13}]$json$
WHERE id = 88;

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"System/Module","field_name":"system","json_column":"form_data","type_id":1,"order_index":9},{"label":"Threat Type","field_name":"threat","json_column":"form_data","type_id":1,"order_index":10},{"label":"Vulnerability Description","field_name":"vuln","json_column":"form_data","type_id":7,"order_index":11},{"label":"Impact Rating","field_name":"impact","json_column":"form_data","type_id":2,"order_index":12},{"label":"Mitigation Strategy","field_name":"strategy","json_column":"form_data","type_id":7,"order_index":13}]$json$
WHERE id = 89;

UPDATE forms SET elements = $json$[{"field_name":"risk_assessment_type_id","data_column":"risk_assessment_type_id","type_id":1,"order_index":0},{"label":"Title","field_name":"title","data_column":"title","type_id":1,"order_index":1},{"label":"Assessment Date","field_name":"assessment_date","data_column":"assessment_date","type_id":3,"order_index":2},{"label":"Location","field_name":"location","data_column":"location","type_id":1,"order_index":3},{"label":"Assessor Names","field_name":"assessor_names","json_column":"form_data","type_id":1,"order_index":4},{"label":"Review Date","field_name":"review_date","data_column":"review_date","type_id":3,"order_index":5},{"label":"Approver","field_name":"approver_name","json_column":"form_data","type_id":1,"order_index":6},{"label":"Work Description","field_name":"work_description","json_column":"form_data","type_id":7,"order_index":7},{"label":"Permit Requirements","field_name":"permit_requirements","json_column":"form_data","type_id":7,"order_index":8},{"label":"Community Area","field_name":"community","json_column":"form_data","type_id":1,"order_index":9},{"label":"Public Concern","field_name":"concern","json_column":"form_data","type_id":7,"order_index":10},{"label":"Likelihood of Escalation","field_name":"escalation","json_column":"form_data","type_id":2,"order_index":11},{"label":"Communication Strategy","field_name":"communication","json_column":"form_data","type_id":7,"order_index":12},{"label":"Resolution Timeline","field_name":"timeline","json_column":"form_data","type_id":1,"order_index":13}]$json$
WHERE id = 90;
