1 | PRCHES3 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ;3/18/93 12:49
|
---|
2 | V ;;5.1;IFCAP;;Oct 20, 2000
|
---|
3 | ;Per VHA Directive 10-93-142, this routine should not be modified.
|
---|
4 | ;ROUTINE FOR MAINTAINING SUBFIELD 19.4 (LCS ELEC. SIG)
|
---|
5 | ; FIELD .6 (PARTIAL), FILE 442
|
---|
6 | DECODE(LEVEL0,LEVEL1) ;return esig to readable form
|
---|
7 | ;returns "" if unsuccessful
|
---|
8 | NEW RECORD,RECORD1,VERSION,PERSON,SIG,CHECKSUM
|
---|
9 | S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0)) I RECORD="" Q ""
|
---|
10 | S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
---|
11 | S VERSION=$P(RECORD1,"^",13)
|
---|
12 | S PERSON=+$P(RECORD1,"^",3)
|
---|
13 | I VERSION'="",VERSION'=1 Q ""
|
---|
14 | S SIG=$P(RECORD1,"^",4)
|
---|
15 | D1 ;decode e signature for version 1
|
---|
16 | S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
|
---|
17 | Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
|
---|
18 | ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode e signature for version 1 only
|
---|
19 | NEW RECORD,RECORD1,SIGBLOCK,CHECKSUM,OLDUSER
|
---|
20 | S USERNUM=+USERNUM
|
---|
21 | I USERNUM=0 S Y=-3 Q ;-3 no user number available for filing
|
---|
22 | S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
|
---|
23 | I SIGBLOCK="" S Y=-2 Q ;-2 no signature block
|
---|
24 | S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
---|
25 | S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
---|
26 | I RECORD="" S Y=-1 Q ;-1 no 2237 record
|
---|
27 | I $P(RECORD1,"^",4)'="" S Y=-4 Q ;-4 cannot re-sign record
|
---|
28 | S OLDUSER=+$P(RECORD1,"^",3)
|
---|
29 | I OLDUSER=0 S $P(RECORD1,"^",3)=USERNUM
|
---|
30 | I OLDUSER>0 S USERNUM=OLDUSER
|
---|
31 | S:$P(RECORD1,"^",5)="" $P(RECORD1,"^",5)=$$NOW^PRCUESIG
|
---|
32 | S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
|
---|
33 | S $P(RECORD1,"^",4)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
|
---|
34 | S $P(RECORD1,"^",13,14)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
|
---|
35 | S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
|
---|
36 | S Y=1 Q
|
---|
37 | REMOVE(LEVEL0,LEVEL1) ;Entry point to remove esig
|
---|
38 | NEW I,RECORD1
|
---|
39 | S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1)) Q:RECORD1=""
|
---|
40 | F I=3,4,5,14 S $P(RECORD1,"^",I)=""
|
---|
41 | S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
|
---|
42 | Q
|
---|
43 | VERIFY(LEVEL0,LEVEL1) ;extrinsic function to verify version 1 esig Returns 1 if valid
|
---|
44 | NEW RECORD,RECORD1,VERSION,SIGBLOCK
|
---|
45 | S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
|
---|
46 | S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
|
---|
47 | S VERSION=$P(RECORD1,"^",13),SIGBLOCK=$P(RECORD1,"^",14)
|
---|
48 | I VERSION_SIGBLOCK="" Q 1
|
---|
49 | Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
|
---|
50 | STRING(X,X1) ;Build String of critical fields
|
---|
51 | Q $P(X,"^")_"^"_$P(X1,"^",5)
|
---|