PK.LABMKEY
A^prefix,
@OPEN.LAB,
@PATS,
END;

OPEN.LAB
@admdir,
O(&,@misdict),
O(:,@admdata),
@labdir,
O(\,@labdict),
@labdir,
O(*,@labdata),
O(\,@labdict),
@pkdir

PATS
/ARGV[1]^DT,
2^nr,
DO{nr</ARGC 1,
   /ARGV[nr]^ACT,
   :AAAI[ACT]^aa,
   @MIC,
   nr+1^nr}

MIC
""^Q,
DO{@NEXT.SPEC @SEND}

NEXT.SPEC
>(*SMSP[aa,Q],sms)^Q

SEND
IF{*SMS[sms]|3<DT;
   *SMS[sms]|2^stat,
   /CONF[.results.micro.nostatus][stat] 1;
   "<Document>"^!,
   "<InstanceMnemonic>"_prefix_sms_"</InstanceMnemonic>"^!,
   @COMPUTE.KEY,
   "append x to key because t0 may be empty",
   "<Key>"_"x"_/tempkey_"</Key>"^!,
   "<PersonMnemonic>"_:AA[aa]|3_"</PersonMnemonic>"^!,
   "<EventEndDateTime>"^!,
   IF{*SMS[sms]|13_.'=. *SMS[sms]|3_*SMS[sms]|4;
      *SMS[sms]|14_.'=. *SMS[sms]|9_*SMS[sms]|10}^!,
   "</EventEndDateTime>"^!,
   "<EventSetMnemonic>MICRO</EventSetMnemonic>"^!,
   "</Document>"^!}

COMPUTE.KEY
*SMS[sms]|23^/tempkey,
""^smp,
DO{+*SMS[sms]T[smp]^smp /tempkey_"-"_smp^/tempkey,
   @GET.LAST.REPORTABLE.RESULTS,
   /tempkey_":"_IF{R *SMS[sms]T[smp]R[R]|1;"none"}^/tempkey}

GET.LAST.REPORTABLE.RESULTS
"Search backwards to get the latest verified results",
""^R^GOT,
DO{IF{GOT "";
   -(*SMS[sms]T[smp]R[R],XX)^R "got result",
      IF{XX|3="V" "and its verified",
            1^GOT;
         R}}}
