source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES1.m@ 1783

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

initial load of FOIAVistA 6/30/08 version

File size: 3.1 KB
Line 
1PRCHES1 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ;3/18/93 11:42
2V ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;ROUTINE FOR MAINTAINING SUBFIELD 7 (ELECTRONIC SIGNATURE)
5 ; FIELD .6 (PARTIAL), FILE 442
6DECODE(LEVEL0,LEVEL1) ;Extrinsic Function to return hashed esig in readable form.
7 ;returns "" if unsuccessful
8 NEW RECORD,RECORD1,VERSION,PERSON,SIG,CHECKSUM
9 ;get record and check version
10 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0)) I RECORD="" Q ""
11 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
12 S VERSION=$P(RECORD1,"^",9)
13 S PERSON=+$P(RECORD,"^",7)
14 I VERSION'="",VERSION'=1 Q ""
15 S SIG=$P(RECORD,"^",8)
16D1 ;decode e signature for version 1
17 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
18 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
19ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode esig for version 1 only
20 NEW RECORD,RECORD1,SIGBLOCK,CHECKSUM,OLDUSER
21 S USERNUM=+USERNUM
22 I USERNUM=0 S Y=-3 Q ;-3 no user number
23 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
24 I SIGBLOCK="" S Y=-2 Q ;-2 no signature block
25 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
26 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
27 I RECORD="" S Y=-1 Q ;-1 no 2237 record
28 I $P(RECORD,"^",8)'="" S Y=-4 Q ;-4 cannot re-sign record
29 S OLDUSER=+$P(RECORD,"^",7)
30 I OLDUSER=0 S $P(RECORD,"^",7)=USERNUM
31 I OLDUSER>0 S USERNUM=OLDUSER
32 S:$P(RECORD,"^",11)="" $P(RECORD,"^",11)=$$NOW^PRCUESIG
33 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
34 S $P(RECORD,"^",8)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
35 S $P(RECORD1,"^",9,10)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
36 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
37 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
38 S Y=1 Q
39RECODE(LEVEL0,LEVEL1,CHECKSUM,Y) ;Recode esig for version 1 only
40 NEW RECORD,RECORD1,SIGBLOCK,USERNUM
41 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
42 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
43 I RECORD=""!(RECORD1="") S Y=-1 Q ;-1 no record
44 S USERNUM=+$P(RECORD,"^",7)
45 I $P(RECORD,"^",8)=""!(USERNUM=0) S Y=-4 Q ;-4 cannot recode record
46 ;S SIGBLOCK=$$DECODE^PRCUESIG($P(RECORD,"^",8),USERNUM,CHECKSUM)
47 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
48 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
49 S $P(RECORD,"^",8)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
50 S $P(RECORD1,"^",10)=$$SUM^PRCUESIG(SIGBLOCK)
51 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
52 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
53 S Y=1
54 Q
55REMOVE(LEVEL0,LEVEL1) ;Entry point to remove esig
56 NEW I,RECORD,RECORD1
57 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
58 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
59 F I=7,8,11 S $P(RECORD,"^",I)=""
60 S $P(RECORD1,"^",10)=""
61 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
62 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
63 Q
64VERIFY(LEVEL0,LEVEL1) ;extrinsic function to verify esig Returns 1 if valid, 0 if not valid
65 NEW RECORD,RECORD1,VERSION,SIGBLOCK
66 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
67 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
68 S VERSION=$P(RECORD1,"^",9),SIGBLOCK=$P(RECORD1,"^",10)
69 I VERSION_SIGBLOCK="" Q 1
70 Q $$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK
71STRING(X) ;Build String of critical fields
72 Q $P(X,"^")_"^"_$P(X,"^",3)_"^"_$P(X,"^",5)_"^"_$P(X,"^",11)_"^"_$P(X,"^",12)_"^"_$P(X,"^",14)
Note: See TracBrowser for help on using the repository browser.