KMPDRDAT ;SP/JML - Cover Sheet Load Raw Data Extract ;5/1/2017
;;4.0;CAPACITY MANAGEMENT;;3/1/2018;Build 38
;
; Send raw data to CPE database
; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
;"KMPD","RDAT",
EN ;
N KMPDBDLT,KMPDBGD,KMPDBGSS,KMPDDAT1,KMPDDATA,KMPDDELT,KMPDDOM,KMPDFDLT,KMPDFGBG,KMPDFGD,KMPDFGSS
N KMPDFMDAY,KMPDHDAY,KMPDID,KMPDLN,KMPDP,KMPDPROD,KMPDSINF,KMPDSITE,KMPDSYS,KMPDTDLT,KMPDWD,Y
;
K ^KMPTMP("KMPD","RDAT")
S KMPDHDAY=+$H-1
S KMPDFMDAY=+$$HTFM^XLFDT(KMPDHDAY,1)
S KMPDWD=$$WORKDAY^XUWORKDY(KMPDFMDAY) ; IA#10046
;
; SET HEADER LINES
S KMPDLN=1
S ^KMPTMP("KMPD","RDAT",KMPDLN)="SYSTEM ID="_$$SITEINFO^KMPVCCFG(),KMPDLN=KMPDLN+1
S ^KMPTMP("KMPD","RDAT",KMPDLN)="UPDATE CONFIG="_KMPDHDAY_U_KMPDWD_"^DAILY",KMPDLN=KMPDLN+1
S ^KMPTMP("KMPD","RDAT",KMPDLN)="SYSTEM CONFIG="_$$SYSCFG^KMPVCCFG(),KMPDLN=KMPDLN+1
;
; DETERMINE FOREGROUND, BACKGROUND OR BOTH
S KMPDFGBG=0,U="^"
I $D(^KMPTMP("KMPDT","ORWCV")) S KMPDFGBG=1
I $D(^KMPTMP("KMPDT","ORWCV-FT")) S KMPDFGBG=KMPDFGBG+2
I KMPDFGBG=1 D ORONE("ORWCV")
I KMPDFGBG=2 D ORONE("ORWCV-FT")
I KMPDFGBG=3 D ORBOTH
;
D TRANSMIT
;
K ^KMPTMP("KMPD","RDAT")
Q
;
ORONE(KMPDSUB) ;
S KMPDID=""
F S KMPDID=$O(^KMPTMP("KMPDT",KMPDSUB,KMPDID)) Q:KMPDID="" D
.S KMPDDAT1=$G(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
.Q:$P(KMPDDAT1,U,5)=1
.; identifier
.S KMPDDATA=""
.; server start date/time
.S $P(KMPDDATA,U,1)=$P(KMPDDAT1,U)
.; (FG or BG delta) and (Total server delta)
.D:$P(KMPDDAT1,U,2)
..S KMPDDELT=$$HDIFF^XLFDT($P(KMPDDAT1,U,2),$P(KMPDDAT1,U),2)
..S KMPDP=$S(KMPDSUB="ORWCV-FT":2,1:3)
..S $P(KMPDDATA,U,KMPDP)=KMPDDELT
..S $P(KMPDDATA,U,4)=KMPDDELT
.; client duz
.S $P(KMPDDATA,U,5)=$P(KMPDDAT1,U,3)
.; client name
.S $P(KMPDDATA,U,6)=$P(KMPDDAT1,U,4)
.; kmptmp subscript key
.S $P(KMPDDATA,U,7)=KMPDSUB
.; application title
.S $P(KMPDDATA,U,8)="CPRS Cover Sheet"
.; ip address
.S $P(KMPDDATA,U,9)=$P($P(KMPDID,"-")," ",2)
.; patient DFN
.S $P(KMPDDATA,U,10)=$P(KMPDID,"-",3)
.; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
.S ^KMPTMP("KMPD","RDAT",KMPDLN)="CVLOAD DATA="_KMPDDATA,KMPDLN=KMPDLN+1
.S $P(^KMPTMP("KMPDT",KMPDSUB,KMPDID),U,5)=1
Q
;
ORBOTH ;
; loop foreground node and concurrently look at related background node
S KMPDBGSS="ORWCV",KMPDFGSS="ORWCV-FT"
S KMPDID=""
F S KMPDID=$O(^KMPTMP("KMPDT",KMPDFGSS,KMPDID)) Q:KMPDID="" D
.S KMPDFGD=$G(^KMPTMP("KMPDT",KMPDFGSS,KMPDID))
.Q:$P(KMPDFGD,U,5)=1 ; ALREADY SENT
.S KMPDBGD=$G(^KMPTMP("KMPDT",KMPDBGSS,KMPDID))
.S KMPDDATA=""
.S $P(KMPDDATA,U,1)=$P(KMPDFGD,U)
.S (KMPDFDLT,KMPDBDLT,KMPDTDLT)=""
.I $P(KMPDFGD,U,2) S KMPDFDLT=$$HDIFF^XLFDT($P(KMPDFGD,U,2),$P(KMPDFGD,U),2)
.I $P(KMPDBGD,U,2) S KMPDBDLT=$$HDIFF^XLFDT($P(KMPDBGD,U,2),$P(KMPDBGD,U),2)
.S KMPDTDLT=KMPDFDLT+KMPDBDLT
.S $P(KMPDDATA,U,2)=KMPDFDLT
.S $P(KMPDDATA,U,3)=KMPDBDLT
.S $P(KMPDDATA,U,4)=KMPDTDLT
.; client duz
.S $P(KMPDDATA,U,5)=$P(KMPDFGD,U,3)
.; client name
.S $P(KMPDDATA,U,6)=$P(KMPDFGD,U,4)
.; kmptmp subscript key
.S $P(KMPDDATA,U,7)="ORWCV-FGBG"
.; application title
.S $P(KMPDDATA,U,8)="CPRS Cover Sheet"
.; ip address
.S $P(KMPDDATA,U,9)=$P($P(KMPDID,"-")," ",2)
.; patient DFN
.S $P(KMPDDATA,U,10)=$P(KMPDID,"-",3)
.; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
.S ^KMPTMP("KMPD","RDAT",KMPDLN)="CVLOAD DATA="_KMPDDATA,KMPDLN=KMPDLN+1
.S $P(^KMPTMP("KMPDT",KMPDFGSS,KMPDID),U,5)=1
.S $P(^KMPTMP("KMPDT",KMPDBGSS,KMPDID),U,5)=1
; Loop BG node in case there is an entry that didn't have a FG entry.
; The reverse situation already handled in first loop.
D ORONE("ORWCV")
Q
;
TRANSMIT ;
; quit if no data to transmit.
Q:'$D(^KMPTMP("KMPD","RDAT"))
N XMSUB,XMTEXT,XMY,XMZ
; send data via mail message.
S XMTEXT="^KMPTMP(""KMPD"",""RDAT"","
S XMSUB="CVLOAD DAILY DATA"
S XMY("S.KMPD-ORWCV-SERVER@VISTA.CPE.DOMAIN.EXT")=""
D ^XMD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDRDAT 4140 printed Dec 13, 2024@01:40:37 Page 2
KMPDRDAT ;SP/JML - Cover Sheet Load Raw Data Extract ;5/1/2017
+1 ;;4.0;CAPACITY MANAGEMENT;;3/1/2018;Build 38
+2 ;
+3 ; Send raw data to CPE database
+4 ; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
+5 ;"KMPD","RDAT",
EN ;
+1 NEW KMPDBDLT,KMPDBGD,KMPDBGSS,KMPDDAT1,KMPDDATA,KMPDDELT,KMPDDOM,KMPDFDLT,KMPDFGBG,KMPDFGD,KMPDFGSS
+2 NEW KMPDFMDAY,KMPDHDAY,KMPDID,KMPDLN,KMPDP,KMPDPROD,KMPDSINF,KMPDSITE,KMPDSYS,KMPDTDLT,KMPDWD,Y
+3 ;
+4 KILL ^KMPTMP("KMPD","RDAT")
+5 SET KMPDHDAY=+$HOROLOG-1
+6 SET KMPDFMDAY=+$$HTFM^XLFDT(KMPDHDAY,1)
+7 ; IA#10046
SET KMPDWD=$$WORKDAY^XUWORKDY(KMPDFMDAY)
+8 ;
+9 ; SET HEADER LINES
+10 SET KMPDLN=1
+11 SET ^KMPTMP("KMPD","RDAT",KMPDLN)="SYSTEM ID="_$$SITEINFO^KMPVCCFG()
SET KMPDLN=KMPDLN+1
+12 SET ^KMPTMP("KMPD","RDAT",KMPDLN)="UPDATE CONFIG="_KMPDHDAY_U_KMPDWD_"^DAILY"
SET KMPDLN=KMPDLN+1
+13 SET ^KMPTMP("KMPD","RDAT",KMPDLN)="SYSTEM CONFIG="_$$SYSCFG^KMPVCCFG()
SET KMPDLN=KMPDLN+1
+14 ;
+15 ; DETERMINE FOREGROUND, BACKGROUND OR BOTH
+16 SET KMPDFGBG=0
SET U="^"
+17 IF $DATA(^KMPTMP("KMPDT","ORWCV"))
SET KMPDFGBG=1
+18 IF $DATA(^KMPTMP("KMPDT","ORWCV-FT"))
SET KMPDFGBG=KMPDFGBG+2
+19 IF KMPDFGBG=1
DO ORONE("ORWCV")
+20 IF KMPDFGBG=2
DO ORONE("ORWCV-FT")
+21 IF KMPDFGBG=3
DO ORBOTH
+22 ;
+23 DO TRANSMIT
+24 ;
+25 KILL ^KMPTMP("KMPD","RDAT")
+26 QUIT
+27 ;
ORONE(KMPDSUB) ;
+1 SET KMPDID=""
+2 FOR
SET KMPDID=$ORDER(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
if KMPDID=""
QUIT
Begin DoDot:1
+3 SET KMPDDAT1=$GET(^KMPTMP("KMPDT",KMPDSUB,KMPDID))
+4 if $PIECE(KMPDDAT1,U,5)=1
QUIT
+5 ; identifier
+6 SET KMPDDATA=""
+7 ; server start date/time
+8 SET $PIECE(KMPDDATA,U,1)=$PIECE(KMPDDAT1,U)
+9 ; (FG or BG delta) and (Total server delta)
+10 if $PIECE(KMPDDAT1,U,2)
Begin DoDot:2
+11 SET KMPDDELT=$$HDIFF^XLFDT($PIECE(KMPDDAT1,U,2),$PIECE(KMPDDAT1,U),2)
+12 SET KMPDP=$SELECT(KMPDSUB="ORWCV-FT":2,1:3)
+13 SET $PIECE(KMPDDATA,U,KMPDP)=KMPDDELT
+14 SET $PIECE(KMPDDATA,U,4)=KMPDDELT
End DoDot:2
+15 ; client duz
+16 SET $PIECE(KMPDDATA,U,5)=$PIECE(KMPDDAT1,U,3)
+17 ; client name
+18 SET $PIECE(KMPDDATA,U,6)=$PIECE(KMPDDAT1,U,4)
+19 ; kmptmp subscript key
+20 SET $PIECE(KMPDDATA,U,7)=KMPDSUB
+21 ; application title
+22 SET $PIECE(KMPDDATA,U,8)="CPRS Cover Sheet"
+23 ; ip address
+24 SET $PIECE(KMPDDATA,U,9)=$PIECE($PIECE(KMPDID,"-")," ",2)
+25 ; patient DFN
+26 SET $PIECE(KMPDDATA,U,10)=$PIECE(KMPDID,"-",3)
+27 ; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
+28 SET ^KMPTMP("KMPD","RDAT",KMPDLN)="CVLOAD DATA="_KMPDDATA
SET KMPDLN=KMPDLN+1
+29 SET $PIECE(^KMPTMP("KMPDT",KMPDSUB,KMPDID),U,5)=1
End DoDot:1
+30 QUIT
+31 ;
ORBOTH ;
+1 ; loop foreground node and concurrently look at related background node
+2 SET KMPDBGSS="ORWCV"
SET KMPDFGSS="ORWCV-FT"
+3 SET KMPDID=""
+4 FOR
SET KMPDID=$ORDER(^KMPTMP("KMPDT",KMPDFGSS,KMPDID))
if KMPDID=""
QUIT
Begin DoDot:1
+5 SET KMPDFGD=$GET(^KMPTMP("KMPDT",KMPDFGSS,KMPDID))
+6 ; ALREADY SENT
if $PIECE(KMPDFGD,U,5)=1
QUIT
+7 SET KMPDBGD=$GET(^KMPTMP("KMPDT",KMPDBGSS,KMPDID))
+8 SET KMPDDATA=""
+9 SET $PIECE(KMPDDATA,U,1)=$PIECE(KMPDFGD,U)
+10 SET (KMPDFDLT,KMPDBDLT,KMPDTDLT)=""
+11 IF $PIECE(KMPDFGD,U,2)
SET KMPDFDLT=$$HDIFF^XLFDT($PIECE(KMPDFGD,U,2),$PIECE(KMPDFGD,U),2)
+12 IF $PIECE(KMPDBGD,U,2)
SET KMPDBDLT=$$HDIFF^XLFDT($PIECE(KMPDBGD,U,2),$PIECE(KMPDBGD,U),2)
+13 SET KMPDTDLT=KMPDFDLT+KMPDBDLT
+14 SET $PIECE(KMPDDATA,U,2)=KMPDFDLT
+15 SET $PIECE(KMPDDATA,U,3)=KMPDBDLT
+16 SET $PIECE(KMPDDATA,U,4)=KMPDTDLT
+17 ; client duz
+18 SET $PIECE(KMPDDATA,U,5)=$PIECE(KMPDFGD,U,3)
+19 ; client name
+20 SET $PIECE(KMPDDATA,U,6)=$PIECE(KMPDFGD,U,4)
+21 ; kmptmp subscript key
+22 SET $PIECE(KMPDDATA,U,7)="ORWCV-FGBG"
+23 ; application title
+24 SET $PIECE(KMPDDATA,U,8)="CPRS Cover Sheet"
+25 ; ip address
+26 SET $PIECE(KMPDDATA,U,9)=$PIECE($PIECE(KMPDID,"-")," ",2)
+27 ; patient DFN
+28 SET $PIECE(KMPDDATA,U,10)=$PIECE(KMPDID,"-",3)
+29 ; START TIME^FG DELTA^BG DELTA^TOT DELTA^CLIENT DUZ^CLIENT NAME^KMPTMP SUBSCRIPT KEY^APPLICATION TITLE^IP^DFN
+30 SET ^KMPTMP("KMPD","RDAT",KMPDLN)="CVLOAD DATA="_KMPDDATA
SET KMPDLN=KMPDLN+1
+31 SET $PIECE(^KMPTMP("KMPDT",KMPDFGSS,KMPDID),U,5)=1
+32 SET $PIECE(^KMPTMP("KMPDT",KMPDBGSS,KMPDID),U,5)=1
End DoDot:1
+33 ; Loop BG node in case there is an entry that didn't have a FG entry.
+34 ; The reverse situation already handled in first loop.
+35 DO ORONE("ORWCV")
+36 QUIT
+37 ;
TRANSMIT ;
+1 ; quit if no data to transmit.
+2 if '$DATA(^KMPTMP("KMPD","RDAT"))
QUIT
+3 NEW XMSUB,XMTEXT,XMY,XMZ
+4 ; send data via mail message.
+5 SET XMTEXT="^KMPTMP(""KMPD"",""RDAT"","
+6 SET XMSUB="CVLOAD DAILY DATA"
+7 SET XMY("S.KMPD-ORWCV-SERVER@VISTA.CPE.DOMAIN.EXT")=""
+8 DO ^XMD
+9 QUIT