PK.RADKEY
A^prefix,
^&(R)^raddict,
^$(R1)^raddata,
^?(R)^radindx,
"PATS",@1,
END;

[1]::PATS
/ARGV[1]^DT,
2^nr,
DO{nr</ARGC 1,
   /ARGV[nr]^ACT,
   ?(A)AAAI[ACT]^aa,
   "RAD",@2,
   nr+1^nr};

[2]::RAD
""^rt^RD,
DO{+[radindx]RTP[RD,aa,rt]^rt "SEND",@3;
   +[radindx]RTP[RD]^RD};

[3]::SEND
IF{"check report enter date against date from pk",
   [raddata]RT[rt]DT|0<DT;
   [raddata]RT[rt]|0^dept,([raddict]RD[dept]|3="Y");
   [raddata]RT[dept]|0="N";
   ('/CONF[.notes.rad.depts]["all"])&('/CONF[.notes.rad.depts][dept]);
   "<Document>"^!,
   "<InstanceMnemonic>"_prefix_rt_"</InstanceMnemonic>"^!,
   "append x to key because t0 may be empty",
   "<Key>"_"x"_[raddata]RT[rt]T|0_"</Key>"^!,
   "<PersonMnemonic>"_$(A)AA[aa]|3_"</PersonMnemonic>"^!,
   "<EventEndDateTime>"_[raddata]RT[rt]DT|0_[raddata]RT[rt]DT|1_"</EventEndDateTime>"^!,
   "<EventSetMnemonic>RAD</EventSetMnemonic>"^!,
   "</Document>"^!};

