source: WorldVistAEHR/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCHES4.m@ 1638

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

initial load of WorldVistAEHR

File size: 2.1 KB
Line 
1PRCHES4 ;WISC/RHD/AKS-ESIG MAINTENANCE ROUTINE ;3/18/93 15:29
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 4 (ELECTRONIC SIGNATURE)
5 ; FIELD 2.4 (OBLIGATION DATA), FILE 442
6DECODE(LEVEL0,LEVEL1) ;return esig in readable form.
7 ;returns "" if unsuccessful
8 NEW RECORD,VERSION,PERSON,SIG,CHECKSUM
9 S RECORD=$G(^PRC(442,LEVEL0,10,LEVEL1,0)) I RECORD="" Q ""
10 S VERSION=$P(RECORD,"^",7)
11 S PERSON=+$P(RECORD,"^",2)
12 I VERSION'="",VERSION'=1 Q ""
13 S SIG=$P(RECORD,"^",5)
14D1 ;decode esig for version 1
15 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
16 Q $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
17ENCODE(LEVEL0,LEVEL1,USERNUM,Y) ;Encode esig for version 1 only
18 NEW RECORD,SIGBLOCK,CHECKSUM,OLDUSER
19 S USERNUM=+USERNUM
20 I USERNUM=0 S Y=-3 Q ;-3 no user number
21 S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
22 I SIGBLOCK="" S Y=-2 Q ;-2 no signature block in file 200
23 S RECORD=$G(^PRC(442,LEVEL0,10,LEVEL1,0))
24 I RECORD="" S Y=-1 Q ;-1 no 2237 record
25 I $P(RECORD,"^",5)'="" S Y=-4 Q ;-4 cannot re-sign record
26 S OLDUSER=+$P(RECORD,"^",2)
27 I OLDUSER=0 S $P(RECORD,"^",2)=USERNUM
28 I OLDUSER>0 S USERNUM=OLDUSER
29 S:$P(RECORD,"^",6)="" $P(RECORD,"^",6)=$$NOW^PRCUESIG
30 S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_LEVEL1_"^"_$$STRING(RECORD))
31 S $P(RECORD,"^",5)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
32 S $P(RECORD,"^",7,8)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
33 S ^PRC(442,LEVEL0,10,LEVEL1,0)=RECORD
34 S Y=1 Q
35REMOVE(LEVEL0,LEVEL1) ;NOT an extrinsic function
36 NEW I,RECORD
37 S RECORD=$G(^PRC(442,LEVEL0,10,LEVEL1,0)) Q:RECORD=""
38 F I=2,5,6,8 S $P(RECORD,"^",I)=""
39 S ^PRC(442,LEVEL0,10,LEVEL1,0)=RECORD
40 Q
41VERIFY(LEVEL0,LEVEL1) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
42 NEW RECORD,VERSION,SIGBLOCK
43 ;get record variables
44 S RECORD=$G(^PRC(442,LEVEL0,10,LEVEL1,0))
45 S VERSION=$P(RECORD,"^",7),SIGBLOCK=$P(RECORD,"^",8)
46 I VERSION_SIGBLOCK="" Q 1
47 Q ($$SUM^PRCUESIG($$DECODE(LEVEL0,LEVEL1))=SIGBLOCK)
48STRING(X) ;Build String of critical fields
49 Q $P(X,"^")_"^"_$P(X,"^",3)_"^"_$P(X,"^",4)_"^"_$P(X,"^",6)
Note: See TracBrowser for help on using the repository browser.