[613] | 1 | PRCSC4 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;5/20/93 9:13 AM
|
---|
| 2 | V ;;5.1;IFCAP;;Oct 20, 2000
|
---|
| 3 | ;Per VHA Directive 10-93-142, this routine should not be modified.
|
---|
| 4 | ;ROUTINE FOR MAINTAINING FIELD 63 (LOG CODE CODE SHEETS ELEC.SIG.), FILE 410
|
---|
| 5 | DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
|
---|
| 6 | ;returns "" if unsuccessful
|
---|
| 7 | NEW RECORD,RECRD100,VERSION,PERSON,SIG,CHECKSUM
|
---|
| 8 | ;get record and check version
|
---|
| 9 | S RECORD=$G(^PRCS(410,LEVEL0,0)) I RECORD="" QUIT ""
|
---|
| 10 | S RECRD100=$G(^PRCS(410,LEVEL0,100))
|
---|
| 11 | S VERSION=$P(RECRD100,"^",9)
|
---|
| 12 | S PERSON=+$P(RECRD100,"^",4)
|
---|
| 13 | I VERSION'="",VERSION'=1 Q ""
|
---|
| 14 | S SIG=$P(RECRD100,"^",5)
|
---|
| 15 | D1 ;decode e signature for version 1
|
---|
| 16 | S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECRD100))
|
---|
| 17 | QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
|
---|
| 18 | ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
|
---|
| 19 | ;Parameter passing entry point
|
---|
| 20 | NEW RECORD,RECRD100,SIGBLOCK,CHECKSUM,OLDUSER
|
---|
| 21 | ;get record
|
---|
| 22 | S USERNUM=+USERNUM
|
---|
| 23 | I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
|
---|
| 24 | S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
|
---|
| 25 | I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
|
---|
| 26 | S RECORD=$G(^PRCS(410,LEVEL0,0))
|
---|
| 27 | S RECRD100=$G(^PRCS(410,LEVEL0,100))
|
---|
| 28 | I RECORD="" S Y=-1 QUIT ;-1 no transaction record
|
---|
| 29 | I $P(RECRD100,"^",5)'="" S Y=-4 QUIT ;-4 cannot re-sign record
|
---|
| 30 | S OLDUSER=+$P(RECRD100,"^",4)
|
---|
| 31 | I OLDUSER=0 S $P(RECRD100,"^",4)=USERNUM
|
---|
| 32 | I OLDUSER>0 S USERNUM=OLDUSER
|
---|
| 33 | S:$P(RECRD100,"^",6)="" $P(RECRD100,"^",6)=$$NOW^PRCUESIG
|
---|
| 34 | S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECRD100))
|
---|
| 35 | S $P(RECRD100,"^",5)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
|
---|
| 36 | S $P(RECRD100,"^",9,10)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
|
---|
| 37 | S ^PRCS(410,LEVEL0,100)=RECRD100
|
---|
| 38 | S Y=1 QUIT
|
---|
| 39 | REMOVE(LEVEL0) ;Entry point to remove e signature from record
|
---|
| 40 | ;NOT an extrinsic function
|
---|
| 41 | NEW RECRD100
|
---|
| 42 | S RECRD100=$G(^PRCS(410,LEVEL0,100))
|
---|
| 43 | S $P(RECRD100,"^",4,6)="^^"
|
---|
| 44 | S $P(RECRD100,"^",10)=""
|
---|
| 45 | S ^PRCS(410,LEVEL0,100)=RECRD100
|
---|
| 46 | QUIT
|
---|
| 47 | VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
|
---|
| 48 | NEW RECRD100,VERSION,SIGBLOCK
|
---|
| 49 | ;get record variables
|
---|
| 50 | S RECRD100=$G(^PRCS(410,LEVEL0,100))
|
---|
| 51 | S VERSION=$P(RECRD100,"^",9),SIGBLOCK=$P(RECRD100,"^",10)
|
---|
| 52 | I VERSION_SIGBLOCK="" QUIT 1
|
---|
| 53 | QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
|
---|
| 54 | STRING(X100) ;Build String of critical fields
|
---|
| 55 | NEW RECRD100,SIGBLOCK,CHECKSUM,OLDUSER
|
---|
| 56 | Q $P(X100,"^",6)_"^"_$P(X100,"^",7)_"^"_$P(X100,"^",8)
|
---|