จำนวนหญิงตั้งครรภ์ที่มาฝากครรครั้งแรก ครบ 4 ครั้ง (ตามเกณฑ์)

Update Delete

ID32
Parent ID9
Table Nameanc_complete
Titleจำนวนหญิงตั้งครรภ์ที่มาฝากครรครั้งแรก ครบ 4 ครั้ง (ตามเกณฑ์)
Description
Script#SQL_OPTIONS#
PROVIDERS=2
PROVIDER1=JHCIS
PROVIDER2=HOSXP
PROVIDER1_VALIDATE_TABLES=visitanc,visitancpregnancy,visit
PROVIDER2_VALIDATE_TABLES=person_anc_service,ovst,ovst_seq
SCRIPT_FLOW=SQL
#SQL_OPTIONS#

#PROVIDER1_SQL#
SET @provcode = :provcode;
SET @rep_year = :rep_year;
SET @hoscode = :hoscode;
SET @hosname = :hosname;
SET @hostype = :hostype;
SET @address = :address;
SET @subdistcode = :subdistcode;
SET @distcode = :distcode;
SET @level_service = :level_service;


SELECT

FROM

WHERE

;

#PROVIDER1_SQL#


#PROVIDER2_SQL#
SET @provcode = :provcode;
SET @rep_year = :rep_year;
SET @hoscode = :hoscode;
SET @hosname = :hosname;
SET @hostype = :hostype;
SET @address = :address;
SET @subdistcode = :subdistcode;
SET @distcode = :distcode;
SET @level_service = :level_service;

select year(anc_service_date) as yy, monthname(anc_service_date) as mm, sum(if((pt.chwpart = '27' and pt.amppart = '01' and pt.tmbpart = '01' and pt.nationality = '99'),1,0)) as tmb_sakeo, sum(if((pt.chwpart = '27' and pt.amppart = '01' and pt.tmbpart <> '01' and pt.nationality = '99'),1,0)) as amp_sakeo, sum(if((pt.chwpart = '27' and pt.amppart <> '01' and pt.nationality = '99'),1,0)) as out_amp_sakeo, sum(if((pt.nationality <> '99'),1,0)) as foreigner
from person_anc_service pas
left outer join person_anc pa on pa.person_anc_id=pas.person_anc_id
left outer join person p on p.person_id=pa.person_id
left outer join patient pt on pt.hn=p.patient_hn
where pas.anc_service_date BETWEEN CONCAT((@rep_year-1),'-10-01') AND CONCAT(@rep_year,'-09-30') and pas.pa_week<=12
and pas.person_anc_id not in (select person_anc_id from person_anc_service where person_anc_id = pas.person_anc_id and anc_service_date < pas.anc_service_date and pa_week <=12 )
group by year(pas.anc_service_date), month(pas.anc_service_date)

;

#PROVIDER2_SQL#
Script Cron
Force Script Cron0
Active1
Client Office Type
Create Date2015-06-12 01:02:27
Last Update2015-06-12 01:13:37