Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PRCFES1

PRCFES1.m

Go to the documentation of this file.
PRCFES1 ;WISC@ALTOONA/CTB/PLT-ESIG MAINTENANCE ROUTINE ;5/20/93  9:35 AM
V ;;5.1;IFCAP;;Oct 20, 2000
 ;Per VHA Directive 10-93-142, this routine should not be modified.
 ;ROUTINE FOR MAINTAINING FIELD 999.3 (ELECTRONIC SIGNATURE), FILE 423
DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
 ;returns "" if unsuccessful
 NEW RECORD,RECORD8,RECORD81,RECCODE,VERSION,PERSON,SIG,CHECKSUM
 ;get record and check version
 S RECORD=$G(^PRCF(423,LEVEL0,0)) I RECORD="" QUIT ""
 S RECORD8=$G(^PRCF(423,LEVEL0,8))
 S RECORD81=$G(^PRCF(423,LEVEL0,8.1))
 S RECCODE=$G(^PRCF(423,LEVEL0,"CODE"))
 S VERSION=$P(RECORD81,"^",1)
 S PERSON=+$P(RECORD,"^",8)
 I VERSION'="",VERSION'=1 Q ""
 S SIG=$P(RECORD8,"^",16)
D1 ;decode e signature for version 1
 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECCODE,RECORD81))
 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
 ;Parameter passing entry point
 NEW RECORD,RECORDE8,RECORD81,RECCODE,SIGBLOCK,CHECKSUM,OLDUSER
 ;get record
 S USERNUM=+USERNUM
 I USERNUM=0 S Y=-3 QUIT  ;-3 no user num available
 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
 I SIGBLOCK="" S Y=-2 QUIT  ;-2 no sigblock in file 200
 S RECORD=$G(^PRCF(423,LEVEL0,0))
 S RECORD8=$G(^PRCF(423,LEVEL0,8))
 S RECORD81=$G(^PRCF(423,LEVEL0,8.1))
 S RECCODE=$G(^PRCF(423,LEVEL0,"CODE"))
 I RECORD="" S Y=-1 QUIT  ;-1 no 2237 record
 I $P(RECORD8,"^",16)'="" S Y=-4 QUIT  ;-4 cannot re-sign record
 S OLDUSER=+$P(RECORD,"^",8)
 I OLDUSER=0 S $P(RECORD,"^",8)=USERNUM
 I OLDUSER>0 S USERNUM=OLDUSER
 S:$P(RECORD81,"^",2)="" $P(RECORD81,"^",2)=$$NOW^PRCUESIG
 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECCODE,RECORD81))
 S $P(RECORD8,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
 S $P(RECORD81,"^",1)=1,$P(RECORD81,"^",3)=$$SUM^PRCUESIG(SIGBLOCK)
 S ^PRCF(423,LEVEL0,0)=RECORD
 S ^PRCF(423,LEVEL0,8)=RECORD8
 S ^PRCF(423,LEVEL0,8.1)=RECORD81
 S Y=1 QUIT
REMOVE(LEVEL0) ;Entry point to remove e signature from record
 ;NOT an extrinsic function
 NEW I,RECORD8,RECORD81
 S RECORD=$G(^PRCF(423,LEVEL0,0))
 S RECORD8=$G(^PRCF(423,LEVEL0,8))
 S RECORD81=$G(^PRCF(423,LEVEL0,8.1))
 S $P(RECORD,"^",8)=""
 S $P(RECORD8,"^",16)=""
 S $P(RECORD81,"^",2,3)="^"
 S ^PRCF(423,LEVEL0,0)=RECORD
 S ^PRCF(423,LEVEL0,8)=RECORD8
 S ^PRCF(423,LEVEL0,8.1)=RECORD81
 QUIT
VERIFY(LEVEL0)      ;extrinsic function to verify version 1 signature.  Returns 1 if valid, 0 if not valid
 NEW RECORD81,VERSION,SIGBLOCK
 ;get record variables
 S RECORD81=$G(^PRCF(423,LEVEL0,8.1))
 S VERSION=$P(RECORD81,"^",1),SIGBLOCK=$P(RECORD81,"^",3)
 I VERSION_SIGBLOCK="" QUIT 1
 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
STRING(X,X81)          ;Build String of critical fields
 Q X_"^"_$P(X81,"^",2)