source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORUTL03.m@ 1704

Last change on this file since 1704 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1RORUTL03 ;HOIFO/CRT,SG - ENCRYPTION/DECRYPTION ; 7/14/05 2:59pm
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** DECRYPTS THE STRING
7DECRYPT(S) ;
8 N ASSOCIX,ASSOCSTR,IDIX,IDSTR
9 S ASSOCIX=$A($E(S,$L(S)))-31,IDIX=$A($E(S))-31
10 S ASSOCSTR=$P($T(Z+ASSOCIX),";;",2,99)
11 S IDSTR=$P($T(Z+IDIX),";;",2,99)
12 Q $TR($E(S,2,$L(S)-1),ASSOCSTR,IDSTR)
13 ;
14 ;***** ENCRYPTS THE STRING
15ENCRYPT(S) ;
16 N %,ASSOCIX,ASSOCSTR,IDIX,IDSTR
17 S ASSOCIX=$R(20)+1
18 F S IDIX=$R(20)+1 Q:ASSOCIX'=IDIX
19 S ASSOCSTR=$P($T(Z+ASSOCIX),";;",2,99)
20 S IDSTR=$P($T(Z+IDIX),";;",2,99)
21 Q $C(IDIX+31)_$TR(S,IDSTR,ASSOCSTR)_$C(ASSOCIX+31)
22 ;
23 ;***** RETURNS DEFAULT SITE FOR HL7 MESSAGES
24SITE(CS) ;
25 N RORSITE,RORSTN S:$G(CS)="" CS="^"
26 S RORSITE=$$SITE^VASITE
27 I RORSITE<0 D Q ""
28 . D ERROR^RORERR(-56,,,,RORSITE,"$$SITE^VASITE")
29 S RORSTN=$E($P(RORSITE,"^",3),1,3)
30 Q RORSTN_CS_$P(RORSITE,"^",2)_CS_"99VA4"
31 ;
32 ;***** XOR ENCRYPTION (from ICR v2.1)
33XOR(X) ;
34 N I,SUFFIX
35 ;--- Separate digits and letters (the suffix)
36 I X'?1N.N D S SUFFIX=$E(X,I,99),X=$E(X,1,I-1)
37 . F I=1:1 Q:$E(X,I)'?1N
38 ;--- Convert the numeric part to hexadecimal
39 S X=$$CNV^XLFUTL(X,16)
40 ;--- Perform XOR of each hexadecimal digit with '1101' (0xD)
41 S X=$TR(X,"0123456789ABCDEF","DCFE98BA54761032")
42 ;--- Pad with 0xD from the left so that the value will contain
43 ; no less that 9 hexadecimal digits, convert numeric part
44 ;--- back to decimal and append the suffix (if available)
45 Q $$DEC^XLFUTL($TR($J(X,9)," ","D"),16)_$G(SUFFIX)
46 ;
47 ;***** ENCODES THE SPECIAL CHARACTERS (&, <, ', and ")
48 ;
49 ; STR Source string
50 ;
51XMLENC(STR) ;
52 N CH,I,IC
53 F I=1:1:5 S CH=$E("&<""'>",I),IC=1 D
54 . F S IC=$F(STR,CH,IC) Q:IC'>0 D
55 . . S $E(STR,IC-1,IC-1)=$P("&amp;^&lt;^&quot;^&apos;^&gt;","^",I)
56 Q STR
57 ;
58 ;***** ENCRYPTION/DECRYPTION TABLE
59Z ;;
60 ;;ko-ZJtdG)49K{nX1BS$vH<:Myf*>Ae0!jQW=;#PwsO`E'%+rmb[gpqN,l6/hFC@DcUa ]zR}"ViIxu?872.(TYL5_3
61 ;;`R;M/9BqAF%tSs#Vh)dO1DZP>r *fX'u[.4KlY=-mg_ci802N7LTG<]!CWo:3?{v+,5Q}(@jaExn$pIyHwzU"k6Jeb
62 ;;ZJk"WQmCn!Y,y@1d+8s?[lNMxgHE(t=uwX:qSLjAI*}6zoF{T3#;cap)/h5%`P4$r]G'9e2if_>UDKb7V<v0- RBO.
63 ;;dpjt3g4W)qD0VNJarseB "?OYhcu[<M%Z`RIL_6:]AX-zG.#}$@vk7/5x*m;(yb2Fn+l'PwUof1K{9,EQi>H=CT8S!
64 ;;:1}K$byP;jk)7'`x90Bcq@iSsEnu,(Nl-hf.Y_?J#R]+voQXZU8mrV[!p4tgOWMez CAaGFD6H53%L/dT2<*>"{wI=
65 ;;J<oZ9phXVNn)m K`t/SI%]A5qOWe?;jTM!fz1l>[D_0xR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