1 | PRPFSIG1 ;WISC@ALTOONA/CTB-ESIG MAINTENANCE ROUTINE ;11/22/96 4:45 PM
|
---|
2 | V ;;3.0;PATIENT FUNDS;**6**;JUNE 1, 1989
|
---|
3 | ;ROUTINE FOR MAINTAINING FIELD 14 (ELECTRONIC SIGNATURE CIDE), FILE 470.1
|
---|
4 | DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
|
---|
5 | ;returns "" if unsuccessful
|
---|
6 | NEW RECORD,VERSION,PERSON,SIG,CHECKSUM
|
---|
7 | ;get record and check version
|
---|
8 | S RECORD=$G(^PRPF(470.1,LEVEL0,0)) I RECORD="" QUIT ""
|
---|
9 | S VERSION=$P(RECORD,"^",22)
|
---|
10 | S PERSON=+$P(RECORD,"^",14)
|
---|
11 | I VERSION'="",VERSION'=1 Q ""
|
---|
12 | S SIG=$P(RECORD,"^",15)
|
---|
13 | I VERSION=1 G D1
|
---|
14 | D ;decode e signature less than version 1
|
---|
15 | S X=$$DECODE^PRPFSIG(SIG,LEVEL0,PERSON)
|
---|
16 | QUIT X
|
---|
17 | D1 ;decode e signature for version 1
|
---|
18 | S CHECKSUM=$$SUM^PRPFSIG(LEVEL0_"^"_$$STRING(RECORD))
|
---|
19 | QUIT $$DECODE^PRPFSIG(SIG,PERSON,CHECKSUM)
|
---|
20 | ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
|
---|
21 | ;Parameter passing entry point
|
---|
22 | NEW RECORD,RECORD4,SIGBLOCK,CHECKSUM,OLDUSER
|
---|
23 | ;get record
|
---|
24 | S RECORD=$G(^PRPF(470.1,LEVEL0,0))
|
---|
25 | I RECORD="" S Y=-1 QUIT ;-1 no master record
|
---|
26 | S OLDUSER=+$P(RECORD,"^",14)
|
---|
27 | I OLDUSER=0 S $P(RECORD,"^",14)=USERNUM
|
---|
28 | I OLDUSER>0 S USERNUM=OLDUSER
|
---|
29 | S USERNUM=+USERNUM
|
---|
30 | I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
|
---|
31 | S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
|
---|
32 | I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
|
---|
33 | I $P(RECORD,"^",15)'="" S Y=-4 QUIT ;-4 cannot re-sign record
|
---|
34 | S:$P(RECORD,"^",23)="" $P(RECORD,"^",23)=$$NOW^PRPFSIG
|
---|
35 | S CHECKSUM=$$SUM^PRPFSIG(LEVEL0_"^"_$$STRING(RECORD))
|
---|
36 | S $P(RECORD,"^",15)=$$ENCODE^PRPFSIG(SIGBLOCK,USERNUM,CHECKSUM)
|
---|
37 | S $P(RECORD,"^",22)=1,$P(RECORD,"^",17)=$$SUM^PRPFSIG(SIGBLOCK)
|
---|
38 | S ^PRPF(470.1,LEVEL0,0)=RECORD
|
---|
39 | S Y=1 QUIT
|
---|
40 | REMOVE(LEVEL0) ;Entry point to remove e signature from record
|
---|
41 | ;NOT an extrinsic function
|
---|
42 | NEW I,RECORD
|
---|
43 | S RECORD=$G(^PRPF(470.1,LEVEL0,0))
|
---|
44 | F I=14,15,17,22,23 S $P(RECORD,"^",I)=""
|
---|
45 | S ^PRPF(470.1,LEVEL0,0)=RECORD
|
---|
46 | QUIT
|
---|
47 | VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
|
---|
48 | NEW RECORD,VERSION,VALCODE
|
---|
49 | ;get record variables
|
---|
50 | S RECORD=$G(^PRPF(470.1,LEVEL0,0))
|
---|
51 | S VERSION=$P(RECORD,"^",22),VALCODE=$P(RECORD,"^",17)
|
---|
52 | I VERSION_VALCODE="" QUIT 1
|
---|
53 | QUIT ($$SUM^PRPFSIG($$DECODE(LEVEL0))=VALCODE)
|
---|
54 | STRING(X) ;Build String of critical fields
|
---|
55 | Q $P(X,"^",1,13)_"^"_$P(X,"^",16)
|
---|