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)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCFES1 2831 printed Oct 16, 2024@18:04:04 Page 2
PRCFES1 ;WISC@ALTOONA/CTB/PLT-ESIG MAINTENANCE ROUTINE ;5/20/93 9:35 AM
V ;;5.1;IFCAP;;Oct 20, 2000
+1 ;Per VHA Directive 10-93-142, this routine should not be modified.
+2 ;ROUTINE FOR MAINTAINING FIELD 999.3 (ELECTRONIC SIGNATURE), FILE 423
DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
+1 ;returns "" if unsuccessful
+2 NEW RECORD,RECORD8,RECORD81,RECCODE,VERSION,PERSON,SIG,CHECKSUM
+3 ;get record and check version
+4 SET RECORD=$GET(^PRCF(423,LEVEL0,0))
IF RECORD=""
QUIT ""
+5 SET RECORD8=$GET(^PRCF(423,LEVEL0,8))
+6 SET RECORD81=$GET(^PRCF(423,LEVEL0,8.1))
+7 SET RECCODE=$GET(^PRCF(423,LEVEL0,"CODE"))
+8 SET VERSION=$PIECE(RECORD81,"^",1)
+9 SET PERSON=+$PIECE(RECORD,"^",8)
+10 IF VERSION'=""
IF VERSION'=1
QUIT ""
+11 SET SIG=$PIECE(RECORD8,"^",16)
D1 ;decode e signature for version 1
+1 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECCODE,RECORD81))
+2 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
+1 ;Parameter passing entry point
+2 NEW RECORD,RECORDE8,RECORD81,RECCODE,SIGBLOCK,CHECKSUM,OLDUSER
+3 ;get record
+4 SET USERNUM=+USERNUM
+5 ;-3 no user num available
IF USERNUM=0
SET Y=-3
QUIT
+6 SET SIGBLOCK=$PIECE($GET(^VA(200,USERNUM,20)),"^",2)
+7 ;-2 no sigblock in file 200
IF SIGBLOCK=""
SET Y=-2
QUIT
+8 SET RECORD=$GET(^PRCF(423,LEVEL0,0))
+9 SET RECORD8=$GET(^PRCF(423,LEVEL0,8))
+10 SET RECORD81=$GET(^PRCF(423,LEVEL0,8.1))
+11 SET RECCODE=$GET(^PRCF(423,LEVEL0,"CODE"))
+12 ;-1 no 2237 record
IF RECORD=""
SET Y=-1
QUIT
+13 ;-4 cannot re-sign record
IF $PIECE(RECORD8,"^",16)'=""
SET Y=-4
QUIT
+14 SET OLDUSER=+$PIECE(RECORD,"^",8)
+15 IF OLDUSER=0
SET $PIECE(RECORD,"^",8)=USERNUM
+16 IF OLDUSER>0
SET USERNUM=OLDUSER
+17 if $PIECE(RECORD81,"^",2)=""
SET $PIECE(RECORD81,"^",2)=$$NOW^PRCUESIG
+18 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECCODE,RECORD81))
+19 SET $PIECE(RECORD8,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
+20 SET $PIECE(RECORD81,"^",1)=1
SET $PIECE(RECORD81,"^",3)=$$SUM^PRCUESIG(SIGBLOCK)
+21 SET ^PRCF(423,LEVEL0,0)=RECORD
+22 SET ^PRCF(423,LEVEL0,8)=RECORD8
+23 SET ^PRCF(423,LEVEL0,8.1)=RECORD81
+24 SET Y=1
QUIT
REMOVE(LEVEL0) ;Entry point to remove e signature from record
+1 ;NOT an extrinsic function
+2 NEW I,RECORD8,RECORD81
+3 SET RECORD=$GET(^PRCF(423,LEVEL0,0))
+4 SET RECORD8=$GET(^PRCF(423,LEVEL0,8))
+5 SET RECORD81=$GET(^PRCF(423,LEVEL0,8.1))
+6 SET $PIECE(RECORD,"^",8)=""
+7 SET $PIECE(RECORD8,"^",16)=""
+8 SET $PIECE(RECORD81,"^",2,3)="^"
+9 SET ^PRCF(423,LEVEL0,0)=RECORD
+10 SET ^PRCF(423,LEVEL0,8)=RECORD8
+11 SET ^PRCF(423,LEVEL0,8.1)=RECORD81
+12 QUIT
VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
+1 NEW RECORD81,VERSION,SIGBLOCK
+2 ;get record variables
+3 SET RECORD81=$GET(^PRCF(423,LEVEL0,8.1))
+4 SET VERSION=$PIECE(RECORD81,"^",1)
SET SIGBLOCK=$PIECE(RECORD81,"^",3)
+5 IF VERSION_SIGBLOCK=""
QUIT 1
+6 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
STRING(X,X81) ;Build String of critical fields
+1 QUIT X_"^"_$PIECE(X81,"^",2)