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

BQIMSPL.m

Go to the documentation of this file.
BQIMSPL ;PRXM/HC/ALA-Get Measures by Panel ; 12 Jun 2007  2:57 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;;Apr 18, 2012;Build 59
 ;
 Q
 ;
EN(DATA,OWNR,PLIEN) ;EP -- BQI GET MY MEASURES BY PANEL
 ;Description - Entry point for the panel
 NEW UID,II,X,BQIRM,VAL,DFN,HIEN,E,J,K,L,MAX,MIN,NAFLG
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMSPL",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIMSPL D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S DFN=0
 I $O(^BQICARE(OWNR,1,PLIEN,40,DFN))="" D PAT(.DATA,OWNR,PLIEN,"") G DONE
 ;
 F  S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN  D
 . I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 . D PAT(.DATA,OWNR,PLIEN,DFN)
 ;
DONE ;
 I II=0,'$D(@DATA) D PAT(.DATA,OWNR,PLIEN,"")
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
 NEW GMET,GHDR
 ; if the user is the owner of the panel, use the owner's display order
 I $G(DUZ)=$G(OWNR),$O(^BQICARE(OWNR,1,PLIEN,21,0)) D NCOWN(OWNR,PLIEN,DFN) G EXIT
 ; if the user is a shared user, use the user's display order
 I $G(DUZ)'=$G(OWNR),$O(^BQICARE(OWNR,1,PLIEN,30,DUZ,21,0)) D NCDUZ(OWNR,PLIEN,DFN) G EXIT
 ; otherwise use the standard display order
 D STAND()
 ;
EXIT ;
 Q
 ;
NCOWN(OWNR,PLIEN,DFN) ;EP - Get customized display for an owner
 ; New (in dev) COWN
 ;Parameters
 ;  DFN = Patient internal entry number
 ;  HEADR = Record header
 ;  STVW  = Panel view definition internal entry number
 ;  VALUE = Record value
 NEW IEN,HDR,VALUE,HEADR,DORD,HDOB,Y,ORD,KEY
 S VALUE=""
 I DFN'="" S Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I"),HDOB=$$FMTE^BQIUL1(Y)
 I DFN'="" S VALUE=DFN_"^"_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_"^"_$$SENS^BQIULPT(DFN)_"^"_$$CALR^BQIULPT(DFN)_"^"_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_"^"_HDOB_"^"
 S HEADR="I00010DFN^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^"
 S IEN=0
 F  S IEN=$O(^BQICARE(OWNR,1,PLIEN,21,IEN)) Q:'IEN  D
 . NEW DA,IENS,STVW
 . S DA(2)=OWNR,DA(1)=PLIEN,DA=IEN,IENS=$$IENS^DILF(.DA)
 . S STVW=$$GET1^DIQ(90505.13,IENS,.01,"I"),STVWCD=STVW
 . S SIEN=$O(^BQI(90506.1,"B",STVW,"")) I SIEN="" Q
 . I $$GET1^DIQ(90506.1,SIEN_",",.1,"I")=1 Q
 . S KEY=$$GET1^DIQ(90506.1,SIEN_",",3.1,"E")
 . I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
 . I $P(^BQI(90506.1,SIEN,0),U,10)=1 Q
 . S HDR=$$GET1^DIQ(90506.1,SIEN_",",.08,"E")
 . ;I $P(^BQI(90506.1,SIEN,2),U,1)="D" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient" S STVW=SIEN D CVAL
 . ;I $P(^BQI(90506.1,SIEN,2),U,1)="R" S STVW=STVWCD D RMVL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Reminders" S STVW=STVWCD D RMVL
 . ;I $P(^BQI(90506.1,SIEN,2),U,1)="G" S STVW=STVWCD D GVAL^BQIGPRA1
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance" S STVW=STVWCD D GVAL^BQIGPRA1
 . ;I $P(^BQI(90506.1,SIEN,2),U,1)="A" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Asthma" S STVW=SIEN D CVAL
 . ;I $P(^BQI(90506.1,SIEN,2),U,1)="H" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="HIV/AIDS" S STVW=SIEN D CVAL
 . S VALUE=VALUE_VAL_"^"
 . S HEADR=HEADR_HDR_"^"
 ;
 ; remove trailing up-arrows
 S HEADR=$$TKO^BQIUL1(HEADR,"^")
 S VALUE=$$TKO^BQIUL1(VALUE,"^")
 ;
 I DFN="" S VALUE=""
 ;
 I II=0 S @DATA@(II)=HEADR_$C(30)
 I VALUE'="" S II=II+1,@DATA@(II)=VALUE_$C(30)
 ;
 Q
 ;
NCDUZ(OWNR,PLIEN,DFN) ;EP - Get customized display for a shared user
 ; New (in DEV) CDUZ
 NEW IEN,HDR,VALUE,HEADR,DORD,HDOB,Y,KEY
 S VALUE=""
 I DFN'="" S Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I"),HDOB=$$FMTE^BQIUL1(Y)
 I DFN'="" S VALUE=DFN_"^"_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_"^"_$$SENS^BQIULPT(DFN)_"^"_$$CALR^BQIULPT(DFN)_"^"_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_"^"_HDOB_"^"
 S HEADR="I00010DFN^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^"
 S IEN=0
 F  S IEN=$O(^BQICARE(OWNR,1,PLIEN,30,DUZ,21,IEN)) Q:'IEN  D
 . NEW DA,IENS,STVW
 . S DA(3)=OWNR,DA(2)=PLIEN,DA(1)=DUZ,DA=IEN
 . S IENS=$$IENS^DILF(.DA)
 . S STVW=$$GET1^DIQ(90505.321,IENS,.01,"I"),STVWCD=STVW
 . NEW SIEN
 . S SIEN=$O(^BQI(90506.1,"B",STVW,"")) I SIEN="" Q
 . I $$GET1^DIQ(90506.1,SIEN_",",.1,"I")=1 Q
 . S KEY=$$GET1^DIQ(90506.1,SIEN_",",3.1,"E")
 . I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
 . NEW STVW
 . S STVW=SIEN
 . S HDR=$$GET1^DIQ(90506.1,SIEN_",",.08,"E")
 . ;I $P($G(^BQI(90506.1,SIEN,2)),U,1)="D" S STVW=SIEN D CVAL
 . ;I $P($G(^BQI(90506.1,SIEN,2)),U,1)="R" S STVW=STVWCD D RMVL
 . ;I $P($G(^BQI(90506.1,SIEN,2)),U,1)="G" S STVW=STVWCD D GVAL^BQIGPRA1
 . ;I $P($G(^BQI(90506.1,SIEN,2)),U,1)="A" S STVW=SIEN D CVAL
 . ;I $P($G(^BQI(90506.1,SIEN,2)),U,1)="H" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Patient" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Reminders" S STVW=STVWCD D RMVL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Performance" S STVW=STVWCD D GVAL^BQIGPRA1
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="Asthma" S STVW=SIEN D CVAL
 . I $$GET1^DIQ(90506.1,SIEN_",",3.01,"E")="HIV/AIDS" S STVW=SIEN D CVAL
 . S VALUE=VALUE_VAL_"^"
 . S HEADR=HEADR_HDR_"^"
 ;
 S HEADR=$$TKO^BQIUL1(HEADR,"^")
 S VALUE=$$TKO^BQIUL1(VALUE,"^")
 ;
 I DFN="" S VALUE=""
 ;
 I II=0 S @DATA@(II)=HEADR_$C(30)
 I VALUE'="" S II=II+1,@DATA@(II)=VALUE_$C(30)
 ;
 Q
 ;
STAND() ;EP - Get standard display
 NEW IEN,HDR,VALUE,HEADR,SENS,HDOB,Y,STVW,TEXT,ORD,KEY
 S VALUE=""
 I DFN'="" S Y=$$GET1^DIQ(9000001,DFN_",",1102.2,"I"),HDOB=$$FMTE^BQIUL1(Y)
 I DFN'="" S VALUE=DFN_"^"_$$FLG^BQIULPT(DUZ,PLIEN,DFN)_"^"_$$SENS^BQIULPT(DFN)_"^"_$$CALR^BQIULPT(DFN)_"^"_$$MFLAG^BQIULPT(OWNR,PLIEN,DFN)_"^"_HDOB_"^"
 S HEADR="I00010DFN^T00001FLAG_INDICATOR^T00001SENS_FLAG^T00001COMM_FLAG^T00001HIDE_MANUAL^D00030HIDE_DOB^"
 S IEN=""
 F  S IEN=$O(^BQI(90506.1,"AC","D",IEN)) Q:IEN=""  D
 . I $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1 Q
 . S STVW=IEN
 . D CVAL
 . S VALUE=VALUE_VAL_"^"
 . S HEADR=HEADR_HDR_"^"
 ;
 F TYP="G","R","A","H" S IEN="" D
 . F  S IEN=$O(^BQI(90506.1,"AC",TYP,IEN)) Q:IEN=""  D
 .. I $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1 Q
 .. S KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
 .. I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
 .. S STVW=$P(^BQI(90506.1,IEN,0),U,1)
 .. S HDR=$$GET1^DIQ(90506.1,IEN_",",.08,"E")
 .. ;I $P($G(^BQI(90506.1,IEN,2)),U,1)="R" D RMVL
 .. ;I $P($G(^BQI(90506.1,IEN,2)),U,1)="G" D GVAL^BQIGPRA1
 .. ;I $P($G(^BQI(90506.1,IEN,2)),U,1)="A" S STVW=IEN D CVAL
 .. ;I $P($G(^BQI(90506.1,IEN,2)),U,1)="H" S STVW=IEN D CVAL
 .. I $$GET1^DIQ(90506.1,IEN_",",3.01,"E")="Reminders" D RMVL
 .. I $$GET1^DIQ(90506.1,IEN_",",3.01,"E")="Performance" D GVAL^BQIGPRA1
 .. I $$GET1^DIQ(90506.1,IEN_",",3.01,"E")="Asthma" S STVW=IEN D CVAL
 .. I $$GET1^DIQ(90506.1,IEN_",",3.01,"E")="HIV/AIDS" S STVW=IEN D CVAL
 .. S VALUE=VALUE_VAL_"^"
 .. S HEADR=HEADR_HDR_"^"
 S HEADR=$$TKO^BQIUL1(HEADR,"^")
 S VALUE=$$TKO^BQIUL1(VALUE,"^")
 ;
 I DFN="" S VALUE=""
 ;
 I II=0 S @DATA@(II)=HEADR_$C(30)
 I VALUE'="" S II=II+1,@DATA@(II)=VALUE_$C(30)
 Q
 ;
CVAL ; Get demographic values
 ;Parameters
 ;  FIL  = FileMan file number
 ;  FLD  = FileMan field number
 ;  EXEC = If an executable is needed to determine value
 ;  HDR  = Header value
 ;the executable expects the value to be returned in variable VAL
 NEW FIL,FLD,EXEC
 S FIL=$$GET1^DIQ(90506.1,STVW_",",.05,"E")
 S FLD=$$GET1^DIQ(90506.1,STVW_",",.06,"E")
 S EXEC=$$GET1^DIQ(90506.1,STVW_",",1,"E")
 S HDR=$$GET1^DIQ(90506.1,STVW_",",.08,"E")
 I $G(DFN)="" S VAL="" Q
 ;
 I $G(EXEC)'="" X EXEC Q
 ;
 I FIL'="",FLD'="" S VAL=$$GET1^DIQ(FIL,DFN_",",FLD,"E")
 Q
 ;
RMVL ;  Reminder value
 NEW RDATA,CT,I,RIEN,DUE
 I DFN="" S VAL="",HDR="T00015"_STVW Q
 S RIEN=$O(^BQIPAT(DFN,40,"B",STVW,"")) I RIEN="" S VAL="NDA" Q
 S RDATA=$G(^BQIPAT(DFN,40,RIEN,0))
 S CT=0
 F I=2:1:4 S:$P(RDATA,U,I)'="" CT=CT+1
 S HDR="T00015"_STVW
 I CT=0 S VAL="N/A" Q
 S DUE=$P(RDATA,U,4)
 I $P(RDATA,U,3)'="",DUE="" S DUE=DT
 I DUE>DT S VAL="F" Q
 S ODT=$$FMADD^XLFDT(DT,-30)
 I DUE<ODT S VAL="O" Q
 S VAL="C"
 ;S VAL=$$FMTE^BQIUL1(DUE)
 Q