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

APCLRT1.m

Go to the documentation of this file.
  1. APCLRT1 ; IHS/CMI/LAB - APC visit counts by selected vars ;
  1. ;;2.0;IHS PCC SUITE;**7**;MAY 14, 2009
  1. ;
  1. START ;
  1. I '$G(DUZ(2)) W $C(7),$C(7),!!,"SITE NOT SET IN DUZ(2) - NOTIFY SITE MANAGER!!",!! Q
  1. S APCLSITE=DUZ(2)
  1. S APCLJOB=$J,APCLBTH=$H
  1. D INFORM
  1. ;
  1. GETDATES ;
  1. BD ;get beginning date
  1. W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Visit Date for Search" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) G XIT
  1. S APCLBD=Y
  1. ED ;get ending date
  1. W ! S DIR(0)="DA^"_APCLBD_":DT:EP",DIR("A")="Enter ending Visit Date for Search: " S Y=APCLBD D DD^%DT S Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) G BD
  1. S APCLED=Y
  1. S X1=APCLBD,X2=-1 D C^%DTC S APCLSD=X
  1. ;
  1. CLINIC ;
  1. S (APCLCLTY,APCLFCLN,APCLTCLN)=""
  1. S DIR(0)="S^S:Returns from one particular clinic to the same clinic;A:Returns from any clinic to any clinic;O:Returns from one particular clinic to any other clinic;P:Returns from any clinic to one particular clinic"
  1. S DIR("A")="Select which scenario",DIR("B")="O" KILL DA D ^DIR KILL DIR
  1. G:$D(DIRUT) GETDATES
  1. S APCLCLTY=Y
  1. I APCLCLTY="A" S APCLFCLN="",APCLTCLN="" G LOC
  1. I APCLCLTY="S" D SCLN I APCLFCLN="" G CLINIC
  1. I APCLCLTY="O" D FCLN I APCLFCLN="" G CLINIC
  1. I APCLCLTY="P" D TCLN I APCLTCLN="" G CLINIC
  1. LOC ;get location
  1. K APCLLOC
  1. S DIR(0)="S^O:One Location;T:Taxonomy of Predefined Locations;A:All Locations"
  1. S DIR("A")="Include visits from which set of locations",DIR("B")="O" KILL DA D ^DIR KILL DIR
  1. G:$D(DIRUT) BD
  1. I Y="A" K APCLLOC G HR
  1. I Y="O" D O G:$D(APCLQ) LOC
  1. I Y="T" D T G:$D(APCLQ) LOC
  1. HR ;48 or 72 hr
  1. S APCLHR=7
  1. ;S DIR(0)="S^7:72 HOURS;4:48 HOURS",DIR("A")="Run Report for returns w/in how many hours",DIR("B")="7" KILL DA D ^DIR KILL DIR
  1. ;I $D(DIRUT) G LOC
  1. ;S APCLHR=Y
  1. DEF ;S X=30,DIC(0)="M",DIC="^DIC(40.7," D ^DIC K DIC,X I Y=-1 W !!,"CLINIC CODE 30 - EMERGENCY ROOM MISSING FROM FILE - NOTIFY YOUR SITE MANAGER!!" G XIT
  1. ;S APCLRTCL=+Y
  1. PROV ;one provider or all
  1. S APCLPROV=""
  1. S DIR(0)="S^A:ANY Provider;O:One particular Provider",DIR("A")="Include Returns from Clinic Visits to",DIR("B")="A" K DA D ^DIR K DIR
  1. G:$D(DIRUT) GETDATES
  1. I Y="A" G DX
  1. PRV ;get provider which the patient should have been seen prior
  1. ;to returning to ER
  1. W !!,"You must indicate in which provider the patient was to have seen seen prior",!,"to returning to the Emergency Room",!
  1. S DIC("A")="Which Provider: ",DIC="^VA(200,",DIC(0)="AEMQ" D ^DIC K DIC,DA G:X="^" PROV K DIC,DA G:Y<0 PRV
  1. S APCLPROV=+Y
  1. DX ;should other visit have the same diagnosis?
  1. S APCLSDX=""
  1. S DIR(0)="Y",DIR("A")="Should the visits have the same primary diagnosis",DIR("B")="Y" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G PROV
  1. S APCLSDX=Y
  1. INC ;
  1. S APCLEINC=""
  1. S DIR(0)="Y",DIR("A")="Should Incomplete visits be excluded",DIR("B")="Y" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G DX
  1. S APCLEINC=Y
  1. ZIS ;call to XBDBQUE
  1. DEMO ;
  1. D DEMOCHK^APCLUTL(.APCLDEMO)
  1. I APCLDEMO=-1 G PROV
  1. S XBRP="^APCLRT1P",XBRC="^APCLRT11",XBRX="XIT^APCLRT1",XBNS="APCL"
  1. D ^XBDBQUE
  1. D XIT
  1. Q
  1. XIT ;
  1. K APCL1,APCL2,APCL3D,APCLAGE,APCLAP,APCLBD,APCLBDD,APCLBT,APCLBTH,APCLCLIN,APCLCLN,APCLDATE,APCLDFN,APCLDISC,APCLDT,APCLED,APCLEDD,APCLRTCL,APCLET,APCLFAC,APCLFRST,APCLFVD,APCLHIGH,APCLHRCN,APCLIVD,APCLJOB,APCLLOC,APCLLOCC,APCLNAME
  1. K APCLODAT,APCLP,APCLPG,APLCPPOV,APCLQUIT,APCLSD,APCLSITE,APCLSKIP,APCLT1,APCLT2,APCLV,APCLVD,APCLVDFN,APCLVLOC,APCLVREC,APCLX,APCLY,APCLZ
  1. K X,X1,X2,IO("Q"),%,Y,POP,DIRUT,ZTSK,ZTQUEUED,H,S,TS,M,DA,D0,DR,DIC,DIE,DIR,DTOUT,DUOUT,H,M,S
  1. Q
  1. INFORM ;
  1. W:$D(IOF) @IOF
  1. W !!,"This report will produce a list of patient visits. The visits are those",!,"for which the patient had a clinic visit and then returned within 72 hours "
  1. W !,"of that visit to the same clinic or to another clinic."
  1. W !,"The user selects which clinic and which location of encounter.",!
  1. W "The user may limit the list to just visits to a particular provider."
  1. Q
  1. ;
  1. TCLN ;get clinic at which the patient should have been seen prior
  1. S (APCLFCLN,APCLTCLN)=""
  1. W !!,"You must indicate in which clinic the patient returned to",!,"w/in 72 hours of another clinic visit."
  1. S DIC("A")="Which Clinic: ",DIC="^DIC(40.7,",DIC(0)="AEMQ" D ^DIC K DIC,DA
  1. Q:X="^"
  1. Q:Y<0
  1. S APCLTCLN=+Y,APCLFCLN=""
  1. Q
  1. FCLN ;get clinic at which the patient should have been seen prior
  1. S (APCLFCLN,APCLTCLN)=""
  1. W !!,"You must indicate in which clinic the patient was seen and returned",!,"to any clinic w/in 72 hours.",!
  1. S DIC("A")="Which Clinic: ",DIC="^DIC(40.7,",DIC(0)="AEMQ" D ^DIC K DIC,DA
  1. Q:X="^"
  1. Q:Y<0
  1. S APCLFCLN=+Y,APCLTCLN=""
  1. Q
  1. SCLN ;get clinic at which the patient should have been seen prior
  1. S (APCLFCLN,APCLTCLN)=""
  1. W !!,"You must indicate in which clinic the patient was seen and returned",!,"to w/in 72 hours.",!
  1. S DIC("A")="Which Clinic: ",DIC="^DIC(40.7,",DIC(0)="AEMQ" D ^DIC K DIC,DA
  1. Q:X="^"
  1. Q:Y<0
  1. S (APCLFCLN,APCLTCLN)=+Y
  1. Q
  1. O ;EP one location
  1. K APCLQ
  1. S DIC="^AUTTLOC(",DIC(0)="AEMQ",DIC("A")="Which LOCATION: " D ^DIC K DIC
  1. I Y=-1 S APCLQ="" Q
  1. S APCLLOC(+Y)=""
  1. Q
  1. T ;
  1. K APCLQ
  1. S DIC="^ATXAX(",DIC(0)="AEMQ",DIC("A")="Which TAXONOMY: ",DIC("S")="I $P(^(0),U,15)=9999999.06" D ^DIC K DIC
  1. I Y=-1 S APCLQ="" Q
  1. S X=0 F S X=$O(^ATXAX(+Y,21,"B",X)) Q:X="" S APCLLOC(X)=""
  1. Q