Special Checkbox and Lookup Snippets

/*This provides a dropdown box for special lookup.*/

/*
<PARAMETERS>

<SPECIAL_LOOKUP
  STATEMENT="select lookup_1_desc
                  , lookup_1_no
             from special_lookup_1
             where trim(lookup_1_desc) <> ''
             union
             select cast('<Patients without ' ||
                      trim(pat_special_lookup_1_label)  ||
                      '>' as varchar(30)) lookup_1_desc
                  , cast(-2 as integer) lookup_1_no
             from system_parameter
             where system_parameter_no = 1
             and trim(pat_special_lookup_1_label) <> ''
             union
             select cast('<Patients with ' ||
                      trim(pat_special_lookup_1_label)  ||
                      '>' as varchar(30)) lookup_1_desc
                  , cast(-1 as integer) lookup_1_no
             from system_parameter
             where system_parameter_no = 1
             and trim(pat_special_lookup_1_label) <> ''
             union
             select cast('<All patients>' as varchar(30)) lookup_1_desc
                  , cast(0 as integer) lookup_1_no
             from rdb$database"
  DEFAULT="<All patients>"
>
</SPECIAL_LOOKUP>

</PARAMETERS>
*/

...
where ((special_lookup_1 = :Special_Lookup)
  or (Cast(-1 as integer) = :Special_Lookup
    and special_lookup_1 is not null)
  or (Cast(-2 as integer) = :Special_Lookup
    and special_lookup_1 is null)
  or (Cast(0 as integer) = :Special_Lookup))
...
/*This provides a dropdown box for special checkbox.*/

/*
<PARAMETERS>

<SPECIAL_CHECKBOX
  STATEMENT="select cast(trim(pat_special_cb_1_label) as varchar(30)) CBox
                  , cast(1 as integer) CBoxNo
             from system_parameter
             where pat_special_cb_1_label <> ''
             union
             select cast('Not ' ||
                      trim(pat_special_cb_1_label) as varchar(30)) CBox
                 ,  cast(0 as integer) CBoxNo
             from system_parameter
             where pat_special_cb_1_label <> ''
             union
             select cast('Unknown' as varchar(30)) CBox
                  , cast(-2 as integer) CBoxNo
             from system_parameter
             union
             select cast('<Any>' as varchar(30)) CBox
                  , cast(-1 as integer) CBoxNo
             from system_parameter"
  DEFAULT="<Any>"
>
</SPECIAL_CHECKBOX>

</PARAMETERS>
*/

...
where ((p.special_cb_1 = case :Special_Checkbox
      when 1 then 'T'
      when 0 then 'F'
    end
  or cast(-1 as integer) = :Special_Checkbox)
  or (p.special_cb_1 is null
    and :Special_Checkbox = -2))
...