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