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

BQICMLST.m

Go to the documentation of this file.
BQICMLST ;VNGT/HS/ALA-Care Management List ; 28 May 2008  6:59 PM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
 Q
 ;
EN(DATA,TYPE) ;EP -- BQI GET CARE MGMT LIST
 ;
 ; Input
 ;   TYPE - type of measures to list see table 90506.5 for list
 ;
 NEW UID,II,TTYPE,SCAT,SCLIN,BQMEAS,CAT,CLIN,TITLE,BATCH,BQIMEASF,CMCOD
 NEW EDIT,NCAT,NCLIN,NVIEW,ORD,PIND,YEAR,SDIR,BQISORT,INACTIVE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQICMLST",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQICMLST D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="I00010MEAS_IEN^T00030TYPE^T00030CATEGORY^T00030CLIN_GROUP^T00050DISPLAY_NAME^T00015CODE^T00001VIEW^T00001PER_DIRECT^"
 S @DATA@(II)=@DATA@(II)_"T00001EXCEPT^I00003SIZE^T00003EDIT^T00003BATCH^T00001DEFAULT_SORT"_$C(30)
 ;
 S TYPE=$G(TYPE,"")
 ;
 I TYPE'="" D  G DONE
 . N TPC,NTYPE
 . F TPC=1:1:$L(TYPE,$C(29)) S NTYPE=$P(TYPE,$C(29),TPC) I NTYPE]"" D
 .. I NTYPE'?.N S CMCOD=$$FIND1^DIC(90506.5,"","X",NTYPE,"B","","ERROR")
 .. I CMCOD=0 S CMCOD=$$FIND1^DIC(90506.5,"","X",NTYPE,"C","","ERROR")
 .. I NTYPE?.N S CMCOD=NTYPE
 .. ;
 .. S TTYPE=$P($G(^BQI(90506.5,CMCOD,0)),U,2)
 .. I TTYPE'="" D RET
 .. ;
 .. ;Get care management columns
 .. D CMGT
 ;
 S TTYPE=""
 F  S TTYPE=$O(^BQI(90506.5,"C",TTYPE)) Q:TTYPE=""  D
 . S CMCOD=$O(^BQI(90506.5,"C",TTYPE,""))
 . S INACTIVE=$$GET1^DIQ(90506.5,CMCOD_",",.1,"I") Q:INACTIVE
 . S IEN=$O(^BQI(90506.1,"AD",TTYPE,""))
 . ;I IEN="" D CMGT Q
 . I IEN'="" D RET
 . D CMGT
 . ;D RET
 ;
DONE ;
 S SRC=""
 F  S SRC=$O(BQISORT(SRC)) Q:SRC=""  D
 . S CAT=""
 . F  S CAT=$O(BQISORT(SRC,CAT)) Q:CAT=""  D
 .. S CLIN=""
 .. F  S CLIN=$O(BQISORT(SRC,CAT,CLIN)) Q:CLIN=""  D
 ... S TITLE=""
 ... F  S TITLE=$O(BQISORT(SRC,CAT,CLIN,TITLE)) Q:TITLE=""  D
 .... S BQMEAS=""
 .... F  S BQMEAS=$O(BQISORT(SRC,CAT,CLIN,TITLE,BQMEAS)) Q:BQMEAS=""  D
 ..... S II=II+1,@DATA@(II)=BQISORT(SRC,CAT,CLIN,TITLE,BQMEAS)
 S II=II+1,@DATA@(II)=$C(31)
 K BQISORT
 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
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
RET ; Data retrieval
 NEW IEN,FDATA,SRC,GCAT,RCAT,DCAT,GCLIN,RCLIN,GVIEW,DVIEW,VIEW,DCLIN
 NEW CAT,CLIN,RVIEW,MVIEW,PDIR,EXCEPT,SIZE,SRCN,KEY
 ; Check for Alternate Display Order fist
 S ORD=""
 F  S ORD=$O(^BQI(90506.1,"AF",TTYPE,ORD)) Q:ORD=""  D
 . S IEN=""
 . F  S IEN=$O(^BQI(90506.1,"AF",TTYPE,ORD,IEN)) Q:IEN=""  D GET(IEN)
 ;
 ; Get normal order
 S ORD=""
 F  S ORD=$O(^BQI(90506.1,"AD",TTYPE,ORD)) Q:ORD=""  D
 . S IEN=""
 . F  S IEN=$O(^BQI(90506.1,"AD",TTYPE,ORD,IEN)) Q:IEN=""  D GET(IEN)
 Q
 ;
GET(IEN) ;EP - Get data values
 S FDATA=$G(^BQI(90506.1,IEN,0)),EXCEPT="",SIZE=""
 I $$GET1^DIQ(90506.1,IEN_",",.1,"I")=1 Q
 I $$GET1^DIQ(90506.1,IEN_",",3.07,"I")=1 Q
 S KEY=$$GET1^DIQ(90506.1,IEN_",",3.1,"E")
 I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
 S SRCN=$$GET1^DIQ(90506.1,IEN_",",3.01,"I")
 S SRC=$S($$GET1^DIQ(90506.5,SRCN_",",.06,"E")'="":$$GET1^DIQ(90506.5,SRCN_",",.06,"E"),1:$$GET1^DIQ(90506.5,SRCN_",",.01,"E"))
 ;S SRC=$$GET1^DIQ(90506.1,IEN_",",3.01,"E")
 S NCAT=$$GET1^DIQ(90506.1,IEN_",",3.03,"E")
 S NCLIN=$$GET1^DIQ(90506.1,IEN_",",3.02,"E")
 S NVIEW=$$GET1^DIQ(90506.1,IEN_",",3.04,"I")
 S PDIR=$$GET1^DIQ(90506.1,IEN_",",.14,"I")
 S SIZE=$$GET1^DIQ(90506.1,IEN_",",.15,"E")
 S EDIT=+$$GET1^DIQ(90506.1,IEN_",",.16,"I")
 S EDIT=$S(EDIT=1:"YES",1:"NO")
 S BATCH=+$$GET1^DIQ(90506.1,IEN_",",.17,"I")
 S BATCH=$S(BATCH=1:"YES",1:"NO")
 S SDIR=$$GET1^DIQ(90506.1,IEN_",",3.08,"I")
 S:SDIR="" SDIR="A"
 S VIEW=NVIEW
 S:VIEW="" VIEW="O"
 S DCLIN=""
 S CAT=NCAT
 S CLIN=NCLIN
 I TTYPE="G" D
 . NEW CODE,BQIH,BQIYR,BQMEAS,VER
 . S CODE=$P(FDATA,U,1),YEAR=$P(CODE,"_",1)
 . S BQMEAS=$P(CODE,"_",2)
 . S BQIH=$$SPM^BQIGPUTL()
 . S BQIYR=$$LKP^BQIGPUTL(YEAR)
 . S VER=$$VERSION^XPDUTL("BGP")
 . I VER>7.0 D
 .. D GFN^BQIGPUTL(BQIH,BQIYR)
 .. S EXCEPT=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1704,"I")
 .. S EXCEPT=$S(EXCEPT="Y":"C",1:"N")
 .. S PDIR=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1705,"E")
 S SCAT=$S(CAT="":"@",1:CAT),SCLIN=$S(CLIN="":"@",1:CLIN)
 S BQISORT(SRC,SCAT,SCLIN,$P(FDATA,U,3),IEN)=IEN_U_SRC_U_CAT_U_CLIN_U_$P(FDATA,U,3)_U_$P(FDATA,U,1)_U_VIEW_U_$G(PDIR)_U_$G(EXCEPT)_U_SIZE_U_EDIT_U_BATCH_U_SDIR_$C(30)
 ;S II=II+1,@DATA@(II)=IEN_U_SRC_U_CAT_U_CLIN_U_$P(FDATA,U,3)_U_$P(FDATA,U,1)_U_VIEW_U_PDIR_U_EXCEPT_U_SIZE_U_EDIT_U_BATCH_U_SDIR_$C(30)
 Q
 ;
CMGT ; Additional Care Mgmt columns
 NEW KEY,DXCL,FDATA,CAT,REQ,SRC,FTY,CLIN,SCLIN
 S KEY=$P(^BQI(90506.5,CMCOD,0),U,12)
 I KEY'="",'$$KEYCHK^BQIULSC(KEY,DUZ) Q
 S DXCL=0
 F  S DXCL=$O(^BQI(90506.5,CMCOD,10,DXCL)) Q:'DXCL  D
 . S FDATA=^BQI(90506.5,CMCOD,10,DXCL,0)
 . I $P(FDATA,U,9)=1 Q
 . S FTY=$P(FDATA,U,2),CAT="",CLIN="",SCLIN=""
 . S CAT=$P($G(^BQI(90506.5,CMCOD,10,DXCL,5)),"^",2),CLIN=$P($G(^BQI(90506.5,CMCOD,10,DXCL,5)),"^",1)
 . I FTY'="" D
 .. I CAT'=""!(CLIN'="") Q
 .. S CAT=$$GET1^DIQ(90621.1,FTY_",",.07,"E")
 .. I CAT="Other" S CLIN=$$GET1^DIQ(90621.1,FTY_",",.08,"E"),SCLIN=$$LOWER^VALM1(CLIN)
 .. ;I CLIN="" S CLIN="@",SCLIN=""
 . S REQ=$S($P(FDATA,U,6)'="":$P(FDATA,U,6),1:"O")
 . S SCAT=$S(CAT="":"@",1:CAT),SCLIN=$S(CLIN="":"@",1:CLIN)
 . S SRC=$S($$GET1^DIQ(90506.5,CMCOD_",",.06,"E")'="":$$GET1^DIQ(90506.5,CMCOD_",",.06,"E"),1:$$GET1^DIQ(90506.5,CMCOD_",",.01,"E"))
 . S BQISORT(SRC,SCAT,SCLIN,$P(FDATA,U,3),DXCL)=DXCL_U_SRC_U_CAT_U_CLIN_U_$P(FDATA,U,3)_U_$P(FDATA,U,1)_U_REQ_U_U_U_U_U_U_$C(30)
 . ;
 ;Get locally created care management columns if associated with a dx tag
 NEW DXTN
 S DXTN=$P($G(^BQI(90506.5,CMCOD,0)),U,11) I DXTN="" Q
 S DXCL=0
 F  S DXCL=$O(^BQI(90506.2,DXTN,6,DXCL)) Q:'DXCL  D
 . S CAT="Local",CLIN="",SCLIN=""
 . S FDATA=^BQI(90506.2,DXTN,6,DXCL,0)
 . I $P(FDATA,U,9)=1 Q
 . S REQ=$S($P(FDATA,U,6)'="":$P(FDATA,U,6),1:"O")
 . S SCAT=$S(CAT="":"@",1:CAT),SCLIN=$S(CLIN="":"@",1:CLIN)
 . S SRC=$S($$GET1^DIQ(90506.5,CMCOD_",",.06,"E")'="":$$GET1^DIQ(90506.5,CMCOD_",",.06,"E"),1:$$GET1^DIQ(90506.5,CMCOD_",",.01,"E"))
 . S BQISORT(SCAT,SCLIN,$P(FDATA,U,3),DXCL)=DXCL_U_SRC_U_CAT_U_CLIN_U_$P(FDATA,U,3)_U_$P(FDATA,U,1)_U_REQ_U_U_U_U_U_U_$C(30)
 Q