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

PRCHES11.m

Go to the documentation of this file.
  1. PRCHES11 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ; 1/4/93 11:04 AM
  1. V ;;5.1;IFCAP;;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;ROUTINE FOR MAINTAINING FIELD 3 (ELECTRONIC SIGNATURE), FILE 443
  1. DECODE(LEVEL0) ;Extrinsic Function to return hashed esig to readable form.
  1. ;returns "" if unsuccessful
  1. NEW RECORD,RECORD1,RECORD12,VERSION,PERSON,SIG,CHECKSUM
  1. S RECORD=$G(^PRC(443,LEVEL0,0)) I RECORD="" Q ""
  1. S VERSION=$P(RECORD,"^",14)
  1. S PERSON=+$P(RECORD,"^",2)
  1. I VERSION'="",VERSION'=1 Q ""
  1. S SIG=$P(RECORD,"^",3)
  1. D1 ;decode e signature for version 1
  1. S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
  1. Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
  1. ENCODE(LEVEL0,USERNUM,Y) ;Encode esig for version 1 only
  1. NEW RECORD,SIGBLOCK,CHECKSUM,OLDUSER
  1. S USERNUM=+USERNUM
  1. I USERNUM=0 S Y=-3 Q ;-3 no user number
  1. S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
  1. I SIGBLOCK="" S Y=-2 Q ;-2 no signature block
  1. S RECORD=$G(^PRC(443,LEVEL0,0))
  1. I RECORD="" S Y=-1 Q ;-1 no record
  1. I $P(RECORD,"^",3)'="" S Y=-4 Q ;-4 cannot re-sign record
  1. S OLDUSER=+$P(RECORD,"^",2)
  1. I OLDUSER=0 S $P(RECORD,"^",2)=USERNUM
  1. I OLDUSER>0 S USERNUM=OLDUSER
  1. S:$P(RECORD,"^",4)="" $P(RECORD,"^",4)=$$NOW^PRCUESIG
  1. S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD))
  1. S $P(RECORD,"^",3)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
  1. S $P(RECORD,"^",14)=1,$P(RECORD,"^",13)=$$SUM^PRCUESIG(SIGBLOCK)
  1. S ^PRC(443,LEVEL0,0)=RECORD
  1. S Y=1 Q
  1. REMOVE(LEVEL0) ;Entry point to remove esig
  1. NEW I,RECORD
  1. S RECORD=$G(^PRC(443,LEVEL0,0))
  1. F I=2,3,4,13 S $P(RECORD,"^",I)=""
  1. S ^PRC(443,LEVEL0,0)=RECORD
  1. Q
  1. VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
  1. NEW RECORD,VERSION,SIGBLOCK
  1. S RECORD=$G(^PRC(443,LEVEL0,0))
  1. S VERSION=$P(RECORD,"^",14),SIGBLOCK=$P(RECORD,"^",13)
  1. I VERSION_SIGBLOCK="" Q 1
  1. Q ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
  1. STRING(X) ;Build String of critical fields
  1. Q $P(X,"^")_"^"_$P(X,"^",4)_"^"_$P(X,"^",9)