source: FOIAVistA/tag/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES5.m@ 1700

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

initial load of FOIAVistA 6/30/08 version

File size: 3.0 KB
Line 
1PRCHES5 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ;9/23/94 10:47 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 16.5 (ELECTRONIC SIGNATURE), FILE 442
5DECODE(LEVEL0) ;return esig in readable form
6 ;returns "" if unsuccessful
7 NEW RECORD,RECORD1,RECORD12,VERSION,PERSON,SIG,CHECKSUM
8 S RECORD=$G(^PRC(442,LEVEL0,0)) I RECORD="" Q ""
9 S RECORD1=$G(^PRC(442,LEVEL0,1))
10 S RECORD12=$G(^PRC(442,LEVEL0,12))
11 S VERSION=$P(RECORD12,"^",11)
12 S PERSON=+$P(RECORD1,"^",10)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD12,"^",2)
15D1 ;esig for ver 1
16 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD12))
17 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
18ENCODE(LEVEL0,USERNUM,Y) ;Encode esig for ver 1 only
19 NEW RECORD,RECORD1,RECORD12,SIGBLOCK,CHECKSUM,OLDUSER
20 S USERNUM=+USERNUM
21 I USERNUM=0 S Y=-3 Q ;-3 no user number
22 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
23 I SIGBLOCK="" S Y=-2 Q ;-2 no sig block
24 S RECORD=$G(^PRC(442,LEVEL0,0))
25 S RECORD1=$G(^PRC(442,LEVEL0,1))
26 S RECORD12=$G(^PRC(442,LEVEL0,12))
27 I RECORD="" S Y=-1 Q ;-1 no record
28 I $P(RECORD12,"^",2)'="" S Y=-4 Q ;-4 cannot re-sign record
29 S OLDUSER=+$P(RECORD1,"^",10)
30 I OLDUSER=0 S $P(RECORD1,"^",10)=USERNUM
31 I OLDUSER>0 S USERNUM=OLDUSER
32 S:$P(RECORD12,"^",3)="" $P(RECORD12,"^",3)=$$NOW^PRCUESIG
33 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD12))
34 S $P(RECORD12,"^",2)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
35 S $P(RECORD12,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
36 S ^PRC(442,LEVEL0,1)=RECORD1
37 S ^PRC(442,LEVEL0,12)=RECORD12
38 S Y=1 Q
39RECODE(LEVEL0,CHECKSUM,Y) ;Recode esig for ver 1 only
40 NEW RECORD,RECORD1,RECORD12,SIGBLOCK,USERNUM
41 S RECORD=$G(^PRC(442,LEVEL0,0))
42 S RECORD1=$G(^PRC(442,LEVEL0,1))
43 S RECORD12=$G(^PRC(442,LEVEL0,12))
44 I RECORD="" S Y=-1 Q ;-1 no record
45 S USERNUM=+$P(RECORD1,"^",10)
46 I $P(RECORD12,"^",2)=""!(USERNUM=0) S Y=-4 Q ;can't recode
47 ;S SIGBLOCK=$$DECODE^PRCUESIG($P(RECORD12,"^",2),USERNUM,CHECKSUM)
48 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
49 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD12))
50 S $P(RECORD12,"^",2)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
51 S $P(RECORD12,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
52 S ^PRC(442,LEVEL0,12)=RECORD12
53 S Y=1 Q
54REMOVE(LEVEL0) ;Entry point to remove esig
55 NEW I,RECORD1,RECORD12
56 S RECORD1=$G(^PRC(442,LEVEL0,1))
57 S RECORD12=$G(^PRC(442,LEVEL0,12))
58 F I=2,3,12 S $P(RECORD12,"^",I)=""
59 S ^PRC(442,LEVEL0,1)=RECORD1
60 S ^PRC(442,LEVEL0,12)=RECORD12
61 Q
62VERIFY(LEVEL0) ;verify ver 1 esig Returns 1 if valid
63 NEW RECORD,RECORD1,RECORD12,VERSION,SIGBLOCK
64 S RECORD12=$G(^PRC(442,LEVEL0,12))
65 S VERSION=$P(RECORD12,"^",11),SIGBLOCK=$P(RECORD12,"^",12)
66 I VERSION_SIGBLOCK="" Q 1
67 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
68STRING(X,X1,X12) ;Build String of critical fields
69 Q $P(X,"^")_"^"_$P(X1,"^",15)_"^"_$P(X,"^",3)_"^"_$P(X,"^",7)_"^"_$P(X,"^",9)_"^"_$P(X1,"^",1)_"^"_$P(X,"^",11)_"^"_$P(X,"^",13)_"^"_$P(X12,"^",3)
Note: See TracBrowser for help on using the repository browser.