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

BQIIPPT.m

Go to the documentation of this file.
BQIIPPT ;VNGT/HS/ALA-IPC Patient Detail ; 30 Jun 2011  12:32 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;;Dec 19, 2017;Build 23
 ;
 ;
EN(DATA,OWNR,PLIEN,CRIPC,PLIST) ;EP - BQI GET IPC PATIENT DETAIL
 ;Description - Entry point for the panel
 ;Input Parameters
 ;  OWNR  - Owner of panel
 ;  PLIEN - Panel IEN
 ;  PLIST - List of DFNs (optional) 
 NEW UID,II,X,PGIEN,STVWCD,TDATA
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIGPPNL",UID)) K @DATA
 S TDATA=$NA(^TMP("BQIPTIP",UID)) K @TDATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPRA1 D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 ;  get the current IPC definition
 S CRIPC=$G(CRIPC,"")
 I CRIPC="" S CRIPC=$P($G(^BQI(90508,1,11)),U,1)
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" Q
 ;
 ; If a list of DFNs, process them instead of entire panel
 I $D(PLIST)>0 D  G DONE
 . I $D(PLIST)>1 D
 .. S LIST="",BN=""
 .. F  S BN=$O(PLIST(BN)) Q:BN=""  S LIST=LIST_PLIST(BN)
 .. K PLIST S PLIST=LIST
 . F BQI=1:1 S DFN=$P(PLIST,$C(28),BQI) Q:DFN=""  D
 .. I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 .. D PAT(.DATA,OWNR,PLIEN,DFN)
 ;
 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 ;
 S II=II+1,@DATA@(II)=$C(31)
 K @TDATA
 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
 ;
PAT(DATA,OWNR,PLIEN,DFN) ;EP - Build record by patient
 NEW IEN,HDR,VALUE,HEADR,DORD,HDOB,Y,VAL,BQIDOD,PROV,PAT,CAT,TITLE,MSN
 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^D00030DOB^"
 S HEADR=HEADR_"T00030PN^T00040HRN^T00035DPCP^D00030LVD^D00030LVDPCP^D00030NAPD^"
 I DFN'="" S VAL=$$HRNL^BQIULPT(DFN),VAL=$TR(VAL,";",$C(10))
 I DFN'="" S PROV=$P($$DPCP^BQIULPT(DFN),U,2) I PROV="" S PROV="{NOT ASSIGNED}"
 I DFN'="" S VALUE=VALUE_$P($G(^DPT(DFN,0)),"^",1)_"^"_VAL_"^"_PROV_"^"_$$LVDT^BQIULPT(DFN)_"^"_$$LVDPCP^BQIULPT(DFN)_"^"_$$NAD^BQIULPT(DFN)_"^"
 I DFN'="" S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I") ; Is patient deceased?
 ;
 D REC(DFN)
 ;
 I DFN'="" D
 . S PAT=DFN,ORD=""
 . F  S ORD=$O(@TDATA@(PAT,ORD)) Q:ORD=""  D
 .. S VAL=$G(@TDATA@(PAT,ORD,"VAL"))
 .. S HDR=$G(@TDATA@(PAT,ORD,"HDR"))
 .. D UP
 ;
 ; 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
 ;
GVAL ;EP - Get GPRA value for patient
 NEW PIEN,DEN,NUM,SPVW,SPIEN,VER
 I $G(BQIMEASF)="" D INP^BQINIGHT
 I $G(DFN)="" S VAL="",HDR="T00003"_STVW,GMET="" Q
 S PIEN=$O(^BQIPAT(DFN,30,"B",STVW,""))
 I PIEN="" S VAL=$S(BQIDOD'="":"{D}",1:"NDA"),HDR="T00003"_STVW,GMET="" Q
 ;
 I $G(BQIH)="" S BQIH=$$SPM^BQIGPUTL()
 I $G(BQIYR)="" S BQIYR=$$GET1^DIQ(90508,BQIH_",",2,"E")
 S BQIY=$$LKP^BQIGPUTL(BQIYR)
 ;
 S VER=$$VERSION^XPDUTL("BGP")
 S SPVW=$P(STVW,"_",2),NAFLG=0
 S NAFLG=$$GET1^DIQ(BQIMEASF,SPVW_",",1704,"I")
 S NAFLG=$S(NAFLG="Y":1,1:0)
 ;
 S DEN=$P(^BQIPAT(DFN,30,PIEN,0),U,4)
 S NUM=+$P(^BQIPAT(DFN,30,PIEN,0),U,3)
 ;
 I DEN="" D
 . I NAFLG'=1 S VAL="N/A" Q
 . I 'NUM S VAL=0,GMET=0 Q
 . S VAL=NUM
 I DEN D
 . I 'NUM S VAL="NO",GMET=0 Q
 . S VAL="YES"
 S HDR="T00003"_STVW
 I BQIDOD'="" S VAL="{D}"
 Q
 ;
UP ;EP
 S VALUE=VALUE_$G(VAL)_"^"
 S HEADR=HEADR_HDR_"^"
 Q
 ;
REC(DFN) ;EP - Record
 S ORD=""
 F  S ORD=$O(^BQI(90508,1,22,CRN,1,"C",ORD)) Q:ORD=""  D
 . S MSN=""
 . F  S MSN=$O(^BQI(90508,1,22,CRN,1,"C",ORD,MSN)) Q:'MSN  D
 .. S IDATA=^BQI(90508,1,22,CRN,1,MSN,0)
 .. S CODE=$P(IDATA,U,1),TYP=$P(IDATA,U,2),TITLE=$P(IDATA,U,4),TAB=$P(IDATA,U,13)
 .. I TAB="A" Q
 .. ; If inactive, quit
 .. I $P(IDATA,U,7)=1 Q
 .. S HDR="T00003"_CODE I DFN="" S HEADR=HEADR_HDR_"^" Q
 .. NEW DA,IENS
 .. S DA(2)=1,DA(1)=CRN,DA=MSN,IENS=$$IENS^DILF(.DA)
 .. S CAT=$$GET1^DIQ(90508.221,IENS,.03,"E")
 .. S MSIEN=$O(^BQI(90506.1,"B",CODE,""))
 .. I CAT="",MSIEN'="" S CAT=$$GET1^DIQ(90506.1,MSIEN_",",3.03,"E")
 .. I CAT="" S CAT="~"
 .. I $P(IDATA,U,5)'="B" S CAT=CAT_"_2"
 .. I TYP="R",$P(IDATA,U,5)="B" D
 ... K XX
 ... I CODE="IPC_OUTC" D
 .... I DFN'="" S VAL=$$OPAT^BQIIPOTC(CRN,DFN)
 ... I CODE["CTRL" D
 .... I DFN'="" S VAL=$$PAT^BQIIPOTC(CRN,DFN,CODE)
 ... I CODE'="IPC_OUTC",CODE'["CTRL" D
 .... D BUN^BQIIPBNL(CRN,MSN,.XX)
 .... I DFN'="" S VAL=$$PAT^BQIIPBNL(DFN,.XX)
 ... S CAT=CAT_"_1"
 ... D STOR(ORD)
 .. I TYP'="G" Q
 .. S STVW=CODE
 .. D GVAL
 .. D STOR(ORD)
 Q
 ;
STOR(ORD) ;EP
 I DFN="" Q
 S @TDATA@(DFN,ORD,"VAL")=$G(VAL)
 S @TDATA@(DFN,ORD,"HDR")=$G(HDR)
 Q