PK.LABNKEY
@OPEN.LAB,
@HDR,
@PATS,
@TRLR,
END;

OPEN.LAB
@admdir,
O(:,@admdata),
IF{/CONF[.labs.source]="lab" "regular labs",
  @labdir,
  O(*,@labdata),
  O(\,@labdict);
"if not regular labs, assume mock labs",
  @mocklabdir,
  O(*,@mocklabdata),
  O(&,@mocklabindx),
  O(\,@mocklabdict)},
@pkdir

HDR
"<?xml version="_D(34)_1.0_D(34)_" ?>"^!,
"<ReplyMessage>"^!,
"<TransactionId>"_1234_"</TransactionId>"^!,
"<Status>Success</Status>"^!,
"<Payload>"^!

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

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

NEXT.SPEC
IF{/CONF[.labs.source]="lab" >(*SLSP[aa,Q],sls);>(&LSPP[ACT,Q],sls)}^Q

SEND
IF{/CONF[.labs.source]="lab" "regular labs",
  *SLS[sls]|3^SPECDT,
  *SLS[sls]|23^SPECKEY;
"if not regular labs, assume mock labs",
  ("20"_*L[sls]|3)^SPECDT,
  *L[sls]|9_*L[sls]|10^SPECKEY},
IF{SPECDT<DT;
  "<Component>"^!,
  "<Specimen>"_sls_"</Specimen>"^!,
  "<Key>"_"x"_SPECKEY_"</Key>"^!,
  "</Component>"^!}

TRLR
"</Payload>"^!,
"</ReplyMessage>"^!
