source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES7.m@ 619

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

initial load of WorldVistAEHR

File size: 2.9 KB
Line 
1PRCHES7 ;WISC/RHD/AKS-ESIG MAINT ;8/25/94 14:40
2V ;;5.1;IFCAP;;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;ROUTINE FOR MAINTAINING SUBFIELD 11 (ELECTRONIC SIGNATURE)
5 ; FIELD 50 (AMENDMENT) FILE 442
6DECODE(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,6,LEVEL1,0)) I RECORD="" Q ""
10 S RECORD1=$G(^PRC(442,LEVEL0,6,LEVEL1,1))
11 S VERSION=$P(RECORD,"^",11)
12 S PERSON=+$P(RECORD1,"^",5)
13 I VERSION'="",VERSION'=1 Q ""
14 S SIG=$P(RECORD1,"^",6)
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 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
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,6,LEVEL1,0))
25 S RECORD1=$G(^PRC(442,LEVEL0,6,LEVEL1,1))
26 I RECORD="" S Y=-1 Q ;-1 no record
27 I $P(RECORD1,"^",6)'="" S Y=-4 Q ;-4 cannot re-sign record
28 S OLDUSER=+$P(RECORD1,"^",5)
29 I OLDUSER=0 S $P(RECORD1,"^",5)=USERNUM
30 I OLDUSER>0 S USERNUM=OLDUSER
31 S:$P(RECORD1,"^",8)="" $P(RECORD1,"^",8)=$$NOW^PRCUESIG
32 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
33 S $P(RECORD1,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
34 S $P(RECORD,"^",11)="1",$P(RECORD1,"^",7)=$$SUM^PRCUESIG(SIGBLOCK)
35 S ^PRC(442,LEVEL0,6,LEVEL1,0)=RECORD
36 S ^PRC(442,LEVEL0,6,LEVEL1,1)=RECORD1
37 S Y=1 Q
38RECODE(LEVEL0,LEVEL1,Y) ;Recode ESIG for version 1 only
39 N RECORD,RECORD1,SIGBLOCK,CHECKSUM,USERNUM
40 S RECORD=$G(^PRC(442,LEVEL0,6,LEVEL1,0))
41 S RECORD1=$G(^PRC(442,LEVEL0,6,LEVEL1,1))
42 I RECORD=""!(RECORD1="") S Y=-1 Q ;-1 no record
43 S USERNUM=$P(RECORD1,"^",5)
44 I $P(RECORD1,"^",6)=""!(USERNUM=0) S Y=-4 Q ;-4 cannot recode record
45 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
46 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD,RECORD1))
47 S $P(RECORD1,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
48 S $P(RECORD,"^",11)="1",$P(RECORD1,"^",7)=$$SUM^PRCUESIG(SIGBLOCK)
49 S ^PRC(442,LEVEL0,6,LEVEL1,0)=RECORD
50 S ^PRC(442,LEVEL0,6,LEVEL1,1)=RECORD1
51 S Y=1 ;1 record recoded properly
52 Q
53REMOVE(LEVEL0,LEVEL1) ;Entry point to remove esig from record
54 NEW RECORD
55 S RECORD=$G(^PRC(442,LEVEL0,6,LEVEL1,0)) Q:RECORD=""
56 S $P(^PRC(442,LEVEL0,6,LEVEL1,1),"^",5,8)="^^^"
57 Q
58VERIFY(LEVEL0,LEVEL1) ;verify version 1 signature. Returns 1 if valid
59 NEW RECORD,RECORD1,VERSION,SIGBLOCK
60 S RECORD=$G(^PRC(442,LEVEL0,6,LEVEL1,0))
61 S RECORD1=$G(^PRC(442,LEVEL0,6,LEVEL1,1))
62 S VERSION=$P(RECORD,"^",11),SIGBLOCK=$P(RECORD1,"^",7)
63 I VERSION_SIGBLOCK="" Q 1
64 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
65STRING(X,X1) ;Build String of critical fields
66 Q $P(X,"^")_"^"_$P(X,"^",2)_"^"_$P(X,"^",3)_"^"_$P(X1,"^",4)_"^"_$P(X1,"^",8)
Note: See TracBrowser for help on using the repository browser.