source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCSC1.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 4.2 KB
Line 
1PRCSC1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;4/23/97 8:55 AM
2V ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;ROUTINE FOR MAINTAINING FIELD 44.5 (ELECTRONIC SIGNATURE), FILE 410
5DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
6 ;returns "" if unsuccessful
7 NEW RECORD7,RECORD71,VERSION,PERSON,SIG,CHECKSUM
8 ;get record and check version
9 S RECORD7=$G(^PRCS(410,LEVEL0,7)) I RECORD7="" QUIT ""
10 S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
11 S VERSION=$P(RECORD71,"^",3)
12 S PERSON=+$P(RECORD7,"^",3)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD7,"^",6)
15 I VERSION=1 G D1
16D ;decode e signature less than version 1
17 S X=$$DECODE^PRCUESIG(SIG,LEVEL0,PERSON)
18 QUIT X
19D1 ;decode e signature for version 1
20 S RECORD=$G(^PRCS(410,LEVEL0,0))
21 S RECORD1=$G(^PRCS(410,LEVEL0,1))
22 S RECORD2=$G(^PRCS(410,LEVEL0,2))
23 S RECORD3=$G(^PRCS(410,LEVEL0,3))
24 S RECORD4=$G(^PRCS(410,LEVEL0,4))
25 S RECORD10=$G(^PRCS(410,LEVEL0,10))
26 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
27 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
28ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
29 ;Parameter passing entry point
30 NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM,OLDUSER
31 ;get record
32 S USERNUM=+USERNUM
33 I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
34 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
35 I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
36 S RECORD=$G(^PRCS(410,LEVEL0,0))
37 S RECORD1=$G(^PRCS(410,LEVEL0,1))
38 S RECORD2=$G(^PRCS(410,LEVEL0,2))
39 S RECORD3=$G(^PRCS(410,LEVEL0,3))
40 S RECORD4=$G(^PRCS(410,LEVEL0,4))
41 S RECORD7=$G(^PRCS(410,LEVEL0,7))
42 S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
43 S RECORD10=$G(^PRCS(410,LEVEL0,10))
44 I RECORD="" S Y=-1 QUIT ;-1 no transaction record
45 I $P(RECORD7,"^",6)'="" S Y=-4 QUIT ;-4 cannot re-sign record
46 S OLDUSER=+$P(RECORD7,"^",3)
47 I OLDUSER=0 S $P(RECORD7,"^",3)=USERNUM
48 I OLDUSER>0 S USERNUM=OLDUSER
49 S:$P(RECORD7,"^",7)="" $P(RECORD7,"^",7)=$$NOW^PRCUESIG
50 S:$P(RECORD7,"^",5)="" $P(RECORD7,"^",5)=$P($$NOW^PRCUESIG,".",1)
51 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
52 S $P(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
53 S $P(RECORD7,"^",4)=$P($G(^VA(200,USERNUM,20)),"^",3)
54 S $P(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
55 S ^PRCS(410,LEVEL0,7)=RECORD7
56 S ^PRCS(410,LEVEL0,7.1)=RECORD71
57 S Y=1 QUIT
58RECODE(LEVEL0,Y) ;Recode esig for version 1 only
59 NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM
60 NEW DA,DIC,RECORD1,RECORD10,RECORD2,RECORD3,RECORD4,USERNUM
61 S RECORD=$G(^PRCS(410,LEVEL0,0))
62 S RECORD1=$G(^PRCS(410,LEVEL0,1))
63 S RECORD2=$G(^PRCS(410,LEVEL0,2))
64 S RECORD3=$G(^PRCS(410,LEVEL0,3))
65 S RECORD4=$G(^PRCS(410,LEVEL0,4))
66 S RECORD7=$G(^PRCS(410,LEVEL0,7))
67 S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
68 S RECORD10=$G(^PRCS(410,LEVEL0,10))
69 I RECORD="" S Y=-1 QUIT ;-1 no transaction record
70 S USERNUM=+$P(RECORD7,"^",3)
71 I $P(RECORD7,"^",6)=""!(USERNUM=0) S Y=-4 QUIT ;-4 cannot re-sign record
72 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
73 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
74 S $P(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
75 S $P(RECORD7,"^",4)=$P($G(^VA(200,USERNUM,20)),"^",3)
76 S $P(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
77 S ^PRCS(410,LEVEL0,7)=RECORD7
78 S ^PRCS(410,LEVEL0,7.1)=RECORD71
79 S Y=1 QUIT
80REMOVE(LEVEL0) ;Entry point to remove e signature from record
81 ;NOT an extrinsic function
82 NEW RECORD7,RECORD71
83 S RECORD7=$G(^PRCS(410,LEVEL0,7))
84 S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
85 S $P(RECORD7,"^",3,7)="^^^^"
86 S $P(RECORD71,"^",4)=""
87 S ^PRCS(410,LEVEL0,7)=RECORD7
88 S ^PRCS(410,LEVEL0,7.1)=RECORD71
89 QUIT
90VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
91 NEW RECORD71,VERSION,SIGBLOCK
92 ;get record variables
93 S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
94 S VERSION=$P(RECORD71,"^",3),SIGBLOCK=$P(RECORD71,"^",4)
95 I VERSION_SIGBLOCK="" QUIT 1
96 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
97STRING(X,X1,X2,X3,X4,X7,X10) ;Build String of critical fields
98 Q $P(X,"^",1)_"^"_$P(X1,"^",1)_"^"_$P(X2,"^",1)_"^"_$P(X3,"^",1)_"^"_$P(X3,"^",3)_"^"_$P(X4,"^",1)_"^"_$P(X7,"^",7)_"^"_$P(X10,"^",1)
Note: See TracBrowser for help on using the repository browser.