72 lines
3.0 KiB
Mathematica
72 lines
3.0 KiB
Mathematica
|
PRCHES2 ;WISC/RHD/AKS-ESIG MAINT ; 05/15/93 1:31 PM
|
||
|
V ;;5.1;IFCAP;;Oct 20, 2000
|
||
|
;Per VHA Directive 10-93-142, this routine should not be modified.
|
||
|
;ROUTINE FOR SUBFIELD 15 (RECEIVED BY ESIG)
|
||
|
; FIELD .6 (PARTIAL), FILE 442
|
||
|
DECODE(LEVEL0,LEVEL1) ;returns esig in readable form
|
||
|
;returns "" if failed
|
||
|
NEW RECORD,RECORD1,VERSION,PERSON,SIG,CHECKSUM
|
||
|
S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0)) I RECORD="" Q ""
|
||
|
S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
||
|
S VERSION=$P(RECORD1,"^",11)
|
||
|
S PERSON=+$P(RECORD,"^",15)
|
||
|
S SIG=$P(RECORD,"^",16)
|
||
|
I VERSION'="",VERSION'=1 Q ""
|
||
|
D1 ;esig for ver 1
|
||
|
S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
|
||
|
Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
|
||
|
ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode esig for ver 1 only
|
||
|
NEW RECORD,RECORD1,SIGBLOCK,CHECKSUM,OLDUSER
|
||
|
S USERNUM=+USERNUM
|
||
|
I USERNUM=0 S Y=-3 Q ;-3 no usernum available
|
||
|
S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
|
||
|
I SIGBLOCK="" S Y=-2 Q ;-2 no sig block
|
||
|
S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
||
|
S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
||
|
I RECORD="" S Y=-1 Q ;-1 no record
|
||
|
I $P(RECORD,"^",16)'="" S Y=-4 Q ;-4 cannot re-sign it
|
||
|
S OLDUSER=+$P(RECORD,"^",15)
|
||
|
I OLDUSER=0 S $P(RECORD,"^",15)=USERNUM
|
||
|
I OLDUSER>0 S USERNUM=OLDUSER
|
||
|
S:$P(RECORD1,"^",15)="" $P(RECORD1,"^",15)=$$NOW^PRCUESIG
|
||
|
S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
|
||
|
S $P(RECORD,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
|
||
|
S $P(RECORD1,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
|
||
|
S Y=1 Q
|
||
|
RECODE(LEVEL0,LEVEL1,CHECKSUM,Y) ;Recode esig for version 1 only
|
||
|
NEW RECORD,RECORD1,SIGBLOCK,USERNUM
|
||
|
S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
||
|
S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
||
|
I RECORD=""!(RECORD1="") S Y=-1 Q ;-1 no record
|
||
|
S USERNUM=+$P(RECORD,"^",15)
|
||
|
I $P(RECORD,"^",16)=""!(USERNUM=0) S Y=-4 Q ;-4 cannot recode record
|
||
|
;S SIGBLOCK=$$DECODE^PRCUESIG($P(RECORD,"^",8),USERNUM,CHECKSUM)
|
||
|
S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
|
||
|
S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
|
||
|
S $P(RECORD,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
|
||
|
S $P(RECORD1,"^",12)=$$SUM^PRCUESIG(SIGBLOCK)
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
|
||
|
S Y=1
|
||
|
Q
|
||
|
REMOVE(LEVEL0,LEVEL1) ;
|
||
|
NEW I,RECORD,RECORD1
|
||
|
S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
||
|
S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
||
|
S $P(RECORD,"^",15,16)="^"
|
||
|
F I=12,15 S $P(RECORD1,"^",I)=""
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
|
||
|
S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
|
||
|
Q
|
||
|
VERIFY(LEVEL0,LEVEL1) ;verify esig Returns 1 if valid
|
||
|
NEW RECORD,RECORD1,VERSION,SIGBLOCK
|
||
|
S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
||
|
S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
||
|
S VERSION=$P(RECORD1,"^",11),SIGBLOCK=$P(RECORD1,"^",12)
|
||
|
I VERSION_SIGBLOCK="" Q 1
|
||
|
Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
|
||
|
STRING(X,X1) ;Build String of critical fields
|
||
|
Q $P(X,"^")_"^"_$P(X,"^",3)_"^"_$P(X,"^",5)_"^"_$P(X,"^",12)_"^"_$P(X,"^",14)_"^"_$P(X1,"^",15)
|