HMPEFX ;SLC/MKB,ASMR/RRB - Reference data update;7/19/12 2:26pm
;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**;Sep 01, 2011;Build 63
;Per VA Directive 6402, this routine should not be modified.
;
; External References DBIA#
; ------------------- -----
; ^DPT 10035
; MPIF001 2701
; XLFSTR 10104
Q
;
EN(LAST,MAX) ; -- get data from ^XTMP("HMPEF-<date>",n)
;[MAX not used yet]
N X,Y,HMPTOTL,DOMCNT,TYPE,NAME,RTN,HMPID
S LAST=$G(LAST) D GETLIST(LAST)
G ENQ:$G(^TMP("HMPX",$J,0))<1 ;no data
;
S (HMPTOTL,DOMCNT)=0
S TYPE="" F S TYPE=$O(^TMP("HMPX",$J,TYPE)) Q:TYPE="" D
. S NAME=$$LOW^XLFSTR(TYPE)
. S RTN=$$TAG^HMPEF(NAME)_"^HMPEF" Q:'$L($T(@RTN))
. S DOMCNT=DOMCNT+1
. ;
. N HMP,HMPI
. S HMP=$NA(^TMP("HMP",$J,DOMCNT)),HMPI=0,HMPID=""
. F S HMPID=$O(^TMP("HMPX",$J,TYPE,HMPID)) Q:HMPID="" D
.. D @RTN S HMPTOTL=HMPTOTL+1
. ;
. I 'HMPI S DOMCNT=DOMCNT-1 Q ;no data, or error
. S:DOMCNT>1 @HMP@(.3)=","
. S @HMP@(.5)="{""domainName"":"""_NAME_""",""total"":"_HMPI_",""items"":["
. S HMPI=HMPI+1,@HMP@(HMPI)="]}"
;
ENQ ;
S Y=$G(^TMP("HMPX",$J,0)) K ^TMP("HMPX",$J)
I '$G(DOMCNT) S @HMP@(.5)="{""apiVersion"":""1.01"",""data"":{""lastUpdate"":"""_LAST_""",""totalItems"":0,""items"":[]}}" Q
;
S @HMP@(.5)="{""apiVersion"":""1.01"",""data"":{""lastUpdate"":"""_Y_""",""totalItems"":"_DOMCNT_",""items"":["
S HMPI=DOMCNT I $D(^TMP($J,"HMP ERROR")) D
. N ERROR,CNT
. D BUILDERR^HMPEF(.ERROR)
. S HMPI=HMPI+1,@HMP@(HMPI)=",",CNT=0
. F S CNT=$O(ERROR(CNT)) Q:CNT'>0 S HMPI=HMPI+1,@HMP@(HMPI)=ERROR(CNT)
. K ^TMP($J,"HMP ERROR")
S HMPI=HMPI+1,@HMP@(HMPI)="]}}"
Q
;
GETLIST(LAST) ; -- build list of updates for client
; Returns ^TMP("HMPX",$J,0) = last DATE:SEQ included
; ^TMP("HMPX",$J,TYPE,ID)=ACT
N DATE,SEQ,BEG,END,IDX,X0,DFN,TYPE,ID,ACT
K ^TMP("HMPX",$J)
S DATE=+LAST,SEQ=+$P(LAST,":",2)
; generate list ID, and end point
S BEG=$NA(^XTMP("HMPEF-"_DATE,SEQ)) ;init loop where left off
; END=$Q(^XTMP("HMPEF-"_(DT+1),9999999),-1) ;last node
S END=+$O(^XTMP("HMPEF-"_DT,"A"),-1) ;last node
S ^TMP("HMPX",$J,0)=DT_":"_END ;date:seq
;
S IDX=BEG F S IDX=$Q(@IDX) Q:$$DONE D
. S X0=@IDX,TYPE=$P(X0,U),ID=$P(X0,U,2),ACT=$P(X0,U,3)
. I TYPE=""!(ID="") Q ;error
. S ^TMP("HMPX",$J,TYPE,ID)=ACT
Q
;
DONE() ; -- Return 1 or 0, if loop has finished
I IDX'?1"^XTMP(""HMPEF-"7N.E Q 1 ;end of ^XTMP
N D,N S D=+$P(IDX,"-",2),N=+$P(IDX,",",2)
; check HMP-DATE subscript
I D<DT Q 0 ;prior day: keep going
I D>DT Q 1 ;next day: stop loop
; D=DT: check sequence# subscript
I N>END Q 1
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPEFX 2788 printed Dec 13, 2024@01:53:53 Page 2
HMPEFX ;SLC/MKB,ASMR/RRB - Reference data update;7/19/12 2:26pm
+1 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**;Sep 01, 2011;Build 63
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; External References DBIA#
+5 ; ------------------- -----
+6 ; ^DPT 10035
+7 ; MPIF001 2701
+8 ; XLFSTR 10104
+9 QUIT
+10 ;
EN(LAST,MAX) ; -- get data from ^XTMP("HMPEF-<date>",n)
+1 ;[MAX not used yet]
+2 NEW X,Y,HMPTOTL,DOMCNT,TYPE,NAME,RTN,HMPID
+3 SET LAST=$GET(LAST)
DO GETLIST(LAST)
+4 ;no data
if $GET(^TMP("HMPX",$JOB,0))<1
GOTO ENQ
+5 ;
+6 SET (HMPTOTL,DOMCNT)=0
+7 SET TYPE=""
FOR
SET TYPE=$ORDER(^TMP("HMPX",$JOB,TYPE))
if TYPE=""
QUIT
Begin DoDot:1
+8 SET NAME=$$LOW^XLFSTR(TYPE)
+9 SET RTN=$$TAG^HMPEF(NAME)_"^HMPEF"
if '$LENGTH($TEXT(@RTN))
QUIT
+10 SET DOMCNT=DOMCNT+1
+11 ;
+12 NEW HMP,HMPI
+13 SET HMP=$NAME(^TMP("HMP",$JOB,DOMCNT))
SET HMPI=0
SET HMPID=""
+14 FOR
SET HMPID=$ORDER(^TMP("HMPX",$JOB,TYPE,HMPID))
if HMPID=""
QUIT
Begin DoDot:2
+15 DO @RTN
SET HMPTOTL=HMPTOTL+1
End DoDot:2
+16 ;
+17 ;no data, or error
IF 'HMPI
SET DOMCNT=DOMCNT-1
QUIT
+18 if DOMCNT>1
SET @HMP@(.3)=","
+19 SET @HMP@(.5)="{""domainName"":"""_NAME_""",""total"":"_HMPI_",""items"":["
+20 SET HMPI=HMPI+1
SET @HMP@(HMPI)="]}"
End DoDot:1
+21 ;
ENQ ;
+1 SET Y=$GET(^TMP("HMPX",$JOB,0))
KILL ^TMP("HMPX",$JOB)
+2 IF '$GET(DOMCNT)
SET @HMP@(.5)="{""apiVersion"":""1.01"",""data"":{""lastUpdate"":"""_LAST_""",""totalItems"":0,""items"":[]}}"
QUIT
+3 ;
+4 SET @HMP@(.5)="{""apiVersion"":""1.01"",""data"":{""lastUpdate"":"""_Y_""",""totalItems"":"_DOMCNT_",""items"":["
+5 SET HMPI=DOMCNT
IF $DATA(^TMP($JOB,"HMP ERROR"))
Begin DoDot:1
+6 NEW ERROR,CNT
+7 DO BUILDERR^HMPEF(.ERROR)
+8 SET HMPI=HMPI+1
SET @HMP@(HMPI)=","
SET CNT=0
+9 FOR
SET CNT=$ORDER(ERROR(CNT))
if CNT'>0
QUIT
SET HMPI=HMPI+1
SET @HMP@(HMPI)=ERROR(CNT)
+10 KILL ^TMP($JOB,"HMP ERROR")
End DoDot:1
+11 SET HMPI=HMPI+1
SET @HMP@(HMPI)="]}}"
+12 QUIT
+13 ;
GETLIST(LAST) ; -- build list of updates for client
+1 ; Returns ^TMP("HMPX",$J,0) = last DATE:SEQ included
+2 ; ^TMP("HMPX",$J,TYPE,ID)=ACT
+3 NEW DATE,SEQ,BEG,END,IDX,X0,DFN,TYPE,ID,ACT
+4 KILL ^TMP("HMPX",$JOB)
+5 SET DATE=+LAST
SET SEQ=+$PIECE(LAST,":",2)
+6 ; generate list ID, and end point
+7 ;init loop where left off
SET BEG=$NAME(^XTMP("HMPEF-"_DATE,SEQ))
+8 ; END=$Q(^XTMP("HMPEF-"_(DT+1),9999999),-1) ;last node
+9 ;last node
SET END=+$ORDER(^XTMP("HMPEF-"_DT,"A"),-1)
+10 ;date:seq
SET ^TMP("HMPX",$JOB,0)=DT_":"_END
+11 ;
+12 SET IDX=BEG
FOR
SET IDX=$QUERY(@IDX)
if $$DONE
QUIT
Begin DoDot:1
+13 SET X0=@IDX
SET TYPE=$PIECE(X0,U)
SET ID=$PIECE(X0,U,2)
SET ACT=$PIECE(X0,U,3)
+14 ;error
IF TYPE=""!(ID="")
QUIT
+15 SET ^TMP("HMPX",$JOB,TYPE,ID)=ACT
End DoDot:1
+16 QUIT
+17 ;
DONE() ; -- Return 1 or 0, if loop has finished
+1 ;end of ^XTMP
IF IDX'?1"^XTMP(""HMPEF-"7N.E
QUIT 1
+2 NEW D,N
SET D=+$PIECE(IDX,"-",2)
SET N=+$PIECE(IDX,",",2)
+3 ; check HMP-DATE subscript
+4 ;prior day: keep going
IF D<DT
QUIT 0
+5 ;next day: stop loop
IF D>DT
QUIT 1
+6 ; D=DT: check sequence# subscript
+7 IF N>END
QUIT 1
+8 QUIT 0