KMPDTU01 ;OAK/RAK - CM Tools Timing Utility ;4/6/06 08:40
;;3.0;KMPD;;Jan 22, 2009;Build 42
;
DAILY(KMPDT) ;-- transmit daily stats to national database
;-----------------------------------------------------------------------
; KMPDT.... Compression date in internal fileman formt. It represents
; the date from which the previous days data should be
; transmitted.
; Example: if KMPDT = 2981011 then tranmission will be
; on 2981010 (KMPDT-1)
;-----------------------------------------------------------------------
;
Q:'$G(KMPDT)
;
N DATE,DATA,DELTA,ERROR,FDA,HOUR,I,IEN,PIECE,PTNP,SDTM,SITE,SS
N STR
;
; storage processed
K ^TMP($J),^TMP("KMPDTU01",$J)
; site info.
S SITE=$$SITE^VASITE Q:SITE=""
S IEN=0
W:'$D(ZTQUEUED) !,"Compressing data into daily format..."
F S IEN=$O(^KMPD(8973.2,"ADT",KMPDT,IEN)) Q:'IEN D
.Q:'$D(^KMPD(8973.2,IEN,0)) S DATA(0)=^(0)
.; quit if daily data has already been sent to national database
.;Q:$P(DATA(0),U,10)
.W:'$D(ZTQUEUED)&('(IEN#1000)) "."
.; start date/time date w/no time delta
.S SDTM=$P(DATA(0),U,3),DATE=$P(SDTM,"."),DELTA=$P(DATA(0),U,4)
.; hour
.S HOUR=+$E($P(SDTM,".",2),1,2)
.; quit if no kmptmp subscript
.S SS=$P(DATA(0),U,7) Q:SS=""
.;
.S PTNP=$$PTNP^KMPDHU03(SDTM) Q:'PTNP
.; piece 4 - prime time
.; piece 5 - non-prime time
.S PIECE=$S(PTNP=1:4,1:5)
.;
.S $P(^TMP($J,KMPDT,SS),U)=KMPDT
.S $P(^TMP($J,KMPDT,SS),U,3)=SS
.S $P(^TMP($J,KMPDT,SS),U,PIECE)=$P(^TMP($J,KMPDT,SS),U,PIECE)+DELTA
.S $P(^TMP($J,KMPDT,SS),U,(PIECE+2))=$P(^TMP($J,KMPDT,SS),U,(PIECE+2))+1
.; hourly delta
.S $P(^TMP($J,KMPDT,SS,PTNP),U,(HOUR+1))=$P($G(^TMP($J,KMPDT,SS,PTNP)),U,(HOUR+1))+DELTA
.; hourly occurrences
.S $P(^TMP($J,KMPDT,SS,PTNP+.1),U,(HOUR+1))=$P($G(^TMP($J,KMPDT,SS,PTNP+.1)),U,(HOUR+1))+1
.; node 99.1 is for national database (end date^facility name)
.S ^TMP($J,KMPDT,SS,99.1)=KMPDT_"^"_$P(SITE,U,2)_"^"_$P(SITE,U,3)_"^"_$$WORKDAY^XUWORKDY(DATE)
.; add to processed array.
.S ^TMP("KMPDTU01",$J,IEN)=""
;
D:$D(^TMP($J)) TRANSMIT(2)
K ^TMP($J)
;
; update field .1 (DAILY - SENT TO CM NATIONAL DB) to 'YES' for all
; processed entries.
W:'$D(ZTQUEUED) !!,"Updating records to reflect transmission..."
S IEN=0
F S IEN=$O(^TMP("KMPDTU01",$J,IEN)) Q:'IEN D
.K FDA,ERROR W:'$D(ZTQUEUED)&('(IEN#1000)) "."
.S FDA($J,8973.2,IEN_",",.1)=1
.D FILE^DIE("","FDA($J)","ERROR")
;
K ^TMP("KMPDTU01",$J)
;
W:'$D(ZTQUEUED) !!,"Finished!"
;
Q
;
TRANSMIT(KMPDTWD) ;-- format data into e-mail and send to cm national database
;-----------------------------------------------------------------------
; KMPDTWD... Weekly/Daily
; 1 - weekly
; 2 - daily
;
; D = date
; S = subscript
;-----------------------------------------------------------------------
;
Q:'$G(KMPDTWD)
Q:'$D(^TMP($J))
;
N CPU,D,DATE,I,IEN,LN,S,TL,TRANSTO,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
;
K ^TMP("KMPDTU01-2",$J)
;
S DATE=$S(KMPDTWD=1:$G(START),1:$G(KMPDT))
S LN=0
; version and patch info
S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="VERSION="_$$VERSION^KMPDUTL
; system information
S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="SYSINFO="_$$SYSINFO^KMPDUTL1()
; send cpu data to national database
D CPU^KMPDUTL5(.CPU) I $D(CPU) S I="" F S I=$O(CPU(I)) Q:I="" D
.S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="CPU="_I_U_CPU(I)
;
W:'$D(ZTQUEUED) !!,"Formatting ",$$FMTE^XLFDT($G(START))," data for mail delivery..."
; reformat so that data is in ^TMP("KMPR UPLOAD",$J,LN)= format.
S IEN=0,D=""
F S D=$O(^TMP($J,D)) Q:D="" S S="" W "." D
.W !,D
.F S S=$O(^TMP($J,D,S)) Q:S="" D
..S IEN=IEN+1,LN=LN+1
..S ^TMP("KMPDTU01-2",$J,LN)=IEN_",0)="_^TMP($J,D,S)
..; if prime time
..I $D(^TMP($J,D,S,1)) D
...S LN=LN+1
...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",1)="_^TMP($J,D,S,1)
...S LN=LN+1
...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",1.1)="_^TMP($J,D,S,1.1)
..; if non-prime time
..I $D(^TMP($J,D,S,2)) D
...S LN=LN+1
...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",2)="_^TMP($J,D,S,2)
...S LN=LN+1
...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",2.1)="_^TMP($J,D,S,2.1)
..; node 99.1 for national database
..S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)=IEN_",99.1)="_$G(^TMP($J,D,S,99.1))
;
; quit if no data to transmit.
Q:'$D(^TMP("KMPDTU01-2",$J))
S TL=$$TESTLAB^KMPDUT1
; send packman message.
S XMTEXT="^TMP(""KMPDTU01-2"","_$J_","
S XMSUB=$S(KMPDTWD=1:"CM TIMING DATA~",1:"CM TIMING DATA-DAILY~")_$P(TL,U,2)_$P(SITE,U,2)_" ("_$P(SITE,U,3)_")~"_$$FMTE^XLFDT(DATE,2)
D TRANSTO^KMPDUTL7(1,4,.TRANSTO) Q:'$D(TRANSTO)
S I=""
F S I=$O(TRANSTO(I)) Q:I="" S XMY(I)=""
D ^XMD
W:'$D(ZTQUEUED) !,"Message #",$G(XMZ)," sent..."
K ^TMP("KMPDTU01-2",$J)
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTU01 4826 printed Dec 13, 2024@01:40:52 Page 2
KMPDTU01 ;OAK/RAK - CM Tools Timing Utility ;4/6/06 08:40
+1 ;;3.0;KMPD;;Jan 22, 2009;Build 42
+2 ;
DAILY(KMPDT) ;-- transmit daily stats to national database
+1 ;-----------------------------------------------------------------------
+2 ; KMPDT.... Compression date in internal fileman formt. It represents
+3 ; the date from which the previous days data should be
+4 ; transmitted.
+5 ; Example: if KMPDT = 2981011 then tranmission will be
+6 ; on 2981010 (KMPDT-1)
+7 ;-----------------------------------------------------------------------
+8 ;
+9 if '$GET(KMPDT)
QUIT
+10 ;
+11 NEW DATE,DATA,DELTA,ERROR,FDA,HOUR,I,IEN,PIECE,PTNP,SDTM,SITE,SS
+12 NEW STR
+13 ;
+14 ; storage processed
+15 KILL ^TMP($JOB),^TMP("KMPDTU01",$JOB)
+16 ; site info.
+17 SET SITE=$$SITE^VASITE
if SITE=""
QUIT
+18 SET IEN=0
+19 if '$DATA(ZTQUEUED)
WRITE !,"Compressing data into daily format..."
+20 FOR
SET IEN=$ORDER(^KMPD(8973.2,"ADT",KMPDT,IEN))
if 'IEN
QUIT
Begin DoDot:1
+21 if '$DATA(^KMPD(8973.2,IEN,0))
QUIT
SET DATA(0)=^(0)
+22 ; quit if daily data has already been sent to national database
+23 ;Q:$P(DATA(0),U,10)
+24 if '$DATA(ZTQUEUED)&('(IEN#1000))
WRITE "."
+25 ; start date/time date w/no time delta
+26 SET SDTM=$PIECE(DATA(0),U,3)
SET DATE=$PIECE(SDTM,".")
SET DELTA=$PIECE(DATA(0),U,4)
+27 ; hour
+28 SET HOUR=+$EXTRACT($PIECE(SDTM,".",2),1,2)
+29 ; quit if no kmptmp subscript
+30 SET SS=$PIECE(DATA(0),U,7)
if SS=""
QUIT
+31 ;
+32 SET PTNP=$$PTNP^KMPDHU03(SDTM)
if 'PTNP
QUIT
+33 ; piece 4 - prime time
+34 ; piece 5 - non-prime time
+35 SET PIECE=$SELECT(PTNP=1:4,1:5)
+36 ;
+37 SET $PIECE(^TMP($JOB,KMPDT,SS),U)=KMPDT
+38 SET $PIECE(^TMP($JOB,KMPDT,SS),U,3)=SS
+39 SET $PIECE(^TMP($JOB,KMPDT,SS),U,PIECE)=$PIECE(^TMP($JOB,KMPDT,SS),U,PIECE)+DELTA
+40 SET $PIECE(^TMP($JOB,KMPDT,SS),U,(PIECE+2))=$PIECE(^TMP($JOB,KMPDT,SS),U,(PIECE+2))+1
+41 ; hourly delta
+42 SET $PIECE(^TMP($JOB,KMPDT,SS,PTNP),U,(HOUR+1))=$PIECE($GET(^TMP($JOB,KMPDT,SS,PTNP)),U,(HOUR+1))+DELTA
+43 ; hourly occurrences
+44 SET $PIECE(^TMP($JOB,KMPDT,SS,PTNP+.1),U,(HOUR+1))=$PIECE($GET(^TMP($JOB,KMPDT,SS,PTNP+.1)),U,(HOUR+1))+1
+45 ; node 99.1 is for national database (end date^facility name)
+46 SET ^TMP($JOB,KMPDT,SS,99.1)=KMPDT_"^"_$PIECE(SITE,U,2)_"^"_$PIECE(SITE,U,3)_"^"_$$WORKDAY^XUWORKDY(DATE)
+47 ; add to processed array.
+48 SET ^TMP("KMPDTU01",$JOB,IEN)=""
End DoDot:1
+49 ;
+50 if $DATA(^TMP($JOB))
DO TRANSMIT(2)
+51 KILL ^TMP($JOB)
+52 ;
+53 ; update field .1 (DAILY - SENT TO CM NATIONAL DB) to 'YES' for all
+54 ; processed entries.
+55 if '$DATA(ZTQUEUED)
WRITE !!,"Updating records to reflect transmission..."
+56 SET IEN=0
+57 FOR
SET IEN=$ORDER(^TMP("KMPDTU01",$JOB,IEN))
if 'IEN
QUIT
Begin DoDot:1
+58 KILL FDA,ERROR
if '$DATA(ZTQUEUED)&('(IEN#1000))
WRITE "."
+59 SET FDA($JOB,8973.2,IEN_",",.1)=1
+60 DO FILE^DIE("","FDA($J)","ERROR")
End DoDot:1
+61 ;
+62 KILL ^TMP("KMPDTU01",$JOB)
+63 ;
+64 if '$DATA(ZTQUEUED)
WRITE !!,"Finished!"
+65 ;
+66 QUIT
+67 ;
TRANSMIT(KMPDTWD) ;-- format data into e-mail and send to cm national database
+1 ;-----------------------------------------------------------------------
+2 ; KMPDTWD... Weekly/Daily
+3 ; 1 - weekly
+4 ; 2 - daily
+5 ;
+6 ; D = date
+7 ; S = subscript
+8 ;-----------------------------------------------------------------------
+9 ;
+10 if '$GET(KMPDTWD)
QUIT
+11 if '$DATA(^TMP($JOB))
QUIT
+12 ;
+13 NEW CPU,D,DATE,I,IEN,LN,S,TL,TRANSTO,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
+14 ;
+15 KILL ^TMP("KMPDTU01-2",$JOB)
+16 ;
+17 SET DATE=$SELECT(KMPDTWD=1:$GET(START),1:$GET(KMPDT))
+18 SET LN=0
+19 ; version and patch info
+20 SET LN=LN+1
SET ^TMP("KMPDTU01-2",$JOB,LN)="VERSION="_$$VERSION^KMPDUTL
+21 ; system information
+22 SET LN=LN+1
SET ^TMP("KMPDTU01-2",$JOB,LN)="SYSINFO="_$$SYSINFO^KMPDUTL1()
+23 ; send cpu data to national database
+24 DO CPU^KMPDUTL5(.CPU)
IF $DATA(CPU)
SET I=""
FOR
SET I=$ORDER(CPU(I))
if I=""
QUIT
Begin DoDot:1
+25 SET LN=LN+1
SET ^TMP("KMPDTU01-2",$JOB,LN)="CPU="_I_U_CPU(I)
End DoDot:1
+26 ;
+27 if '$DATA(ZTQUEUED)
WRITE !!,"Formatting ",$$FMTE^XLFDT($GET(START))," data for mail delivery..."
+28 ; reformat so that data is in ^TMP("KMPR UPLOAD",$J,LN)= format.
+29 SET IEN=0
SET D=""
+30 FOR
SET D=$ORDER(^TMP($JOB,D))
if D=""
QUIT
SET S=""
WRITE "."
Begin DoDot:1
+31 WRITE !,D
+32 FOR
SET S=$ORDER(^TMP($JOB,D,S))
if S=""
QUIT
Begin DoDot:2
+33 SET IEN=IEN+1
SET LN=LN+1
+34 SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",0)="_^TMP($JOB,D,S)
+35 ; if prime time
+36 IF $DATA(^TMP($JOB,D,S,1))
Begin DoDot:3
+37 SET LN=LN+1
+38 SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",1)="_^TMP($JOB,D,S,1)
+39 SET LN=LN+1
+40 SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",1.1)="_^TMP($JOB,D,S,1.1)
End DoDot:3
+41 ; if non-prime time
+42 IF $DATA(^TMP($JOB,D,S,2))
Begin DoDot:3
+43 SET LN=LN+1
+44 SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",2)="_^TMP($JOB,D,S,2)
+45 SET LN=LN+1
+46 SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",2.1)="_^TMP($JOB,D,S,2.1)
End DoDot:3
+47 ; node 99.1 for national database
+48 SET LN=LN+1
SET ^TMP("KMPDTU01-2",$JOB,LN)=IEN_",99.1)="_$GET(^TMP($JOB,D,S,99.1))
End DoDot:2
End DoDot:1
+49 ;
+50 ; quit if no data to transmit.
+51 if '$DATA(^TMP("KMPDTU01-2",$JOB))
QUIT
+52 SET TL=$$TESTLAB^KMPDUT1
+53 ; send packman message.
+54 SET XMTEXT="^TMP(""KMPDTU01-2"","_$JOB_","
+55 SET XMSUB=$SELECT(KMPDTWD=1:"CM TIMING DATA~",1:"CM TIMING DATA-DAILY~")_$PIECE(TL,U,2)_$PIECE(SITE,U,2)_" ("_$PIECE(SITE,U,3)_")~"_$$FMTE^XLFDT(DATE,2)
+56 DO TRANSTO^KMPDUTL7(1,4,.TRANSTO)
if '$DATA(TRANSTO)
QUIT
+57 SET I=""
+58 FOR
SET I=$ORDER(TRANSTO(I))
if I=""
QUIT
SET XMY(I)=""
+59 DO ^XMD
+60 if '$DATA(ZTQUEUED)
WRITE !,"Message #",$GET(XMZ)," sent..."
+61 KILL ^TMP("KMPDTU01-2",$JOB)
+62 ;
+63 QUIT