Sex Snippets

/*This provides a dropdown box for patient sex.*/

/*
<PARAMETERS>

<PATIENT_SEX
  STATEMENT="select sex_caption, sex_code
             from sex
             union
             select cast('Sex Not Recorded' as char(40)) sex
                  , cast('X' as char(1)) sex_code
             from rdb$database
             union
             select cast('Male or Female only' as char(40)) sex
                  , cast('1' as char(1)) sex_code
             from rdb$database
             union
             select cast('Neither Male nor Female' as char(40)) sex
                  , cast('0' as char(1)) sex_code
             from rdb$database
             union
             select cast('<All Patients>' as char(40)) sex
                  , cast('*' as char(1)) sex_code
             from rdb$database"
  DEFAULT="<All Patients>"
>
</PATIENT_SEX>

</PARAMETERS>
*/

...
where ((p.pat_sex = :Patient_Sex)
  or (p.pat_sex is null
    and cast('X' as char(1)) = :Patient_Sex)
  or (p.pat_sex in ('M', 'F')
    and cast('1' as char(1)) = :Patient_Sex)
  or (p.pat_sex is distinct from 'M'
    and p.pat_sex is distinct from 'F'
    and cast('0' as char(1)) = :Patient_Sex)
  or (cast('*' as char(1)) = :Patient_Sex))
...