- PRCSC1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;4/23/97 8:55 AM
- V ;;5.1;IFCAP;**120**;Oct 20, 2000;Build 27
- ;Per VHA Directive 2004-038, this routine should not be modified.
- ;ROUTINE FOR MAINTAINING FIELD 44.5 (ELECTRONIC SIGNATURE), FILE 410
- DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
- ;returns "" if unsuccessful
- NEW RECORD7,RECORD71,VERSION,PERSON,SIG,CHECKSUM
- ;get record and check version
- S RECORD7=$G(^PRCS(410,LEVEL0,7)) I RECORD7="" QUIT ""
- S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
- S VERSION=$P(RECORD71,"^",3)
- S PERSON=+$P(RECORD7,"^",3)
- I VERSION'="",VERSION'=1 Q ""
- S SIG=$P(RECORD7,"^",6)
- I VERSION=1 G D1
- D ;decode e signature less than version 1
- S X=$$DECODE^PRCUESIG(SIG,LEVEL0,PERSON)
- QUIT X
- D1 ;decode e signature for version 1
- S RECORD=$G(^PRCS(410,LEVEL0,0))
- S RECORD1=$G(^PRCS(410,LEVEL0,1))
- S RECORD2=$G(^PRCS(410,LEVEL0,2))
- S RECORD3=$G(^PRCS(410,LEVEL0,3))
- S RECORD4=$G(^PRCS(410,LEVEL0,4))
- S RECORD10=$G(^PRCS(410,LEVEL0,10))
- S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
- ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
- ;Parameter passing entry point
- NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM,OLDUSER
- ;get record
- S USERNUM=+USERNUM
- I USERNUM=0 S Y=-3 QUIT ;-3 no user num available
- S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
- I SIGBLOCK="" S Y=-2 QUIT ;-2 no sigblock in file 200
- S RECORD=$G(^PRCS(410,LEVEL0,0))
- S RECORD1=$G(^PRCS(410,LEVEL0,1))
- S RECORD2=$G(^PRCS(410,LEVEL0,2))
- S RECORD3=$G(^PRCS(410,LEVEL0,3))
- S RECORD4=$G(^PRCS(410,LEVEL0,4))
- S RECORD7=$G(^PRCS(410,LEVEL0,7))
- S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
- S RECORD10=$G(^PRCS(410,LEVEL0,10))
- I RECORD="" S Y=-1 QUIT ;-1 no transaction record
- I $P(RECORD7,"^",6)'="" S Y=-4 QUIT ;-4 cannot re-sign record
- S OLDUSER=+$P(RECORD7,"^",3)
- I OLDUSER=0 S $P(RECORD7,"^",3)=USERNUM
- I OLDUSER>0 S USERNUM=OLDUSER
- ;PRC*5.1*120 will check FCP EDI switch and ALL/DELIVERY ORDER switch to recode record due to auto obligation
- I $P($G(XQY0),"^")'="PRCSENRB",$P($G(XQY0),"^")'="PRCSANTN",$P($G(XQY0),"^")'="PRCSRI GENERATE",$P($G(XQY0),"^")'="PRCSEDTD",$P($G(XQY0),"^")'="PRCSAPP" D
- . I $G(PRCHDELV),'$G(AUTOOBLG) Q
- . I $P(RECORD4,"^",4)="" S $P(RECORD4,"^",4)=$P($$NOW^PRCUESIG,".",1),^PRCS(410,LEVEL0,4)=RECORD4
- . I '$D(PRC("CP")),$D(PRCB("CP")) S CPSW=1,PRC("CP")=PRCB("CP")
- . I $D(PRC("CP")) I ($P($G(^PRC(420,+PRC("SITE"),1,+PRC("CP"),6)),U)="Y")!($P($G(^PRC(420,+PRC("SITE"),3)),U)="Y")!($P($G(^PRC(420,+PRC("SITE"),3)),U,2)'="")!($P($G(^PRC(420,+PRC("SITE"),1,+PRC("CP"),6)),U,2)'="") D
- .. Q:$G(PRCHAMDA)=32
- .. D ENCODE^PRCSC2(LEVEL0,USERNUM)
- . I $G(CPSW)=1 K PRC("CP"),CPSW
- S:$P(RECORD7,"^",7)="" $P(RECORD7,"^",7)=$$NOW^PRCUESIG
- S:$P(RECORD7,"^",5)="" $P(RECORD7,"^",5)=$P($$NOW^PRCUESIG,".",1)
- S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- S $P(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
- S $P(RECORD7,"^",4)=$P($G(^VA(200,USERNUM,20)),"^",3)
- S $P(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
- S ^PRCS(410,LEVEL0,7)=RECORD7
- S ^PRCS(410,LEVEL0,7.1)=RECORD71
- S Y=1 QUIT
- RECODE(LEVEL0,Y) ;Recode esig for version 1 only
- NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM
- NEW DA,DIC,RECORD1,RECORD10,RECORD2,RECORD3,RECORD4,USERNUM
- S RECORD=$G(^PRCS(410,LEVEL0,0))
- S RECORD1=$G(^PRCS(410,LEVEL0,1))
- S RECORD2=$G(^PRCS(410,LEVEL0,2))
- S RECORD3=$G(^PRCS(410,LEVEL0,3))
- S RECORD4=$G(^PRCS(410,LEVEL0,4))
- S RECORD7=$G(^PRCS(410,LEVEL0,7))
- S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
- S RECORD10=$G(^PRCS(410,LEVEL0,10))
- I RECORD="" S Y=-1 QUIT ;-1 no transaction record
- S USERNUM=+$P(RECORD7,"^",3)
- I $P(RECORD7,"^",6)=""!(USERNUM=0) S Y=-4 QUIT ;-4 cannot re-sign record
- S SIGBLOCK=$P($G(^VA(200,USERNUM,20)),"^",2)
- S CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- S $P(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
- S $P(RECORD7,"^",4)=$P($G(^VA(200,USERNUM,20)),"^",3)
- S $P(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
- S ^PRCS(410,LEVEL0,7)=RECORD7
- S ^PRCS(410,LEVEL0,7.1)=RECORD71
- S Y=1 QUIT
- REMOVE(LEVEL0) ;Entry point to remove e signature from record
- ;NOT an extrinsic function
- NEW RECORD7,RECORD71
- S RECORD7=$G(^PRCS(410,LEVEL0,7))
- S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
- S $P(RECORD7,"^",3,7)="^^^^"
- S $P(RECORD71,"^",4)=""
- S ^PRCS(410,LEVEL0,7)=RECORD7
- S ^PRCS(410,LEVEL0,7.1)=RECORD71
- QUIT
- VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
- NEW RECORD71,VERSION,SIGBLOCK
- ;get record variables
- S RECORD71=$G(^PRCS(410,LEVEL0,7.1))
- S VERSION=$P(RECORD71,"^",3),SIGBLOCK=$P(RECORD71,"^",4)
- I VERSION_SIGBLOCK="" QUIT 1
- QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
- STRING(X,X1,X2,X3,X4,X7,X10) ;Build String of critical fields
- Q $P(X,"^",1)_"^"_$P(X1,"^",1)_"^"_$P(X2,"^",1)_"^"_$P(X3,"^",1)_"^"_$P(X3,"^",3)_"^"_$P(X4,"^",1)_"^"_$P(X7,"^",7)_"^"_$P(X10,"^",1)
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCSC1 5195 printed Jan 18, 2025@03:18:25 Page 2
- PRCSC1 ;WISC/LEM-ESIG MAINTENANCE ROUTINE ;4/23/97 8:55 AM
- V ;;5.1;IFCAP;**120**;Oct 20, 2000;Build 27
- +1 ;Per VHA Directive 2004-038, this routine should not be modified.
- +2 ;ROUTINE FOR MAINTAINING FIELD 44.5 (ELECTRONIC SIGNATURE), FILE 410
- DECODE(LEVEL0) ;Extrinsic Function to return hashed electronic sig to readable form.
- +1 ;returns "" if unsuccessful
- +2 NEW RECORD7,RECORD71,VERSION,PERSON,SIG,CHECKSUM
- +3 ;get record and check version
- +4 SET RECORD7=$GET(^PRCS(410,LEVEL0,7))
- IF RECORD7=""
- QUIT ""
- +5 SET RECORD71=$GET(^PRCS(410,LEVEL0,7.1))
- +6 SET VERSION=$PIECE(RECORD71,"^",3)
- +7 SET PERSON=+$PIECE(RECORD7,"^",3)
- +8 IF VERSION'=""
- IF VERSION'=1
- QUIT ""
- +9 SET SIG=$PIECE(RECORD7,"^",6)
- +10 IF VERSION=1
- GOTO D1
- D ;decode e signature less than version 1
- +1 SET X=$$DECODE^PRCUESIG(SIG,LEVEL0,PERSON)
- +2 QUIT X
- D1 ;decode e signature for version 1
- +1 SET RECORD=$GET(^PRCS(410,LEVEL0,0))
- +2 SET RECORD1=$GET(^PRCS(410,LEVEL0,1))
- +3 SET RECORD2=$GET(^PRCS(410,LEVEL0,2))
- +4 SET RECORD3=$GET(^PRCS(410,LEVEL0,3))
- +5 SET RECORD4=$GET(^PRCS(410,LEVEL0,4))
- +6 SET RECORD10=$GET(^PRCS(410,LEVEL0,10))
- +7 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- +8 QUIT $$DECODE^PRCUESIG(SIG,PERSON,CHECKSUM)
- ENCODE(LEVEL0,USERNUM,Y) ;Encode e signature for version 1 only
- +1 ;Parameter passing entry point
- +2 NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM,OLDUSER
- +3 ;get record
- +4 SET USERNUM=+USERNUM
- +5 ;-3 no user num available
- IF USERNUM=0
- SET Y=-3
- QUIT
- +6 SET SIGBLOCK=$PIECE($GET(^VA(200,USERNUM,20)),"^",2)
- +7 ;-2 no sigblock in file 200
- IF SIGBLOCK=""
- SET Y=-2
- QUIT
- +8 SET RECORD=$GET(^PRCS(410,LEVEL0,0))
- +9 SET RECORD1=$GET(^PRCS(410,LEVEL0,1))
- +10 SET RECORD2=$GET(^PRCS(410,LEVEL0,2))
- +11 SET RECORD3=$GET(^PRCS(410,LEVEL0,3))
- +12 SET RECORD4=$GET(^PRCS(410,LEVEL0,4))
- +13 SET RECORD7=$GET(^PRCS(410,LEVEL0,7))
- +14 SET RECORD71=$GET(^PRCS(410,LEVEL0,7.1))
- +15 SET RECORD10=$GET(^PRCS(410,LEVEL0,10))
- +16 ;-1 no transaction record
- IF RECORD=""
- SET Y=-1
- QUIT
- +17 ;-4 cannot re-sign record
- IF $PIECE(RECORD7,"^",6)'=""
- SET Y=-4
- QUIT
- +18 SET OLDUSER=+$PIECE(RECORD7,"^",3)
- +19 IF OLDUSER=0
- SET $PIECE(RECORD7,"^",3)=USERNUM
- +20 IF OLDUSER>0
- SET USERNUM=OLDUSER
- +21 ;PRC*5.1*120 will check FCP EDI switch and ALL/DELIVERY ORDER switch to recode record due to auto obligation
- +22 IF $PIECE($GET(XQY0),"^")'="PRCSENRB"
- IF $PIECE($GET(XQY0),"^")'="PRCSANTN"
- IF $PIECE($GET(XQY0),"^")'="PRCSRI GENERATE"
- IF $PIECE($GET(XQY0),"^")'="PRCSEDTD"
- IF $PIECE($GET(XQY0),"^")'="PRCSAPP"
- Begin DoDot:1
- +23 IF $GET(PRCHDELV)
- IF '$GET(AUTOOBLG)
- QUIT
- +24 IF $PIECE(RECORD4,"^",4)=""
- SET $PIECE(RECORD4,"^",4)=$PIECE($$NOW^PRCUESIG,".",1)
- SET ^PRCS(410,LEVEL0,4)=RECORD4
- +25 IF '$DATA(PRC("CP"))
- IF $DATA(PRCB("CP"))
- SET CPSW=1
- SET PRC("CP")=PRCB("CP")
- +26 IF $DATA(PRC("CP"))
- IF ($PIECE($GET(^PRC(420,+PRC("SITE"),1,+PRC("CP"),6)),U)="Y")!($PIECE($GET(^PRC(420,+PRC("SITE"),3)),U)="Y")!($PIECE($GET(^PRC(420,+PRC("SITE"),3)),U,2)'="")!($PIECE($GET(^PRC(420,+PRC("SITE"),1,+PRC("CP"),6)),U,2)'
- ="")
- Begin DoDot:2
- +27 if $GET(PRCHAMDA)=32
- QUIT
- +28 DO ENCODE^PRCSC2(LEVEL0,USERNUM)
- End DoDot:2
- +29 IF $GET(CPSW)=1
- KILL PRC("CP"),CPSW
- End DoDot:1
- +30 if $PIECE(RECORD7,"^",7)=""
- SET $PIECE(RECORD7,"^",7)=$$NOW^PRCUESIG
- +31 if $PIECE(RECORD7,"^",5)=""
- SET $PIECE(RECORD7,"^",5)=$PIECE($$NOW^PRCUESIG,".",1)
- +32 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- +33 SET $PIECE(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
- +34 SET $PIECE(RECORD7,"^",4)=$PIECE($GET(^VA(200,USERNUM,20)),"^",3)
- +35 SET $PIECE(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
- +36 SET ^PRCS(410,LEVEL0,7)=RECORD7
- +37 SET ^PRCS(410,LEVEL0,7.1)=RECORD71
- +38 SET Y=1
- QUIT
- RECODE(LEVEL0,Y) ;Recode esig for version 1 only
- +1 NEW RECORD,RECORD7,RECORD71,SIGBLOCK,CHECKSUM
- +2 NEW DA,DIC,RECORD1,RECORD10,RECORD2,RECORD3,RECORD4,USERNUM
- +3 SET RECORD=$GET(^PRCS(410,LEVEL0,0))
- +4 SET RECORD1=$GET(^PRCS(410,LEVEL0,1))
- +5 SET RECORD2=$GET(^PRCS(410,LEVEL0,2))
- +6 SET RECORD3=$GET(^PRCS(410,LEVEL0,3))
- +7 SET RECORD4=$GET(^PRCS(410,LEVEL0,4))
- +8 SET RECORD7=$GET(^PRCS(410,LEVEL0,7))
- +9 SET RECORD71=$GET(^PRCS(410,LEVEL0,7.1))
- +10 SET RECORD10=$GET(^PRCS(410,LEVEL0,10))
- +11 ;-1 no transaction record
- IF RECORD=""
- SET Y=-1
- QUIT
- +12 SET USERNUM=+$PIECE(RECORD7,"^",3)
- +13 ;-4 cannot re-sign record
- IF $PIECE(RECORD7,"^",6)=""!(USERNUM=0)
- SET Y=-4
- QUIT
- +14 SET SIGBLOCK=$PIECE($GET(^VA(200,USERNUM,20)),"^",2)
- +15 SET CHECKSUM=$$SUM^PRCUESIG(LEVEL0_"^"_$$STRING(RECORD,RECORD1,RECORD2,RECORD3,RECORD4,RECORD7,RECORD10))
- +16 SET $PIECE(RECORD7,"^",6)=$$ENCODE^PRCUESIG(SIGBLOCK,USERNUM,CHECKSUM)
- +17 SET $PIECE(RECORD7,"^",4)=$PIECE($GET(^VA(200,USERNUM,20)),"^",3)
- +18 SET $PIECE(RECORD71,"^",3,4)="1^"_$$SUM^PRCUESIG(SIGBLOCK)
- +19 SET ^PRCS(410,LEVEL0,7)=RECORD7
- +20 SET ^PRCS(410,LEVEL0,7.1)=RECORD71
- +21 SET Y=1
- QUIT
- REMOVE(LEVEL0) ;Entry point to remove e signature from record
- +1 ;NOT an extrinsic function
- +2 NEW RECORD7,RECORD71
- +3 SET RECORD7=$GET(^PRCS(410,LEVEL0,7))
- +4 SET RECORD71=$GET(^PRCS(410,LEVEL0,7.1))
- +5 SET $PIECE(RECORD7,"^",3,7)="^^^^"
- +6 SET $PIECE(RECORD71,"^",4)=""
- +7 SET ^PRCS(410,LEVEL0,7)=RECORD7
- +8 SET ^PRCS(410,LEVEL0,7.1)=RECORD71
- +9 QUIT
- VERIFY(LEVEL0) ;extrinsic function to verify version 1 signature. Returns 1 if valid, 0 if not valid
- +1 NEW RECORD71,VERSION,SIGBLOCK
- +2 ;get record variables
- +3 SET RECORD71=$GET(^PRCS(410,LEVEL0,7.1))
- +4 SET VERSION=$PIECE(RECORD71,"^",3)
- SET SIGBLOCK=$PIECE(RECORD71,"^",4)
- +5 IF VERSION_SIGBLOCK=""
- QUIT 1
- +6 QUIT ($$SUM^PRCUESIG($$DECODE(LEVEL0))=SIGBLOCK)
- STRING(X,X1,X2,X3,X4,X7,X10) ;Build String of critical fields
- +1 QUIT $PIECE(X,"^",1)_"^"_$PIECE(X1,"^",1)_"^"_$PIECE(X2,"^",1)_"^"_$PIECE(X3,"^",1)_"^"_$PIECE(X3,"^",3)_"^"_$PIECE(X4,"^",1)_"^"_$PIECE(X7,"^",7)_"^"_$PIECE(X10,"^",1)