<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="RSC_VALUE_ASSESS_HD" defaultOrderBy="t1.assess_hd_id desc">
    <bm:fields>
        <bm:field name="assess_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ASSESS_HD_ID" prompt="RSC_VALUE_ASSESS_HD.ASSESS_HD_ID"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" prompt="RSC_VALUE_ASSESS_HD.BP_ID_TENANT"/>
        <bm:field name="req_date" databaseType="DATE" datatype="java.util.Date" physicalName="REQ_DATE" prompt="RSC_VALUE_ASSESS_HD.REQ_DATE"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="risk_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="assess_hd_id" queryExpression="assess_hd_id = ${@assess_hd_id} "/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        t.assess_hd_id,
                        t.bp_id_tenant,
                        (SELECT bp_code FROM hls_bp_master m WHERE m.bp_id = t.bp_id_tenant
                        ) bp_code,
                        (SELECT bp_name FROM hls_bp_master m WHERE m.bp_id = t.bp_id_tenant
                        ) bp_name,
                        t.req_date,
                        t.risk_flag
                    FROM
                        rsc_value_assess_hd t
                    )t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    rsc_value_assess_wfl_pkg.update_risk_flag( p_assess_hd_id => ${@assess_hd_id}, p_risk_flag =>${@risk_flag} );
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
