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

PRCHES14.m

Go to the documentation of this file.
  1. PRCHES14 ;WISC/RHD/AKS-ESIG MAINT ;AUG 2, 2001
  1. V ;;5.1;IFCAP;**38**;Oct 20, 2000
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;ROUTINE FOR MAINTAINING SUBFIELD 11 (ELECTRONIC SIGNATURE)
  1. ; FIELD 50 (AMENDMENT) FILE 443.6
  1. DECODE(LEVEL0,LEVEL1) ;return esig to readable form
  1. ;returns "" if unsuccessful
  1. NEW RECORD,RECORD1,VERSION,PERSON,SIG,CHECKSUM
  1. S RECORD=$G(^PRC(443.6,LEVEL0,6,LEVEL1,0)) I RECORD="" Q ""
  1. S RECORD1=$G(^PRC(443.6,LEVEL0,6,LEVEL1,1))
  1. S VERSION=$P(RECORD,"^",11)
  1. S PERSON=+$P(RECORD1,"^",5)
  1. I VERSION'="",VERSION'=1 Q ""
  1. S SIG=$P(RECORD1,"^",6)
  1. D1 ;esig for ver 1
  1. S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
  1. Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
  1. ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode esig for version 1 only
  1. NEW RECORD,RECORD1,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.6,LEVEL0,6,LEVEL1,0))
  1. S RECORD1=$G(^PRC(443.6,LEVEL0,6,LEVEL1,1))
  1. I RECORD="" S Y=-1 Q ;-1 no record
  1. I $P(RECORD1,"^",6)'="" S Y=-4 Q ;-4 cannot re-sign record
  1. S OLDUSER=+$P(RECORD1,"^",5)
  1. I OLDUSER=0 S $P(RECORD1,"^",5)=USERNUM
  1. I OLDUSER>0 S USERNUM=OLDUSER
  1. S:$P(RECORD1,"^",8)="" $P(RECORD1,"^",8)=$$NOW^PRCUESIG
  1. S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
  1. S $P(RECORD1,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
  1. S $P(RECORD,"^",11)="1",$P(RECORD1,"^",7)=$$SUM^PRCUESIG(SIGBLOCK)
  1. S ^PRC(443.6,LEVEL0,6,LEVEL1,0)=RECORD
  1. S ^PRC(443.6,LEVEL0,6,LEVEL1,1)=RECORD1
  1. S Y=1 Q
  1. ;
  1. RECODE(LEVEL0,CHECKSUM,Y) ;Recode esig for version 1 only
  1. NEW RECORD,RECORD1,RECORD12,SIGBLOCK,USERNUM
  1. S RECORD=$G(^PRC(443.6,LEVEL0,0))
  1. S RECORD1=$G(^PRC(443.6,LEVEL0,1))
  1. S RECORD12=$G(^PRC(443.6,LEVEL0,12))
  1. I RECORD="" S Y=-1 Q ;-1 no record
  1. ;S USERNUM=+$P(RECORD1,"^",10)
  1. S USERNUM=DUZ
  1. I USERNUM=0!'CHECKSUM S Y=-4 Q ;-4 cannot recode record
  1. S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
  1. S $P(RECORD12,"^",2)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
  1. S $P(RECORD12,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
  1. S ^PRC(443.6,LEVEL0,12)=RECORD12
  1. S Y=1 Q
  1. REMOVE(LEVEL0,LEVEL1) ;Entry point to remove esig from record
  1. NEW RECORD
  1. S RECORD=$G(^PRC(443.6,LEVEL0,6,LEVEL1,0)) Q:RECORD=""
  1. S $P(^PRC(443.6,LEVEL0,6,LEVEL1,1),"^",5,8)="^^^"
  1. Q
  1. VERIFY(LEVEL0,LEVEL1) ;verify version 1 signature. Returns 1 if valid
  1. NEW RECORD,RECORD1,VERSION,SIGBLOCK
  1. S RECORD=$G(^PRC(443.6,LEVEL0,6,LEVEL1,0))
  1. S RECORD1=$G(^PRC(443.6,LEVEL0,6,LEVEL1,1))
  1. S VERSION=$P(RECORD,"^",11),SIGBLOCK=$P(RECORD1,"^",7)
  1. I VERSION_SIGBLOCK="" Q 1
  1. Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
  1. STRING(X,X1) ;Build String of critical fields
  1. Q $P(X,"^")_"^"_$P(X,"^",2)_"^"_$P(X,"^",3)_"^"_$P(X1,"^",4)_"^"_$P(X1,"^",8)