PXRMFMTO ;SLC/PKR - Produce the formatted output for reminder evaluation. ;08/21/2019
;;2.0;CLINICAL REMINDERS;**47,42**;Feb 04, 2005;Build 245
;
;===================
FMTOUT(TMPSUB,NL,OUTPUT) ;Produce the formatted output.
I '$D(^TMP(TMPSUB,$J)) Q
N FREQ,LNUM,RIEN,RNAME,TEMP
S RIEN=$O(^TMP(TMPSUB,$J,""))
S RNAME=$O(^TMP(TMPSUB,$J,RIEN,""))
S FREQ=$G(^TMP(TMPSUB,$J,RIEN,RNAME,"FREQ"))
S TEMP=$G(^TMP(TMPSUB,$J,RIEN,RNAME))
D STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
S LNUM=0
F S LNUM=$O(^TMP(TMPSUB,$J,RIEN,RNAME,"TXT",LNUM)) Q:LNUM="" D
. S NL=NL+1,OUTPUT(NL)=^TMP(TMPSUB,$J,RIEN,RNAME,"TXT",LNUM)
Q
;
;===================
MHVOUT(TMPSUB,STATUS,RNAME,RIEN,NL,OUTPUT) ;MHV summary or detailed output.
I '$D(^TMP(TMPSUB,$J)) Q
N FREQ,LNUM,TEMP
S FREQ=$G(^TMP(TMPSUB,$J,STATUS,RNAME,RIEN,"FREQ"))
S TEMP=^TMP(TMPSUB,$J,STATUS,RNAME,RIEN)
D STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
S LNUM=0
F S LNUM=$O(^TMP(TMPSUB,$J,STATUS,RNAME,RIEN,"TXT",LNUM)) Q:LNUM="" D
. S NL=NL+1,OUTPUT(NL)=^TMP(TMPSUB,$J,STATUS,RNAME,RIEN,"TXT",LNUM)
S NL=NL+1,OUTPUT(NL)="",NL=NL+1,OUTPUT(NL)=""
Q
;
;===================
MHVCOUT(TMPSUB,NL,OUTPUT) ;MHV combined output.
I '$D(^TMP(TMPSUB,$J)) Q
N FREQ,LNUM,RIEN,RNAME,TEMP
S RIEN=$O(^TMP(TMPSUB,$J,""))
S RNAME=^TMP(TMPSUB,$J,RIEN,"RNAME")
S FREQ=$G(^TMP(TMPSUB,$J,RIEN,"FREQ"))
S TEMP=^TMP(TMPSUB,$J,RIEN,"STATUS")
D STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
S NL=NL+1,OUTPUT(NL)="---------- Detailed Output ----------"
S LNUM=0
F S LNUM=$O(^TMP(TMPSUB,$J,RIEN,"DETAIL",LNUM)) Q:LNUM="" D
. S NL=NL+1,OUTPUT(NL)=^TMP(TMPSUB,$J,RIEN,"DETAIL",LNUM)
S NL=NL+1,OUTPUT(NL)="",NL=NL+1,OUTPUT(NL)=""
S NL=NL+1,OUTPUT(NL)="---------- Summary Output ----------"
D STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
Q
;
;===================
STATUS(FREQ,RNAME,TEMP,NL,OUTPUT) ;Build the status text.
N DFMT,DUE,DUECOL,DUETIME,LAST,LASTCOL,LASTTIME,LRNAME,NOUT
N STATCOL,STATUS,TEXT,TEXTOUT
S DFMT=$S(FREQ["H":"5Z",1:"5DZ")
S STATUS=$P(TEMP,U,1)
S DUE=$$DDATE^PXRMDATE($P(TEMP,U,2),DFMT)
S LAST=$$DDATE^PXRMDATE($P(TEMP,U,3),DFMT)
I DFMT="5Z" D
. S DUETIME=$P(DUE,"@",2)
. I DUETIME'="" S DUETIME="@"_DUETIME
. S DUE=$P(DUE,"@",1)
. S LASTTIME=$P(LAST,"@",2)
. I LASTTIME'="" S LASTTIME="@"_LASTTIME
. S LAST=$P(LAST,"@",1)
S STATCOL=41-($L(STATUS)/2)
S DUECOL=53-($L(DUE)/2)
S LASTCOL=67-($L(LAST)/2)
S TEXT=$$REPEAT^XLFSTR(" ",36)_"--STATUS-- --DUE DATE-- --LAST DONE--"
S NL=NL+1,OUTPUT(NL)=TEXT
S LRNAME=$L(RNAME)
I LRNAME<STATCOL S TEXT=RNAME,NOUT=1
E D
. D FORMATS^PXRMTEXT(1,(STATCOL-2),RNAME,.NOUT,.TEXTOUT)
. S TEXT=TEXTOUT(1)
. S LRNAME=$L(TEXT)
S TEXT=TEXT_$$REPEAT^XLFSTR(" ",(STATCOL-LRNAME))_STATUS
S TEXT=TEXT_$$REPEAT^XLFSTR(" ",(DUECOL-$L(TEXT)))_DUE
S TEXT=TEXT_$$REPEAT^XLFSTR(" ",(LASTCOL-$L(TEXT)))_LAST
S NL=NL+1,OUTPUT(NL)=TEXT
I NOUT=2 S TEXT=TEXTOUT(2)
I DFMT="5Z" D
. S TEXT=$$REPEAT^XLFSTR(" ",(DUECOL+1))_DUETIME
. S TEXT=TEXT_$$REPEAT^XLFSTR(" ",(LASTCOL-$L(TEXT)+1))_LASTTIME
I (NOUT=2)!(DFMT="5Z") S NL=NL+1,OUTPUT(NL)=TEXT
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMFMTO 3116 printed Oct 16, 2024@17:46:21 Page 2
PXRMFMTO ;SLC/PKR - Produce the formatted output for reminder evaluation. ;08/21/2019
+1 ;;2.0;CLINICAL REMINDERS;**47,42**;Feb 04, 2005;Build 245
+2 ;
+3 ;===================
FMTOUT(TMPSUB,NL,OUTPUT) ;Produce the formatted output.
+1 IF '$DATA(^TMP(TMPSUB,$JOB))
QUIT
+2 NEW FREQ,LNUM,RIEN,RNAME,TEMP
+3 SET RIEN=$ORDER(^TMP(TMPSUB,$JOB,""))
+4 SET RNAME=$ORDER(^TMP(TMPSUB,$JOB,RIEN,""))
+5 SET FREQ=$GET(^TMP(TMPSUB,$JOB,RIEN,RNAME,"FREQ"))
+6 SET TEMP=$GET(^TMP(TMPSUB,$JOB,RIEN,RNAME))
+7 DO STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
+8 SET LNUM=0
+9 FOR
SET LNUM=$ORDER(^TMP(TMPSUB,$JOB,RIEN,RNAME,"TXT",LNUM))
if LNUM=""
QUIT
Begin DoDot:1
+10 SET NL=NL+1
SET OUTPUT(NL)=^TMP(TMPSUB,$JOB,RIEN,RNAME,"TXT",LNUM)
End DoDot:1
+11 QUIT
+12 ;
+13 ;===================
MHVOUT(TMPSUB,STATUS,RNAME,RIEN,NL,OUTPUT) ;MHV summary or detailed output.
+1 IF '$DATA(^TMP(TMPSUB,$JOB))
QUIT
+2 NEW FREQ,LNUM,TEMP
+3 SET FREQ=$GET(^TMP(TMPSUB,$JOB,STATUS,RNAME,RIEN,"FREQ"))
+4 SET TEMP=^TMP(TMPSUB,$JOB,STATUS,RNAME,RIEN)
+5 DO STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
+6 SET LNUM=0
+7 FOR
SET LNUM=$ORDER(^TMP(TMPSUB,$JOB,STATUS,RNAME,RIEN,"TXT",LNUM))
if LNUM=""
QUIT
Begin DoDot:1
+8 SET NL=NL+1
SET OUTPUT(NL)=^TMP(TMPSUB,$JOB,STATUS,RNAME,RIEN,"TXT",LNUM)
End DoDot:1
+9 SET NL=NL+1
SET OUTPUT(NL)=""
SET NL=NL+1
SET OUTPUT(NL)=""
+10 QUIT
+11 ;
+12 ;===================
MHVCOUT(TMPSUB,NL,OUTPUT) ;MHV combined output.
+1 IF '$DATA(^TMP(TMPSUB,$JOB))
QUIT
+2 NEW FREQ,LNUM,RIEN,RNAME,TEMP
+3 SET RIEN=$ORDER(^TMP(TMPSUB,$JOB,""))
+4 SET RNAME=^TMP(TMPSUB,$JOB,RIEN,"RNAME")
+5 SET FREQ=$GET(^TMP(TMPSUB,$JOB,RIEN,"FREQ"))
+6 SET TEMP=^TMP(TMPSUB,$JOB,RIEN,"STATUS")
+7 DO STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
+8 SET NL=NL+1
SET OUTPUT(NL)="---------- Detailed Output ----------"
+9 SET LNUM=0
+10 FOR
SET LNUM=$ORDER(^TMP(TMPSUB,$JOB,RIEN,"DETAIL",LNUM))
if LNUM=""
QUIT
Begin DoDot:1
+11 SET NL=NL+1
SET OUTPUT(NL)=^TMP(TMPSUB,$JOB,RIEN,"DETAIL",LNUM)
End DoDot:1
+12 SET NL=NL+1
SET OUTPUT(NL)=""
SET NL=NL+1
SET OUTPUT(NL)=""
+13 SET NL=NL+1
SET OUTPUT(NL)="---------- Summary Output ----------"
+14 DO STATUS(FREQ,RNAME,TEMP,.NL,.OUTPUT)
+15 QUIT
+16 ;
+17 ;===================
STATUS(FREQ,RNAME,TEMP,NL,OUTPUT) ;Build the status text.
+1 NEW DFMT,DUE,DUECOL,DUETIME,LAST,LASTCOL,LASTTIME,LRNAME,NOUT
+2 NEW STATCOL,STATUS,TEXT,TEXTOUT
+3 SET DFMT=$SELECT(FREQ["H":"5Z",1:"5DZ")
+4 SET STATUS=$PIECE(TEMP,U,1)
+5 SET DUE=$$DDATE^PXRMDATE($PIECE(TEMP,U,2),DFMT)
+6 SET LAST=$$DDATE^PXRMDATE($PIECE(TEMP,U,3),DFMT)
+7 IF DFMT="5Z"
Begin DoDot:1
+8 SET DUETIME=$PIECE(DUE,"@",2)
+9 IF DUETIME'=""
SET DUETIME="@"_DUETIME
+10 SET DUE=$PIECE(DUE,"@",1)
+11 SET LASTTIME=$PIECE(LAST,"@",2)
+12 IF LASTTIME'=""
SET LASTTIME="@"_LASTTIME
+13 SET LAST=$PIECE(LAST,"@",1)
End DoDot:1
+14 SET STATCOL=41-($LENGTH(STATUS)/2)
+15 SET DUECOL=53-($LENGTH(DUE)/2)
+16 SET LASTCOL=67-($LENGTH(LAST)/2)
+17 SET TEXT=$$REPEAT^XLFSTR(" ",36)_"--STATUS-- --DUE DATE-- --LAST DONE--"
+18 SET NL=NL+1
SET OUTPUT(NL)=TEXT
+19 SET LRNAME=$LENGTH(RNAME)
+20 IF LRNAME<STATCOL
SET TEXT=RNAME
SET NOUT=1
+21 IF '$TEST
Begin DoDot:1
+22 DO FORMATS^PXRMTEXT(1,(STATCOL-2),RNAME,.NOUT,.TEXTOUT)
+23 SET TEXT=TEXTOUT(1)
+24 SET LRNAME=$LENGTH(TEXT)
End DoDot:1
+25 SET TEXT=TEXT_$$REPEAT^XLFSTR(" ",(STATCOL-LRNAME))_STATUS
+26 SET TEXT=TEXT_$$REPEAT^XLFSTR(" ",(DUECOL-$LENGTH(TEXT)))_DUE
+27 SET TEXT=TEXT_$$REPEAT^XLFSTR(" ",(LASTCOL-$LENGTH(TEXT)))_LAST
+28 SET NL=NL+1
SET OUTPUT(NL)=TEXT
+29 IF NOUT=2
SET TEXT=TEXTOUT(2)
+30 IF DFMT="5Z"
Begin DoDot:1
+31 SET TEXT=$$REPEAT^XLFSTR(" ",(DUECOL+1))_DUETIME
+32 SET TEXT=TEXT_$$REPEAT^XLFSTR(" ",(LASTCOL-$LENGTH(TEXT)+1))_LASTTIME
End DoDot:1
+33 IF (NOUT=2)!(DFMT="5Z")
SET NL=NL+1
SET OUTPUT(NL)=TEXT
+34 QUIT
+35 ;