procedure GlobalOnCreate;
begin
GetDateRangeDialog(td1, td2);
ds1:=formatdatetime('yyyy-mm-dd',td1);
ds2:=formatdatetime('yyyy-mm-dd',td2);
d1:=ds1;
d2:=ds2;
pc1 := getsqlsubquerydata('select pttype from pttype where pcode in ("A2")');
pc2 := getsqlsubquerydata('select pttype from pttype where pcode in ("A7")');
pc3 :=
getsqlsubquerydata('select pttype from pttype where pcode in ("UC","UA")');
pc4 :=
getsqlsubquerydata('select pttype from pttype where pcode in ("AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","UB")');
pc5 := getsqlsubquerydata('select pttype from pttype where pcode in ("AL")');
pc6 := getsqlsubquerydata('select pttype from pttype where pcode in ("AM")');
pc7 := getsqlsubquerydata('select pttype from pttype where pcode not in (' +
'"A2","A7","UC","UA","UB","AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK",' +
'"AL","AM" ) ');
pc7:=pc7+','+getsqlsubquerydata('select pttype from pttype where pcode IS NULL');
dm1 := getsqlsubquerydata('select hn from clinicmember where clinic="' +
gethosvariable('dm_clinic_code') + '"');
ht1 := getsqlsubquerydata('select hn from clinicmember where clinic="' +
gethosvariable('ht_clinic_code') + '"');
new_dm1 := getsqlsubquerydata('select hn from clinicmember where clinic="' +
gethosvariable('dm_clinic_code') + '" and regdate between "' + d1 + '" and "'
+ d2 + '" ');
new_ht1 := getsqlsubquerydata('select hn from clinicmember where clinic="' +
gethosvariable('ht_clinic_code') + '" and regdate between "' + d1 + '" and "'
+ d2 + '" ');
baby_vn :=
getsqlsubquerydata('select distinct b1.vn from baby_visit b1,ovst o where o.vstdate '
+
' between "' + d1 + '" and "' + d2 + '" and o.vn=b1.vn ');
fp_vn :=
getsqlsubquerydata('select distinct b1.vn from fp_visit b1,ovst o where o.vstdate '
+
' between "' + d1 + '" and "' + d2 + '" and o.vn=b1.vn ');
anc_vn :=
getsqlsubquerydata('select distinct b1.vn from anc_visit b1,ovst o where o.vstdate '
+
' between "' + d1 + '" and "' + d2 + '" and o.vn=b1.vn ');
service_exclude_cri:=' and vn not in ('+baby_vn+','+fp_vn+','+anc_vn+') ';
pt_subtype_cri := ' and pt_subtype in ("0","","2") ';
pt_subtype_cri_pcu := ' and pt_subtype in ("1") ';
dtp_vaccine_id := getsqlsubquerydata('select wbc_vaccine_id from wbc_vaccine where wbc_vaccine_code in ("DTP1","DTP2","DTP3")');
bcg_vaccine_id := getsqlsubquerydata('select wbc_vaccine_id from wbc_vaccine where wbc_vaccine_code in ("BCG")');
mmr_vaccine_id := getsqlsubquerydata('select wbc_vaccine_id from wbc_vaccine where wbc_vaccine_code in ("MMR")');
hbv_vaccine_id := getsqlsubquerydata('select wbc_vaccine_id from wbc_vaccine where wbc_vaccine_code in ("HBV1","HBV2","HBV3")');
dtp_vaccine_id2 := getsqlsubquerydata('select epi_vaccine_id from epi_vaccine where vaccine_code in ("DTP4","DTP5")');
end;