source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCSC3.m@ 836

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

initial load of WorldVistAEHR

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