/*
    ir.dlg

*!  VERSION 1.1.2  13nov2008

*/

VERSION 11.0

INCLUDE _std_large
INCLUDE _ht340
INCLUDE header
HELP hlp1, view("help ir")
RESET res1

DIALOG main, label("ir - Cohort studies") tabtitle("Main")
BEGIN
  INCLUDE  _epitab_vars
  TEXT	   tx_timevar	_lft	_ls	_iwd	.,		///
	label("Person-time variable:")
  VARNAME  vn_timevar	_lft	_ss	_vnwd	.,		///
	label("Person-time variable")
END

INCLUDE ifin
INCLUDE weights_f

DIALOG opt, tabtitle("Options")
BEGIN
  CHECKBOX ck_byopt	_lft	_top	_cwd1	.,		///
	label("Stratify on variable:")				///
	onclickon(program byopt_on)				///
	onclickoff(script byopt_off)
  VARNAME  vn_byopt	_indent2 _ss	_vnwd	.,		///
	label("Stratify on variable")

  INCLUDE  _epitab_stdopts

  CHECKBOX ck_ird	_lft	_ms	_iwd	.,		///
	option(ird)						///
	label("Calculate std. incidence-rate difference")

  CHECKBOX ck_tb	_lft2	_top	_cwd1	.,		///
	option(tb) label("Test-based conf. intervals")

  DEFINE _x _lft2
  DEFINE _y _ls
  DEFINE _cx _spr2
  INCLUDE _sp_level
END

PROGRAM byopt_on
BEGIN
	call gaction opt.vn_byopt.enable
	call gaction opt.rb_mstd.enable
	call gaction opt.rb_istd.enable
	call gaction opt.rb_estd.enable
	call gaction opt.rb_vstd.enable
	call gaction opt.ck_nocrude.enable
	call gaction opt.ck_missing.enable
	call gaction opt.ck_pool.enable
	call gaction opt.ck_nohom.enable
	if opt.rb_vstd {
		call gaction opt.vn_vstd.enable
	}
	if opt.rb_istd | opt.rb_estd | opt.rb_vstd {
		call gaction opt.ck_ird.enable
	}
END

SCRIPT byopt_off
BEGIN
	opt.vn_byopt.disable
	opt.rb_mstd.disable
	opt.rb_istd.disable
	opt.rb_estd.disable
	opt.rb_vstd.disable
	opt.ck_nocrude.disable
	opt.ck_missing.disable
	opt.ck_pool.disable
	opt.ck_nohom.disable
	opt.ck_ird.disable
	opt.vn_vstd.disable
END

SCRIPT mstd_on
BEGIN
	opt.ck_ird.disable
	opt.vn_vstd.disable
END

SCRIPT estd_on
BEGIN
	opt.ck_ird.enable
	opt.vn_vstd.disable
END

SCRIPT istd_on
BEGIN
	opt.ck_ird.enable
	opt.vn_vstd.disable
END

SCRIPT vstd_on
BEGIN
	opt.ck_ird.enable
	opt.vn_vstd.enable
END

PROGRAM ir_by_var_output
BEGIN
	put opt.vn_byopt
	if opt.ck_missing {
		put ", " 
		option opt.ck_missing
	}
END

PROGRAM command
BEGIN
	put "ir "
	varlist main.vn_varcase
	varlist main.vn_varexp
	varlist main.vn_timevar
	INCLUDE _weights_pr
	INCLUDE _ifin_pr
	beginoptions
		if opt.ck_byopt {
			require opt.vn_byopt
			put "by("
			put /program ir_by_var_output
			put ")"
		}
		if opt.ck_byopt {
			option radio(opt rb_mstd rb_istd rb_estd rb_vstd)
		}
		if opt.rb_vstd {
			optionarg opt.vn_vstd
		}
		option opt.ck_pool
		option opt.ck_nocrude
		option opt.ck_nohom
		option opt.ck_ird
		option opt.ck_tb
		INCLUDE _level_opt_pr
	endoptions
END
