source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCSC2.m@ 1688

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

initial load of FOIAVistA 6/30/08 version

File size: 2.9 KB
Line 
1PRCSC2 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;3/3/95 3:22 PM
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 29.5 (OBLIGATION E S CODE), FILE 410
5DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
6 ;returns "" if unsuccessful
7 NEW RECORD,RECORD4,VERSION,PERSON,SIG,CHECKSUM
8 ;get record and check version
9 S RECORD=$G(^PRCS(410,LEVEL0,0)) I RECORD="" QUIT ""
10 S RECORD4=$G(^PRCS(410,LEVEL0,4))
11 S VERSION=$P(RECORD4,"^",11)
12 S PERSON=+$P(RECORD4,"^",9)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD4,"^",10)
15D1 ;decode e signature for version 1
16 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD4))
17 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
18ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
19 ;Parameter passing entry point
20 NEW RECORD,RECORD4,SIGBLOCK,CHECKSUM,OLDUSER
21 ;get record
22 S USERNUM=+USERNUM
23 I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
24 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
25 I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
26 S RECORD=$G(^PRCS(410,LEVEL0,0))
27 S RECORD4=$G(^PRCS(410,LEVEL0,4))
28 I RECORD="" S Y=-1 QUIT ;-1 no transaction record
29 I $P(RECORD4,"^",10)'="" S Y=-4 QUIT ;-4 cannot re-sign record
30 S OLDUSER=+$P(RECORD4,"^",9)
31 I OLDUSER=0 S $P(RECORD4,"^",9)=USERNUM
32 I OLDUSER>0 S USERNUM=OLDUSER
33 S:$P(RECORD4,"^",13)="" $P(RECORD4,"^",13)=$$NOW^PRCUESIG
34 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD4))
35 S $P(RECORD4,"^",10)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
36 S $P(RECORD4,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
37 S ^PRCS(410,LEVEL0,4)=RECORD4
38 S Y=1 QUIT
39RECODE(LEVEL0,Y) ;Recode esig for ver 1 only
40 N RECORD,RECORD4,SIGBLOCK,USERNUM
41 S RECORD=$G(^PRCS(410,LEVEL0,0))
42 S RECORD4=$G(^PRCS(410,LEVEL0,4))
43 I RECORD="" S Y=-1 Q ;-1 no record
44 S USERNUM=+$P(RECORD4,"^",9)
45 I $P(RECORD4,U,10)=""!(USERNUM=0) S Y=-4 Q ;can't recode
46 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
47 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD4))
48 S $P(RECORD4,"^",10)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
49 S $P(RECORD4,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
50 S ^PRCS(410,LEVEL0,4)=RECORD4
51 S Y=1 QUIT
52REMOVE(LEVEL0) ;Entry point to remove esig from record
53 ;NOT an extrinsic function
54 NEW RECORD4,I
55 S RECORD4=$G(^PRCS(410,LEVEL0,4))
56 F I=9,10,12,13 S $P(RECORD4,"^",I)=""
57 S ^PRCS(410,LEVEL0,4)=RECORD4
58 QUIT
59VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
60 NEW RECORD4,VERSION,SIGBLOCK
61 ;get record variables
62 S RECORD4=$G(^PRCS(410,LEVEL0,4))
63 S VERSION=$P(RECORD4,"^",11),SIGBLOCK=$P(RECORD4,"^",12)
64 I VERSION_SIGBLOCK="" QUIT 1
65 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
66STRING(X,X4) ;Build String of critical fields
67 NEW RECORD,RECORD4,SIGBLOCK,CHECKSUM,OLDUSER
68 Q $P(X,"^",1)_"^"_$P(X4,"^",3)_"^"_$P(X4,"^",4)_"^"_$P(X4,"^",5)_"^"_$P(X4,"^",13)
Note: See TracBrowser for help on using the repository browser.