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

APCLT1.m

Go to the documentation of this file.
APCLT1 ; IHS/CMI/LAB - TOP T POVS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;IHS/CMI/LAB - patch 4 Y2K
 ;
 ;IHS/TUCSON/LAB - added subroutine APWI for patch 1 to allow
 ;selection by appointment or walkin 05/01/97
 ;
 W !!?20,"*****  WAITING TIMES BY CLINIC AND PROVIDER *****",!!
 W !,"This report will display minimum, maximum and mean waiting times by provider,",!,"and clinic.  In order to have any data for this report, you must be entering",!,"the time the primary provider saw the patient.",!!
 D EXIT
GETDATES ;
BD ;get beginning date
 W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Visit Date" D ^DIR S:$D(DUOUT) DIRUT=1 K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G EXIT
 S APCLBD=Y
ED ;get ending date
 W ! S DIR(0)="D^"_APCLBD_":DT:EP",DIR("A")="Enter ending Visit Date" S Y=APCLBD D DD^%DT D ^DIR S:$D(DUOUT) DIRUT=1 K DIR S:$D(DUOUT) DIRUT=1
 I Y="" G BD
 I $D(DIRUT) G BD
 S APCLED=Y
 S X1=APCLBD,X2=-1 D C^%DTC S APCLSD=X
 S Y=APCLBD D DD^%DT S APCLBDD=Y S Y=APCLED D DD^%DT S APCLEDD=Y
 ;
CLINIC ;
 K APCLCLNT
 W ! S DIR(0)="Y",DIR("A")="Tally Waiting Times for ALL clinics" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 G:$D(DIRUT) BD
 I Y=1 G APWI
CLINIC1 ;
 S X="CLINIC",DIC="^AMQQ(5,",DIC(0)="FM",DIC("S")="I $P(^(0),U,14)" D ^DIC K DIC,DA I Y=-1 W "OOPS - QMAN NOT CURRENT - QUITTING" G EXIT
 D PEP^AMQQGTX0(+Y,"APCLCLNT(")
 I '$D(APCLCLNT) G CLINIC
 I $D(APCLCLNT("*")) K APCLCLNT
APWI ;ask appt or walk ins ;IHS/TUCSON/LAB - added this subroutine patch 1 05/01/97
 S APCLAPWI=""
 S DIR(0)="S^W:WALK-INS Only;A:APPOINTMENTS Only",DIR("A")="Do you wish to include",DIR("B")="A" KILL DA D ^DIR KILL DIR
 G:$D(DIRUT) CLINIC
 S APCLAPWI=Y
 ;IHS/TUCSON/LAB -  05/01/97 of patch 1
ZIS ;
DEMO ;
 D DEMOCHK^APCLUTL(.APCLDEMO)
 I APCLDEMO=-1 G APWI
 S XBRC="PROC^APCLT1",XBRP="^APCLT1P",XBNS="APCL",XBRX="EXIT^APCLT1"
 D ^XBDBQUE
 D EXIT
 Q
EXIT ;
 K APCLBD,APCLBDD,APCLSD,APCLED,APCLEDD,APCLCLNT,APCLAPPT,APCLBD,APCLBDD,APCLVT,APCLBTH,APCLCI,APCLCN,APCDT,APCLED,APCLEDD,APCLAPWI
 K APCLJOB,APCLLENG,APCLLOCT,APCLODAT,APCLPG,APCLPP,APCLPPS,APCLQUIT,APCLSD,APCLSEC,APCLTOT,APCLTOTV,APCLVIEN,APCLVREC,APCLX
 Q
PROC ;EP - called from xbdbque
 S APCLTOTV=0
 S (APCLBTH,APCLBT)=$H,APCLJOB=$J
 K ^XTMP("APCLT1",APCLJOB,APCLBTH)
 D XTMP^APCLOSUT("APCLT1","PCC CLINIC WAIT TIMES REPORT")
 ;
V ; Run by visit date
 S APCLODAT=APCLSD_".9999" F  S APCLODAT=$O(^AUPNVSIT("B",APCLODAT)) Q:APCLODAT=""!((APCLODAT\1)>APCLED)  D V1
 S C=0 F  S C=$O(^XTMP("APCLT1",APCLJOB,APCLBTH,"MODE",C)) Q:C'=+C  D
 . S P=0 F  S P=$O(^XTMP("APCLT1",APCLJOB,APCLBTH,"MODE",C,P)) Q:P'=+P  D
  .. S S=0 F  S S=$O(^XTMP("APCLT1",APCLJOB,APCLBTH,"MODE",C,P,S)) Q:S'=+S  S X=^XTMP("APCLT1",APCLJOB,APCLBTH,"MODE",C,P,S),^XTMP("APCLT1",APCLJOB,APCLBTH,"SET",C,P,9999999-X)=S
 .. Q
 . Q
 ;
END ;
 S APCLET=$H
 Q
V1 ;
 S APCLVIEN="" F  S APCLVIEN=$O(^AUPNVSIT("B",APCLODAT,APCLVIEN)) Q:APCLVIEN'=+APCLVIEN  I $D(^AUPNVSIT(APCLVIEN,0)),$P(^(0),U,9),'$P(^(0),U,12) S APCLVREC=^(0) D PROC1
 Q
PROC1 ;
 Q:'$P(APCLVREC,U,8)  ;no clinic
 Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 Q:'$D(^AUPNVPRV("AD",APCLVIEN))  ;no provider
 S APCLPP=$$PRIMPROV^APCLV(APCLVIEN,"I")
 Q:'APCLPP  ;no primary provider returned
 S APCLCLN=$P(APCLVREC,U,8)
 I $D(APCLCLNT),'$D(APCLCLNT(APCLCLN)) Q
 ;IHS/TUCSON/LAB - added this next line for patch 1 05/01/97
 I $D(APCLAPWI),$P(APCLVREC,U,16)'=APCLAPWI Q
 S APCLAPPT=$P(APCLVREC,U,26)
 S APCLCI=$P(APCLVREC,U)
 S APCLPPS="",X=0 F  S X=$O(^AUPNVPRV("AD",APCLVIEN,X)) Q:X'=+X  I $P(^AUPNVPRV(X,0),U,4)="P",APCLPP=$P(^(0),U),$P($G(^AUPNVPRV(X,12)),U)]"" S APCLPPS=$P(^AUPNVPRV(X,12),U)
 S $P(^(APCLPP),U)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP)):$P(^(APCLPP),U)+1,1:1)
 S $P(^(APCLCLN),U)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN)):$P(^(APCLCLN),U)+1,1:1)
 ;Q:APCLAPPT=""  ;cmi/lab 09/18/97 - commented this out added line below
 I $G(APCLAPWI)="A" Q:$P(APCLAPPT,".",2)=""  ;IHS/CMI/LAG - if report is run for appointments, do no use any visit whose appt time is blank
 Q:APCLCI=""
 Q:APCLPPS=""
 Q:$P(APCLPPS,".",2)=""
 ;Q:APCLPPS<APCLAPPT  ;*****what if see provider before appt time
 ;Q:APCLPPS<APCLCI  ;******what if see provider before arrival time
 ;quit if don't have all the 3 pieces -- is this ok?
CALC ;calculate # mins waiting, use appt or arr, whichever is later
 S APCLX=$S(APCLAPPT>APCLCI:APCLAPPT,1:APCLCI)
 S APCLSEC=$S(APCLPPS<APCLX:0,1:$$FMDIFF^XLFDT(APCLPPS,APCLX,2))
 ;begin Y2K
 ;I APCLSEC>14400 S ^XTMP("APCLT1",APCLJOB,APCLBTH,"OUTLIERS",APCLVIEN)=$$FMTE^XLFDT($P(APCLVREC,U),"2E")_"^"_$P(^DPT($P(APCLVREC,U,5),0),U)_"^"_$$FMTE^XLFDT($P(APCLVREC,U,26),"2E")_"^"_$$FMTE^XLFDT(APCLPPS,"2E") Q  ;Y2000
 I APCLSEC>14400 S ^XTMP("APCLT1",APCLJOB,APCLBTH,"OUTLIERS",APCLVIEN)=$$FMTE^XLFDT($P(APCLVREC,U),"5D")_"^"_$P(^DPT($P(APCLVREC,U,5),0),U)_"^"_$$FMTE^XLFDT($P(APCLVREC,U,26),"5D")_"^"_$$FMTE^XLFDT(APCLPPS,"5D") Q  ;Y2000
 ;I APCLSEC<-14400 S ^XTMP("APCLT1",APCLJOB,APCLBTH,"OUTLIERS",APCLVIEN)=$$FMTE^XLFDT($P(APCLVREC,U),"2E")_"^"_$P(^DPT($P(APCLVREC,U,5),0),U)_"^"_$$FMTE^XLFDT($P(APCLVREC,U,26),"2E")_"^"_$$FMTE^XLFDT(APCLPPS,"2E") Q   ;Y2000
 I APCLSEC<-14400 S ^XTMP("APCLT1",APCLJOB,APCLBTH,"OUTLIERS",APCLVIEN)=$$FMTE^XLFDT($P(APCLVREC,U),"5E")_"^"_$P(^DPT($P(APCLVREC,U,5),0),U)_"^"_$$FMTE^XLFDT($P(APCLVREC,U,26),"5E")_"^"_$$FMTE^XLFDT(APCLPPS,"5E") Q  ;Y2000
 ;end Y2K
 S $P(^(APCLPP),U,2)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP)):$P(^(APCLPP),U,2)+1,1:1)
 S $P(^(APCLCLN),U,2)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN)):$P(^(APCLCLN),U,2)+1,1:1)
SET S $P(^(APCLPP),U,3)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP)):$P(^(APCLPP),U,3)+APCLSEC,1:APCLSEC)
 S $P(^(APCLCLN),U,3)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN)):$P(^(APCLCLN),U,3)+APCLSEC,1:APCLSEC)
 S:$P(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP),U,4)="" $P(^(APCLPP),U,4)=APCLSEC I $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP),U,4)>APCLSEC S $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP),U,4)=APCLSEC
 S:$P(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN),U,4)="" $P(^(APCLCLN),U,4)=APCLSEC I $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN),U,4)>APCLSEC S $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN),U,4)=APCLSEC
 I $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP),U,5)<APCLSEC S $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP),U,5)=APCLSEC
 I $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN),U,5)<APCLSEC S $P(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN),U,5)=APCLSEC
 S X=$$FMDIFF^XLFDT(APCLCI,APCLAPPT,2)
 I X<-300 S $P(^(APCLPP),U,6)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP)):$P(^(APCLPP),U,6)+1,1:1)
 I X<-300 S $P(^(APCLCLN),U,6)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN)):$P(^(APCLCLN),U,6)+1,1:1)
 I X>300 S $P(^(APCLPP),U,7)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"IND",APCLCLN,APCLPP)):$P(^(APCLPP),U,7)+1,1:1)
 I X>300 S $P(^(APCLCLN),U,7)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"TOTAL",APCLCLN)):$P(^(APCLCLN),U,7)+1,1:1)
 S $P(^(APCLSEC),U)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"MODEP",APCLCLN,APCLPP,APCLSEC)):$P(^(APCLSEC),U)+1,1:1)
 S $P(^(APCLSEC),U)=$S($D(^XTMP("APCLT1",APCLJOB,APCLBTH,"MODEC",APCLCLN,APCLSEC)):$P(^(APCLSEC),U)+1,1:1)
 Q
 ;
 ;
 ;
 ;