source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES11.m@ 823

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

initial load of WorldVistAEHR

File size: 2.0 KB
Line 
1PRCHES11 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ; 1/4/93 11:04 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 3 (ELECTRONIC SIGNATURE), FILE 443
5DECODE(LEVEL0) ;Extrinsic Function to return hashed esig to readable form.
6 ;returns "" if unsuccessful
7 NEW RECORD,RECORD1,RECORD12,VERSION,PERSON,SIG,CHECKSUM
8 S RECORD=$G(^PRC(443,LEVEL0,0)) I RECORD="" Q ""
9 S VERSION=$P(RECORD,"^",14)
10 S PERSON=+$P(RECORD,"^",2)
11 I VERSION'="",VERSION'=1 Q ""
12 S SIG=$P(RECORD,"^",3)
13D1 ;decode e signature for version 1
14 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
15 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
16ENCODE(LEVEL0,USERNUM,Y) ;Encode esig for version 1 only
17 NEW RECORD,SIGBLOCK,CHECKSUM,OLDUSER
18 S USERNUM=+USERNUM
19 I USERNUM=0 S Y=-3 Q ;-3 no user number
20 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
21 I SIGBLOCK="" S Y=-2 Q ;-2 no signature block
22 S RECORD=$G(^PRC(443,LEVEL0,0))
23 I RECORD="" S Y=-1 Q ;-1 no record
24 I $P(RECORD,"^",3)'="" S Y=-4 Q ;-4 cannot re-sign record
25 S OLDUSER=+$P(RECORD,"^",2)
26 I OLDUSER=0 S $P(RECORD,"^",2)=USERNUM
27 I OLDUSER>0 S USERNUM=OLDUSER
28 S:$P(RECORD,"^",4)="" $P(RECORD,"^",4)=$$NOW^PRCUESIG
29 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
30 S $P(RECORD,"^",3)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
31 S $P(RECORD,"^",14)=1,$P(RECORD,"^",13)=$$SUM^PRCUESIG(SIGBLOCK)
32 S ^PRC(443,LEVEL0,0)=RECORD
33 S Y=1 Q
34REMOVE(LEVEL0) ;Entry point to remove esig
35 NEW I,RECORD
36 S RECORD=$G(^PRC(443,LEVEL0,0))
37 F I=2,3,4,13 S $P(RECORD,"^",I)=""
38 S ^PRC(443,LEVEL0,0)=RECORD
39 Q
40VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
41 NEW RECORD,VERSION,SIGBLOCK
42 S RECORD=$G(^PRC(443,LEVEL0,0))
43 S VERSION=$P(RECORD,"^",14),SIGBLOCK=$P(RECORD,"^",13)
44 I VERSION_SIGBLOCK="" Q 1
45 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
46STRING(X) ;Build String of critical fields
47 Q $P(X,"^")_"^"_$P(X,"^",4)_"^"_$P(X,"^",9)
Note: See TracBrowser for help on using the repository browser.