source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES0.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: 2.2 KB
Line 
1PRCHES0 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ; 05/15/93 1:30 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 SUBFIELD 3 (ELECTRONIC SIGNATURE)
5 ; FIELD .05 (2237 REFERENCE NUMBER), FILE 442
6DECODE(LEVEL0,LEVEL1) ;Extrinsic Function to return hashed electronic sig to readable form.
7 ;returns "" if unsuccessful
8 NEW RECORD,VERSION,PERSON,SIG,CHECKSUM
9 ;get record and check version
10 S RECORD=$G(^PRC(442,LEVEL0,13,LEVEL1,0)) I RECORD="" Q ""
11 S VERSION=$P(RECORD,"^",14)
12 S PERSON=+$P(RECORD,"^",2)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD,"^",3)
15D1 ;decode e signature for version 1
16 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
17 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
18ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;usage:D ENCODE^PRCHES0(...)
19 ;Encode esig for version 1 only
20 NEW RECORD,SIGBLOCK,CHECKSUM,OLDUSER
21 ;get record
22 S USERNUM=+USERNUM
23 I USERNUM=0 S Y=-3 Q ;-3 no user number
24 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
25 I SIGBLOCK="" S Y=-2 Q ;-2 = no sig block in file 200
26 S RECORD=$G(^PRC(442,LEVEL0,13,LEVEL1,0))
27 I RECORD="" S Y=-1 Q ;-1 no record
28 I $P(RECORD,"^",3)'="" S Y=-4 Q ;-4 cannot re-sign record
29 S OLDUSER=+$P(RECORD,"^",2)
30 I OLDUSER=0 S $P(RECORD,"^",2)=USERNUM
31 I OLDUSER>0 S USERNUM=OLDUSER
32 S:$P(RECORD,"^",4)="" $P(RECORD,"^",4)=$$NOW^PRCUESIG
33 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
34 S $P(RECORD,"^",3)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
35 S $P(RECORD,"^",13,14)=$$SUM^PRCUESIG(SIGBLOCK)_"^"_1
36 S ^PRC(442,LEVEL0,13,LEVEL1,0)=RECORD
37 S Y=1 Q
38REMOVE(LEVEL0,LEVEL1) ;Entry Point to remove esig
39 NEW I,RECORD
40 S RECORD=$G(^PRC(442,LEVEL0,13,LEVEL1,0)) I RECORD="" Q
41 F I=2,3,4,13 S $P(RECORD,"^",I)=""
42 S ^PRC(442,LEVEL0,13,LEVEL1,0)=RECORD
43 Q
44VERIFY(LEVEL0,LEVEL1) ;extrinsic function to verify esig Returns 1 if valid, 0 if not valid
45 NEW RECORD,VERSION,SIGBLOCK
46 S RECORD=$G(^PRC(442,LEVEL0,13,LEVEL1,0))
47 S VERSION=$P(RECORD,"^",14),SIGBLOCK=$P(RECORD,"^",13)
48 I VERSION_SIGBLOCK="" Q 1
49 Q $$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK
50STRING(X) ;Build String of critical fields
51 Q $P(X,"^")_"^"_$P(X,"^",4)_"^"_$P(X,"^",9)
Note: See TracBrowser for help on using the repository browser.