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

BQIGPRA2.m

Go to the documentation of this file.
BQIGPRA2 ;PRXM/HC/ALA - GPRA (continued) ; 13 Jan 2006  5:48 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 Q
 ;
SNG(DATA,DFN,YEAR) ;  EP -- BQI GET PATIENT GPRA DETAIL
 NEW UID,II,BQIH,BQIYR,BQIINDG,BQIINDT,BQIMEASG,BQIND,BQMEAS,CURR,DEN,NUM,FDT,TDT,VALUE
 NEW DA,IENS,BQIN,BQIMEASF,BQIINDF,TITLE,CAT,ORDER,ORN,RPERIOD,STATUS,TMGLB,TWTEN,X
 NEW NAFLG,SUM,GPCODE,CLIN,GPIEN,TIT,CLN,GPMEAS,PIND,VER
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIGPSNG",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPRA D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 I $O(^BQIPAT(DFN,30,0))="" S BMXSEC="Patient's Natl Measures not available" Q
 ;
 ;  get the current year for CRS
 S YEAR=$G(YEAR,"")
 I YEAR="" S YEAR=$P($G(^BQIPAT(DFN,0)),U,2)
 S BQIH=$$SPM^BQIGPUTL()
 I YEAR="" S YEAR=$$GET1^DIQ(90508,BQIH_",",2,"E")
 S BQIYR=$$LKP^BQIGPUTL(YEAR)
 I BQIYR<1 S BMXSEC="Natl Measures Year does not exist" Q
 ;
 S DA(1)=BQIH,DA=BQIYR
 S IENS=$$IENS^DILF(.DA)
 S BQIINDF=$$GET1^DIQ(90508.01,IENS,.02,"E")
 S BQIMEASF=$$GET1^DIQ(90508.01,IENS,.03,"E")
 S BQIINDG=$$ROOT^DILFD(BQIINDF,"",1)
 S BQIMEASG=$$ROOT^DILFD(BQIMEASF,"",1)
 ;
 S TMGLB=$NA(^TMP("BQIGPDFN",UID))
 K @TMGLB
 S BQIND=""
 F  S BQIND=$O(^BQI(90506.1,"AC","G",BQIND)) Q:BQIND=""  D
 . ; if inactive, quit
 . I $P(^BQI(90506.1,BQIND,0),U,10)=1 Q
 . S GPCODE=$P(^BQI(90506.1,BQIND,0),U,1)
 . ; if it is not the right GPRA year, quit
 . I $P(GPCODE,"_",1)'=YEAR Q
 . S BQMEAS=$P(GPCODE,"_",2)
 . S VER=$$VERSION^XPDUTL("BGP")
 . S CAT=$$GET1^DIQ(90506.1,BQIND_",",3.03,"E")
 . S CLIN=$$GET1^DIQ(90506.1,BQIND_",",3.02,"E")
 . S TITLE=$$GET1^DIQ(90506.1,BQIND_",",.03,"E")
 . I VER>7.0 D
 .. S NAFLG=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1704,"I")
 .. S IPC=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1707,"I")
 .. I IPC=1,$$CIPC^BQIIPCUT(GPCODE) D
 ... S CAT="IPC",CLIN=$$CLIN^BQIIPCUT(GPCODE)
 ... I CLIN="" S CLIN=$$GET1^DIQ(90506.1,BQIND_",",3.02,"E")
 .. S NAFLG=$S(NAFLG="Y":1,1:0)
 .. S @TMGLB@(CAT,CLIN,TITLE,BQIND)=$S(NAFLG=1:0,1:"N/A")_"^"_CAT_"^"_CLIN_"^"_GPCODE_"^"_BQIND_"^"_TITLE_"^"
 . ;
 . I VER<8.0 D
 .. S PIND=$O(^BQI(90508,BQIH,20,BQIYR,20,"B",BQMEAS,""))
 .. S NAFLG=+$P(^BQI(90508,BQIH,20,BQIYR,20,PIND,0),U,4)
 .. S ORDER=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1406,"E"),SUM="NA"
 .. I ORDER="" S ORDER=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1506,"E"),SUM="NN"
 .. S @TMGLB@(CAT,CLIN,TITLE,BQIND)=$S(NAFLG=1:0,1:"N/A")_"^"_CAT_"^"_CLIN_"^"_GPCODE_"^"_BQIND_"^"_TITLE_"^"
 ;
 S @DATA@(II)="T00025REPORT_PERIOD^D00030LAST_UPDATE^T00003STATUS^T00030CATEGORY^T00030CLIN_GROUP^T00015CODE^I00010MEAS_IEN^T00040TEXT^T00020ADHERENCE_VAL"_$C(30)
 ;
 S FDT=$$GET1^DIQ(90507.5,DFN_",",.03,"I")
 S TDT=$$GET1^DIQ(90507.5,DFN_",",.04,"I")
 S BQIINDT=$$FMTE^BQIUL1($$GET1^DIQ(90507.5,DFN_",",.05,"I"))
 S RPERIOD=$$FMTE^XLFDT(FDT,1)_"-"_$$FMTE^XLFDT(TDT,1)
 ;
 S BQIND=0
 F  S BQIND=$O(^BQIPAT(DFN,30,BQIND)) Q:'BQIND  D
 . S BQMEAS=$P(^BQIPAT(DFN,30,BQIND,0),U,1),VALUE=$P(^(0),U,2),NUM=$P(^(0),U,3),DEN=$P(^(0),U,4)
 . S GPCODE=BQMEAS,GPMEAS=$P(BQMEAS,"_",2)
 . S GPIEN=$O(^BQI(90506.1,"B",BQMEAS,""))
 . I $P(^BQI(90506.1,GPIEN,0),"^",10)=1 Q
 . S TITLE=$P(^BQI(90506.1,GPIEN,0),U,3)
 . ;
 . I VER>7.0 D
 .. S NAFLG=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1704,"I")
 .. S NAFLG=$S(NAFLG="Y":1,1:0)
 . ;
 . I VER<8.0 D
 .. S PIND=$O(^BQI(90508,BQIH,20,BQIYR,20,"B",GPMEAS,""))
 .. S NAFLG=+$P(^BQI(90508,BQIH,20,BQIYR,20,PIND,0),U,4)
 .. S ORDER=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1406,"E"),SUM="NA"
 .. I ORDER="" S ORDER=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1506,"E"),SUM="NN"
 . ;
 . S TWTEN=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1403,"E")
 . I TWTEN="" S TWTEN=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1503,"E")
 . S CURR=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1402,"E")
 . I CURR="" S CURR=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1502,"E")
 . S CURR=$$STRIP^XLFSTR(CURR," @#&!")
 . ;
 . S CAT=$$GET1^DIQ(90506.1,GPIEN_",",3.03,"E")
 . S CLIN=$$GET1^DIQ(90506.1,GPIEN_",",3.02,"E")
 . S IPC=$$GET1^DIQ(BQIMEASF,GPMEAS_",",1707,"I")
 . I IPC=1,$$CIPC^BQIIPCUT(GPCODE) D
 .. S CAT="IPC",CLIN=$$CLIN^BQIIPCUT(GPCODE)
 .. I CLIN="" S CLIN=$$GET1^DIQ(90506.1,GPIEN_",",3.02,"E")
 . ;
 . I '+DEN&('NAFLG) Q
 . S STATUS=$S(NUM>0&(NAFLG):NUM,NUM<1&(NAFLG):0,NUM>0:"YES",1:"NO")
 . I VER<8.0 D
 .. S @TMGLB@(CAT,CLIN,TITLE,GPIEN)=STATUS_"^"_CAT_"^"_CLIN_"^"_BQMEAS_"^"_GPIEN_"^"_TITLE_"^"_$P(VALUE,"|||",2)
 . I VER>7.0 D
 .. S @TMGLB@(CAT,CLIN,TITLE,GPIEN)=STATUS_"^"_CAT_"^"_CLIN_"^"_BQMEAS_"^"_GPIEN_"^"_TITLE_"^"_$P(VALUE,"|||",2)
 ;
 S CAT=""
 F  S CAT=$O(@TMGLB@(CAT)) Q:CAT=""  D
 . S CLN=""
 . F  S CLN=$O(@TMGLB@(CAT,CLN)) Q:CLN=""  D
 .. S TIT=""
 .. F  S TIT=$O(@TMGLB@(CAT,CLN,TIT)) Q:TIT=""  D
 ... S ORN=""
 ... F  S ORN=$O(@TMGLB@(CAT,CLN,TIT,ORN)) Q:ORN=""  D
 .... S II=II+1,@DATA@(II)=RPERIOD_"^"_BQIINDT_"^"_@TMGLB@(CAT,CLN,TIT,ORN)_$C(30)
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q