PRCFAES1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;5/20/93 9:27 AM
V ;;5.1;IFCAP;;Oct 20, 2000
;Per VHA Directive 10-93-142, this routine should not be modified.
;ROUTINE FOR MAINTAINING FIELD 5.5 (ELECTRONIC SIGNATURE) FILE 421.2
DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
;returns "" if unsuccessful
NEW RECORD,RECORD05,VERSION,PERSON,SIG,CHECKSUM
;get record and check version
S RECORD=$G(^PRCF(421.2,LEVEL0,0)) I RECORD="" QUIT ""
S RECORD05=$G(^PRCF(421.2,LEVEL0,.5))
S VERSION=$P(RECORD05,"^",1)
S PERSON=+$P(RECORD,"^",5)
I VERSION'="",VERSION'=1 Q ""
S SIG=$P(RECORD,"^",6)
D1 ;decode e signature for version 1
S RECORD=$G(^PRCF(421.2,LEVEL0,0))
S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
;Parameter passing entry point
NEW RECORD,RECORD05,SIGBLOCK,CHECKSUM,OLDUSER
;get record
S USERNUM=+USERNUM
S RECORD=$G(^PRCF(421.2,LEVEL0,0))
S RECORD05=$G(^PRCF(421.2,LEVEL0,.5))
I RECORD="" S Y=-1 QUIT ;-1 no transaction record
S OLDUSER=+$P(RECORD,"^",5)
I OLDUSER>0,+$P(RECORD05,"^",1)<1,$P(RECORD,"^",6)'="" S Y=-4 QUIT ;-4 cannot re-sign record with version <1
I OLDUSER>0 S USERNUM=OLDUSER
I USERNUM=0 S Y=-3 QUIT ;-3 no usernumber for filing
S SIGBLOCK=$P(RECORD05,"^",2)
I SIGBLOCK="" S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
I SIGBLOCK="" S Y=-2 QUIT ;-2 = no signature block in file 200
I OLDUSER=0 S $P(RECORD,"^",5)=USERNUM
S:$P(RECORD,"^",10)="" $P(RECORD,"^",10)=$$NOW^PRCUESIG
S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
S $P(RECORD,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
S $P(RECORD05,"^",1,2)="1^"_SIGBLOCK
S ^PRCF(421.2,LEVEL0,0)=RECORD
S ^PRCF(421.2,LEVEL0,.5)=RECORD05
S Y=1 QUIT
REMOVE(LEVEL0) ;Entry point to remove e signature from record
;NOT an extrinsic function
NEW RECORD,RECORD05
S RECORD=$G(^PRCF(421.2,LEVEL0,0))
S RECORD05=$G(^PRCF(421.2,LEVEL0,.5))
S $P(RECORD,"^",5,6)="^"
S $P(RECORD,"^",10)=""
S $P(RECORD05,"^",2)=""
S ^PRCF(421.2,LEVEL0,0)=RECORD
S ^PRCF(421.2,LEVEL0,.5)=RECORD05
QUIT
VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
NEW RECORD05,VERSION,SIGBLOCK
;get record variables
S RECORD05=$G(^PRCF(421.2,LEVEL0,.5))
S VERSION=$P(RECORD05,"^",1),SIGBLOCK=$P(RECORD05,"^",2)
I VERSION_SIGBLOCK="" QUIT 1
QUIT ($$DECODE(LEVEL0,TRANS)=SIGBLOCK)
STRING(X) ;Build String of critical fields
NEW RECORD
Q $P(X,"^",1)_"^"_$P(X,"^",10)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCFAES1 2644 printed Dec 13, 2024@02:02:22 Page 2
PRCFAES1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;5/20/93 9:27 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 5.5 (ELECTRONIC SIGNATURE) FILE 421.2
DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
+1 ;returns "" if unsuccessful
+2 NEW RECORD,RECORD05,VERSION,PERSON,SIG,CHECKSUM
+3 ;get record and check version
+4 SET RECORD=$GET(^PRCF(421.2,LEVEL0,0))
IF RECORD=""
QUIT ""
+5 SET RECORD05=$GET(^PRCF(421.2,LEVEL0,.5))
+6 SET VERSION=$PIECE(RECORD05,"^",1)
+7 SET PERSON=+$PIECE(RECORD,"^",5)
+8 IF VERSION'=""
IF VERSION'=1
QUIT ""
+9 SET SIG=$PIECE(RECORD,"^",6)
D1 ;decode e signature for version 1
+1 SET RECORD=$GET(^PRCF(421.2,LEVEL0,0))
+2 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
+3 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,RECORD05,SIGBLOCK,CHECKSUM,OLDUSER
+3 ;get record
+4 SET USERNUM=+USERNUM
+5 SET RECORD=$GET(^PRCF(421.2,LEVEL0,0))
+6 SET RECORD05=$GET(^PRCF(421.2,LEVEL0,.5))
+7 ;-1 no transaction record
IF RECORD=""
SET Y=-1
QUIT
+8 SET OLDUSER=+$PIECE(RECORD,"^",5)
+9 ;-4 cannot re-sign record with version <1
IF OLDUSER>0
IF +$PIECE(RECORD05,"^",1)<1
IF $PIECE(RECORD,"^",6)'=""
SET Y=-4
QUIT
+10 IF OLDUSER>0
SET USERNUM=OLDUSER
+11 ;-3 no usernumber for filing
IF USERNUM=0
SET Y=-3
QUIT
+12 SET SIGBLOCK=$PIECE(RECORD05,"^",2)
+13 IF SIGBLOCK=""
SET SIGBLOCK=$PIECE($GET(^VA(200,USERNUM,20)),"^",2)
+14 ;-2 = no signature block in file 200
IF SIGBLOCK=""
SET Y=-2
QUIT
+15 IF OLDUSER=0
SET $PIECE(RECORD,"^",5)=USERNUM
+16 if $PIECE(RECORD,"^",10)=""
SET $PIECE(RECORD,"^",10)=$$NOW^PRCUESIG
+17 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
+18 SET $PIECE(RECORD,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
+19 SET $PIECE(RECORD05,"^",1,2)="1^"_SIGBLOCK
+20 SET ^PRCF(421.2,LEVEL0,0)=RECORD
+21 SET ^PRCF(421.2,LEVEL0,.5)=RECORD05
+22 SET Y=1
QUIT
REMOVE(LEVEL0) ;Entry point to remove e signature from record
+1 ;NOT an extrinsic function
+2 NEW RECORD,RECORD05
+3 SET RECORD=$GET(^PRCF(421.2,LEVEL0,0))
+4 SET RECORD05=$GET(^PRCF(421.2,LEVEL0,.5))
+5 SET $PIECE(RECORD,"^",5,6)="^"
+6 SET $PIECE(RECORD,"^",10)=""
+7 SET $PIECE(RECORD05,"^",2)=""
+8 SET ^PRCF(421.2,LEVEL0,0)=RECORD
+9 SET ^PRCF(421.2,LEVEL0,.5)=RECORD05
+10 QUIT
VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
+1 NEW RECORD05,VERSION,SIGBLOCK
+2 ;get record variables
+3 SET RECORD05=$GET(^PRCF(421.2,LEVEL0,.5))
+4 SET VERSION=$PIECE(RECORD05,"^",1)
SET SIGBLOCK=$PIECE(RECORD05,"^",2)
+5 IF VERSION_SIGBLOCK=""
QUIT 1
+6 QUIT ($$DECODE(LEVEL0,TRANS)=SIGBLOCK)
STRING(X) ;Build String of critical fields
+1 NEW RECORD
+2 QUIT $PIECE(X,"^",1)_"^"_$PIECE(X,"^",10)