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

PRCHES12.m

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