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

BHSFLOW.m

Go to the documentation of this file.
BHSFLOW ;IHS/CIA/MGH - Health Summary for Flowsheets ;02-Jan-2014 14:31;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**2,9**;March 17, 2006;Build 16
 ;===================================================================
 ; Taken from APCHS12
 ; IHS/TUCSON/LAB - PART 12 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS RPMS/PCC Health Summary;**5,8,9**;JUN 24, 1997
 ;Modified to be used in VA health summary for flowsheet component of health summary
 ;======================================================================
FLOW ; ********** FLOWSHEET PRODUCTION **********
 ; <SETUP>
 N BHSPAT,APCHSPAT
 S (BHSPAT,APCHSPAT)=DFN
 Q:'$D(^AUPNVSIT("AA",BHSPAT))
 S BHSFNM=0
 S BHSND2=GMTSNDM
 Q:$O(GMTSEG(GMTSEGN,9001020,0))'>0
 F BHSFOR=0:0 S BHSFOR=$O(GMTSEG(GMTSEGN,9001020,BHSFOR)) Q:'BHSFOR  S GMTSNDM=BHSND2 D FLOWOUT Q:$D(GMTSQIT)
FLOWX K BHSFOR,BHSND2,BHSDUS,BHSFCN,BHSIVD,BHSTB,BHSDB,BHSI,BHST,BHSW,BHSFDF,BHSAS,BHSVDF,BHSN,BHSIT,BHSCLN
 K BHSDAT,BHSIDF,BHSITP,BHSJ,BHSL,BHSMXL,BHSTTL,BHSVGL,BHSX,BHSXT,BHSII,BHSNGL,BHSXS,BHSFXF
 K BHSFOK,BHSPI,BHSCI,BHSC1,BHSC2,BHSCM,BHSFNM,BHSP,BHSQ,APCHSNVN,APCHSNYR,APCHSBD,APCHSFDF
 Q
FLOWOUT ; <DISPLAY>
 S BHSFDF=$G(GMTSEG(GMTSEGN,9001020,BHSFOR))
 D FLOWCHK Q:'BHSFOK
 S BHSFNM=BHSFNM+1 I BHSFNM=1
 D CKP^GMTSUP Q:$D(GMTSQIT)   ; VA health summary routine
 S BHSFCN=$P(^APCHSFLC(BHSFDF,0),U,1)
 D FLOWTB
 D CKP^GMTSUP Q:$D(GMTSQIT)
 D FLOWHD
 S BHSIVD="" F BHSQ=0:0 S BHSIVD=$O(^AUPNVSIT("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D FLOWBD Q:$D(GMTSQIT)  I BHSDUS S GMTSNDM=GMTSNDM-1 Q:GMTSNDM=0
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I 'GMTSNPG S BHSP="",$P(BHSP,"-",BHSMXL+9)="" W ?2,BHSP,!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I 'GMTSNPG W !
 Q
FLOWCHK ; <SCREEN>
 I '$O(^APCHSFLC(BHSFDF,2,0)) S BHSFOK=1 Q
 S BHSFOK=0
 ;Q:'$O(^AUPNPROB("AC",BHSPAT,0))
 F BHSPI=0:0 S BHSPI=$O(^AUPNPROB("AC",BHSPAT,BHSPI)) Q:'BHSPI  D FLOWCP Q:BHSFOK
 Q:BHSFOK  ;found on Problem list
PVCH ;IHS/CMI/LAB - now check for dx in past year per Bill and Charlton by pcp
 N X,%,V,Y,D,E
 K APCHY,APCHV,^TMP($J,"ALL VISITS")
 S APCHSNVN=$S($P($G(^APCHSITE(DUZ(2),12,BHSFDF,0)),U,2):$P($G(^APCHSITE(DUZ(2),12,BHSFDF,0)),U,2),1:1)
 S APCHSNYR=$S($P($G(^APCHSITE(DUZ(2),12,BHSFDF,0)),U,3):$P($G(^APCHSITE(DUZ(2),12,BHSFDF,0)),U,3),1:1)
 S APCHSNYR=APCHSNYR*365
 S APCHSBD=$$FMADD^XLFDT(DT,-(APCHSNYR))
 S APCHY="^TMP($J,""ALL VISITS"",",%=BHSPAT_"^ALL VISITS;DURING "_$$FMTE^XLFDT($$FMADD^XLFDT(DT,-365))_"-"_$$FMTE^XLFDT(DT),E=$$START1^APCLDF(%,APCHY)
 I '$D(^TMP($J,"ALL VISITS",1)) Q
 S X=0 F  S X=$O(^TMP($J,"ALL VISITS",X)) Q:X'=+X!(BHSFOK)  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))
 .;code set versioning changes
 .;S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S BHSCM=$P($G(^AUPNVPOV(Y,0)),U) I BHSCM S BHSCM=$P($G(^ICD9(BHSCM,0)),U) I BHSCM]"" D CHKCODE
 .N APCHSVDT
 .S APCHSVDT=$P(+V,".")
 .S (D,Y)=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D)  S BHSCM=$P($G(^AUPNVPOV(Y,0)),U) I BHSCM S BHSCM=$P($$ICDDX^ICDEX(BHSCM,APCHSVDT),U,2) I BHSCM]"" D CHKCODE
 .Q:'D
 .S Y=$$PRIMPROV^APCLV(V,"F")
 .Q:'Y
 .Q:$P($G(^DIC(7,Y,9999999)),U,3)'="Y"
 .S BHSFOK=1
 .Q
 K ^TMP($J,"ALL VISITS"),APCHV,APCHY
 Q
FLOWCP ;
 S BHSP=^AUPNPROB(BHSPI,0) Q:$P(BHSP,U,12)'="A"
 ;S BHSCM=$P(^ICD9(+$P(BHSP,U,1),0),U,1)
 S BHSCM=$P($$ICDDX^ICDEX(+$P(BHSP,U,1),0),U,2) ;code set versioning
 F BHSCI=0:0 S BHSCI=$O(^APCHSFLC(BHSFDF,2,BHSCI)) Q:'BHSCI  D FLOWCR Q:BHSFOK
 Q
FLOWCR ;
 S BHSC1=$P(^APCHSFLC(BHSFDF,2,BHSCI,0),U,1)
 I BHSC1["-" S BHSC2=$P(BHSC1,"-",2),BHSC1=$P(BHSC1,"-",1)
 E  S BHSC2=BHSC1
 S BHSC1=BHSC1_" ",BHSC2=BHSC2_" "
 I BHSC1'](BHSCM_" "),(BHSCM_" ")']BHSC2 S BHSFOK=1
 ;I BHSC1']BHSCM,BHSCM']BHSC2 S BHSFOK=1
 Q
CHKCODE ;
 F BHSCI=0:0 S BHSCI=$O(^APCHSFLC(BHSFDF,2,BHSCI)) Q:'BHSCI  D CHKCODE1 Q:D
 Q
CHKCODE1 ;
 S D=0
 S BHSC1=$P(^APCHSFLC(BHSFDF,2,BHSCI,0),U,1)
 I BHSC1["-" S BHSC2=$P(BHSC1,"-",2),BHSC1=$P(BHSC1,"-",1)
 E  S BHSC2=BHSC1
 S BHSC1=BHSC1_" ",BHSC2=BHSC2_" "
 I BHSC1'](BHSCM_" "),(BHSCM_" ")']BHSC2 S D=1
 Q
FLOWCKP ;ENTRY POINT
 D CKP^GMTSUP Q:$D(GMTSQIT)  Q:'GMTSNPG
FLOWHD ;ENTRY POINT
 ; DISPLAY HEADER
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W BHSFCN,!
 I $O(^APCHSFLC(BHSFDF,3,0)) W ?2,"Clinics limited to:"
 S X=0 F  S X=$O(^APCHSFLC(BHSFDF,3,X)) Q:'X  D CKP^GMTSUP  G:GMTSNPG FLOWHD W ?22,$P(^DIC(40.7,X,0),U),!
 D CKP^GMTSUP Q:$D(GMTSQIT)  G:GMTSNPG FLOWHD
 F BHSII=0:0 S BHSII=$O(BHSTB(BHSII)) Q:'BHSII  W ?14+BHSTB(BHSII),BHSTB(BHSII,"L")
 W !
 Q
FLOWTB ; BUILD TAB TABLE
 K BHSTB
 S BHST=1,BHSMXL=0
 F BHSI=0:0 S BHSI=$O(^APCHSFLC(BHSFDF,1,BHSI)) Q:'BHSI  D FLOWTB2
 Q
FLOWTB2 S BHSW=0
 Q:'($D(^APCHSFLC(BHSFDF,1,BHSI,0))#2)  S BHSN=^(0)
 S BHSTTL=$P(BHSN,U,3) S BHSP=$L(BHSTTL) S:BHSP>BHS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SFDF,1,BHSIDF,2,I,0),U,1)=BHSITP D FLOWADD Q
 Q
FLOWBA ; ADD ALL (NO ITEMS SPECIFIED)
 N DA
 F DA=0:0 S DA=$O(@BHSVGL@(DA)) Q:'DA  D FLOWADD
 Q
FLOWADD ; ADD VALUE FROM SELECTED FILE/DFN
 N I
 S BHSL=$P(BHSTB(BHSIDF),U,2)
 X BHSX
FLOWS I $L(X),$E(X,$L(X))=" " S X=$E(X,1,$L(X)-1) G FLOWS
 I BHSFXF]"",$P(X,"=",2)]"" S BHSXS=$P(X,"="),X=$P(X,"=",2) X BHSFXF S X=BHSXS_"="_X
 S:$E(X,$L(X))="=" X="n/r" ;per Gary Lawless do not display name of test 12/26/01
 I BHSNGL,X["=" S X=$P(X,"=",2)
 F BHSI=1:BHSL S BHSP=$E(X,BHSI,BHSL+BHSI-1) Q:BHSP=""  S BHSJ=BHSJ+1,BHSDB(BHSJ,BHSIDF)=BHSP
 Q