US-EPA-CAMD / easey-ui

Project Management repo for EPA Clean Air Markets Division (CAMD) Business Suite of applications
MIT License
0 stars 0 forks source link

Implement inventory and program change logic for MP reporting frequency and eval status #5576

Open JanellC opened 1 year ago

JanellC commented 1 year ago

Certain facility/unit inventory changes made via CBS may have a direct impact on the evaluation status of existing monitoring plans in ECMPS 2.0 and/or the reporting frequency associated with existing monitoring plans in ECMPS 2.0. In some cases, changes in CBS may require sources to make changes to affected monitoring plans prior to making future submissions.

On the CBS side, when these changes are made, the affected facility and/or unit is logged in the CAMDAUX.INVENTORY_STATUS_LOG table along with a code the indicates the type of change that was made. This table is included in the CDC process that syncs data between the NCC Oracle database and the cloud.gov PG database.

CBS data changes that only affect values displayed in ECMPS 2.0:

CBS data changes that may affect monitoring plan evaluation status:

CBS data changes that may affect monitoring plan reporting frequency:

CBS data changes that affect the facility to which a monitoring plan is associated:

Developer Notes:

Acceptance Criteria:

Original Description:

Context

The logic will need to be collected from Mark

The camdecmpswks.update_mp_eval_status_and_reporting_freq procedure should be updated before it is used. The last block of the procedure attempts to update `camdecmpswks.monitor_plan with the following logic:

    UPDATE camdecmpswks.MONITOR_PLAN
    SET needs_eval_flg = 'Y',
        eval_status_cd = 'EVAL',
        submission_availability_cd = 'GRANTED',
        userid = V_USERID,
        update_date = V_CURRENT_DATETIME
    WHERE mon_plan_id IN (
        SELECT mon_plan_id FROM (
            SELECT DISTINCT unit_id
            FROM camdaux.inventory_status_log
            WHERE data_type_cd IN ('INVENTORY')
        ) AS d
        JOIN camdecmps.monitor_location AS ml USING(unit_id)
        JOIN camdecmps.monitor_plan_location AS mpl USING(mon_loc_id)
        JOIN camdecmps.monitor_plan AS mp USING(mon_plan_id)
        WHERE mp.end_rpt_period_id IS null
    );

The first WHERE condition is filtering to plans with a mon_plan_id in a list of unit_ids, which will return zero rows.

Additionally, the submission_availability_cd is set to REQUIRE in version 1.0, rather than GRANTED.

JanellC commented 1 year ago

This ticket will need to be tested asa part of the CDC changes. Only those with direct access to the database can test this

mark-hayward-erg commented 1 month ago

Testing is blocked by https://github.com/US-EPA-CAMD/easey-ui/issues/5997