source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCFDES1.m@ 810

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

initial load of WorldVistAEHR

File size: 2.7 KB
Line 
1PRCFDES1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;1/19/93 1:05 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 FIELD 61 (CERTIFIED BY ELEC SIG), FILE 421.5
5DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
6 ;returns "" if unsuccessful
7 NEW RECORD2,RECORD21,VERSION,PERSON,SIG,CHECKSUM
8 ;get record and check version
9 S RECORD2=$G(^PRCF(421.5,LEVEL0,2)) I RECORD2="" QUIT ""
10 S RECORD21=$G(^PRCF(421.5,LEVEL0,2.1))
11 S VERSION=$P(RECORD21,"^",1)
12 S PERSON=+$P(RECORD2,"^",10)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD2,"^",12)
15D1 ;decode e signature for version 1
16 S RECORD=$G(^PRCF(421.5,LEVEL0,0))
17 S RECORD1=$G(^PRCF(421.5,LEVEL0,1))
18 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1))
19 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
20ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
21 ;Parameter passing entry point
22 NEW SIGBLOCK,CHECKSUM,OLDUSER
23 NEW RECORD,RECORD1,RECORD2,RECORD21
24 ;get record
25 S USERNUM=+USERNUM
26 I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
27 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
28 I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
29 S RECORD=$G(^PRCF(421.5,LEVEL0,0))
30 S RECORD1=$G(^PRCF(421.5,LEVEL0,1))
31 S RECORD2=$G(^PRCF(421.5,LEVEL0,2))
32 S RECORD21=$G(^PRCF(421.5,LEVEL0,2.1))
33 I RECORD="" S Y=-1 QUIT ;-1 no transaction record
34 I $P(RECORD2,"^",12)'="" S Y=-4 QUIT ;-4 cannot re-sign record
35 S OLDUSER=+$P(RECORD2,"^",10)
36 I OLDUSER=0 S $P(RECORD2,"^",10)=USERNUM
37 I OLDUSER>0 S USERNUM=OLDUSER
38 S:$P(RECORD21,"^",5)="" $P(RECORD21,"^",5)=$$NOW^PRCUESIG
39 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1))
40 S $P(RECORD2,"^",12)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
41 S $P(RECORD21,"^",1,2)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
42 S ^PRCF(421.5,LEVEL0,2)=RECORD2
43 S ^PRCF(421.5,LEVEL0,2.1)=RECORD21
44 S Y=1 QUIT
45REMOVE(LEVEL0) ;Entry point to remove e signature from record
46 ;NOT an extrinsic function
47 NEW RECORD2,RECORD21,I
48 S RECORD2=$G(^PRCF(421.5,LEVEL0,2))
49 S RECORD21=$G(^PRCF(421.5,LEVEL0,2.1))
50 F I=10,12 S $P(RECORD2,"^",I)=""
51 F I=2,5 S $P(RECORD21,"^",I)=""
52 S ^PRCF(421.5,LEVEL0,2)=RECORD2
53 S ^PRCF(421.5,LEVEL0,2.1)=RECORD21
54 QUIT
55VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
56 NEW RECORD21,VERSION,SIGBLOCK
57 ;get record variables
58 S RECORD21=$G(^PRCF(421.5,LEVEL0,2.1))
59 S VERSION=$P(RECORD21,"^",1),SIGBLOCK=$P(RECORD21,"^",2)
60 I VERSION_SIGBLOCK="" QUIT 1
61 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
62STRING(X,X1) ;Build String of critical fields
63 NEW RECORD,RECORD1
64 Q $P(X,"^",1)_"^"_$P(X,"^",3)_"^"_$P(X,"^",4)_"^"_$P(X,"^",8)_"^"_$P(X,"^",15)_"^"_$P(X1,"^",3)
Note: See TracBrowser for help on using the repository browser.