LOGIN
@LOGIN.OPEN.PREFIXES,
@LOGIN.VERIFY.USER,
@LOGIN.HDR,
@LOGIN.SEND.FILE,
@LOGIN.TRLR,
END;

LOGIN.OPEN.PREFIXES
@misdir,
O(&,@misdict),
@pkdir

LOGIN.VERIFY.USER
"Error"^so,
IF{/ARGV[1]^LOGINNAME^usr,
/ARGV[2]^pw^Q,
IF{/CONF[.login.encrypt] @LOGIN.ENCRYPT},
IF{&GUIX[usr]^usr2 usr2^usr},
Q'=(&GU[usr]|2) "Bad Password"^sod;
%Z.date.in("T")'<(&GU[usr]|7) "Expired Password"^sod;
"Success"^so^sod},so_" "_sod

LOGIN.ENCRYPT
""^X^i^V^L^j,
DO{Q X*96+IF{E(Q)>31<128;32}-32^X,Q%0^Q},
Q(1,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73)^PR,
DO{V#0+i\21^i,V*X+PR|i^V,
IF{L(V)/2^L>6 V%L_(V$L)^V},
j+1^j<21&(L<70)},
V\205220027820018761729^Q

LOGIN.HDR
"<?xml version="_D(34)_1.0_D(34)_"?>"^!,
"<ReplyMessage>"^!,
"<TransactionId>"_0_"</TransactionId>"^!,
"<Status>"_so_"</Status>"^!,
"<StatusDescription>"_sod_"</StatusDescription>"^!,
"<Payload>"^!,
"<Prsnl>"^!

LOGIN.SEND.FILE
"<FullName><![CDATA["_&GU[usr]|1_"]]></FullName>"^!,
"<UserNumber>"_(&GU[usr]|13^ggg)_"</UserNumber>"^!,
"<Username>"_LOGINNAME_"</Username>"^!,
"<Key/>"^!,
"<Positions>"^!,
"<Position>"^!,
"<Display>"_IF{ggg "Provider";"User"}_"</Display>"^!,
"<PrsnlReltnTypes>"^!,
"<PrsnlReltnType>"^!,
"<Display>PatientKeeper</Display>"^!,
"<Mnemonic>PATIENTKEEPERDOC</Mnemonic>"^!,
"</PrsnlReltnType>"^!,
"</PrsnlReltnTypes>"^!,
"</Position>"^!,
"</Positions>"^!,
"<Groups>"^!,
IF{&GGG[ggg]|14 "<Group>"^!,
"<Display><![CDATA["_&GGH[&GGG[ggg]|14]|1_"]]></Display>"^!,
"<Mnemonic><![CDATA[GRP."_&GGG[ggg]|14_"]]></Mnemonic>"^!,
"</Group>"^!},
""^FAC,
DO{+&GGG[ggg]FAC[FAC]^FAC IF{&GGG[ggg]FAC[FAC]|14^Q 1,
"<Group>"^!,
"<Display><![CDATA["_&GGH[Q]|1_"]]></Display>"^!,
"<Mnemonic><![CDATA[GRP."_Q_"]]></Mnemonic>"^!,
"</Group>"^!}},
"</Groups>"^!

LOGIN.TRLR
"</Prsnl>"^!,
"</Payload>"^!,
"</ReplyMessage>"^!
