PXRMEXCS ; SLC/PKR - Routines to compute checksums. ;10/24/2012
;;2.0;CLINICAL REMINDERS;**6,12,26**;Feb 04, 2005;Build 404
;====================================================
CHECKSUM(ATTR,START,END) ;Get the the checksum for a packed reminder
;component and load it into the attribute array.
N CS,LINE
;If checksum is in packed component return it otherwise calculate it.
I ATTR("FILE NUMBER")=0 D
. S LINE=^PXD(811.8,PXRMRIEN,100,START-3,0)
. S CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
. I CS="" S CS=$$PRTNCS(PXRMRIEN,START,END)
I ATTR("FILE NUMBER")>0 D
. S LINE=^PXD(811.8,PXRMRIEN,100,START-2,0)
. S CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
. I CS="" S CS=$$PFDACS(PXRMRIEN,START,END)
S ATTR("CHECKSUM")=CS
Q
;
;====================================================
DIQOUTCS(DIQOUT) ;Return checksum for a processed DIQOUT array.
N CS,DATA,FIELD,FNUM,IENS,IND,SFN,STRING,TARGET,TEXT,WP
S FNUM=$O(DIQOUT(""))
D FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
S SFN=+$G(TARGET("SPECIFIER"))
S (CS,FNUM)=0
F S FNUM=$O(DIQOUT(FNUM)) Q:FNUM="" D
. I FNUM=SFN Q
. S IENS=""
. F S IENS=$O(DIQOUT(FNUM,IENS)) Q:IENS="" D
.. S FIELD=0
.. F S FIELD=$O(DIQOUT(FNUM,IENS,FIELD)) Q:FIELD="" D
... S DATA=DIQOUT(FNUM,IENS,FIELD)
... S TEXT=FNUM_$L(IENS,",")_FIELD_DATA
... S CS=$$CRC32^XLFCRC(TEXT,CS)
... I DATA["WP-start" F IND=1:1:$P(DATA,"~",2) D
.... S TEXT=DIQOUT(FNUM,IENS,FIELD,IND)
.... S CS=$$CRC32^XLFCRC(TEXT,CS)
Q CS
;
;====================================================
FILE(FILENUM,IEN) ;Return checksum for entry IEN in file FILENUM.
;Make sure the entry exists.
I +$$FIND1^DIC(FILENUM,,"AU","`"_IEN)=0 Q 0
N CS,DIQOUT,IENROOT,MSG
D GETS^DIQ(FILENUM,IEN,"**","N","DIQOUT","MSG")
D CLDIQOUT^PXRMEXPD(FILENUM,IEN,"**",.IENROOT,.DIQOUT)
S CS=$$DIQOUTCS(.DIQOUT)
Q CS
;
;====================================================
HFCS(PATH,FILENAME) ;Return checksum for host file.
N CS,GBL,GBLZISH,SUCCESS
K ^TMP($J,"PXRMHFCS")
S GBL="^TMP($J,""PXRMHFCS"")"
S GBLZISH="^TMP($J,""PXRMHFCS"",1)"
S GBLZISH=$NA(@GBLZISH)
S SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBLZISH,3)
S CS=$S(SUCCESS:$$HFCSGBL(GBL),1:-1)
K ^TMP($J,"PXRMHFCS")
Q CS
;
;====================================================
HFCSGBL(GBL) ;Return checksum for host file loaded into global GBL.
N CS,IND,LINE
S (CS,IND)=0
F S IND=$O(@GBL@(IND)) Q:+IND=0 S LINE=@GBL@(IND),CS=$$CRC32^XLFCRC(LINE,CS)
Q CS
;
;====================================================
MMCS(XMZ) ;Return checksum for MailMan message ien XMZ.
N CS,IND,LINE,NLINES
S NLINES=+$P($G(^XMB(3.9,XMZ,2,0)),U,3)
S CS=0
F IND=1:1:NLINES S LINE=$G(^XMB(3.9,XMZ,2,IND,0)),CS=$$CRC32^XLFCRC(LINE,CS)
Q CS
;
;====================================================
PFDACS(IEN,FDASTART,FDAEND) ;Return checksum for FDA array of packed
;reminder component.
N CS,DATA,IENS,IND,JND,FIELD,FNUM,SFN,TARGET,TEMP,TEXT
S TEMP=^PXD(811.8,IEN,100,FDASTART,0)
S FNUM=$P(TEMP,";",1)
D FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
S SFN=+$G(TARGET("SPECIFIER"))
S CS=0
F IND=FDASTART:1:FDAEND D
. S TEMP=^PXD(811.8,IEN,100,IND,0)
. S DATA=$P(TEMP,"~",2,99)
. S TEMP=$P(TEMP,"~",1)
. S FNUM=$P(TEMP,";",1)
. I FNUM=SFN Q
. I FNUM="Exchange Stub" Q
. S IENS=$P(TEMP,";",2)
. S FIELD=$P(TEMP,";",3)
. S TEXT=FNUM_$L(IENS,",")_FIELD_DATA
. S CS=$$CRC32^XLFCRC(TEXT,CS)
. I DATA["WP-start" F JND=1:1:$P(DATA,"~",2) D
.. S IND=IND+1
.. S TEXT=^PXD(811.8,IEN,100,IND,0)
.. S CS=$$CRC32^XLFCRC(TEXT,CS)
Q CS
;
;====================================================
ROUTINE(RA) ;Return checksum for a routine loaded in array RA. RA has the
;form created by ^%ZOSF("LOAD") i.e, RA(1,0) ... RA(N,0).
N CS,IND,TEXT
S (CS,IND)=0
;Get rid of the build number on the second line.
S RA(2,0)=$P(RA(2,0),";",1,6)
F S IND=$O(RA(IND)) Q:+IND=0 D
. S TEXT=RA(IND,0)
. S CS=$$CRC32^XLFCRC(RA(IND,0),CS)
Q CS
;
;====================================================
RTNCS(ROUTINE) ;Return checksum for a routine ROUTINE.
N CS,DIF,RA,X,XCNP
S XCNP=0
S DIF="RA("
S X=ROUTINE
;Make sure the routine exists.
X ^%ZOSF("TEST")
I $T D
. X ^%ZOSF("LOAD")
. S CS=$$ROUTINE(.RA)
E S CS=-1
Q CS
;
;====================================================
PRTNCS(IEN,START,END) ;Return checksum for a packed routine.
N CS,IND,SL,TEXT
S CS=0,SL=START+1
F IND=START:1:END D
. S TEXT=^PXD(811.8,IEN,100,IND,0)
. ;Get rid of the build number on the second line.
. I IND=SL S TEXT=$P(TEXT,";",1,6)
. S CS=$$CRC32^XLFCRC(TEXT,CS)
Q CS
;
PXRMEXCS ; SLC/PKR - Routines to compute checksums. ;10/24/2012
+1 ;;2.0;CLINICAL REMINDERS;**6,12,26**;Feb 04, 2005;Build 404
+2 ;====================================================
CHECKSUM(ATTR,START,END) ;Get the the checksum for a packed reminder
+1 ;component and load it into the attribute array.
+2 NEW CS,LINE
+3 ;If checksum is in packed component return it otherwise calculate it.
+4 IF ATTR("FILE NUMBER")=0
Begin DoDot:1
+5 SET LINE=^PXD(811.8,PXRMRIEN,100,START-3,0)
+6 SET CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
+7 IF CS=""
SET CS=$$PRTNCS(PXRMRIEN,START,END)
End DoDot:1
+8 IF ATTR("FILE NUMBER")>0
Begin DoDot:1
+9 SET LINE=^PXD(811.8,PXRMRIEN,100,START-2,0)
+10 SET CS=$$GETTAGV^PXRMEXU3(LINE,"<CHECKSUM>")
+11 IF CS=""
SET CS=$$PFDACS(PXRMRIEN,START,END)
End DoDot:1
+12 SET ATTR("CHECKSUM")=CS
+13 QUIT
+14 ;
+15 ;====================================================
DIQOUTCS(DIQOUT) ;Return checksum for a processed DIQOUT array.
+1 NEW CS,DATA,FIELD,FNUM,IENS,IND,SFN,STRING,TARGET,TEXT,WP
+2 SET FNUM=$ORDER(DIQOUT(""))
+3 DO FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
+4 SET SFN=+$GET(TARGET("SPECIFIER"))
+5 SET (CS,FNUM)=0
+6 FOR
SET FNUM=$ORDER(DIQOUT(FNUM))
IF FNUM=""
QUIT
Begin DoDot:1
+7 IF FNUM=SFN
QUIT
+8 SET IENS=""
+9 FOR
SET IENS=$ORDER(DIQOUT(FNUM,IENS))
IF IENS=""
QUIT
Begin DoDot:2
+10 SET FIELD=0
+11 FOR
SET FIELD=$ORDER(DIQOUT(FNUM,IENS,FIELD))
IF FIELD=""
QUIT
Begin DoDot:3
+12 SET DATA=DIQOUT(FNUM,IENS,FIELD)
+13 SET TEXT=FNUM_$LENGTH(IENS,",")_FIELD_DATA
+14 SET CS=$$CRC32^XLFCRC(TEXT,CS)
+15 IF DATA["WP-start"
FOR IND=1:1:$PIECE(DATA,"~",2)
Begin DoDot:4
+16 SET TEXT=DIQOUT(FNUM,IENS,FIELD,IND)
+17 SET CS=$$CRC32^XLFCRC(TEXT,CS)
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+18 QUIT CS
+19 ;
+20 ;====================================================
FILE(FILENUM,IEN) ;Return checksum for entry IEN in file FILENUM.
+1 ;Make sure the entry exists.
+2 IF +$$FIND1^DIC(FILENUM,,"AU","`"_IEN)=0
QUIT 0
+3 NEW CS,DIQOUT,IENROOT,MSG
+4 DO GETS^DIQ(FILENUM,IEN,"**","N","DIQOUT","MSG")
+5 DO CLDIQOUT^PXRMEXPD(FILENUM,IEN,"**",.IENROOT,.DIQOUT)
+6 SET CS=$$DIQOUTCS(.DIQOUT)
+7 QUIT CS
+8 ;
+9 ;====================================================
HFCS(PATH,FILENAME) ;Return checksum for host file.
+1 NEW CS,GBL,GBLZISH,SUCCESS
+2 KILL ^TMP($JOB,"PXRMHFCS")
+3 SET GBL="^TMP($J,""PXRMHFCS"")"
+4 SET GBLZISH="^TMP($J,""PXRMHFCS"",1)"
+5 SET GBLZISH=$NAME(@GBLZISH)
+6 SET SUCCESS=$$FTG^%ZISH(PATH,FILENAME,GBLZISH,3)
+7 SET CS=$SELECT(SUCCESS:$$HFCSGBL(GBL),1:-1)
+8 KILL ^TMP($JOB,"PXRMHFCS")
+9 QUIT CS
+10 ;
+11 ;====================================================
HFCSGBL(GBL) ;Return checksum for host file loaded into global GBL.
+1 NEW CS,IND,LINE
+2 SET (CS,IND)=0
+3 FOR
SET IND=$ORDER(@GBL@(IND))
IF +IND=0
QUIT
SET LINE=@GBL@(IND)
SET CS=$$CRC32^XLFCRC(LINE,CS)
+4 QUIT CS
+5 ;
+6 ;====================================================
MMCS(XMZ) ;Return checksum for MailMan message ien XMZ.
+1 NEW CS,IND,LINE,NLINES
+2 SET NLINES=+$PIECE($GET(^XMB(3.9,XMZ,2,0)),U,3)
+3 SET CS=0
+4 FOR IND=1:1:NLINES
SET LINE=$GET(^XMB(3.9,XMZ,2,IND,0))
SET CS=$$CRC32^XLFCRC(LINE,CS)
+5 QUIT CS
+6 ;
+7 ;====================================================
PFDACS(IEN,FDASTART,FDAEND) ;Return checksum for FDA array of packed
+1 ;reminder component.
+2 NEW CS,DATA,IENS,IND,JND,FIELD,FNUM,SFN,TARGET,TEMP,TEXT
+3 SET TEMP=^PXD(811.8,IEN,100,FDASTART,0)
+4 SET FNUM=$PIECE(TEMP,";",1)
+5 DO FIELD^DID(FNUM,"EDIT HISTORY","","SPECIFIER","TARGET")
+6 SET SFN=+$GET(TARGET("SPECIFIER"))
+7 SET CS=0
+8 FOR IND=FDASTART:1:FDAEND
Begin DoDot:1
+9 SET TEMP=^PXD(811.8,IEN,100,IND,0)
+10 SET DATA=$PIECE(TEMP,"~",2,99)
+11 SET TEMP=$PIECE(TEMP,"~",1)
+12 SET FNUM=$PIECE(TEMP,";",1)
+13 IF FNUM=SFN
QUIT
+14 IF FNUM="Exchange Stub"
QUIT
+15 SET IENS=$PIECE(TEMP,";",2)
+16 SET FIELD=$PIECE(TEMP,";",3)
+17 SET TEXT=FNUM_$LENGTH(IENS,",")_FIELD_DATA
+18 SET CS=$$CRC32^XLFCRC(TEXT,CS)
+19 IF DATA["WP-start"
FOR JND=1:1:$PIECE(DATA,"~",2)
Begin DoDot:2
+20 SET IND=IND+1
+21 SET TEXT=^PXD(811.8,IEN,100,IND,0)
+22 SET CS=$$CRC32^XLFCRC(TEXT,CS)
End DoDot:2
End DoDot:1
+23 QUIT CS
+24 ;
+25 ;====================================================
ROUTINE(RA) ;Return checksum for a routine loaded in array RA. RA has the
+1 ;form created by ^%ZOSF("LOAD") i.e, RA(1,0) ... RA(N,0).
+2 NEW CS,IND,TEXT
+3 SET (CS,IND)=0
+4 ;Get rid of the build number on the second line.
+5 SET RA(2,0)=$PIECE(RA(2,0),";",1,6)
+6 FOR
SET IND=$ORDER(RA(IND))
IF +IND=0
QUIT
Begin DoDot:1
+7 SET TEXT=RA(IND,0)
+8 SET CS=$$CRC32^XLFCRC(RA(IND,0),CS)
End DoDot:1
+9 QUIT CS
+10 ;
+11 ;====================================================
RTNCS(ROUTINE) ;Return checksum for a routine ROUTINE.
+1 NEW CS,DIF,RA,X,XCNP
+2 SET XCNP=0
+3 SET DIF="RA("
+4 SET X=ROUTINE
+5 ;Make sure the routine exists.
+6 XECUTE ^%ZOSF("TEST")
+7 IF $TEST
Begin DoDot:1
+8 XECUTE ^%ZOSF("LOAD")
+9 SET CS=$$ROUTINE(.RA)
End DoDot:1
+10 IF '$TEST
SET CS=-1
+11 QUIT CS
+12 ;
+13 ;====================================================
PRTNCS(IEN,START,END) ;Return checksum for a packed routine.
+1 NEW CS,IND,SL,TEXT
+2 SET CS=0
SET SL=START+1
+3 FOR IND=START:1:END
Begin DoDot:1
+4 SET TEXT=^PXD(811.8,IEN,100,IND,0)
+5 ;Get rid of the build number on the second line.
+6 IF IND=SL
SET TEXT=$PIECE(TEXT,";",1,6)
+7 SET CS=$$CRC32^XLFCRC(TEXT,CS)
End DoDot:1
+8 QUIT CS
+9 ;