sp72268_get_cancel_status derives a human-readable cancellation or collection status for a policy by combining policy status-group data with collection, audit, payroll-report, balance, and submission-ownership checks.
Status group APP yields saifQuote only when pk73102_policy.does_wcis_own_submission(...) = 'N'.
BR-VP-029 Pending-cancel policies only derive the demanded status¶
Field
Value
Statement
When the policy status group is PENDCA, the function derives cancellation status only by checking for a demand row with COLLECTION_ACT_RESPONSE_CODE IS NULL.
Trigger
SP72268_GET_CANCEL_STATUS executes for a policy whose policy_status_group_code is PENDCA.
Enforcement
The main program routes PENDCA to pending_cancel_status, which calls only look_for_demand_status.
Outcome
A pending-cancel policy returns Demanded when an open demand exists; otherwise it returns null.
BR-VP-030 Cancelled policies use a fixed precedence order for derived collection statuses¶
Field
Value
Statement
For cancelled policies, the function derives collection status in a fixed order: Judgment, Lien, Defaulted, Demanded, Pending Audit, Pending PR, Closed w/Bal, and finally Closed.
Trigger
SP72268_GET_CANCEL_STATUS executes for a policy whose policy_status_group_code is CANCEL.
Enforcement
cancel_status calls the local derivation procedures only while v_cancel_status remains null, then defaults to Closed.
Outcome
The first matching collection condition determines the returned cancellation status.
BR-VP-031 Defaulted and demanded statuses come from policy-demand response codes¶
Field
Value
Statement
The function derives Defaulted from a POLICY_DEMAND row whose COLLECTION_ACT_RESPONSE_CODE = 'D' and derives Demanded from a POLICY_DEMAND row whose response code is null.
Trigger
look_for_default_status or look_for_demand_status executes.
Enforcement
Each local procedure opens a cursor over POLICY_DEMAND with its respective response-code filter and assigns the corresponding status when a row is found.
Outcome
Demand and default statuses are driven directly by the collection-action response state.
BR-VP-032 Application policies return saifQuote only when WCIS does not own the submission¶
Field
Value
Statement
For application-status policies, the function returns saifQuote only when pk73102_policy.does_wcis_own_submission(in_policy_num) = 'N' and no prior status has been assigned.
Trigger
SP72268_GET_CANCEL_STATUS executes for a policy whose policy_status_group_code is APP.
Enforcement
The main program routes APP to saifquote_status, which tests pk73102_policy.does_wcis_own_submission before assigning v_cancel_status := 'saifQuote'.
Outcome
Application policies are labeled saifQuote only for non-WCIS-owned submissions.
FUNCTIONSP72268_GET_CANCEL_STATUS/*****************************************************************Procedure Title : Get cancel status.*Name : SP72268_GET_CANCEL_STATUS*Called by : forms******************************************************************PROGRAMMER ANALYST DATE MOD #*CARADE CARADE 01/17/2001 Combo 5.4.1; csr 8*Description: This stored procedure will derive the cancellation status* for a policy.** INPUTS: policy number* RETURNS: cancel status - varchar2(13)** Maintenance Log:* Release Name Date Description* 7.0.3 genhyd 06/15/2006 - Changed to use the policy_demand table instead of policy_demand_action.* 7.0.3 valrey 05/22/2006 - Enhanced the collection status.* 7.0.2 bricot 02/11/2005 - remove references to payroll summary* and audit schedule tables * Retro Cancel 5.4.1 Carade 02/26/01 Added derivation of demand and* default statuses.* 7.0.3 CSR86 leedas 08/24/2006 - Corrected the spelling Judgment used in look_for_judgement.* OSQ leedas 02/07/2008 - Changed to also derive saifQuote if the wcis system did not own the* application***********************************************************************************************/(in_policy_numINNUMBER)RETURNVARCHAR2IS/******************* Local Variables *************************/v_cancel_statusVARCHAR2(13);v_countNUMBER;CURSORpol_curISSELECTpol.POLICY_STATUS_CODE,pol.current_balance,psc.policy_status_group_codeFROMPOLICYpol,POLICY_STATUS_CODEpscWHEREpol.policy_num=in_policy_numANDpol.POLICY_STATUS_CODE=psc.code;pol_recpol_cur%ROWTYPE;/********************************************************************//*********************** Local Procedures *************************//********************************************************************/PROCEDURElook_for_default_status/* derive the default status */ISCURSORdefault_csrISSELECTpolicy_numFROMPOLICY_DEMANDWHEREpolicy_num=in_policy_numANDCOLLECTION_ACT_RESPONSE_CODE='D';default_recdefault_csr%ROWTYPE;BEGINIFdefault_csr%isopenTHENCLOSEdefault_csr;ENDIF;OPENdefault_csr;FETCHdefault_csrINTOdefault_rec;IFdefault_csr%FOUNDTHENv_cancel_status:='Defaulted';ENDIF;CLOSEdefault_csr;END;/* look_for_default_status */PROCEDURElook_for_demand_status/* derive the demand status */ISCURSORdemand_csrISSELECTpolicy_numFROMPOLICY_DEMANDWHEREpolicy_num=in_policy_numANDCOLLECTION_ACT_RESPONSE_CODEISNULL;demand_recdemand_csr%ROWTYPE;BEGINIFdemand_csr%isopenTHENCLOSEdemand_csr;ENDIF;OPENdemand_csr;FETCHdemand_csrINTOdemand_rec;IFdemand_csr%FOUNDTHENv_cancel_status:='Demanded';ENDIF;CLOSEdemand_csr;END;/* look_for_demand_status */PROCEDURElook_for_pending_audit_status/* derive the pending audit status */IS/* Look for assigned or received audit with an effective date prior to the cancel date. If the cancel date is the same as the audit start date then there was no coverage and we don't care about any pending audits. Only physical audits are considered. */CURSORau_curISSELECTpolicy_numFROMPOLICY_PERIOD_PAYROLL_AUDITpppa,AUDIT_CODEacWHEREpppa.policy_num=in_policy_numANDpppa.AUDIT_STATUS_CODEIN('A','R')ANDpppa.audit_period_start_date<(SELECTcancel_dateFROMCANCELLATIONcanWHEREpolicy_num=in_policy_numANDcancellation_seq_num=(SELECTMAX(cancellation_seq_num)FROMCANCELLATIONcan2WHEREpolicy_num=in_policy_num))ANDpppa.AUDIT_CODE=ac.codeANDac.AUDIT_TYPE_CODEIN('PHYS','PHYSR');au_recau_cur%ROWTYPE;BEGINIFau_cur%isopenTHENCLOSEau_cur;ENDIF;OPENau_cur;FETCHau_curINTOau_rec;IFau_cur%FOUNDTHENv_cancel_status:='Pending Audit';ENDIF;CLOSEau_cur;END;/* look_for_pending_audit_status */PROCEDURElook_for_pending_pr_status/* derive the pending payroll report status */IS/* Look for initial or pending payroll reports for reporting periods with a start date prior to the cancel date. If the cancel date is the same as the period start date then there was no coverage and we don't care about any pending payroll reports as of the cancel date. The payroll reports selected are for other than physical audits. */CURSORpr_curISSELECTpolicy_numFROMPOLICY_PERIOD_PAYROLL_AUDITpppaWHEREpolicy_num=in_policy_numANDAUDIT_STATUS_CODEIN('A','I','R')ANDaudit_period_start_date<(SELECTcancel_dateFROMCANCELLATIONcanWHEREpolicy_num=in_policy_numANDcancellation_seq_num=(SELECTMAX(cancellation_seq_num)FROMCANCELLATIONcan2WHEREpolicy_num=in_policy_num))ANDNOTEXISTS(SELECT1FROMPOLICY_PERIOD_PAYROLL_AUDITpppa1,AUDIT_CODEacWHEREpppa1.payroll_seq_num=pppa.payroll_seq_numANDpppa1.AUDIT_CODE=ac.codeANDac.AUDIT_TYPE_CODEIN('PHYS','PHYSR'));pr_recpr_cur%ROWTYPE;BEGINIFpr_cur%isopenTHENCLOSEpr_cur;ENDIF;OPENpr_cur;FETCHpr_curINTOpr_rec;IFpr_cur%FOUNDTHENv_cancel_status:='Pending PR';ENDIF;CLOSEpr_cur;END;/* look_for_pending_pr_status */PROCEDURElook_for_closed_bal_status/* derive the pending payroll report status */ISBEGIN/* The policy balance was retrieved with the policy cursor. */IFNVL(pol_rec.current_balance,0)=0THENNULL;ELSEv_cancel_status:='Closed w/Bal';ENDIF;END;/* look_for_closed_bal_status */PROCEDURElook_for_judgementISBEGINSELECTCOUNT(*)INTOv_countFROMCOLLECTION_LEGAL_ACTIONclaWHEREcla.POLICY_NUM=in_policy_numANDcla.COLLECTION_ACTION_CODE='018'ANDcla.CANCEL_DATEISNULL;IFv_count>0THENv_cancel_status:='Judgment';ENDIF;END;PROCEDURElook_for_lienISBEGINSELECTCOUNT(*)INTOv_countFROMCOLLECTION_LEGAL_ACTIONclaWHEREcla.POLICY_NUM=in_policy_numANDcla.COLLECTION_ACTION_CODEIN('016','017')ANDcla.CANCEL_DATEISNULL;IFv_count>0THENv_cancel_status:='Lien';ENDIF;END;PROCEDUREpending_cancel_status/* derive the cancel status for a pending cancel policy */ISBEGINlook_for_demand_status;END;/* pending_cancel_status */PROCEDUREcancel_status/* derive the cancel status for a cancelled policy */ISBEGINlook_for_judgement;IFv_cancel_statusISNULLTHENlook_for_lien;ENDIF;IFv_cancel_statusISNULLTHENlook_for_default_status;ENDIF;IFv_cancel_statusISNULLTHENlook_for_demand_status;ENDIF;IFv_cancel_statusISNULLTHENlook_for_pending_audit_status;ENDIF;IFv_cancel_statusISNULLTHENlook_for_pending_pr_status;ENDIF;IFv_cancel_statusISNULLTHENlook_for_closed_bal_status;ENDIF;/* If no other status was derived then set it closed */IFv_cancel_statusISNULLTHENv_cancel_status:='Closed';ENDIF;END;/* cancel_status */PROCEDUREsaifquote_status/* derives saifQuote status for an application */ISBEGINIFpk73102_policy.does_wcis_own_submission(in_policy_num)='N'ANDv_cancel_statusISNULLTHENv_cancel_status:='saifQuote';ENDIF;END;/* saifquote_status *//********************************************************************//*********************** Main Program *************************//********************************************************************/BEGINIFpol_cur%isopenTHENCLOSEpol_cur;ENDIF;OPENpol_cur;FETCHpol_curINTOpol_rec;CLOSEpol_cur;IFpol_rec.policy_status_group_code='PENDCA'THENpending_cancel_status;ELSIFpol_rec.policy_status_group_code='CANCEL'THENcancel_status;ELSIFpol_rec.policy_status_group_code='APP'THENsaifquote_status;ENDIF;RETURNv_cancel_status;EXCEPTIONWHENOTHERSTHENRAISE_APPLICATION_ERROR(-20002,'Error in sp72268: '||SQLERRM);END;/*SP72268_GET_CANCEL_STATUS */