labset,
IF{"T"=/ARGV[1] 1;""}^compdefs,
"HDR",@1,
"TESTS",@3,
"TRLR",@2,
END;

[1]::HDR
"<?xml version="_D(34)_1.0_D(34)_" ?>"^!,
"<ReplyMessage>"^!,
"<TransactionId>0</TransactionId>"^!,
"<Status>Success</Status>"^!,
"<StatusDescription>Step returned a Success status.</StatusDescription>"^!,
"<Payload>"^!;

[2]::TRLR
"</Payload>"^!,
"</ReplyMessage>"^!;

[3]::TESTS
IF{compdefs "doing component defs",
      "<ComponentDefinition>"^A1,
      "</ComponentDefinition>"^A2,
      "<ComponentDefinitionMnemonic>"^A3,
      "</ComponentDefinitionMnemonic>"^A4;
   "doing panel defs",
      "<PanelDefinition>"^A1,
      "</PanelDefinition>"^A2,
      "<PanelDefinitionMnemonic>"^A3,
      "</PanelDefinitionMnemonic>"^A4},
""^slt,
DO{"NEXT.TEST",@4 "got a test",
   "GET.TEST.TYPE",@5,
   IF{"IS.OUTPUTABLE",@6 "SEND",@11}};

[4]::NEXT.TEST
+&(SL)SLT[slt]^slt;

[5]::GET.TEST.TYPE
&(SL)SLT[slt]|3^typ;

[6]::IS.OUTPUTABLE
"IS.PROFILE.OR.GROUP",@7^cntr,
"IS.REPORTABLE",@9^rptbl,
"IS.ORDERABLE",@10^ordrbl,
IF{(compdefs)&(cntr) "generating comps, ignore containers",
      "N";
   (compdefs)&('rptbl) "generating comps, ignore not reportable ttests",
      "N";
   ('compdefs)&('ordrbl) "generating panels, should ignore non-orderable",
      "but for now will pass them thru in case data refers to them",
      "Y";
   "otherwise we have something to output",
      "Y"}^tmp,
("Y"=tmp);

[7]::IS.PROFILE.OR.GROUP
("P"=typ)!("G"=typ);

[8]::IS.TTEST.OR.C
"type of C might be charge, but we havent filtered out in the past, so include here",
("T"=typ)!("C"=typ);

[9]::IS.REPORTABLE
&(SL)SLT[slt]|8^tmp,
("Y"=tmp);

[10]::IS.ORDERABLE
&(SL)SLT[slt]|9^tmp,
("Y"=tmp);

[11]::SEND
K(/T.COMPONENTS),
&(SL)SLD[&(SL)SLT[slt]|4]|1^CATEGORY,
&(SL)SLT[slt]|6^SHORTNAME,
&(SL)SLT[slt]|1^LONGNAME,
"seq must be an integer",
slt'#(L(slt,.))^SEQ,
A1^!,
A3_slt_A4^!,
"<Category>"_CATEGORY_"</Category>"^!,
"IS.PROFILE.OR.GROUP",@7^cntr,
IF{(compdefs)!(cntr) 1,
   "any compdef OR (paneldef for container), put longname into name",
      "<Name><![CDATA["_LONGNAME_"]]></Name>"^!,
      "<Display><![CDATA["_SHORTNAME_"]]></Display>"^!;
   "paneldef for component, put shortname into name",
      "<Name><![CDATA["_SHORTNAME_"]]></Name>"^!,
      "<Display><![CDATA["_LONGNAME_"]]></Display>"^!},
"<CollatingSequence>"_SEQ_"</CollatingSequence>"^!,
"<Key>"_"x"_slt_&(SL)SLT[slt]UPD_"</Key>"^!,
"<EventCodes>"^!,
IF{"IS.TTEST.OR.C",@8 "individual ttest, just put on list",
      slt^/T.COMPONENTS[slt][slt];
   "group/profile, populate components",
      ""^slt2,
      "GET.COMPONENTS",%labsetlist.txt(slt,slt)},
DO{"NEXT.TTEST",@12 "got one",
   "<EventCode>"^!,
   &(SL)SLT[slt2]|6^SHORTNAME,
   &(SL)SLT[slt2]|1^LONGNAME,
   "<DefinitionCode>"_slt2_"</DefinitionCode>"^!,
   "<Name><![CDATA["_SHORTNAME_"]]></Name>"^!,
   "<Display><![CDATA["_LONGNAME_"]]></Display>"^!,
   "<Key>"_"x"_&(SL)SLT[slt2]UPD_"</Key>"^!,
   "</EventCode>"^!},
"</EventCodes>"^!,
A2^!,
K(/T.COMPONENTS);

[12]::NEXT.TTEST
+/T.COMPONENTS[slt][slt2]^slt2;
