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

BATBLG.m

Go to the documentation of this file.
  1. BATBLG ; IHS/CMI/LAB - ;
  1. ;;1.0;IHS ASTHMA REGISTER;;FEB 19, 2003
  1. ;
  1. ;
  1. W:$D(IOF) @IOF
  1. W !!,"This option is used to initially populate your register with a pre-defined",!,"set of patients. If you continue with this option your patient file will"
  1. W !,"be scanned and all patients within a [user defined] age range living in",!,"[user defined] community with at least two asthma visits (POV with",!,"ICD-9 codes 493.00-493.99) in the past year will be automatically added to the"
  1. W !,"register with a status of Unreviewed.",!!
  1. S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="N" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) D EOJ Q
  1. I 'Y D EOJ Q
  1. COM ;
  1. K BATCOMM
  1. S DIR(0)="S^O:One particular Community;A:All Communities;S:Selected Set of Communities (Taxonomy)",DIR("A")="Include patients who live in",DIR("B")="O" K DA D ^DIR K DIR
  1. G:$D(DIRUT) EOJ
  1. I Y="A" W !!,"Patients from all communities will be included in the report.",! G AGE
  1. I Y="O" D G:'$D(BATCOMM) COM G AGE
  1. .K BATCOMM
  1. .S DIC="^AUTTCOM(",DIC(0)="AEMQ",DIC("A")="Which COMMUNITY: " D ^DIC K DIC
  1. .Q:Y=-1
  1. .S BATCOMM($P(^AUTTCOM(+Y,0),U))=""
  1. K BATCOMM S X="COMMUNITY",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" S BATERR=1 Q
  1. D ^AMQQGTX0(+Y,"BATCOMM(")
  1. I '$D(BATCOMM) G COM
  1. I $D(BATCOMM("*")) K BATCOMM G COM
  1. ;
  1. AGE ;Age Screening
  1. K BATAGE,BATAGET
  1. W ! S DIR(0)="YO",DIR("A")="Would you like to restrict the report by Patient age range",DIR("B")="YES"
  1. S DIR("?")="If you wish to include visits from ALL age ranges, anwser No. If you wish to include visits for only patients within a particular age range, enter Yes."
  1. D ^DIR K DIR
  1. G:$D(DIRUT) COM
  1. I 'Y G PROCESS
  1. ;
  1. AGER ;Age Screening
  1. W !
  1. S DIR(0)="FO^1:7",DIR("A")="Enter an Age Range (e.g. 5-12,1-1)" D ^DIR
  1. I Y="" W !!,"No age range entered." G AGE
  1. I Y'?1.3N1"-"1.3N W !!,$C(7),$C(7),"Enter a numeric range in the format nnn-nnn. e.g. 0-5, 0-99, 5-20." G AGER
  1. S BATAGET=Y
  1. ;
  1. ;
  1. PROCESS ;
  1. S BATCNT=0
  1. W !!,"Please be patient while I populate the asthma register, this could take",!,"anywhere from 10 minutes to an hour depending on the size of your patient",!,"database.",!
  1. S BATB=$$FMTE^XLFDT($$FMADD^XLFDT(DT,-365))
  1. S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="N" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) D EOJ Q
  1. I 'Y D EOJ Q
  1. S BATE=$$FMTE^XLFDT(DT)
  1. S BATDFN=0 F S BATDFN=$O(^DPT(BATDFN)) Q:BATDFN'=+BATDFN D
  1. .Q:$P(^DPT(BATDFN,0),U,19)
  1. .S BATAGE=$$AGE^AUPNPAT(BATDFN)
  1. .I $D(BATAGET),BATAGE>$P(BATAGET,"-",2) Q
  1. .I $D(BATAGET),BATAGE<$P(BATAGET,"-") Q
  1. .Q:$$DOD^AUPNPAT(BATDFN)]""
  1. .I $D(BATCOMM) S C=$P($G(^AUPNPAT(BATDFN,11)),U,18) Q:C="" I '$D(BATCOMM(C)) Q
  1. .Q:'$$AST2(BATDFN,BATB,BATE)
  1. .D ^XBFMK
  1. .I $D(^BATREG(BATDFN,0)) W !,"Patient ",$P(^DPT(BATDFN,0),U)," already on Register.",! Q
  1. .S DIC="^BATREG(",(DINUM,X)=BATDFN,DIC(0)="L",DIC("DR")=".02////U",DLAYGO=90181.01,DIADD=1 K DD,DO D FILE^DICN K DIC,DLAYGO,DIADD,DINUM
  1. .I Y=-1 W !,"error uploading patient dfn ",BATDFN,!
  1. .S BATCNT=BATCNT+1
  1. .W ".",BATCNT
  1. W !!,BATCNT," patients were added to the asthma register."
  1. D PAUSE
  1. EOJ ;
  1. K DIR
  1. D EN^XBVK("BAT")
  1. Q
  1. PAUSE ;EP
  1. S DIR(0)="EO",DIR("A")="Press enter to continue...." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. Q
  1. AST2(P,B,E) ;EP - return date of last asthma diagnosis
  1. I $G(P)="" Q 0
  1. NEW BATX,BATY,I,S,Q
  1. K BATX
  1. S BATY="BATX("
  1. S S=P_"^LAST 2 DX [BAT ASTHMA DIAGNOSES;DURING "_B_"-"_E S Q=$$START1^APCLDF(S,BATY)
  1. I '$D(BATX(2)) Q ""
  1. Q 1