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

BQITRPRT.m

Go to the documentation of this file.
BQITRPRT ;PRXM/HC/ALA-Get Treatment Prompts for a Patient ; 18 May 2007  12:05 PM
 ;;2.5;ICARE MANAGEMENT SYSTEM;**1**;May 24, 2016;Build 17
 ;
EN(DATA,DFN,NUM) ;EP -- BQI PATIENT TRMT PROMPTS
 ; Input
 ;   DFN - Patient internal entry number
 ;
 NEW DXCAT,DOD,DXFND,UID,II,CT,TRIEN,TIT,RMK,REMARK,DTLUP,CAT,DXCAT,PRI,ORD,LPRI
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQITRPRT",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITRPRT D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S NUM=$G(NUM,"")
 S @DATA@(II)="T00030CATEGORY^T00030PROMPT^D00030DATE_LAST_UPDATED^T01024REMARK^I00003DISPLAY_ORDER"_$C(30)
 ;
 ;Do not display for deceased patients
 S DOD=$$GET1^DIQ(2,DFN_",",.351,"I") I DOD]""  S II=II+1,@DATA@(II)=$C(31) Q
 ;
 S TRIEN=0,CT=0,CAT="CVD-RELATED",DTLUP=$$GET1^DIQ(90507.5,DFN_",",.07,"I")
 ;
 ;Pull CVD-RELATED entries from ^BQIPAT
 ;
 F  S TRIEN=$O(^BQIPAT(DFN,50,TRIEN)) Q:'TRIEN  D
 . S PRI=$$GET1^DIQ(90508.5,TRIEN_",",.03,"I") Q:PRI=""
 . S DXCAT=$$GET1^DIQ(90508.5,TRIEN_",",.02,"E") Q:DXCAT=""
 . S TIT=$$GET1^DIQ(90508.5,TRIEN_",",.01,"E")
 . S RMK=0,REMARK=""
 . F  S RMK=$O(^BQIPAT(DFN,50,TRIEN,1,RMK)) Q:'RMK  D
 .. S REMARK=REMARK_^BQIPAT(DFN,50,TRIEN,1,RMK,0)_" "
 . S ORD(CAT,DXCAT,PRI)=CAT_U_TIT_U_$$FMTE^BQIUL1(DTLUP)_U_REMARK_U_PRI_$C(30)
 ;
 ; Check for other Treatment Prompts (note - there may be additional CVD-RELATED entries)
 ; 
 I $T(GVTP^APCHSMU)'="" D
 . S TRIEN=0,DTLUP="",PRI=0
 . F  S TRIEN=$O(^APCHSURV(TRIEN)) Q:'TRIEN  D
 .. N ARRAY
 .. I $P(^APCHSURV(TRIEN,0),U,7)'="T" Q
 .. I $P(^APCHSURV(TRIEN,0),U,2)["BQITRASM" D VAR^BQIRMDR1
 .. D GVTP^APCHSMU(DFN,TRIEN,80,.ARRAY)
 .. I $P($G(ARRAY(0)),U)'=1 Q
 .. S CAT=$$GET1^DIQ(9001018,TRIEN_",",.05,"E")
 .. S DXCAT="",LPRI=$G(LPRI)+1
 .. S TIT=$$GET1^DIQ(9001018,TRIEN_",",.01,"E")
 .. S DXCAT=$$GET1^DIQ(9001018,TRIEN_",",.05,"E") Q:DXCAT=""
 .. S RMK=0,REMARK=""
 .. F  S RMK=$O(ARRAY(RMK)) Q:RMK=""  D
 ... S REMARK=REMARK_ARRAY(RMK)_" "
 .. S PRI=PRI+1
 .. S ORD(CAT,DXCAT,PRI)=CAT_U_TIT_U_$$FMTE^BQIUL1(DTLUP)_U_REMARK_U
 ;
 ;Process CVD-RELATED entries
 S CAT="CVD-RELATED",LPRI=0
 I $D(ORD(CAT)) D
 . S DXFND="",CT=0
 . F DXCAT="CVD-RELATED" D
 .. S PRI="" F  S PRI=$O(ORD(CAT,DXCAT,PRI)) Q:PRI=""  D
 ... S CT=CT+1 I NUM'="",CT>NUM Q
 ... S LPRI=$S(PRI>LPRI:PRI,1:LPRI)
 ... I $E(ORD(CAT,DXCAT,PRI),$L(ORD(CAT,DXCAT,PRI)))'=$C(30) S ORD(CAT,DXCAT,PRI)=ORD(CAT,DXCAT,PRI)_$C(30)
 ... S II=II+1,@DATA@(II)=ORD(CAT,DXCAT,PRI)
 . ;F DXCAT="CVD Known","CVD Highest Risk","CVD Significant Risk","CVD At Risk" D  Q:DXFND
 . F DXCAT="ASCVD Known","ASCVD At Risk" D  Q:DXFND
 .. S PRI="" F  S PRI=$O(ORD(CAT,DXCAT,PRI)) Q:PRI=""  D
 ... S CT=CT+1 I NUM'="",CT>NUM Q
 ... S LPRI=$S(PRI>LPRI:PRI,1:LPRI)
 ... S DXFND=1  ;Found an entry for this ASSOCIATED DX TAG
 ... I $E(ORD(CAT,DXCAT,PRI),$L(ORD(CAT,DXCAT,PRI)))'=$C(30) S ORD(CAT,DXCAT,PRI)=ORD(CAT,DXCAT,PRI)_$C(30)
 ... S II=II+1,@DATA@(II)=ORD(CAT,DXCAT,PRI)
 . K ORD(CAT)
 ;
 ;Process other CAT entries
 S CAT="" F  S CAT=$O(ORD(CAT)) Q:CAT=""  D
 . S DXCAT="",CT=0 F  S DXCAT=$O(ORD(CAT,DXCAT)) Q:DXCAT=""  D
 .. S PRI="" F  S PRI=$O(ORD(CAT,DXCAT,PRI)) Q:PRI=""  D
 ... S LPRI=LPRI+1,ORD(CAT,DXCAT,PRI)=ORD(CAT,DXCAT,PRI)_LPRI_$C(30)
 ... S CT=CT+1 I NUM'="",CT>NUM Q
 ... S II=II+1,@DATA@(II)=ORD(CAT,DXCAT,PRI)
 ;
 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
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q