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

ACMSRT.m

Go to the documentation of this file.
ACMSRT ; IHS/TUCSON/TMJ - SORT CONTROLLER FOR REPORTS ; [ 02/10/2009  9:50 AM ]
 ;;2.0;ACM CASE MANAGEMENT SYSTEM;**4,6,8**;JAN 10, 1996
EN ;PEP - ENTRY POINT FOR SORT VARIABLES
 K ACMQUIT
 D ^ACMSRT2
 Q:$D(ACMQUIT)
EN1 D HEAD,CHOICE
EXIT D EXIT^ACMSRT1
 Q
 S ACMX="REPORT SORTING UTILITY"
 W !!?80-$L(ACMX)\2,ACMX,!!?10,"The ",@ACMRVON,ACMRPT,@ACMRVOFF," report can be sorted by one or more",!?10,"of the following attributes.  '<==' indicates a mandatory selection.",!
 K ACMX,ACMFORC
 Q
CHOICE D M2
C1 I $D(ACMXZ) W !!?10,"Sorting by: ",ACMXZ
 S DIR(0)="NOA^1:"_$S(ACMYI>1:ACMYI,1:1),DIR("A")="          Your choice: ",DIR("?")="Type "_$S(ACMYI>1:"a number from 1",1:"number 1: ")_$S(ACMYI>1:"-"_ACMYI_":",1:"")
 W !
 D ^DIR K DIR
 I $E(X)=U!(X="") S ACMQUIT="" Q
 I ACMUB(Y)="" W !!,"Already selected as a sort criterion." G C1
 S ACMZZ=Y
 G:'ACMZZ CHOICE
OK S:'$D(ACMXZ) ACMXZ=""
 S ACMYZ=ACMU(ACMZZ),(X,ACMSNO)=+ACMYZ,ACMSNA=$P(ACMYZ,U,2),ACMCSTG=ACMCSTG_ACMZZ_U,ACMXZ=ACMXZ_$S(ACMXZ'="":", then ",1:"")_ACMSNA
 K ACMYZ
 S ACMUB(ACMZZ)=""
 W "   ",ACMSNA
OK1 I BY'="" S BY=BY_","
 S ACMNAV=^ACM(48.5,X,0)
 I $D(ACMDM),$P(^ACM(48.5,X,0),U,5)["41," F ACMJ=42,43,44,45,46,47,48,49,51,53,57 I ACMFILE=ACMJ,(($P(^ACM(48.5,X,0),U,2)="P"!($P(^(0),U,2)="D")!($P(^(0),U,2)="A")))!(ACMSNA["STATUS") S BY=BY_"REGISTER:," Q  ;IHS/CIM/THL PATCH 4
 I ACMSNA["APPOINT",ACMFILE=41 S BY=BY_"CMS APPOINTMENT:,"
 I ACMSNA["REGISTER-" S BY=BY_"REGISTER,"
 K ACMJ
 S BY=BY_^ACM(48.5,X,3)
 I BY["EDITED NOT PRINTED" S BY="[ACM EDITED NOT PRINTED]",DIC=ACMDIC K FR,TO D PRT1 S ACMQUIT="" Q
 D @("S"_$P(ACMNAV,U,2)_"^ACMSRT1")
 K ACMNAV
 I $D(ACMQUIT) Q
 I $D(ACMFORC) K ACMFORC D PRINT Q
 I BY["[" S BY="["_$P(BY,"[",2) S BY=$P(BY,"]")_"]" D PRINT Q
 I ACMYI<2 D PRINT Q
 W !!,"Within ",ACMSNA,", want to sort by another attribute"
 S %=2 D YN^DICN
 I %Y=U S ACMQUIT="" Q
 I "Nn"[$E(%Y) D CHECK G:$D(ACMFORC) OK D PRINT Q
 W !!!
 S ACMN=ACMN+1
 G EN1
M2 K ACMU
 S ACMYII=ACMYI\2+(ACMYI#2)
 S (ACMJ,ACMZ)=0
 F ACMJ=1:1:ACMYII D
 .I ACMUB(ACMJ)'="" D
 ..S (ACMU(ACMJ),ACMSRT)=ACMUB(ACMJ),X=$P(ACMSRT,U,2),Y=$P(ACMSRT,U),ACMYZ=$P(ACMSRT,U,3)
 ..W !?8,$J(ACMJ,3),") ",X I ACMYZ W " <==" S ACMMAND=ACMJ,ACMMANN=X,ACMMAN=Y_U_X
 .E  W !?8,$J(ACMJ,3),") "
 .I $D(ACMUB(ACMJ+ACMYII)) D
 ..S ACMJ1=ACMJ+ACMYII
 ..S (ACMU(ACMJ1),ACMSRT)=ACMUB(ACMJ1),X=$P(ACMSRT,U,2),Y=$P(ACMSRT,U),ACMYZ=$P(ACMSRT,U,3)
 ..W ?45,$J(ACMJ1,3),") ",X I ACMYZ W " <==" S ACMMAND=ACMJ1,ACMMANN=X,ACMMAN=Y_U_X
 .E  I $D(ACMJ1) W:$D(ACMUB(ACMJ1+1)) ?45,$J(ACMJ1,3),") "
 K ACMSRT,ACMZ,ACMYZ
 Q
PS I ACMRPT["RECALL LETTERS" S ACMX="P" Q
 D PS^ACMSRT1
 Q
PRINT I $D(ACMPP),$D(ACMDM),((ACMFILE'=41)&(ACMFILE'=48)) D PS Q:$D(ACMQUIT)
PRNT S DIC=ACMDIC
 I $D(ACMDM),DIC["41",BY'["STATUS" S BY="@STATUS,"_BY,TO="ACTIVE,"_TO,FR="ACTIVE,"_FR
 I $D(ACMDM),DIC["41" S BY="@NAME OF REGISTER,"_BY,TO=ACMRGNA_","_TO,FR=ACMRGNA_","_FR G PRT1
 I $D(ACMDM),DIC'["41" F ACMJ=42,43,44,45,46,47,48,49,51,53,57 I ACMFILE=ACMJ S:BY'["STATUS" BY="REGISTER:,@STATUS,"_BY,TO="ACTIVE,"_TO,FR="ACTIVE,"_FR Q  ;IHS/CIM/THL PATCH 4
 I $D(ACMDM),DIC'["41" F ACMJ=42,43,44,45,46,47,48,49,51,53,57 I ACMFILE=ACMJ S BY="@NAME OF REGISTER,"_BY,TO=ACMRGNA_","_TO,FR=ACMRGNA_","_FR Q
 K ACMJ
PRT1 I ACMDIC'["." S ACMSDIC=$P(ACMDIC,",")_")" D:$E(ACMENTRY,1,4)'="APPL" ^ACMSTMP
 D ZIS
 I $D(ACMQUIT) K ACMQUIT Q
 S DIOEND="W:IOST[""C-"" !!,""End of report.  Strike <CR> to continue."" R:IOST[""C-"" ACMX:300 W:$D(IOF) @IOF"
 W ! D WAIT^DICD W !
 S IOP=ION
DIP S DIC=ACMDIC,DC=0
 D EN1^DIP
 D ^%ZISC
 Q
ZIS I $E(ACMENTRY,1,3)="MPS" S DIR(0)="YO",DIR("A")="Include PCC HEALTH SUMMARY",DIR("B")="NO" W ! D ^DIR K DIR I Y=1 S ACMMHS="" D SELTYP^ACMPPDTX
 I $E(ACMENTRY,1,4)="APPL" S DIR(0)="YO",DIR("A")="Do you want to VIEW the Standard Letter before printing",DIR("B")="NO" W ! D ^DIR K DIR I Y=1 W ! S ACMBY=BY,ACMFR=FR,ACMTO=TO,ACMFLDS=FLDS D ^ACMLTR2 G:ACMLTREX=1 ACMLTREX D
 .S DIC=ACMDIC,BY=ACMBY,FLDS=ACMFLDS,L=0,FR=ACMFR,TO=ACMTO K ACMBY,ACMFLDS,ACMFR,ACMTO
 .Q
 K IOP
 S %ZIS="PMNQ"
 W !
 K IOP
 D ^%ZIS
 G:POP DONE
 S:ION["HOST" %ZIS("IOPAR")=IOPAR
 I IO=IO(0),$D(IO("Q")) W !,"Cannot Queue to Screen or Slave Printer!",! K IO("Q") G ZIS
 ;I IO'=IO(0),'$D(IO("Q")) W !,"I will QUEUE this report to run for you now." S IO("Q")=1
 I $D(IO("Q")) D TSK S ACMQUIT=""
 Q
TSK S ZTRTN="DIP^ACMSRT",DIC=ACMDIC,IOP=ION
 S ZTSAVE("*")=""
 S ZTDESC="CMS REPORT",ZTIO=IO
 D ^%ZTLOAD
 W !,"REQUEST QUEUED!"
 K IO("Q"),ZTSK
DONE I '$D(ZTQUEUED) D ^%ZISC
 S ACMQUIT=""
 Q
CHECK I ACMCSTG[(U_ACMMAND_U) Q
 S ACMZZ=ACMMAND,ACMFORC="",ACMN=ACMN+1
 W !!,*7,"You must also sort by"
 Q
ENTRY ;EP;VARIABLE TO CONTROL SORT
 S ACMENTRY=$T(@ACMENTRY^ACMCTRL1) G EN
 ;
ACMLTREX ;Exit if User doesn't want to print letter
 K ACMLTREX G DONE
 ;
BACKEXIT ;Tmp qued in bckgrnd
 K ACMBACK G DONE
 ;
AMPM(FMDT)         ;EP; return fileman date in AM/PM
 ;IHS/CMI/TMJ PATCH #6
 I $P(FMDT,".",2)="" Q $$FMTE^XLFDT(FMDT)
 I $L($P(FMDT,"."))'=7 Q ""
 S FMTE=$$FMTE^XLFDT(FMDT)
 S FMTED=$P(FMTE,"@")
 S FMTEMC=$P(FMTE,"@",2)
 S FMTEH=$E(FMTEMC,1,2)
 S FMTEM=$E(FMTEMC,4,5)
 I FMTEH=12 Q FMTED_"@"_FMTEH_":"_FMTEM_" PM"
 I FMTEH="00" Q FMTED_"@12:"_FMTEM_" AM"
 I FMTEH>12 Q FMTED_"@"_(FMTEH-12)_":"_FMTEM_" PM"
 Q FMTED_"@"_FMTEH_":"_FMTEM_" AM"
 Q