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

RAORDCP.m

Go to the documentation of this file.
RAORDCP ;WOIFO/KLM - Log of Discontinued Requests ; May 26, 2021@10:50:10
 ;;5.0;Radiology/Nuclear Medicine;**179**;Mar 16, 1998;Build 4
 ;
 ; This report looks at all orders in file 75.1 with status=1 (Discontinued)
 ; and field 21 (Desired Date) within the date range selected.
 ;
 ; File                IA          Type
 ; -------------------------------------
 ; ^DPT(             10035         (S)
 ; ^SC(              10040         (S)
 ;
EN ;Option entry point - [RA ORDER DISCONTINUED]
 W !!?2,"This option will generate a list of DISCONTINUED requests",!?2,"for a selected date range"
 W ! S RAORDST=1 ;discontinued
 S RANOSCRN="" D OMA^RAUTL13 K RANOSCRN I '$L($O(RALOC(0)))!($G(RAQUIT)=1) D KILL Q
 S RADDT=1 D DATE^RAUTL K RADDT I RAPOP D KILL Q
 S RAOBEG=BEGDATE,RAOEND=ENDDATE+.9 K BEGDATE,ENDDATE
 S ZTSAVE("RAOBEG")="",ZTSAVE("RAOEND")=""
 S ZTRTN="START^RAORDCP",ZTSAVE("RALOC(")="",ZTSAVE("RASORTBY")="",ZTSAVE("RAORDST")=""
 W !!,"This report requires a 132 column output device." D ZIS^RAUTL I RAPOP D KILL Q
 ;
START ;report processing
 N RAODD S RAODD=RAOBEG-.000001
 U IO S QQ="",$P(QQ,"=",132)="=",RALOCNM="",RAOLOC="",RAHDR="LOG OF DISCONTINUED REQUESTS",RAHDRDSH="",$P(RAHDRDSH,"-",$L(RAHDR))="-"
 S RAOBEG("X")=+$E(RAOBEG,4,5)_"/"_+$E(RAOBEG,6,7)_"/"_$E(RAOBEG,2,3)
 S RAOEND("X")=+$E(RAOEND,4,5)_"/"_+$E(RAOEND,6,7)_"/"_$E(RAOEND,2,3)
 S X="NOW",%DT="T" D ^%DT D D^RAUTL S RARUNDTE=Y K %DT
 I $D(ZTQUEUED) S ZTREQ="@"
 F  S RALOCNM=$O(RALOC(RALOCNM)) Q:RALOCNM=""  S RA791IEN="" F  S RA791IEN=$O(RALOC(RALOCNM,RA791IEN)) Q:RA791IEN=""  S RALOC1(RA791IEN)=0,RALOCIT(+$P(^RA(79.1,RA791IEN,0),"^",6))=""
 K RALOCNM,RA791IEN
 N RAOIEN
 F  S RAODD=$O(^RAO(75.1,"BDD",RAODD)) Q:RAODD=""!(RAODD>RAOEND)  D
 .S RAOIEN=0 F  S RAOIEN=$O(^RAO(75.1,"BDD",RAODD,RAOIEN)) Q:RAOIEN=""  D
 ..Q:$P(^RAO(75.1,RAOIEN,0),U,5)>RAORDST
 ..S RAO0=$G(^RAO(75.1,RAOIEN,0)),RADFN=$P(RAO0,U)
 ..S RAODT=$P(RAO0,U,21),RAOREA=$P(RAO0,U,10),RALADT=$P(RAO0,U,18),RAILOC=$P(RAO0,U,20),RAIMTYP=$P(RAO0,U,3)
 ..N RAT S RAT=$O(^RAO(75.1,RAOIEN,"T",""),-1),RADCBY=$S($D(^RAO(75.1,RAOIEN,"T",0)):$P(^RAO(75.1,RAOIEN,"T",RAT,0),U,3),1:"Unknown")
 ..I $D(RALOC1(+RAILOC)) D SETTMP Q
 ..I RAILOC="",$D(RALOCIT(+RAIMTYP)) D SETTMP
 ..Q
 .Q
 I $D(RAEOS) D KILL Q
 S RAILOC=""
 F  S RAILOC=$O(RALOC1(RAILOC)) Q:RAILOC=""!($D(RAEOS))  S RACNT=0 D CONT
KILL W !
 K ^TMP($J,"RAODC")
 K QQ,RACNT,RADFN,RADDT,RADT,RAEOS,RAHDR,RAHDRDSH,RAILOC,RAIMTYP,RALOC,RALOC1,RALOCIT
 K RALOCN,RAO,RAOBEG,RAODT,RAOEND,RAOIFN,RAOLOC,RAPOP,RAPR,RAQUIT,RARDT,RAREQSTA,BEGDATE,ENDDATE,RARUNDTE
 K X,Y,RALADT,RAOREA,RADD,ZTDESC,ZTRTN,ZTSAVE,RADCBY,RAO0,RAORDST,RADLOCS,RAODD,RAT,RALADTX
 D CLOSE^RAUTL
 Q
CONT ;
 I $E(IOST,1,2)="C-",RAOLOC]"",RAOLOC'=RAILOC D EOS Q:$D(RAEOS)
 D HDR Q:$D(RAEOS)
 I +RALOC1(RAILOC)=0 W !?2,"No DISCONTINUED requests for "_RAOBEG("X")_" to "_RAOEND("X")_".",! I $E(IOST,1,2)="C-"&($O(RALOC1(RAILOC))]"") D EOS Q:$D(RAEOS)  D  Q
 .S RAOLOC(0)=$O(RALOC1(RAILOC)) S:RAOLOC(0)]"" RAOLOC=RAOLOC(0) K RAOLOC(0)
 S RADT=0 F  S RADT=$O(^TMP($J,"RAODC",RAILOC,RADT)) Q:'RADT!($D(RAEOS))  S RADFN=0 F  S RADFN=$O(^TMP($J,"RAODC",RAILOC,RADT,RADFN)) Q:'RADFN!($D(RAEOS))  D MORE
 Q
MORE ; 
 S RAPR=0 F  S RAPR=$O(^TMP($J,"RAODC",RAILOC,RADT,RADFN,RAPR)) Q:'RAPR!($D(RAEOS))  D
 .S RADCBY="" F  S RADCBY=$O(^TMP($J,"RAODC",RAILOC,RADT,RADFN,RAPR,RADCBY)) Q:RADCBY=""!($D(RAEOS))  D
 ..S RALADT=0 F  S RALADT=$O(^TMP($J,"RAODC",RAILOC,RADT,RADFN,RAPR,RADCBY,RALADT)) Q:'RALADT!($D(RAEOS))  D
 ...S RAO=0 F  S RAO=$O(^TMP($J,"RAODC",RAILOC,RADT,RADFN,RAPR,RADCBY,RALADT,RAO)) Q:'RAO!($D(RAEOS))  D
 ....N RAREA S RAOREA=$G(^TMP($J,"RAODC",RAILOC,RADT,RADFN,RAPR,RADCBY,RALADT,RAO))
 ....S RACNT=RACNT+1
 ....K RALOCN,RARLOCN
 ....D WRT
 ....Q
 ...Q
 ..Q
 .Q
 Q
WRT ;
 S Y=RADT D DD^%DT S RADD=Y S Y=$P(RALADT,".") D DD^%DT S RALADTX=Y
 W !,$S($D(^DPT(RADFN,0)):$E($P(^(0),"^"),1,19),1:"Unknown"),?21,$E($P(^DPT(RADFN,0),"^",9),6,9),?27,$S($D(^RAMIS(71,RAPR,0)):$E($P(^(0),"^"),1,24),1:"Unknown"),?53,$P(RADD,"@")
 W ?67,RALADTX
 W ?83,$S(RADCBY="Unknown":RADCBY,1:$E($$GET1^DIQ(200,RADCBY,.01),1,19))
 ;If there's no cancel reason, get cancel description (should only occur with provider DC through CPRS)
 W ?104,$S(RAOREA="":$E($$GET1^DIQ(75.1,RAO,27),1,28),1:$E($$GET1^DIQ(75.2,RAOREA,.01),1,28))
 S RAOLOC=RAILOC
 I ($Y+6)>IOSL D EOS Q:$D(RAEOS)  D:RACNT<RALOC1(RAILOC) HDR Q:$D(RAEOS)  I RACNT=RALOC1(RAILOC) S RAOLOC(0)=$O(RALOC1(RAILOC)) S:RAOLOC(0)]"" RAOLOC=RAOLOC(0) K RAOLOC(0)
 Q
HDR ; header
 W:$Y>0 @IOF
 W !?(80-$L(RAHDR)/2),RAHDR
 W !?14,"Includes discontinued requests from ",RAOBEG("X")," to ",RAOEND("X") ;W !?(80-$L(RAHDR)/2),RAHDRDSH
 W !,"IMAGING LOCATION: ",$S('RAILOC:"Unknown",$D(^RA(79.1,RAILOC,0)):$S($D(^SC($P(^(0),"^"),0)):$P(^(0),"^"),1:"Unknown"),1:"Unknown"),?51,"Run Date: ",RARUNDTE,!
 W !,"PATIENT NAME",?21,"SSN",?27,"PROCEDURE",?53,"DATE DESIRED",?67,"CANCELLED DATE"
 W ?83,"CANCELLED BY"
 W ?104,"CANCEL REASON",!,QQ,!!
 I $D(ZTQUEUED) D STOPCHK^RAUTL9 S:$G(ZTSTOP)=1 RAEOS=""
 Q
SETTMP ;results in TMP
 ;^TMP($J,"RAODC",I-LOC,DATE_DESIRED,DFN,PROCEDURE,DC'D_BY,DC'D_DATE,ORDER_IEN)=DC_REASON
 I $D(ZTQUEUED) D STOPCHK^RAUTL9 S:$G(ZTSTOP)=1 RAEOS="" Q:$D(RAEOS)
 S ^TMP($J,"RAODC",$S(RAILOC:RAILOC,1:"UNKNOWN"),$P(RAO0,U,21),RADFN,$P(RAO0,U,2),RADCBY,RALADT,RAOIEN)=RAOREA D
 .I RAILOC="" S:'$D(RALOC1("UNKNOWN")) RALOC1("UNKNOWN")=0 S RALOC1("UNKNOWN")=RALOC1("UNKNOWN")+1 Q
 .S:RAILOC>0 RALOC1(RAILOC)=RALOC1(RAILOC)+1
 Q
EOS ; end of screen
 S X=$$EOS^RAUTL5
 S:X=1 RAEOS=""
 Q