Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APCLSRT

APCLSRT.m

Go to the documentation of this file.
APCLSRT ; IHS/CMI/LAB - IHS GETS SORT INFO FOR PCC REPORTS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;SORT CONTROLLER FOR REPORTS
EN D CHKVARS^APCLSRT2
 G:$D(APCLQUIT) EXIT
 D MENU
EN1 D HEAD,CHOICE,EXIT
 Q
CHKNAV ;check for navigation string for file and sort field
 I '$D(^APCLSRT(X,4,APCLFILE)) W !,$C(7),$C(7),"Navigation not defined for the File!  Notify programmer!",!! S APCLQUIT="" Q
 S APCLNAV=$P(^APCLSRT(X,4,APCLFILE,0),U,2)
 Q
 ;
 W:$D(IOF) @IOF
 S APCLX="REPORT SORTING UTILITY" W !!?80-$L(APCLX)\2,APCLX K APCLX,APCLFORC
 W !
 W !,"The ",@APCLRVON,APCLRPT,@APCLRVOF
 W " report can be sorted by one or more"
 W !,"of the following attributes.  "
 W "'<<===' indicates a mandatory selection.",!
 Q
 F  S X=$O(^APCLSRT("B",X)) Q:X=""  F Y=0:0 S Y=$O(^APCLSRT("B",X,Y)) Q:'Y  I $D(^APCLSRT(Y,2,"B",APCLPTMP)) D M1
 W ! Q
CHOICE D M2
 I (J-1)=1 S APCLZZ=1 G OK
 W !!?6,"Your choice (1",$S((J-1)>1:"-"_(J-1),1:""),"): "
 R APCLZZ:DTIME I '$T S APCLZZ=U
 I APCLZZ=""!(APCLZZ[U) S APCLQUIT="" Q
 I APCLZZ'?1N.2N!(APCLZZ>(J-1)) W !!?6,$C(7),"Type ",$S((J-1)>1:"a number from 1",1:"number 1: "),$S((J-1)>1:"-"_(J-1)_":",1:"") W ! G CHOICE
 I APCLZZ,APCLZZ'>J G OK
 G CHOICE
OK S Z=%APCL(APCLZZ),(X,APCLSNO)=+Z,APCLSNA=$P(Z,U,2),APCLCSTG=APCLCSTG_APCLZZ_U
 K Z,%APCLB(X) W:(J-1)>1 "   ",APCLSNA
OK1 I BY]"" S BY=BY_","
 S APCLREC=^APCLSRT(X,0)
 S APCLDIC=^DIC(APCLFILE,0,"GL")
 D CHKNAV I $D(APCLQUIT) Q
 K J
 S BY=BY_APCLNAV
 D @("S"_$P(APCLREC,U,2)_"^APCLSRT1")
 K APCLNAV,APCLREC
 I $D(APCLQUIT) Q
 I $D(APCLFORC) K APCLFORC D PRINT Q
 I BY["[" S BY="["_$P(BY,"[",2) S BY=$P(BY,"]")_"]" G PRINT
 I I<2 D PRINT Q
 W !!,"Within ",APCLSNA,", want to sort by another attribute"
 S %=2 D YN^DICN
 I %Y=U S APCLQUIT="" Q
 I "Nn"[$E(%Y) D CHECK G:$D(APCLFORC) OK D PRINT Q
 W !!! S APCLN=APCLN+1,I=I-1 G EN1
EXIT K X,J,Y,Z,%Y,APCLZ,APCLZZ,APCLDIC,APCLN,APCLPTMP,BY,FR,TO,FLDS,I,APCLQUIT,APCLFILE,APCLRPT,%,%DT,APCLDM,APCLI,APCLSET,BY1,BY2,DHD,DIC,DIOEND,DIR,DUOUT,B,P,APCLBEGD
 K APCLSNO,APCLSNA,%APCL,%APCLB,APCLRVOF,APCLRVON,APCLTRM
 K APCLX,APCLY,APCLMAND,APCLCSTG,APCLMANN,APCLMAN,APCLSRT,APCLCST,APCLTRM,APCLREC,APCLNAV,APCLFORC,APCLPS
 D ^%ZISC
 I '$D(ZTQUEUED) S IOP="HOME" D ^%ZIS
 W:$D(IOF) @IOF
 Q
M1 N Z
 S Z=$O(^APCLSRT(Y,2,"B",APCLPTMP,"")),Z=^(Z)
 S I=I+1,%APCLB(Y)=Y_U_X_U_Z
 Q
M2 K %APCL S APCLZ=""
 F J=1:1 S APCLZ=$O(%APCLB(APCLZ)) Q:'APCLZ  S (%APCL(J),APCLSRT)=%APCLB(APCLZ),X=$P(APCLSRT,U,2),Y=$P(APCLSRT,U),Z=$P(APCLSRT,U,3) W:J#2 !?6 W:'(J#2) ?45 W $J(J,3),") ",X I Z W "  <<===" S APCLMAND=J,APCLMANN=X,APCLMAN=Y_U_X
 K APCLSRT,APCLZ
 Q
TITLE ;
 S DIR(0)="FO^2:60",DIR("A")="Please enter a TITLE for this report: ",DIR("B")="PATIENT LISTING",DIR("?")="Enter a narrative title that you want to see on this report" D ^DIR K DIR
 I $D(DUOUT) S APCLQUIT="" Q
 S DHD=X
 Q
PRINT ;
 D TITLE
 Q:$D(APCLQUIT)
PRNT S DIC=APCLDIC
PRT1 S DIOEND="D EOR^APCLSRT"
DIP D EN1^DIP
 Q
CHECK I APCLCSTG[(U_APCLMAND_U) Q
 S APCLZZ=APCLMAND,APCLFORC="",APCLN=APCLN+1
 W !!,$C(7),"You must also sort by"
 Q
EOR ;
 I $D(IOST),IOST["C-" W !!,"End of report.  Strike <CR> to continue" R APCLX:300
 W:$D(IOF) @IOF
 Q