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

APCLGV.m

Go to the documentation of this file.
APCLGV ; IHS/CMI/LAB - ACTIVE CLIENT LIST ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
 ;
START ;
 S APCLJOB=$J,APCLBTH=$H K DIR
 D XTMP^APCLOSUT("APCLGV","PCC REPORT ON PTS SEEN N TIMES")
 I '$D(IOF) D HOME^%ZIS
 W @(IOF),!!
 W ?10,"**********  PATIENTS SEEN AT LEAST N NUMBER OF TIMES  **********",!!
 W "This report will produce a report of patients who have been seen at least",!," N number of times in a date range specified by the user.",!
 W !,"The output form this report can be in the form of a list of patients",!,"or a search template.",!
GETDATES ;
BD ;get beginning date
 W !,"Please enter the date range during which the patient should be seen.",!
 W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Date" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G XIT
 S APCLBD=Y
ED ;get ending date
 W ! S DIR(0)="DA^"_APCLBD_":DT:EP",DIR("A")="Enter ending Date:  " S Y=APCLBD D DD^%DT S Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 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
 ;
 S APCLNCAN=1 D ADD^APCLVL01 I $D(APCLQUIT) D DEL^APCLVL K APCLQUIT G GETDATES
NUM ;
 ;S DIR(0)="N^2:100:0",DIR("A")="Enter the minimum number of times the patient should have been seen" D ^DIR K DIR S:$D(DUOUT) DIRUT=1 ;IHS/CMI/LAB 10/1/96
 S DIR(0)="N^1:100:0",DIR("A")="Enter the minimum number of times the patient should have been seen" D ^DIR K DIR S:$D(DUOUT) DIRUT=1 ;IHS/CMI/LAB 10/14/96
 G:$D(DIRUT) GETDATES
 G:Y="" GETDATES
 S APCLNUM=+Y
SCREEN ;
 S APCLTCW=0,APCLPTVS="V",APCLTYPE="D",APCLCTYP="T"
 K ^APCLVRPT(APCLRPT,11) S APCLCNTL="S" D ^APCLVL4 K APCLCNTL I $D(APCLQUIT) D DEL^APCLVL G GETDATES
OUTPUT ;IHS/TUCSON/LAB - added OUTPUT to SORT-1
 K APCLSTMP,APCLSNAM,APCLQUIT
 S APCLOUT=""
 S DIR(0)="S^L:List of Patients;S:Search Template of Patients",DIR("A")="Type of output",DIR("B")="L" KILL DA D ^DIR KILL DIR
 G:$D(DIRUT) SCREEN
 S APCLOUT=Y
 I APCLOUT'="S" G SORT
STEMP ;
 K APCLQUIT
 D ^APCLSTMP
 I $D(APCLQUIT) G OUTPUT
 I $G(APCLSTMP)=""!($G(APCLSNAM))="" K APCLQUIT W !,"No template selected!" G OUTPUT
 G ZIS
SORT ;
 S APCLTCW=0,APCLPTVS="P",APCLTYPE="D",APCLCTYP="T"
 S APCLCNTL="R" D ^APCLVL4 K APCLCNTL I $D(APCLQUIT) D DEL^APCLVL G GETDATES
PAGE ;
 S APCLNPAG=0,DIR(0)="Y",DIR("A")="Do you want each "_APCLSORV_" on a separate page",DIR("B")="N" K DA D ^DIR K DIR
 G:$D(DIRUT) SORT
 S APCLNPAG=Y
ZIS ;
DEMO ;
 D DEMOCHK^APCLUTL(.APCLDEMO)
 I APCLDEMO=-1 G OUTPUT
 S XBRC="PROC^APCLGV",XBRP="^APCLGVP",XBNS="APCL",XBRX="XIT^APCLGV"
 D ^XBDBQUE
XIT ;
 D ^XBFMK
 D EN^XBVK("APCL"),EN^XBVK("AMQQ")
 K I,J,K,P,X,Y,Z,%,DDH,DIV,DIU,DFN,DIG,DIW
 Q
 ;
PROC ;EP - entry point for processing
 S APCLTOT=0,DFN=0,APCLBT=$H
 F  S DFN=$O(^AUPNVSIT("AA",DFN)) Q:DFN'=+DFN  D PROC1
 S APCLET=$H
 K DFN
 Q
PROC1 ;
 S APCLR=0,APCLBDO=(9999999-APCLBD)_".9999",APCLEDO=(9999999-APCLED),APCLSD=(APCLEDO-1)_".9999",APCLRCNT=0
 F  S APCLSD=$O(^AUPNVSIT("AA",DFN,APCLSD)) Q:APCLSD>APCLBDO!(APCLSD="")  D
 .S APCLVIEN=0 F  S APCLVIEN=$O(^AUPNVSIT("AA",DFN,APCLSD,APCLVIEN)) Q:APCLVIEN'=+APCLVIEN  D
 ..Q:'$P(^AUPNVSIT(APCLVIEN,0),U,9)
 ..Q:$P(^AUPNVSIT(APCLVIEN,0),U,11)
 ..S APCLVREC=^AUPNVSIT(APCLVIEN,0)
 ..Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 ..D SCREENS
 ..Q:$D(APCLSKIP)
 ..S APCLRCNT=APCLRCNT+1 ;COUNT # VISITS
 .Q
 I APCLRCNT'<APCLNUM D
 .I APCLOUT="S" S ^XTMP("APCLGV",APCLJOB,APCLBTH,"PATIENTS","TEMPLATE",DFN)="",APCLTOT=APCLTOT+1 Q
 .K APCLSRT,APCLPRNT S APCLCRIT=APCLSORT,APCLX=0
 .X:$D(^APCLVSTS(APCLSORT,4)) ^APCLVSTS(APCLSORT,4)
 .S APCLSRT=$G(APCLPRNT) S:APCLSRT="" APCLSRT="??"
 .S ^XTMP("APCLGV",APCLJOB,APCLBTH,"PATIENTS",APCLSRT,DFN)="",APCLTOT=APCLTOT+1
 Q
 ;
SCREENS ;EP
 K APCLSKIP
 S APCLI=0 F  S APCLI=$O(^APCLVRPT(APCLRPT,11,APCLI)) Q:APCLI'=+APCLI!($D(APCLSKIP))  D
 .I '$P(^APCLVSTS(APCLI,0),U,8) D SINGLE Q
 .D MULT
 .Q
 Q
SINGLE ;
 K X,APCLSPEC S X="",APCLX=0
 X:$D(^APCLVSTS(APCLI,1)) ^(1)
 I X="" S APCLSKIP="" Q
 I '$D(APCLSPEC),'$D(^APCLVRPT(APCLRPT,11,APCLI,11,"B",X)) S APCLSKIP="" Q
 Q
MULT ;
 K APCLFOUN,APCLSKIP,APCLSPEC,X S APCLX=0,X=""
 X:$D(^APCLVSTS(APCLI,1)) ^(1)
 I $O(X(""))="" S APCLSKIP="" Q
 I '$D(APCLSPEC) S Y="" F  S Y=$O(X(Y)) Q:Y=""  I $D(^APCLVRPT(APCLRPT,11,APCLI,11,"B",Y)) S APCLFOUN="" Q
 I $D(APCLSPEC),$D(X) S APCLFOUN=1 Q
 S:'$D(APCLFOUN) APCLSKIP=""
 Q