SCRPW10 ;RENO/KEITH - Clinic Group Maintenance functionality ; 15 Jul 98 02:38PM
;;5.3;Scheduling;**139,144**;AUG 13, 1993
N DIR
ASK D TITL^SCRPW50("Clinic Group Maintenance for Reports")
S DIR(0)="SO^EG:EDIT CLINIC GROUPS;PG:PRINT CLINIC GROUPS;DG:DELETE CLINIC GROUP;EA:EDIT CLINIC GROUP ASSIGNMENTS;PA:PRINT CLINIC GROUP ASSIGNMENTS",DIR("A")="Select clinic group maintenance action"
D ^DIR G:$D(DTOUT)!$D(DUOUT) END G:X="" END D @Y G ASK
;
END D END^SCRPW50 Q
;
EG N DIC,DIE,DLAYGO S DLAYGO=409.67,DIC="^SD(409.67,",DIC(0)="AEMQL" F W ! D ^DIC Q:$D(DTOUT)!$D(DUOUT) Q:Y<1 D:'$D(^SD(409.67,"AB",1,+Y)) MCGR(+Y) S DIE=DIC,DA=+Y,DR=.01 D ^DIE Q:$D(DTOUT)!$D(DUOUT)
D EXIT Q
;
PG N ZTSAVE W ! D EN^XUTMDEVQ("PGP^SCRPW10","LIST OF CLINIC GROUPS",.ZTSAVE) Q
;
PGP N SDCG,SDCGN,SDOUT D HINI D:$E(IOST)="C" DISP0^SCRPW23 S SDTITL="LIST OF CLINIC GROUPS",SDOUT=0 D HDR Q:SDOUT S SDCG=""
I '$D(^SD(409.67,"AB",1)) W !!,"No 'report' type CLINIC GROUP records identified." D EXIT Q
F D:$Y>(IOSL-4) HDR Q:SDOUT S SDCG=$O(^SD(409.67,"B",SDCG)) Q:SDCG="" S SDCGN=$O(^SD(409.67,"B",SDCG,0)) I $D(^SD(409.67,"AB",1,SDCGN)) W !,SDCG
I $E(IOST)="C",'SDOUT N DIR S DIR(0)="E" D ^DIR
D EXIT Q
;
DG N DIR,DIC,DIK,DA
DG1 S DIC="^SD(409.67,",DIC(0)="AEMQ" W ! D ^DIC Q:$D(DTOUT)!$D(DUOUT) Q:Y<1 S DA=+Y
I $D(^SC("ASCRPW",+Y)) W !!,$C(7),"You cannot delete a clinic group that has clinics assigned to it!",! G DG1
S DIR(0)="Y",DIR("A")="Are you sure you want to delete this clinic group",DIR("B")="NO",DIR("?")="Specify if you wish to remove this clinic group."
D ^DIR Q:$D(DTOUT)!$D(DUOUT) Q:'Y S DIK=DIC D ^DIK W " ...deleted." G DG1
;
EA K DIR S DIR(0)="SO^E:EDIT SELECTED CLINICS;A:ASSIGN SELECTED CLINICS;L:LOOP THROUGH CLINICS",DIR("A")="Edit by" D ^DIR Q:$D(DTOUT)!$D(DUOUT) Q:X=""
D @Y D EXIT Q
;
E N DIC,DIE,DA,DR S DIC="^SC(",DIC(0)="AEMQ" W ! D ^DIC Q:$D(DTOUT)!$D(DUOUT) Q:Y<1 S DIE=DIC,DA=+Y,DR=31 D ^DIE G E
;
A K DIC,DIE,DA,DR,SDCL,SDCLNA S DIC="^SD(409.67,",DIC(0)="AEMQ",DIC("A")="Select CLINIC GROUP to assign clinics to: "
F Q:$D(DTOUT)!$D(DUOUT) W ! D ^DIC Q:$D(DTOUT)!$D(DUOUT) Q:Y<1 S SDCG="`"_+Y,SDCGNA=$P(Y,U,2) D S1
Q
;
S1 N DIC F D CLIN("Select CLINIC to assign: ") Q:'$G(SDCL) K DIE S DIE="^SC(",DA=SDCL,DR="31///^S X=SDCG" D ^DIE W !,"Assigned to ",SDCGNA
Q
;
CLIN(A) K DIC,SDCL S:$L(A) DIC("A")=A S DIC="^SC(",DIC(0)="AQEMZ"
CL1 W ! D ^DIC Q:$D(DTOUT)!$D(DUOUT) Q:Y<1 I $P(Y(0),U,3)'="C" W !!,$C(7),"Only clinics can be selected!" K Y G CL1
S SDCL=+Y,SDCLN=$P(Y,U,2) Q
;
L D CLIN("Select clinic to begin with: ") Q:'$G(SDCL) S SDCLN=$O(^SC("B",SDCLN),-1) D L1 Q
;
L1 N SDC,SDI,Y S SDC=0
F S SDCLN=$O(^SC("B",SDCLN)) Q:SDCLN=""!$D(DTOUT)!$D(DUOUT) S SDCL=$O(^SC("B",SDCLN,0)) D L2 Q:$D(Y)
W:'SDC !!,"No active clinics found in this range." W !!,"End of loop." H 1
K SDCL,SDCLN,DTOUT,DUOUT Q
;
L2 I SDCL,$P(^SC(SDCL,0),U,3)="C" S SDI=$P($G(^SC(SDCL,"I")),U) W:SDI "." I 'SDI S SDC=SDC+1 W !!,"Clinic: ",SDCLN D EDIT(SDCL)
Q
;
EDIT(DA) N DIE,DR S DIE="^SC(",DR=31 D ^DIE Q
;
PA N DIR,ZTSAVE,SDORD,SDINAC,SDUNAS
S DIR(0)="SO^CG:CLINIC GROUP;CN:CLINIC NAME",DIR("A")="Sort output by" D ^DIR Q:$D(DTOUT)!$D(DUOUT) Q:X="" S SDORD=Y,ZTSAVE("SDORD")=""
S DIR(0)="Y",DIR("A")="Include clinics that are inactive",DIR("B")="NO",DIR("?")="Indicate if clinics that are currently inactive should be included." W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) S SDINAC=Y,ZTSAVE("SDINAC")=""
S DIR("A")="Include clinics that are unassigned",DIR("?")="Indicate if clinics not assigned to a clinic group should be included." W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) S SDUNAS=Y,ZTSAVE("SDUNAS")=""
W ! D EN^XUTMDEVQ("PAP^SCRPW10","PRINT CLINIC GROUP ASSIGNMENTS",.ZTSAVE) Q
;
PAP K ^TMP("SCRPW",$J) D HINI S (SDSTOP,SDOUT)=0,SDCLN="",SDTITL="CLINIC GROUPS ASSIGNED TO CLINICS",SDTITLX="W !,""Clinic:"",?40,""Clinic Group:"",!,SDLINE",SDOUT=0
I SDUNAS,SDINAC S SDTITL(1)="Including inactive and unassigned clinics"
I 'SDUNAS,'SDINAC S SDTITL(1)="Excluding inactive and unassigned clinics"
I '$D(SDTITL(1)) S SDTITL(1)=$S(SDINAC:"In",1:"Ex")_"cluding inactive, "_$S(SDUNAS:"in",1:"ex")_"cluding unassigned clinics"
F S SDCLN=$O(^SC("B",SDCLN)) Q:SDCLN="" D Q:SDOUT
.S SDSTOP=SDSTOP+1 I SDSTOP#500=0 D STOP Q:SDOUT
.S SDCL=$O(^SC("B",SDCLN,0)) I $$OK() S SDCG=$P($G(^SC(SDCL,0)),U,31),^TMP("SCRPW",$J,$S(SDORD="CN"!'SDCG:"~",1:$P($G(^SD(409.67,SDCG,0)),U)_"~"),SDCLN,SDCL)=""
.Q
D:$E(IOST)="C" DISP0^SCRPW23 D HDR Q:SDOUT I '$D(^TMP("SCRPW",$J)) W !!,"No clinic group assignments found!" Q
S SDCG="" F S SDCG=$O(^TMP("SCRPW",$J,SDCG)) Q:SDCG=""!SDOUT D:SDORD="CG" CGH S SDCLN="" F S SDCLN=$O(^TMP("SCRPW",$J,SDCG,SDCLN)) Q:SDCLN=""!SDOUT D CLP
I $E(IOST)="C",'SDOUT N DIR S DIR(0)="E" D ^DIR
EXIT D KVA^VADPT K %,%H,%I,A,SDI,SDINAC,SDUNAS,SDPNOW,SDCG,SDCGNA,SDCLN,SDCLNA,SDLINE,SDORD,SDOUT,SDSTOP,SDPAGE,SDTITL,SDTITLX,DA,DIC,DIE,DIR,DR,DTOUT,DUOUT,X,Y,ZTSAVE D END^SCRPW50 Q
;
OK() ;Ok to include in report?
;Output: 1=include, 0=exclude
Q:$P($G(^SC(SDCL,0)),U,3)'="C" 0
N SDX S SDX=$P(^SC(SDCL,0),U,31)
Q:'SDUNAS&('SDX!'$D(^SD(409.67,+SDX))) 0 Q:SDINAC 1
S SDX=$G(^SC(SDCL,"I")) I SDX,SDX'>DT,('$P(SDX,U,2)!($P(SDX,U,2)>DT)) Q 0
Q 1
;
CGH D:$Y>(IOSL-4) HDR Q:SDOUT W !!,"Clinic group: ",$S(SDCG="~":"(not assigned)",1:$P(SDCG,"~")) Q
;
CLP D:$Y>(IOSL-3) HDR Q:SDOUT S SDCL=$O(^TMP("SCRPW",$J,SDCG,SDCLN,0)) W !,$P($G(^SC(SDCL,0)),U),?40,$S(SDORD="CG":$S(SDCG="~":"(not assigned)",1:$P(SDCG,"~")),1:$P($G(^SD(409.67,+$P($G(^SC(SDCL,0)),U,31),0)),U)) Q
;
HINI ;Initialize header variables
D NOW^%DTC S Y=% X ^DD("DD") S SDPNOW=$P(Y,":",1,2),SDPAGE=1,SDLINE="",$P(SDLINE,"-",(IOM+1))="" Q
;
HDR ;Print report headers
I $E(IOST)="C",SDPAGE>1 N DIR S DIR(0)="E" D ^DIR S SDOUT=Y'=1 Q:SDOUT
D STOP Q:SDOUT W:SDPAGE>1!($E(IOST)="C") $$XY^SCRPW50(IOF,1,0) W:$X $$XY^SCRPW50("",0,0)
W SDLINE,!?(IOM-10-$L(SDTITL)\2),"<*> ",SDTITL," <*>" S SDI=0 F S SDI=$O(SDTITL(SDI)) Q:'SDI W !?(IOM-$L(SDTITL(SDI))\2),SDTITL(SDI)
W !,SDLINE,!,"Date printed: ",SDPNOW,?(IOM-6-$L(SDPAGE)),"Page: ",SDPAGE,!,SDLINE X:$D(SDTITLX) SDTITLX S SDPAGE=SDPAGE+1 Q
;
STOP ;Check for stop task request
S:$G(ZTQUEUED) (SDOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0) Q
;
MCGR(SDN) ;Mark CLINIC GROUP record as type="report
;Required input: SDN=CLINIC GROUP record IFN
N DIC,DINUM,Y,X,SDA D FIELD^DID(409.67,1,,"SPECIFIER","SDA") S X=1,DIC="^SD(409.67,"_SDN_",1,",DIC(0)="L",DIC("P")=SDA("SPECIFIER"),DA(1)=SDN D FILE^DICN Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCRPW10 6563 printed Dec 13, 2024@02:43:16 Page 2
SCRPW10 ;RENO/KEITH - Clinic Group Maintenance functionality ; 15 Jul 98 02:38PM
+1 ;;5.3;Scheduling;**139,144**;AUG 13, 1993
+2 NEW DIR
ASK DO TITL^SCRPW50("Clinic Group Maintenance for Reports")
+1 SET DIR(0)="SO^EG:EDIT CLINIC GROUPS;PG:PRINT CLINIC GROUPS;DG:DELETE CLINIC GROUP;EA:EDIT CLINIC GROUP ASSIGNMENTS;PA:PRINT CLINIC GROUP ASSIGNMENTS"
SET DIR("A")="Select clinic group maintenance action"
+2 DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
GOTO END
if X=""
GOTO END
DO @Y
GOTO ASK
+3 ;
END DO END^SCRPW50
QUIT
+1 ;
EG NEW DIC,DIE,DLAYGO
SET DLAYGO=409.67
SET DIC="^SD(409.67,"
SET DIC(0)="AEMQL"
FOR
WRITE !
DO ^DIC
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if Y<1
QUIT
if '$DATA(^SD(409.67,"AB",1,+Y))
DO MCGR(+Y)
SET DIE=DIC
SET DA=+Y
SET DR=.01
DO ^DIE
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+1 DO EXIT
QUIT
+2 ;
PG NEW ZTSAVE
WRITE !
DO EN^XUTMDEVQ("PGP^SCRPW10","LIST OF CLINIC GROUPS",.ZTSAVE)
QUIT
+1 ;
PGP NEW SDCG,SDCGN,SDOUT
DO HINI
if $EXTRACT(IOST)="C"
DO DISP0^SCRPW23
SET SDTITL="LIST OF CLINIC GROUPS"
SET SDOUT=0
DO HDR
if SDOUT
QUIT
SET SDCG=""
+1 IF '$DATA(^SD(409.67,"AB",1))
WRITE !!,"No 'report' type CLINIC GROUP records identified."
DO EXIT
QUIT
+2 FOR
if $Y>(IOSL-4)
DO HDR
if SDOUT
QUIT
SET SDCG=$ORDER(^SD(409.67,"B",SDCG))
if SDCG=""
QUIT
SET SDCGN=$ORDER(^SD(409.67,"B",SDCG,0))
IF $DATA(^SD(409.67,"AB",1,SDCGN))
WRITE !,SDCG
+3 IF $EXTRACT(IOST)="C"
IF 'SDOUT
NEW DIR
SET DIR(0)="E"
DO ^DIR
+4 DO EXIT
QUIT
+5 ;
DG NEW DIR,DIC,DIK,DA
DG1 SET DIC="^SD(409.67,"
SET DIC(0)="AEMQ"
WRITE !
DO ^DIC
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if Y<1
QUIT
SET DA=+Y
+1 IF $DATA(^SC("ASCRPW",+Y))
WRITE !!,$CHAR(7),"You cannot delete a clinic group that has clinics assigned to it!",!
GOTO DG1
+2 SET DIR(0)="Y"
SET DIR("A")="Are you sure you want to delete this clinic group"
SET DIR("B")="NO"
SET DIR("?")="Specify if you wish to remove this clinic group."
+3 DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if 'Y
QUIT
SET DIK=DIC
DO ^DIK
WRITE " ...deleted."
GOTO DG1
+4 ;
EA KILL DIR
SET DIR(0)="SO^E:EDIT SELECTED CLINICS;A:ASSIGN SELECTED CLINICS;L:LOOP THROUGH CLINICS"
SET DIR("A")="Edit by"
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if X=""
QUIT
+1 DO @Y
DO EXIT
QUIT
+2 ;
E NEW DIC,DIE,DA,DR
SET DIC="^SC("
SET DIC(0)="AEMQ"
WRITE !
DO ^DIC
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if Y<1
QUIT
SET DIE=DIC
SET DA=+Y
SET DR=31
DO ^DIE
GOTO E
+1 ;
A KILL DIC,DIE,DA,DR,SDCL,SDCLNA
SET DIC="^SD(409.67,"
SET DIC(0)="AEMQ"
SET DIC("A")="Select CLINIC GROUP to assign clinics to: "
+1 FOR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
WRITE !
DO ^DIC
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if Y<1
QUIT
SET SDCG="`"_+Y
SET SDCGNA=$PIECE(Y,U,2)
DO S1
+2 QUIT
+3 ;
S1 NEW DIC
FOR
DO CLIN("Select CLINIC to assign: ")
if '$GET(SDCL)
QUIT
KILL DIE
SET DIE="^SC("
SET DA=SDCL
SET DR="31///^S X=SDCG"
DO ^DIE
WRITE !,"Assigned to ",SDCGNA
+1 QUIT
+2 ;
CLIN(A) KILL DIC,SDCL
if $LENGTH(A)
SET DIC("A")=A
SET DIC="^SC("
SET DIC(0)="AQEMZ"
CL1 WRITE !
DO ^DIC
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if Y<1
QUIT
IF $PIECE(Y(0),U,3)'="C"
WRITE !!,$CHAR(7),"Only clinics can be selected!"
KILL Y
GOTO CL1
+1 SET SDCL=+Y
SET SDCLN=$PIECE(Y,U,2)
QUIT
+2 ;
L DO CLIN("Select clinic to begin with: ")
if '$GET(SDCL)
QUIT
SET SDCLN=$ORDER(^SC("B",SDCLN),-1)
DO L1
QUIT
+1 ;
L1 NEW SDC,SDI,Y
SET SDC=0
+1 FOR
SET SDCLN=$ORDER(^SC("B",SDCLN))
if SDCLN=""!$DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET SDCL=$ORDER(^SC("B",SDCLN,0))
DO L2
if $DATA(Y)
QUIT
+2 if 'SDC
WRITE !!,"No active clinics found in this range."
WRITE !!,"End of loop."
HANG 1
+3 KILL SDCL,SDCLN,DTOUT,DUOUT
QUIT
+4 ;
L2 IF SDCL
IF $PIECE(^SC(SDCL,0),U,3)="C"
SET SDI=$PIECE($GET(^SC(SDCL,"I")),U)
if SDI
WRITE "."
IF 'SDI
SET SDC=SDC+1
WRITE !!,"Clinic: ",SDCLN
DO EDIT(SDCL)
+1 QUIT
+2 ;
EDIT(DA) NEW DIE,DR
SET DIE="^SC("
SET DR=31
DO ^DIE
QUIT
+1 ;
PA NEW DIR,ZTSAVE,SDORD,SDINAC,SDUNAS
+1 SET DIR(0)="SO^CG:CLINIC GROUP;CN:CLINIC NAME"
SET DIR("A")="Sort output by"
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
if X=""
QUIT
SET SDORD=Y
SET ZTSAVE("SDORD")=""
+2 SET DIR(0)="Y"
SET DIR("A")="Include clinics that are inactive"
SET DIR("B")="NO"
SET DIR("?")="Indicate if clinics that are currently inactive should be included."
WRITE !
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET SDINAC=Y
SET ZTSAVE("SDINAC")=""
+3 SET DIR("A")="Include clinics that are unassigned"
SET DIR("?")="Indicate if clinics not assigned to a clinic group should be included."
WRITE !
DO ^DIR
if $DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET SDUNAS=Y
SET ZTSAVE("SDUNAS")=""
+4 WRITE !
DO EN^XUTMDEVQ("PAP^SCRPW10","PRINT CLINIC GROUP ASSIGNMENTS",.ZTSAVE)
QUIT
+5 ;
PAP KILL ^TMP("SCRPW",$JOB)
DO HINI
SET (SDSTOP,SDOUT)=0
SET SDCLN=""
SET SDTITL="CLINIC GROUPS ASSIGNED TO CLINICS"
SET SDTITLX="W !,""Clinic:"",?40,""Clinic Group:"",!,SDLINE"
SET SDOUT=0
+1 IF SDUNAS
IF SDINAC
SET SDTITL(1)="Including inactive and unassigned clinics"
+2 IF 'SDUNAS
IF 'SDINAC
SET SDTITL(1)="Excluding inactive and unassigned clinics"
+3 IF '$DATA(SDTITL(1))
SET SDTITL(1)=$SELECT(SDINAC:"In",1:"Ex")_"cluding inactive, "_$SELECT(SDUNAS:"in",1:"ex")_"cluding unassigned clinics"
+4 FOR
SET SDCLN=$ORDER(^SC("B",SDCLN))
if SDCLN=""
QUIT
Begin DoDot:1
+5 SET SDSTOP=SDSTOP+1
IF SDSTOP#500=0
DO STOP
if SDOUT
QUIT
+6 SET SDCL=$ORDER(^SC("B",SDCLN,0))
IF $$OK()
SET SDCG=$PIECE($GET(^SC(SDCL,0)),U,31)
SET ^TMP("SCRPW",$JOB,$SELECT(SDORD="CN"!'SDCG:"~",1:$PIECE($GET(^SD(409.67,SDCG,0)),U)_"~"),SDCLN,SDCL)=""
+7 QUIT
End DoDot:1
if SDOUT
QUIT
+8 if $EXTRACT(IOST)="C"
DO DISP0^SCRPW23
DO HDR
if SDOUT
QUIT
IF '$DATA(^TMP("SCRPW",$JOB))
WRITE !!,"No clinic group assignments found!"
QUIT
+9 SET SDCG=""
FOR
SET SDCG=$ORDER(^TMP("SCRPW",$JOB,SDCG))
if SDCG=""!SDOUT
QUIT
if SDORD="CG"
DO CGH
SET SDCLN=""
FOR
SET SDCLN=$ORDER(^TMP("SCRPW",$JOB,SDCG,SDCLN))
if SDCLN=""!SDOUT
QUIT
DO CLP
+10 IF $EXTRACT(IOST)="C"
IF 'SDOUT
NEW DIR
SET DIR(0)="E"
DO ^DIR
EXIT DO KVA^VADPT
KILL %,%H,%I,A,SDI,SDINAC,SDUNAS,SDPNOW,SDCG,SDCGNA,SDCLN,SDCLNA,SDLINE,SDORD,SDOUT,SDSTOP,SDPAGE,SDTITL,SDTITLX,DA,DIC,DIE,DIR,DR,DTOUT,DUOUT,X,Y,ZTSAVE
DO END^SCRPW50
QUIT
+1 ;
OK() ;Ok to include in report?
+1 ;Output: 1=include, 0=exclude
+2 if $PIECE($GET(^SC(SDCL,0)),U,3)'="C"
QUIT 0
+3 NEW SDX
SET SDX=$PIECE(^SC(SDCL,0),U,31)
+4 if 'SDUNAS&('SDX!'$DATA(^SD(409.67,+SDX)))
QUIT 0
if SDINAC
QUIT 1
+5 SET SDX=$GET(^SC(SDCL,"I"))
IF SDX
IF SDX'>DT
IF ('$PIECE(SDX,U,2)!($PIECE(SDX,U,2)>DT))
QUIT 0
+6 QUIT 1
+7 ;
CGH if $Y>(IOSL-4)
DO HDR
if SDOUT
QUIT
WRITE !!,"Clinic group: ",$SELECT(SDCG="~":"(not assigned)",1:$PIECE(SDCG,"~"))
QUIT
+1 ;
CLP if $Y>(IOSL-3)
DO HDR
if SDOUT
QUIT
SET SDCL=$ORDER(^TMP("SCRPW",$JOB,SDCG,SDCLN,0))
WRITE !,$PIECE($GET(^SC(SDCL,0)),U),?40,$SELECT(SDORD="CG":$SELECT(SDCG="~":"(not assigned)",1:$PIECE(SDCG,"~")),1:$PIECE($GET(^SD(409.67,+$PIECE($GET(^SC(SDCL,0)),U,31),0)),U))
QUIT
+1 ;
HINI ;Initialize header variables
+1 DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
SET SDPNOW=$PIECE(Y,":",1,2)
SET SDPAGE=1
SET SDLINE=""
SET $PIECE(SDLINE,"-",(IOM+1))=""
QUIT
+2 ;
HDR ;Print report headers
+1 IF $EXTRACT(IOST)="C"
IF SDPAGE>1
NEW DIR
SET DIR(0)="E"
DO ^DIR
SET SDOUT=Y'=1
if SDOUT
QUIT
+2 DO STOP
if SDOUT
QUIT
if SDPAGE>1!($EXTRACT(IOST)="C")
WRITE $$XY^SCRPW50(IOF,1,0)
if $X
WRITE $$XY^SCRPW50("",0,0)
+3 WRITE SDLINE,!?(IOM-10-$LENGTH(SDTITL)\2),"<*> ",SDTITL," <*>"
SET SDI=0
FOR
SET SDI=$ORDER(SDTITL(SDI))
if 'SDI
QUIT
WRITE !?(IOM-$LENGTH(SDTITL(SDI))\2),SDTITL(SDI)
+4 WRITE !,SDLINE,!,"Date printed: ",SDPNOW,?(IOM-6-$LENGTH(SDPAGE)),"Page: ",SDPAGE,!,SDLINE
if $DATA(SDTITLX)
XECUTE SDTITLX
SET SDPAGE=SDPAGE+1
QUIT
+5 ;
STOP ;Check for stop task request
+1 if $GET(ZTQUEUED)
SET (SDOUT,ZTSTOP)=$SELECT($$S^%ZTLOAD:1,1:0)
QUIT
+2 ;
MCGR(SDN) ;Mark CLINIC GROUP record as type="report
+1 ;Required input: SDN=CLINIC GROUP record IFN
+2 NEW DIC,DINUM,Y,X,SDA
DO FIELD^DID(409.67,1,,"SPECIFIER","SDA")
SET X=1
SET DIC="^SD(409.67,"_SDN_",1,"
SET DIC(0)="L"
SET DIC("P")=SDA("SPECIFIER")
SET DA(1)=SDN
DO FILE^DICN
QUIT