PXRMEUT ;SLC/PJH - General extract utilities ;07/29/2010
;;2.0;CLINICAL REMINDERS;**4,6,17,18**;Feb 04, 2005;Build 152
;
;=================================================
ASKNUM(TEXT,MIN,MAX) ;
N DIR,X,Y
K DIROUT,DIRUT,DTOUT,DUOUT
S DIR(0)="N"_U_MIN_":"_MAX
S DIR("A")=TEXT
S DIR("B")=MIN
S DIR("?")="Enter a number between "_MIN_" and "_MAX_"."
W !
D ^DIR
I $D(DTOUT)!$D(DUOUT) S Y=MIN
Q Y
;
;=================================================
ASKYN(DEF,TEXT,RTN,HLP) ;
N DIR,X,Y
K DIROUT,DIRUT,DTOUT,DUOUT
S DIR(0)="Y0"
S DIR("A")=TEXT
S DIR("B")=DEF
S DIR("?")="Enter Y or N."
I $G(RTN)'="",$G(HLP)'="" D
. S DIR("?")="Enter Y or N. For detailed help type ??"
. S DIR("??")=U_"D HELP^"_RTN_"(HLP)"
W !
D ^DIR
I $D(DTOUT)!$D(DUOUT) S Y=DEF
Q Y
;
;=================================================
BHELP ;Write the beginning date help.
N BDHTEXT,%DT
S BDHTEXT(1)="This is the beginning date for the "_LIT_"."
D HELP^PXRMEUT(.BDHTEXT)
S %DT="P",%DT(0)=-DT
D HELP^%DTC
Q
;
;=================================================
CALC(NEXT,START,END) ;Calculate period start and end dates
;Next is current run period
N CMON,CYR,ETYPE,NMON,NYR,PERIOD,YEAR
;extract year and period (M1,M2,Q1,Q2,Y etc)
I NEXT["/" S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/"),ETYPE=$E(PERIOD)
I NEXT?4N S YEAR=NEXT,PERIOD="",ETYPE="Y"
;Two digit year
S CYR=$E(YEAR,3,4),NYR=CYR
;If yearly use Jan 1st of current year and next
I ETYPE="Y" D
.S CMON="1",NMON="1",NYR=NYR+1
;If quarterly use start of first month of next quarter
I ETYPE="Q" D
.S CMON=$E(PERIOD,2,99),NMON=CMON*3+1 I NMON>12 S NYR=NYR+1,NMON=1
.S CMON=CMON*3-2
;If monthly use start of next month
I ETYPE="M" D
.S CMON=$E(PERIOD,2,99),NMON=CMON+1 I NMON>12 S NYR=NYR+1,NMON=1
;Zero fill the month fields
S CMON=$$RJ^XLFSTR(CMON,2,0),NMON=$$RJ^XLFSTR(NMON,2,0)
;Zero fill the year fields
S CYR=$$RJ^XLFSTR(CYR,2,0),NYR=$$RJ^XLFSTR(NYR,2,0)
;Report start date is start of current period
S START=3_CYR_CMON_"01"
;Report end date is start of next period less one day
S END=$$FMADD^XLFDT(3_NYR_NMON_"01",-1)
Q
;
;=================================================
DATES(BDATE,EDATE,LIT) ;Get a past date range.
BEGIN ;Select the beginning date.
N DIR,%DT,X,Y
K DIROUT,DIRUT,DTOUT,DUOUT
S DIR(0)="DA^::ETX"
S DIR("A")="Enter "_LIT_" BEGINNING DATE: "
S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
S DIR("?")="For detailed help type ??"
S DIR("??")=U_"D BHELP^PXRMEUT"
W !
D ^DIR K DIR
I $D(DIROUT) S DTOUT=1
I $D(DTOUT)!($D(DUOUT)) Q
S BDATE=Y
I $E(Y,6,7)="00" W $C(7)," ?? Enter exact date" G BEGIN
S BDATE=Y
;
END ;Select the ending date.
S DIR(0)="DA^"_BDATE_"::ETX"
S DIR("A")="Enter "_LIT_" ENDING DATE: "
S DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
S DIR("?")="This date cannot be before "_$$FMTE^XLFDT(BDATE,"D")_". For detailed help type ??"
S DIR("??")=U_"D EHELP^PXRMEUT"
D ^DIR
I $D(DIROUT) S DTOUT=1
I $D(DTOUT) Q
I $D(DUOUT) G BEGIN
S EDATE=Y
I $E(Y,6,7)="00" W $C(7)," ?? Enter exact date" G END
K DIROUT,DIRUT,DTOUT,DUOUT
Q
;
;=================================================
DOCUMENT(PXRMLIST,PXRMRULE,INDP,INTP,BEG,END) ;Document how the
;list was built.
N CDATE,CLASS,CREATOR,IND,LDATA,LNAME
N NDL,NL,NPAT,OUTPUT,SNAME,SOURCE,TEXT,TYPE,VALMCNT
K ^TMP("PXRMLRED",$J)
S LDATA=$G(^PXRMXP(810.5,PXRMLIST,0))
S LNAME=$P(LDATA,U,1)
S CDATE=$P(LDATA,U,4)
S SOURCE=$P(LDATA,U,5),SNAME="NONE"
;Check if generated from #810.2
I SOURCE S SNAME="Extract Parameter - "_$P($G(^PXRM(810.2,SOURCE,0)),U)
;If not check if generated from #810.4
I 'SOURCE S SOURCE=$P(LDATA,U,6) S:SOURCE SNAME="List Rule - "_$P($G(^PXRM(810.4,SOURCE,0)),U)
;Creator
S CREATOR=+$P(LDATA,U,7)
S CREATOR=$S(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
;Type
S TYPE=$P(LDATA,U,8)
S TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
;Class
S CLASS=$P($G(^PXRMXP(810.5,PXRMLIST,100)),U,1)
S CLASS=$S(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
S NPAT=$P(^PXRMXP(810.5,PXRMLIST,30,0),U,4)
S TEXT(1)="List Name: "_LNAME_" ("_NPAT_" patients)"
S TEXT(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
S TEXT(2)=$$LJ^XLFSTR(TEXT(2),40)_"Creator: "_CREATOR
S TEXT(3)=" Class: "_CLASS
S TEXT(3)=$$LJ^XLFSTR(TEXT(3),40)_"Type: "_TYPE
S TEXT(4)=" Source: "_SNAME
S TEXT(5)=" Patient List Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
S TEXT(6)=" Patient List Ending Date: "_$$FMTE^XLFDT(END,"5Z")
S TEXT(7)=" "
S NL=7
F IND=1:1:NL S ^PXRMXP(810.5,PXRMLIST,200,IND,0)=TEXT(IND)
D BLDLIST^PXRMLRED(PXRMRULE,3)
F IND=1:1:VALMCNT S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=^TMP("PXRMLRED",$J,IND,0)
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" --- List Build Information ---"
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Ending Date: "_$$FMTE^XLFDT(END,"5Z")
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=" "
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include deceased patients: "_$S(INDP:"Yes",1:"No")
S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include test patients: "_$S(INTP:"Yes",1:"No")
;Get the beginning and ending date information
D DOCDATES^PXRMEUT1(PXRMRULE,BEG,END,.NDL,.OUTPUT)
F IND=1:1:NDL S NL=NL+1,^PXRMXP(810.5,PXRMLIST,200,NL,0)=OUTPUT(IND)
S ^PXRMXP(810.5,PXRMLIST,200,0)=U_U_NL_U_NL_U_DT_U
K ^TMP("PXRMLRED",$J)
Q
;
;=================================================
EHELP ;Write the ending date help.
N EDHTEXT,%DT
S EDHTEXT(1)="This is the ending date for the "_LIT_"."
D HELP^PXRMEUT(.EDHTEXT)
S %DT="P",%DT(0)=-DT
D HELP^%DTC
Q
;
;=================================================
HELP(HTEXT) ;General help text output routine.
N IND,NIN,NOUT,TEXTIN,TEXOUT
;Make sure the text is in a form the formatting routine can handle.
S IND="",NIN=0
F S IND=$O(HTEXT(IND)) Q:IND="" S NIN=NIN+1,TEXTIN(NIN)=HTEXT(IND)
D FORMAT^PXRMTEXT(1,72,NIN,.TEXTIN,.NOUT,.TEXTOUT)
F IND=1:1:NOUT W !,TEXTOUT(IND)
W !
Q
;
;=================================================
LDELOK(LISTIEN) ;Return a 1 if it is ok for this user to delete the list.
N CREATOR,DELOK
S CREATOR=$P(^PXRMXP(810.5,LISTIEN,0),U,7)
S DELOK=$S(CREATOR=DUZ:1,$D(^XUSEC("PXRM MANAGER",DUZ)):1,1:0)
Q DELOK
;
;=================================================
MES(TEXT) ;General mail message
N XMSUB
K ^TMP("PXRMXMZ",$J)
S XMSUB="CLINICAL REMINDER EXTRACT"
S ^TMP("PXRMXMZ",$J,1,0)=TEXT
D SEND^PXRMMSG("PXRMXMZ",XMSUB,"",DUZ)
Q
;
;=================================================
PERIOD(FREQ) ;Calculate next period
N CMON,CUR,CYR,ETYPE,NEXT,PERIOD,YEAR
;Format current date YY/MM/DD
S CUR=$$FMTE^XLFDT($$NOW^XLFDT,7)
;extract year and period
S YEAR=$P(CUR,"/"),PERIOD=$P(CUR,"/",2)
;If yearly current year
I FREQ="Y" D
.S NEXT=YEAR
;If quarterly use current quarter
I FREQ="Q" D
.S NEXT="Q"_((PERIOD-1\3)+1)_"/"_YEAR
;If monthly use current month
I FREQ="M" D
.S NEXT="M"_PERIOD_"/"_YEAR
Q NEXT
;
;=================================================
RMPAT(NODE,INDP,INTP) ;Remove dead and test patients from
;the list.
I INDP,INTP Q
N DFN,DOD,REMOVE
S DFN=0
F S DFN=$O(^TMP($J,NODE,DFN)) Q:DFN="" D
.;DBIA 3744
. S REMOVE=$S('INTP:$$TESTPAT^VADPT(DFN),1:0)
. I REMOVE K ^TMP($J,NODE,DFN) Q
. I INDP Q
.;DBIA #10035
. S DOD=+$P($G(^DPT(DFN,.35)),U,1)
. I DOD=0 Q
. K ^TMP($J,NODE,DFN)
Q
;
PXRMEUT ;SLC/PJH - General extract utilities ;07/29/2010
+1 ;;2.0;CLINICAL REMINDERS;**4,6,17,18**;Feb 04, 2005;Build 152
+2 ;
+3 ;=================================================
ASKNUM(TEXT,MIN,MAX) ;
+1 NEW DIR,X,Y
+2 KILL DIROUT,DIRUT,DTOUT,DUOUT
+3 SET DIR(0)="N"_U_MIN_":"_MAX
+4 SET DIR("A")=TEXT
+5 SET DIR("B")=MIN
+6 SET DIR("?")="Enter a number between "_MIN_" and "_MAX_"."
+7 WRITE !
+8 DO ^DIR
+9 IF $DATA(DTOUT)!$DATA(DUOUT)
SET Y=MIN
+10 QUIT Y
+11 ;
+12 ;=================================================
ASKYN(DEF,TEXT,RTN,HLP) ;
+1 NEW DIR,X,Y
+2 KILL DIROUT,DIRUT,DTOUT,DUOUT
+3 SET DIR(0)="Y0"
+4 SET DIR("A")=TEXT
+5 SET DIR("B")=DEF
+6 SET DIR("?")="Enter Y or N."
+7 IF $GET(RTN)'=""
IF $GET(HLP)'=""
Begin DoDot:1
+8 SET DIR("?")="Enter Y or N. For detailed help type ??"
+9 SET DIR("??")=U_"D HELP^"_RTN_"(HLP)"
End DoDot:1
+10 WRITE !
+11 DO ^DIR
+12 IF $DATA(DTOUT)!$DATA(DUOUT)
SET Y=DEF
+13 QUIT Y
+14 ;
+15 ;=================================================
BHELP ;Write the beginning date help.
+1 NEW BDHTEXT,%DT
+2 SET BDHTEXT(1)="This is the beginning date for the "_LIT_"."
+3 DO HELP^PXRMEUT(.BDHTEXT)
+4 SET %DT="P"
SET %DT(0)=-DT
+5 DO HELP^%DTC
+6 QUIT
+7 ;
+8 ;=================================================
CALC(NEXT,START,END) ;Calculate period start and end dates
+1 ;Next is current run period
+2 NEW CMON,CYR,ETYPE,NMON,NYR,PERIOD,YEAR
+3 ;extract year and period (M1,M2,Q1,Q2,Y etc)
+4 IF NEXT["/"
SET YEAR=$PIECE(NEXT,"/",2)
SET PERIOD=$PIECE(NEXT,"/")
SET ETYPE=$EXTRACT(PERIOD)
+5 IF NEXT?4N
SET YEAR=NEXT
SET PERIOD=""
SET ETYPE="Y"
+6 ;Two digit year
+7 SET CYR=$EXTRACT(YEAR,3,4)
SET NYR=CYR
+8 ;If yearly use Jan 1st of current year and next
+9 IF ETYPE="Y"
Begin DoDot:1
+10 SET CMON="1"
SET NMON="1"
SET NYR=NYR+1
End DoDot:1
+11 ;If quarterly use start of first month of next quarter
+12 IF ETYPE="Q"
Begin DoDot:1
+13 SET CMON=$EXTRACT(PERIOD,2,99)
SET NMON=CMON*3+1
IF NMON>12
SET NYR=NYR+1
SET NMON=1
+14 SET CMON=CMON*3-2
End DoDot:1
+15 ;If monthly use start of next month
+16 IF ETYPE="M"
Begin DoDot:1
+17 SET CMON=$EXTRACT(PERIOD,2,99)
SET NMON=CMON+1
IF NMON>12
SET NYR=NYR+1
SET NMON=1
End DoDot:1
+18 ;Zero fill the month fields
+19 SET CMON=$$RJ^XLFSTR(CMON,2,0)
SET NMON=$$RJ^XLFSTR(NMON,2,0)
+20 ;Zero fill the year fields
+21 SET CYR=$$RJ^XLFSTR(CYR,2,0)
SET NYR=$$RJ^XLFSTR(NYR,2,0)
+22 ;Report start date is start of current period
+23 SET START=3_CYR_CMON_"01"
+24 ;Report end date is start of next period less one day
+25 SET END=$$FMADD^XLFDT(3_NYR_NMON_"01",-1)
+26 QUIT
+27 ;
+28 ;=================================================
DATES(BDATE,EDATE,LIT) ;Get a past date range.
BEGIN ;Select the beginning date.
+1 NEW DIR,%DT,X,Y
+2 KILL DIROUT,DIRUT,DTOUT,DUOUT
+3 SET DIR(0)="DA^::ETX"
+4 SET DIR("A")="Enter "_LIT_" BEGINNING DATE: "
+5 SET DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
+6 SET DIR("?")="For detailed help type ??"
+7 SET DIR("??")=U_"D BHELP^PXRMEUT"
+8 WRITE !
+9 DO ^DIR
KILL DIR
+10 IF $DATA(DIROUT)
SET DTOUT=1
+11 IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+12 SET BDATE=Y
+13 IF $EXTRACT(Y,6,7)="00"
WRITE $CHAR(7)," ?? Enter exact date"
GOTO BEGIN
+14 SET BDATE=Y
+15 ;
END ;Select the ending date.
+1 SET DIR(0)="DA^"_BDATE_"::ETX"
+2 SET DIR("A")="Enter "_LIT_" ENDING DATE: "
+3 SET DIR("PRE")="S X=$$DCHECK^PXRMDATE(X) K:X=-1 X"
+4 SET DIR("?")="This date cannot be before "_$$FMTE^XLFDT(BDATE,"D")_". For detailed help type ??"
+5 SET DIR("??")=U_"D EHELP^PXRMEUT"
+6 DO ^DIR
+7 IF $DATA(DIROUT)
SET DTOUT=1
+8 IF $DATA(DTOUT)
QUIT
+9 IF $DATA(DUOUT)
GOTO BEGIN
+10 SET EDATE=Y
+11 IF $EXTRACT(Y,6,7)="00"
WRITE $CHAR(7)," ?? Enter exact date"
GOTO END
+12 KILL DIROUT,DIRUT,DTOUT,DUOUT
+13 QUIT
+14 ;
+15 ;=================================================
DOCUMENT(PXRMLIST,PXRMRULE,INDP,INTP,BEG,END) ;Document how the
+1 ;list was built.
+2 NEW CDATE,CLASS,CREATOR,IND,LDATA,LNAME
+3 NEW NDL,NL,NPAT,OUTPUT,SNAME,SOURCE,TEXT,TYPE,VALMCNT
+4 KILL ^TMP("PXRMLRED",$JOB)
+5 SET LDATA=$GET(^PXRMXP(810.5,PXRMLIST,0))
+6 SET LNAME=$PIECE(LDATA,U,1)
+7 SET CDATE=$PIECE(LDATA,U,4)
+8 SET SOURCE=$PIECE(LDATA,U,5)
SET SNAME="NONE"
+9 ;Check if generated from #810.2
+10 IF SOURCE
SET SNAME="Extract Parameter - "_$PIECE($GET(^PXRM(810.2,SOURCE,0)),U)
+11 ;If not check if generated from #810.4
+12 IF 'SOURCE
SET SOURCE=$PIECE(LDATA,U,6)
IF SOURCE
SET SNAME="List Rule - "_$PIECE($GET(^PXRM(810.4,SOURCE,0)),U)
+13 ;Creator
+14 SET CREATOR=+$PIECE(LDATA,U,7)
+15 SET CREATOR=$SELECT(CREATOR>0:$$GET1^DIQ(200,CREATOR,.01),1:"None")
+16 ;Type
+17 SET TYPE=$PIECE(LDATA,U,8)
+18 SET TYPE=$$EXTERNAL^DILFD(810.5,.08,"",TYPE,.EM)
+19 ;Class
+20 SET CLASS=$PIECE($GET(^PXRMXP(810.5,PXRMLIST,100)),U,1)
+21 SET CLASS=$SELECT(CLASS="N":"National",CLASS="V":"VISN",1:"Local")
+22 SET NPAT=$PIECE(^PXRMXP(810.5,PXRMLIST,30,0),U,4)
+23 SET TEXT(1)="List Name: "_LNAME_" ("_NPAT_" patients)"
+24 SET TEXT(2)=" Created: "_$$FMTE^XLFDT(CDATE,"5Z")
+25 SET TEXT(2)=$$LJ^XLFSTR(TEXT(2),40)_"Creator: "_CREATOR
+26 SET TEXT(3)=" Class: "_CLASS
+27 SET TEXT(3)=$$LJ^XLFSTR(TEXT(3),40)_"Type: "_TYPE
+28 SET TEXT(4)=" Source: "_SNAME
+29 SET TEXT(5)=" Patient List Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
+30 SET TEXT(6)=" Patient List Ending Date: "_$$FMTE^XLFDT(END,"5Z")
+31 SET TEXT(7)=" "
+32 SET NL=7
+33 FOR IND=1:1:NL
SET ^PXRMXP(810.5,PXRMLIST,200,IND,0)=TEXT(IND)
+34 DO BLDLIST^PXRMLRED(PXRMRULE,3)
+35 FOR IND=1:1:VALMCNT
SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)=^TMP("PXRMLRED",$JOB,IND,0)
+36 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)=" --- List Build Information ---"
+37 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Beginning Date: "_$$FMTE^XLFDT(BEG,"5Z")
+38 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)="List Build Ending Date: "_$$FMTE^XLFDT(END,"5Z")
+39 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)=" "
+40 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include deceased patients: "_$SELECT(INDP:"Yes",1:"No")
+41 SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)="Include test patients: "_$SELECT(INTP:"Yes",1:"No")
+42 ;Get the beginning and ending date information
+43 DO DOCDATES^PXRMEUT1(PXRMRULE,BEG,END,.NDL,.OUTPUT)
+44 FOR IND=1:1:NDL
SET NL=NL+1
SET ^PXRMXP(810.5,PXRMLIST,200,NL,0)=OUTPUT(IND)
+45 SET ^PXRMXP(810.5,PXRMLIST,200,0)=U_U_NL_U_NL_U_DT_U
+46 KILL ^TMP("PXRMLRED",$JOB)
+47 QUIT
+48 ;
+49 ;=================================================
EHELP ;Write the ending date help.
+1 NEW EDHTEXT,%DT
+2 SET EDHTEXT(1)="This is the ending date for the "_LIT_"."
+3 DO HELP^PXRMEUT(.EDHTEXT)
+4 SET %DT="P"
SET %DT(0)=-DT
+5 DO HELP^%DTC
+6 QUIT
+7 ;
+8 ;=================================================
HELP(HTEXT) ;General help text output routine.
+1 NEW IND,NIN,NOUT,TEXTIN,TEXOUT
+2 ;Make sure the text is in a form the formatting routine can handle.
+3 SET IND=""
SET NIN=0
+4 FOR
SET IND=$ORDER(HTEXT(IND))
IF IND=""
QUIT
SET NIN=NIN+1
SET TEXTIN(NIN)=HTEXT(IND)
+5 DO FORMAT^PXRMTEXT(1,72,NIN,.TEXTIN,.NOUT,.TEXTOUT)
+6 FOR IND=1:1:NOUT
WRITE !,TEXTOUT(IND)
+7 WRITE !
+8 QUIT
+9 ;
+10 ;=================================================
LDELOK(LISTIEN) ;Return a 1 if it is ok for this user to delete the list.
+1 NEW CREATOR,DELOK
+2 SET CREATOR=$PIECE(^PXRMXP(810.5,LISTIEN,0),U,7)
+3 SET DELOK=$SELECT(CREATOR=DUZ:1,$DATA(^XUSEC("PXRM MANAGER",DUZ)):1,1:0)
+4 QUIT DELOK
+5 ;
+6 ;=================================================
MES(TEXT) ;General mail message
+1 NEW XMSUB
+2 KILL ^TMP("PXRMXMZ",$JOB)
+3 SET XMSUB="CLINICAL REMINDER EXTRACT"
+4 SET ^TMP("PXRMXMZ",$JOB,1,0)=TEXT
+5 DO SEND^PXRMMSG("PXRMXMZ",XMSUB,"",DUZ)
+6 QUIT
+7 ;
+8 ;=================================================
PERIOD(FREQ) ;Calculate next period
+1 NEW CMON,CUR,CYR,ETYPE,NEXT,PERIOD,YEAR
+2 ;Format current date YY/MM/DD
+3 SET CUR=$$FMTE^XLFDT($$NOW^XLFDT,7)
+4 ;extract year and period
+5 SET YEAR=$PIECE(CUR,"/")
SET PERIOD=$PIECE(CUR,"/",2)
+6 ;If yearly current year
+7 IF FREQ="Y"
Begin DoDot:1
+8 SET NEXT=YEAR
End DoDot:1
+9 ;If quarterly use current quarter
+10 IF FREQ="Q"
Begin DoDot:1
+11 SET NEXT="Q"_((PERIOD-1\3)+1)_"/"_YEAR
End DoDot:1
+12 ;If monthly use current month
+13 IF FREQ="M"
Begin DoDot:1
+14 SET NEXT="M"_PERIOD_"/"_YEAR
End DoDot:1
+15 QUIT NEXT
+16 ;
+17 ;=================================================
RMPAT(NODE,INDP,INTP) ;Remove dead and test patients from
+1 ;the list.
+2 IF INDP
IF INTP
QUIT
+3 NEW DFN,DOD,REMOVE
+4 SET DFN=0
+5 FOR
SET DFN=$ORDER(^TMP($JOB,NODE,DFN))
IF DFN=""
QUIT
Begin DoDot:1
+6 ;DBIA 3744
+7 SET REMOVE=$SELECT('INTP:$$TESTPAT^VADPT(DFN),1:0)
+8 IF REMOVE
KILL ^TMP($JOB,NODE,DFN)
QUIT
+9 IF INDP
QUIT
+10 ;DBIA #10035
+11 SET DOD=+$PIECE($GET(^DPT(DFN,.35)),U,1)
+12 IF DOD=0
QUIT
+13 KILL ^TMP($JOB,NODE,DFN)
End DoDot:1
+14 QUIT
+15 ;