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

BQIRGDMA.m

Go to the documentation of this file.
BQIRGDMA ;VNGT/HS/ALA-Set up Diabetes Audit fields ; 17 Feb 2016  2:46 PM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
EN ;EP - Update Diabetes Audit when new one comes in
 NEW PRVY,DMN,YR,NYRN,NYR,BQIGDA,BQIN1,BQIN2,DVY
 S PRVY=$P($G(^BQI(90508,1,"DM")),U,1)
 I PRVY'="" S NYR=PRVY+1
 I PRVY="" S DVY=$P($$FMTE^XLFDT(DT,7),"/",1) D
 . I '$D(^BDMDMTX("B",DVY)) S NYR=DVY-1 Q
 . I $D(^BDMDMTX("B",DVY)) S NYR=DVY
 ; 
 S NYRN=$O(^BDMDMTX("B",NYR,"")) I NYRN="" Q
 S BQIN1=$P(^BDMDMTX(NYRN,0),U,2),BQIN2=$P(^(0),U,3)
 I PRVY'=NYR D
 . S BQIDA=1
 . NEW DA,IENS,DIC
 . S DA(1)=BQIDA,X=NYR,DIC(0)="LMNZ",DIC="^BQI(90508,"_DA(1)_",21,"
 . D ^DIC
 . I +Y<1 Q
 . S BQIGDA=+Y
 . S DA=BQIGDA,IENS=$$IENS^DILF(.DA)
 . S BQIUPD(90508.021,IENS,.02)=BQIN1
 . S BQIUPD(90508.021,IENS,.03)=BQIN2
 . S BQIUPD(90508.021,IENS,.04)="BDMDM"_$E(NYR,3,4)
 . S BQIUPD(90508,BQIDA_",",21.01)=NYR
 . D FILE^DIE("","BQIUPD","ERROR")
 . D TAX(NYR)
 . ;
 . D AU
 . ;
 . D JBDM^BQITASK2
 Q
 ;
AU ; Update Dm Audit in 90506.5
 NEW BDMN,CODE,EXEC,IEN,BDMDATA,IEN,BQIUPD,TBDMN,TEXT
 S IEN=""
 F  S IEN=$O(^BQI(90506.1,"AC","DM",IEN)) Q:IEN=""  D
 . S BQIUPD(90506.1,IEN_",",.1)=1
 . I $P(^BQI(90506.1,IEN,0),U,11)="" S BQIUPD(90506.1,IEN_",",.11)=DT
 D FILE^DIE("","BQIUPD","ERROR")
 K BQIUPD
 ;
 S BDMN=0
 F  S BDMN=$O(^BDMDMTX(NYRN,11,BDMN)) Q:'BDMN  D
 . S BDMDATA=$G(^BDMDMTX(NYRN,11,BDMN,1)) I BDMDATA="" Q
 . I $P(BDMDATA,U,4)="" Q
 . S CODE="DM_"_$P(BDMDATA,U,4),EXEC=$TR($P(BDMDATA,U,3),"~","^")
 . I CODE="DM_COMB",EXEC["COMBINEE" S EXEC="$$COMBINED^BDMDD1C(BDMPD)"
 . I CODE="DM_HDL",EXEC["$$LDL" D
 .. I NYR=2016 S EXEC="$$HDL^BDMDD18(BDMPD,BDMBDAT,BDMADAT)"
 .. I NYR=2015 S EXEC="$$HDL^BDMDC18(BDMPD,BDMBDAT,BDMADAT)"
 . S HDR="T00030"_CODE,NSOURCE="DM Audit",NCLIN="",NCAT=$P(BDMDATA,U,2)
 . S ORD=$P(^BDMDMTX(NYRN,11,BDMN,0),"^",3)
 . I ORD="" D
 .. F I=1:1:12 S TEXT=$P($T(THER+I),";;",2) Q:TEXT=""  D
 ... S TBDMN=$O(^BDMDMTX(NYRN,11,"B","DM THERAPY","")) I TBDMN="" S TBDMN=$O(^BDMDMTX(NYRN,11,"B","DIABETES THERAPY","")) I TBDMN="" Q
 ... I CODE=TEXT S ORD=$P(^BDMDMTX(NYRN,11,TBDMN,0),"^",3)
 . S TEXT=$P(BDMDATA,U,1)
 . I CODE="DM_TBTEST" S TEXT="TB Test Done"
 . NEW DA,X,DIC,DLAYGO
 . S DIC="^BQI(90506.1,",DIC(0)="L",X=CODE
 . S DA=$O(^BQI(90506.1,"B",CODE,""))
 . ;I DA'="" S ORD=$O(^BQI(90506.1,"AD","DM",""),-1)+1
 . I DA="" D  Q:$G(ERROR)=1
 .. K DO,DD D FILE^DICN
 .. S DA=+Y I DA=-1 S ERROR=1
 .. ;S ORD=$O(^BQI(90506.1,"AD","DM",""),-1)+1
 . S BQIUPD(90506.1,DA_",",.03)=TEXT
 . S BQIUPD(90506.1,DA_",",.08)=HDR
 . S BQIUPD(90506.1,DA_",",.15)=120
 . S BQIUPD(90506.1,DA_",",.1)="@"
 . S BQIUPD(90506.1,DA_",",.11)="@"
 . D FILE^DIE("","BQIUPD","ERROR")
 . ;
 . S BQIUPD(90506.1,DA_",",3.01)=NSOURCE
 . S BQIUPD(90506.1,DA_",",3.02)=NCLIN
 . S BQIUPD(90506.1,DA_",",3.03)=NCAT
 . S BQIUPD(90506.1,DA_",",3.04)="Default"
 . S BQIUPD(90506.1,DA_",",3.05)=ORD
 . S BQIUPD(90506.1,DA_",",1)="S VAL=$$DSP^BQIRGDMA(DFN,STVW)"
 . ;S BQIUPD(90506.1,DA_",",5)="S VAL=$$AUD^BQIRGDMA("_EXEC_")"
 . S BQIUPD(90506.1,DA_",",5)="S VAL="_EXEC
 . D FILE^DIE("E","BQIUPD","ERROR")
 . K BQIUPD
 . S HELP(1)="Diabetes Audit "_NYR_" for "_TEXT_"."
 . D WP^DIE(90506.1,DA_",",4,"","HELP","ERROR")
 . K HELP
 Q
 ;
TAX(YEAR) ; Set up Taxonomies for Diabetes Register
 NEW TXN,RGN,IEN,VALUE,TAX,FILE,SITE,TAX,BQIUPD
 S TXN=$O(^BDMTAXS("B",YEAR,"")) I TXN="" Q
 S RGN=$O(^BQI(90507,"B","DIABETES","")) I RGN="" Q
 S IEN=0
 F  S IEN=$O(^BDMTAXS(TXN,11,IEN)) Q:'IEN  D
 . S VALUE=^BDMTAXS(TXN,11,IEN,0)
 . S TAX=$P(VALUE,U,1),FILE=$P(VALUE,U,2),SITE=$P(VALUE,U,3)
 . NEW DA,DIC,IENS,GLB,TAXN,TXDN,CN,CAT,ID
 . S DA(1)=RGN,DIC(0)="LNZ",DLAYGO=90507.01,DIC="^BQI(90507,"_DA(1)_",10,"
 . I $G(^BQI(90507,DA(1),10,0))="" S ^BQI(90507,DA(1),10,0)="^90507.01^^"
 . S X=TAX
 . D ^DIC
 . I +Y=-1 K DO,DD D FILE^DICN
 . S DA=+Y,IENS=$$IENS^DILF(.DA)
 . S BQIUPD(90507.01,IENS,.04)=$S(SITE=1:1,1:"")
 . S GLB=$S(FILE=60:"^ATXLAB",1:"^ATXAX")
 . S TAXN=$O(@GLB@("B",TAX,"")) I TAXN="" Q
 . S TXDN=$O(^BQI(90508.4,"B",FILE,"")) I TXDN="" Q
 . S CN=$P(^BQI(90508.4,TXDN,0),U,2)
 . I $G(CN)'="" S CAT=$P(^BQI(90508.3,CN,0),U,1),ID=$P(^BQI(90508.3,CN,0),U,2)
 . I CAT="" S CAT="OTHER",ID="OTHER"
 . S BQIUPD(90507.01,IENS,.03)=CAT
 . S BQIUPD(90507.01,IENS,.02)=TAXN_";"_$P(GLB,U,2)_"("
 . S BQIUPD(90507.01,IENS,.05)=$$STCC^BQIUL2(90507.01,.05,ID)
 . D FILE^DIE("","BQIUPD","ERROR")
 Q
 ;
AUD(EVAL) ;EP - Execute DM Audit executable
 ;NEW BDMPD,BDMRBD,BDMRED,BDMBDAT,BDMADAT,BDMDMRG,BDM6MBD
 S RESULT=0
 I EVAL="" D
 . S EVAL=$P(EXEC,"(",2,99)
 . S EVAL=$P(EVAL,")",1)
 . S EVAL=EVAL_")"
 ;S EVAL="S RES="_$TR(EVAL,"~","^")
 S BDMPD=DFN,BDMADAT=DT,BDMDMRG=$P($G(^BQI(90508,1,"DM")),U,2)
 S BDM6MBD=$$FMADD^XLFDT(BDMADAT,-(6*31))
 S BDMBDAT=$$FMADD^XLFDT(BDMADAT,-365),BDMRBD=$$FMTE^XLFDT(BDMBDAT),BDMRED=$$FMTE^XLFDT(BDMADAT)
 S EVAL="S RES="_EVAL
 X EVAL
 I RES'="" S RESULT=1_U_RES
 Q RESULT
 ;
GLS(DATA,FAKE) ;EP - BQI GET DM AUDIT GLOSSARY
 NEW UID,II,TRIEN,CAT,TIT,SORT,RMK,REMARK,CT,NXT,GLIEN,IEN
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIRGDMGLS",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRGPG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T32767REPORT_TEXT"_$C(30)
 S PRVY=$P($G(^BQI(90508,1,"DM")),U,1)
 S NYRN=$O(^BDMDMTX("B",PRVY,"")) I NYRN="" G DONE
 S IEN=0
 F  S IEN=$O(^BDMDMTX(NYRN,11,IEN)) Q:'IEN  D
 . S II=II+1,@DATA@(II)=$P(^BDMDMTX(NYRN,11,IEN,0),U,1)_$C(10)_$C(13)
 . ;S II=II+1,@DATA@(II)=" "_$C(10)_$C(13)
 . S GLIEN=0
 . F  S GLIEN=$O(^BDMDMTX(NYRN,11,IEN,11,GLIEN)) Q:'GLIEN  D
 .. S II=II+1,@DATA@(II)="  "_$G(^BDMDMTX(NYRN,11,IEN,11,GLIEN,0))_$C(10)_$C(13)
 . S II=II+1,@DATA@(II)=" "_$C(10)_$C(13)
 I II>0 S @DATA@(II)=@DATA@(II)_$C(30)
 ;
DONE S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DSP(RGDFN,RGSTVW) ;EP = Display Audit information
 NEW VALUE,RESULT,RGPIEN,CRIEN,CMSN,LINK
 S CODE=$P($G(^BQI(90506.1,RGSTVW,0)),U,1) I CODE="" Q ""
 ;S RGSTVW=$O(^BQI(90506.1,"B",CODE,"")) I RGSTVW="" Q ""
 I $P(^BQI(90506.1,RGSTVW,0),"^",10)=1 Q ""
 S CMSN=$P($G(^BQI(90506.1,RGSTVW,3)),U,1) I CMSN="" Q ""
 S CRIEN=$O(^BQIPAT(RGDFN,60,"B",CMSN,"")) I CRIEN="" Q ""
 S RGPIEN="",VALUE="",HOVER="",LINK="",RESULT=""
 F  S RGPIEN=$O(^BQIPAT(RGDFN,60,CRIEN,1,"B",CODE,RGPIEN)) Q:RGPIEN=""  D
 . S VALUE=$P($G(^BQIPAT(RGDFN,60,CRIEN,1,RGPIEN,0)),U,2)
 . S HOVER=$P($G(^BQIPAT(RGDFN,60,CRIEN,1,RGPIEN,0)),U,5)
 . S LINK=$P($G(^BQIPAT(RGDFN,60,CRIEN,1,RGPIEN,0)),U,4)
 I VALUE'="" D
 . I $L(VALUE,"  ")=2 S VALUE=$$UP^XLFSTR($P(VALUE,"  ",2)) Q
 . ;I $L(VALUE," ")=2 S VALUE=$$UP^XLFSTR($P(VALUE," ",2)) Q
 . I $P(VALUE,"  ",1)=1!($P(VALUE,"  ",1)=2)!($P(VALUE,"  ",1)=3) S VALUE=$P(VALUE,"  ",2,99) Q
 . I VALUE?.7N,$$FMTE^BQIUL1(VALUE)'="" S VALUE=$$FMTE^XLFDT(VALUE,"5Z") Q
 . Q
 I VALUE'="",HOVER'="" S RESULT=VALUE_$C(26)_HOVER_$C(26)_LINK
 E  S RESULT=VALUE
 Q RESULT
 ;
THER ;EP - Therapy who don't have an order
 ;;DM_INSU
 ;;DM_SULF
 ;;DM_SULFL
 ;;DM_METFOR
 ;;DM_ACAR
 ;;DM_PIOG
 ;;DM_DPP4
 ;;DM_AMYL
 ;;DM_GLP
 ;;DM_BROMO
 ;;DM_COLES
 ;;DM_SGLT2