begin
GetDateRangeDialog(date1,date2);
ds1:= FormatDateTime('yyyy-mm-dd', date1);
ds2:= FormatDateTime('yyyy-mm-dd', date2);
pod :=GetPickupList('select concat (drugitems.name," ", drugitems.strength) as DNS from drugitems where istatus="Y"');
pod :=GetSQLStringData('select concat (drugitems.name," ", drugitems.strength) as DNS from drugitems where name = "'+pod +'"');
ChangeReportSQL('SELECT opitemrece.vstdate, opitemrece.hn, patient.pname, patient.fname,'+
' patient.lname, opitemrece.icode, drugitems.name, drugitems.strength,'+
' opitemrece.qty, opitemrece.unitprice, opitemrece.sum_price, opitemrece.pttype,'+
' pttype.name, thaiaddress.full_name, drugusage.name1, drugusage.name2,'+
' patient.addrpart, patient.moopart, opitemrece.an,concat (drugitems.name," ", drugitems.strength) as DNS,'+
' concat (patient.pname,patient.fname," ",patient.lname) as PPFL'+
'FROM opitemrece INNER JOIN'+
' patient ON opitemrece.hn = patient.hn INNER JOIN'+
' drugitems ON opitemrece.icode = drugitems.icode INNER JOIN'+
' pttype ON pttype.pttype = opitemrece.pttype INNER JOIN'+
' thaiaddress ON patient.tmbpart = thaiaddress.tmbpart AND patient.amppart ='+
' thaiaddress.amppart AND patient.chwpart = thaiaddress.chwpart INNER JOIN'+
' drugusage ON opitemrece.drugusage = drugusage.drugusage'+
'WHERE opitemrece.vstdate between "'+ds1+'" and "'+ds2+'" and drugitems.name="'+pod +'"'+
'ORDER BY opitemrece.vstdate ');
end;