RSLTDATA.TXT,
"HDR",@1,
"HANDLE.ARGS",@2,
"TRLR",@5,
END;

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

[2]::HANDLE.ARGS
%open("NUR"),
%open("RAD"),
1^nr,
DO{nr</ARGC 1,
   /ARGV[nr]^arg,
   "HANDLE.ARG",@3,
   nr+1^nr};

[3]::HANDLE.ARG
K(/T.INFO),
K(/T.REC),
arg$1^prefix,
arg'$1^mnemonic,
IF{prefix="N" %nurnotedata.txt(prefix,mnemonic);
   prefix="R" %radnotedata.txt(prefix,mnemonic)},
"SEND.TEST",@4,
K(/T.INFO),
K(/T.REC);

[4]::SEND.TEST
"<Document>"^!,
"<Display><![CDATA["_(/T.INFO["TESTNAME"])_"]]></Display>"^!,
"<EventMnemonic></EventMnemonic>"^!,
"<EventCode><Mnemonic></Mnemonic></EventCode>"^!,
"<PersonMnemonic>"_(/T.INFO["MRN"])_"</PersonMnemonic>"^!,
"<EncounterMnemonic>"_(/T.INFO["ACCT"])_"</EncounterMnemonic>"^!,
"<EventEndDateTime>"_(/T.INFO["TESTDATE"])_"</EventEndDateTime>"^!,
"<InstanceMnemonic>"_prefix_mnemonic_"</InstanceMnemonic>"^!,
"append x to key to ensure that its not empty",
"<Key>"_"x"_(/T.INFO["UPDATENODE"])_"</Key>"^!,
"<EventSetMnemonic>"_(/T.INFO["TESTTYPE"])_"</EventSetMnemonic>"^!,
"<ResultStatus>"^!,
"<Display>"^!,
IF{/T.INFO["STATUS"]="ORD" "Ordered";
   /T.INFO["STATUS"]="COLB" "Collection Batch";
   /T.INFO["STATUS"]="RECD" "Received";
   /T.INFO["STATUS"]="UNV" "Unverified Results";
   /T.INFO["STATUS"]="RES" "Resulted";
   /T.INFO["STATUS"]="COMP" "Completed";
   /T.INFO["STATUS"]="CAN" "Cancelled";
   /T.INFO["STATUS"]="SOUT" "Signed";
   /T.INFO["STATUS"]="ENT" "Entered";
   /T.INFO["STATUS"]}^!,
"</Display>"^!,
"<Meaning>"_(/T.INFO["STATUS"])_"</Meaning>"^!,
"<Value></Value>"^!,
"</ResultStatus>"^!,
IF{/T.INFO["AUTHOR"] "<EventPrsnlActions>"^!,
   "<EventPrsnlAction>"^!,
   "<ActionPrsnl><FullName>"_(/T.INFO["AUTHOR"])_"</FullName></ActionPrsnl>"^!,
   "<ActionType><Meaning>AUTHOR</Meaning></ActionType>"^!,
   "</EventPrsnlAction>"^!,
   "</EventPrsnlActions>"^!},
"<DocumentComponents><Body><![CDATA["^!,
""^T,
DO{+(/T.REC[T],XX)^T XX_D(10)^!},
"]]></Body></DocumentComponents></Document>"^!;

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