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

BDMFLOW.m

Go to the documentation of this file.
BDMFLOW ; IHS/CMI/LAB - flowsheet bdm ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**1,3,8**;JUN 14, 2007;Build 53
 ;
 ;
 ;
 D FULL^VALM1,CLEAR^VALM1
 D EN^XBNEW("EP^BDMFLOW","DFN")
 Q
EP ;EP
 W !,"Please enter the name of the Flowsheet you would like to display.",!
 I '$G(DFN) W !!,"Invalid patient DFN" D EOP Q
 D ^XBFMK
 S DIC="^APCHSFLC(",DIC(0)="AEMQ" D ^DIC K DIC
 I Y=-1 W !,"No flowsheet selected." D EXIT,EOP Q
 S BDMFDF=+Y
 D SETVARS
ZIS ;
 W ! S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to",DIR("B")="P" K DA D ^DIR K DIR
 I $D(DIRUT) D EXIT Q
 I Y="B" D BROWSE,EXIT Q
 S XBRP="FLOWDISP^BDMFLOW",XBRC="",XBRX="EXIT^BDMFLOW",XBNS="BDM;DFN"
 D ^XBDBQUE
 D EXIT
 D PAUSE^BDMFMENU
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""FLOWDISP^BDMFLOW"")"
 S XBRC="",XBRX="EXIT^BDMFLOW",XBIOP=0 D ^XBDBQUE
 Q
EXIT ;
 K BDMFLOW
 D ^XBFMK
 Q
SETVARS ;EP
 S BDMFCN=$P(^APCHSFLC(BDMFDF,0),U)
 S BDMSPAT=DFN
 S X=$$FMADD^XLFDT(DT,-365)  ;1 YEAR PER DOROTHY, may change in future
 S BDMDLM=9999999-X
 S BDMNDM=-1
 K BDMQIT
 S BDMCKP="Q:$D(BDMQIT)  S BDMNPG=0 I $Y>(IOSL-3) "
 S BDMBRK="D BREAK^BDMFLOW"
 I $P(IOST,"-",1)="C" S BDMCKP=BDMCKP_"W *7,""<>"" R X:DTIME S:'$T X=U W *13 S:X[U BDMQIT="""" I '$D(BDMQIT) "
 S BDMCKP=BDMCKP_"W @IOF"_$S($P(IOST,"-",1)="C":",!",1:"")_" D HEADER^BDMFLOW,BREAK^BDMFLOW S BDMNPG=1"
 X:$D(IO("S")) $S($D(^DD("OS",^DD("OS"),"XY")):"S (IOX,IOY)=0 X ^(""XY"")",1:"W @IOF")
 S BDMCVD="S:Y]"""" Y=+Y,Y=$E(Y,4,5)_""/""_$S($E(Y,6,7):$E(Y,6,7)_""/"",1:"""")_$E(Y,2,3)"
 S BDMSPG=0
 S BDMSHDR="CONFIDENTIAL PATIENT INFORMATION -- "_$$FMTE^XLFDT(DT,5)_"  ["_$P(^VA(200,DUZ,0),U,2)_"]" S X="",$P(X,"*",((IOM-6-$L(BDMSHDR))\2)+1)="*" S BDMSHDR=X_" "_BDMSHDR_" "_X
 Q
EOP ;EP - End of page.
 Q:$E(IOST)'="C"
 Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
 NEW DIR
 K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
 S DIR(0)="E" D ^DIR
 Q
 ;----------
FLOWDISP ;EP ********** FLOWSHEET PRODUCTION **********
 D HEADER
 S BDMFNM=0
 S BDMND2=BDMNDM
FLOWOUT ; <DISPLAY>
 S BDMFNM=BDMFNM+1 I BDMFNM=1 X BDMCKP Q:$D(BDMQIT)  X:'BDMNPG BDMBRK
 S BDMFCN=$P(^APCHSFLC(BDMFDF,0),U,1)
 D FLOWTB
 X BDMCKP Q:$D(BDMQIT)  D FLOWHD
 S BDMIVD="" F BDMQ=0:0 S BDMIVD=$O(^AUPNVSIT("AA",BDMSPAT,BDMIVD)) Q:BDMIVD=""!(BDMIVD>BDMDLM)  D FLOWBD Q:$D(BDMQIT)  I BDMDUS S BDMNDM=BDMNDM-1 Q:BDMNDM=0
 X BDMCKP Q:$D(BDMQIT)  I 'BDMNPG S BDMP="",$P(BDMP,"-",BDMMXL+9)="" W ?2,BDMP,!
 X BDMCKP Q:$D(BDMQIT)  I 'BDMNPG W !
 Q
FLOWCHK ; <SCREEN>
 I '$O(^APCHSFLC(BDMFDF,2,0)) S BDMFOK=1 Q
 S BDMFOK=0
 F BDMPI=0:0 S BDMPI=$O(^AUPNPROB("AC",BDMSPAT,BDMPI)) Q:'BDMPI  D FLOWCP Q:BDMFOK
 Q:BDMFOK  ;found on Problem list
PVCH ;IHS/CMI/LAB - now check for dx in past year per Bill and Charlton by pcp
 K BDMY,BDMV,^TMP($J,"ALL VISITS")
 S BDMY="^TMP($J,""ALL VISITS"",",%=BDMSPAT_"^ALL VISITS;DURING "_$$FMTE^XLFDT($$FMADD^XLFDT(DT,-365))_"-"_$$FMTE^XLFDT(DT),E=$$START1^APCLDF(%,BDMY)
 I '$D(^TMP($J,"ALL VISITS",1)) Q
 S X=0 F  S X=$O(^TMP($J,"ALL VISITS",X)) Q:X'=+X!(BDMFOK)  S V=$P(^TMP($J,"ALL VISITS",X),U,5) D
 .Q:'$P(^AUPNVSIT(V,0),U,9)
 .Q:$P(^AUPNVSIT(V,0),U,11)
 .Q:"DAHO"'[$P(^AUPNVSIT(V,0),U,7)
 .Q:'$D(^AUPNVPRV("AD",V))
 .Q:'$D(^AUPNVPOV("AD",V))
 .;S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S BDMCM=$P($G(^AUPNVPOV(Y,0)),U) I BDMCM S BDMCM=$P($G(^ICD9(BDMCM,0)),U) I BDMCM]"" D CHKCODE  cmi/anch/maw 8/27/2007 orig code patch 1
 .S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S BDMCM=$P($G(^AUPNVPOV(Y,0)),U) I BDMCM S BDMCM=$P($$ICDDX^BDMUTL(BDMCM,$P(+V,".")),U,2) I BDMCM]"" D CHKCODE  ;cmi/anch/maw 8/27/2007 code set versioning patch 1
 .Q:'D
 .S Y=$$PRIMPROV^APCLV(V,"F")
 .Q:'Y
 .Q:$P($G(^DIC(7,Y,9999999)),U,3)'="Y"
 .S BDMFOK=1
 .Q
 K ^TMP($J,"ALL VISITS"),BDMV,BDMY
 Q
FLOWCP ;
 S BDMP=^AUPNPROB(BDMPI,0) Q:$P(BDMP,U,12)'="A"
 S BDMCM=$P(^ICD9(+$P(BDMP,U,1),0),U,1)
 F BDMCI=0:0 S BDMCI=$O(^APCHSFLC(BDMFDF,2,BDMCI)) Q:'BDMCI  D FLOWCR Q:BDMFOK
 Q
FLOWCR ;
 S BDMC1=$P(^APCHSFLC(BDMFDF,2,BDMCI,0),U,1)
 I BDMC1["-" S BDMC2=$P(BDMC1,"-",2),BDMC1=$P(BDMC1,"-",1)
 E  S BDMC2=BDMC1
 S BDMC1=BDMC1_" ",BDMC2=BDMC2_" "
 I BDMC1'](BDMCM_" "),(BDMCM_" ")']BDMC2 S BDMFOK=1
 Q
CHKCODE ;
 F BDMCI=0:0 S BDMCI=$O(^APCHSFLC(BDMFDF,2,BDMCI)) Q:'BDMCI  D CHKCODE1 Q:D
 Q
CHKCODE1 ;
 S D=0
 S BDMC1=$P(^APCHSFLC(BDMFDF,2,BDMCI,0),U,1)
 I BDMC1["-" S BDMC2=$P(BDMC1,"-",2),BDMC1=$P(BDMC1,"-",1)
 E  S BDMC2=BDMC1
 S BDMC1=BDMC1_" ",BDMC2=BDMC2_" "
 I BDMC1'](BDMCM_" "),(BDMCM_" ")']BDMC2 S D=1
 Q
FLOWCKP ;ENTRY POINT
 X BDMCKP Q:$D(BDMQIT)  Q:'BDMNPG
FLOWHD ;ENTRY POINT
 ; DISPLAY HEADER
 X BDMCKP Q:$D(BDMQIT)
 W BDMFCN,!
 I $O(^APCHSFLC(BDMFDF,3,0)) W ?2,"Clinics limited to:" S X=0 F  S X=$O(^APCHSFLC(BDMFDF,3,X)) Q:'X  X BDMCKP Q:$D(BDMQIT)  G:BDMNPG FLOWHD W ?22,$P(^DIC(40.7,X,0),U),!
 X BDMCKP Q:$D(BD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U,3),BDMVGL=^DIC(BDMP,0,"GL")_"""AD"",BDMVDF)"
 S BDMAS=$O(^APCHSFLC(BDMFDF,1,BDMIDF,2,0)),BDMNGL=BDMAS&'$O(^(BDMAS)) D FLOWBA:'BDMAS,FLOWBS:BDMAS
 Q
FLOWBS ; ADD SPECIFIED ITEMS
 F DA=0:0 S DA=$O(@BDMVGL@(DA)) Q:'DA  D FLOWBS2
 Q
FLOWBS2 ;
 X BDMXT
 S BDMITP=X
 F I=0:0 S I=$O(^APCHSFLC(BDMFDF,1,BDMIDF,2,I)) Q:'I  I +$P(^APCHSFLC(BDMFDF,1,BDMIDF,2,I,0),U,1)=BDMITP D FLOWADD Q
 Q
FLOWBA ; ADD ALL (NO ITEMS SPECIFIED)
 F DA=0:0 S DA=$O(@BDMVGL@(DA)) Q:'DA  D FLOWADD
 Q
FLOWADD ; ADD VALUE FROM SELECTED FILE/DFN
 S BDML=$P(BDMTB(BDMIDF),U,2)
 X BDMX
FLOWS I $L(X),$E(X,$L(X))=" " S X=$E(X,1,$L(X)-1) G FLOWS
 I BDMFXF]"",$P(X,"=",2)]"" S BDMXS=$P(X,"="),X=$P(X,"=",2) X BDMFXF S X=BDMXS_"="_X
 S:$E(X,$L(X))="=" X="n/r"
 I $G(^APCHSFLC(BDMFDF,1,BDMIDF,1))]"" X ^APCHSFLC(BDMFDF,1,BDMIDF,1)
 I BDMNGL,X["=" S X=$P(X,"=",2)
 F BDMI=1:BDML S BDMP=$E(X,BDMI,BDML+BDMI-1) Q:BDMP=""  S BDMJ=BDMJ+1,BDMDC(BDMJ,BDMIDF)=BDMP
 Q
FLOWD ;ENTRY POINT
 S Y=-BDMIVD\1+9999999 X BDMCVD S BDMDAT=Y
 S BDMP="",$P(BDMP,"-",BDMMXL+9)="" X BDMCKP Q:$D(BDMQIT)  W:'BDMNPG ?2,BDMP,! D:BDMNPG FLOWHD
 D FLOWCKP Q:$D(BDMQIT)
 W ?2,BDMDAT
 F BDMI=0:0 S BDMI=$O(BDM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