source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES12.m@ 1154

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

initial load of FOIAVistA 6/30/08 version

File size: 2.3 KB
Line 
1PRCHES12 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ;9/23/94 10:49 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 443.6
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.6,LEVEL0,0)) I RECORD="" Q ""
9 S RECORD1=$G(^PRC(443.6,LEVEL0,1))
10 S RECORD12=$G(^PRC(443.6,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 ;decode e signature for version 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 version 1 only
19 S Y=-4 Q ;-4 cannot encode record
20 ;
21RECODE(LEVEL0,CHECKSUM,Y) ;Recode esig for version 1 only
22 NEW RECORD,RECORD1,RECORD12,SIGBLOCK,USERNUM
23 S RECORD=$G(^PRC(443.6,LEVEL0,0))
24 S RECORD1=$G(^PRC(443.6,LEVEL0,1))
25 S RECORD12=$G(^PRC(443.6,LEVEL0,12))
26 I RECORD="" S Y=-1 Q ;-1 no record
27 S USERNUM=+$P(RECORD1,"^",10)
28 I $P(RECORD12,"^",2)=""!(USERNUM=0)!'CHECKSUM S Y=-4 Q ;-4 cannot recode record
29 ;S SIGBLOCK=$$DECODE^PRCUESIG($P(RECORD12,"^",2),USERNUM,CHECKSUM)
30 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
31 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD12))
32 S $P(RECORD12,"^",2)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
33 S $P(RECORD12,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
34 S ^PRC(443.6,LEVEL0,12)=RECORD12
35 S Y=1 Q
36REMOVE(LEVEL0) ;Entry point to remove esig from record
37 NEW I,RECORD1,RECORD12
38 S RECORD1=$G(^PRC(443.6,LEVEL0,1))
39 S RECORD12=$G(^PRC(443.6,LEVEL0,12))
40 F I=2,3,12 S $P(RECORD12,"^",I)=""
41 S ^PRC(443.6,LEVEL0,1)=RECORD1
42 S ^PRC(443.6,LEVEL0,12)=RECORD12
43 Q
44VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
45 NEW RECORD,RECORD1,RECORD12,VERSION,SIGBLOCK
46 S RECORD12=$G(^PRC(443.6,LEVEL0,12))
47 S VERSION=$P(RECORD12,"^",11),SIGBLOCK=$P(RECORD12,"^",12)
48 I VERSION_SIGBLOCK="" Q 1
49 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
50STRING(X,X1,X12) ;Build String of critical fields
51 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.