source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES2.m@ 1544

Last change on this file since 1544 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.0 KB
Line 
1PRCHES2 ;WISC/RHD/AKS-ESIG MAINT ; 05/15/93 1:31 PM
2V ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;ROUTINE FOR SUBFIELD 15 (RECEIVED BY ESIG)
5 ; FIELD .6 (PARTIAL), FILE 442
6DECODE(LEVEL0,LEVEL1) ;returns esig in readable form
7 ;returns "" if failed
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,"^",11)
12 S PERSON=+$P(RECORD,"^",15)
13 S SIG=$P(RECORD,"^",16)
14 I VERSION'="",VERSION'=1 Q ""
15D1 ;esig for ver 1
16 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
17 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
18ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode esig for ver 1 only
19 NEW RECORD,RECORD1,SIGBLOCK,CHECKSUM,OLDUSER
20 S USERNUM=+USERNUM
21 I USERNUM=0 S Y=-3 Q ;-3 no usernum available
22 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
23 I SIGBLOCK="" S Y=-2 Q ;-2 no sig 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 record
27 I $P(RECORD,"^",16)'="" S Y=-4 Q ;-4 cannot re-sign it
28 S OLDUSER=+$P(RECORD,"^",15)
29 I OLDUSER=0 S $P(RECORD,"^",15)=USERNUM
30 I OLDUSER>0 S USERNUM=OLDUSER
31 S:$P(RECORD1,"^",15)="" $P(RECORD1,"^",15)=$$NOW^PRCUESIG
32 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
33 S $P(RECORD,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
34 S $P(RECORD1,"^",11,12)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
35 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
36 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
37 S Y=1 Q
38RECODE(LEVEL0,LEVEL1,CHECKSUM,Y) ;Recode esig for version 1 only
39 NEW RECORD,RECORD1,SIGBLOCK,USERNUM
40 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
41 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
42 I RECORD=""!(RECORD1="") S Y=-1 Q ;-1 no record
43 S USERNUM=+$P(RECORD,"^",15)
44 I $P(RECORD,"^",16)=""!(USERNUM=0) S Y=-4 Q ;-4 cannot recode record
45 ;S SIGBLOCK=$$DECODE^PRCUESIG($P(RECORD,"^",8),USERNUM,CHECKSUM)
46 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
47 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
48 S $P(RECORD,"^",16)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
49 S $P(RECORD1,"^",12)=$$SUM^PRCUESIG(SIGBLOCK)
50 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
51 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
52 S Y=1
53 Q
54REMOVE(LEVEL0,LEVEL1) ;
55 NEW I,RECORD,RECORD1
56 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
57 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
58 S $P(RECORD,"^",15,16)="^"
59 F I=12,15 S $P(RECORD1,"^",I)=""
60 S ^PRC(442,LEVEL0,11,LEVEL1,0)=RECORD
61 S ^PRC(442,LEVEL0,11,LEVEL1,1)=RECORD1
62 Q
63VERIFY(LEVEL0,LEVEL1) ;verify esig Returns 1 if valid
64 NEW RECORD,RECORD1,VERSION,SIGBLOCK
65 S RECORD=$G(^PRC(442,LEVEL0,11,LEVEL1,0))
66 S RECORD1=$G(^PRC(442,LEVEL0,11,LEVEL1,1))
67 S VERSION=$P(RECORD1,"^",11),SIGBLOCK=$P(RECORD1,"^",12)
68 I VERSION_SIGBLOCK="" Q 1
69 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
70STRING(X,X1) ;Build String of critical fields
71 Q $P(X,"^")_"^"_$P(X,"^",3)_"^"_$P(X,"^",5)_"^"_$P(X,"^",12)_"^"_$P(X,"^",14)_"^"_$P(X1,"^",15)
Note: See TracBrowser for help on using the repository browser.