BQINOTR ;GDIT/HS/ALA-Reminder Notification Log ; 03 Jan 2013 12:21 PM
;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
;
LOG(DFN,NTYP,TIUP,IMML,PWHN,REM,PROV) ;PEP - Log a notification entry
; Input
; DFN - Patient IEN
; NTYP - Notification Type LETTER, EMAIL, PHONE
; TIUP - TIU note pointer
; IMML - Immunization letter pointer
; PWHN - Patient Wellness Handout pointer (no longer needed)
; REM - Reminder (IMMUNIZATIONS if from immunization package)
; PROV - Provider
;
NEW DDATA
S DDATA=$P($G(^DD(90509.4,.02,0)),U,3)
I DDATA[":MAIL" D
. I NTYP="LETTER" S NTYP="MAIL"
NEW DIC,DIE,X,DLAYGO,IEN,Y,PTPF,BQIUPD,BQIEXT,RMM,D
S DIC="^BQI(90509.4,",DIE=DIC,X=DFN
S DLAYGO=90509.4,DIC(0)="L",DIC("P")=DLAYGO
K DO,DD D FILE^DICN
S IEN=+Y I Y=-1 Q
S PTPF=$$GET1^DIQ(9000001,DFN_",",4002,"E")
S BQIUPD(90509.4,IEN_",",.05)=DUZ,BQIUPD(90509.4,IEN_",",.04)=$$NOW^XLFDT()
S BQIEXT(90509.4,IEN_",",.02)=PTPF,BQIEXT(90509.4,IEN_",",.03)=NTYP
S BQIUPD(90509.4,IEN_",",.06)=$G(TIUP),BQIUPD(90509.4,IEN_",",.07)=$G(PWHN)
S BQIUPD(90509.4,IEN_",",.09)=$G(REM),BQIUPD(90509.4,IEN_",",.08)=$G(PROV)
I REM="IMMUNIZATIONS" D IMM(DFN)
I REM'="",REM'="IMMUNIZATIONS" D DUE(DFN,REM)
I $D(BQIEXT) D FILE^DIE("E","BQIEXT","ERROR")
I $D(BQIUPD) D FILE^DIE("","BQIUPD","ERROR")
Q
;
IMM(BIDFN) ;EP - Expand immunization reminders
NEW FRN,IT,RCDUE,OVDUE,REMDUE
D IMM^BQIRMIZ(BIDFN)
I '$D(^BQI(90509.4,IEN,1,0)) S ^BQI(90509.4,IEN,1,0)="^90509.41^^"
S FRN=""
F S FRN=$O(^BIPDUE("B",BIDFN,FRN)) Q:FRN="" D
. S IT=$P(^BIPDUE(FRN,0),"^",2)
. S RCDUE=$P(^BIPDUE(FRN,0),"^",4),OVDUE=$P(^(0),"^",5)
. S REMDUE=$S(RCDUE'="":RCDUE,1:OVDUE)
. S BTYP=$P(^AUTTIMM(IT,0),"^",2)
. NEW DA,IENS
. S DA(1)=IEN,X=BTYP,DIC="^BQI(90509.4,"_DA(1)_",1,",DIC(0)="L",DLAYGO=90509.41
. D ^DIC S DA=+Y
. S IENS=$$IENS^DILF(.DA),BQIUPD(90509.41,IENS,.02)=REMDUE
I $D(BQIUPD) D FILE^DIE("","BQIUPD","ERROR")
Q
;
DUE(BQDFN,REM) ;EP - Reminders from ICARE PATIENT file
NEW RN,DUE
S RN=$O(^BQIPAT(BQDFN,40,"B",REM,"")) I RN="" Q
S DUE=$P(^BQIPAT(BQDFN,40,RN,0),U,4)
S BQIUPD(90509.4,IEN_",",.1)=DUE
Q
;
COMP(BQDFN,REM) ;EP - Set completion
NEW RN,DUE,RMN,BQIUPD,NNIEN,IMN,LIMM,IMIEN,NDUE
S RN=$O(^BQIPAT(BQDFN,40,"B",REM,"")) I RN'="" D
. S DUE=$P(^BQIPAT(BQDFN,40,RN,0),U,4),LIMM=$P(^(0),U,2)
. ;
. S RMN=$O(^BQI(90509.4,"C",BQDFN,REM,""),-1) I RMN="" Q
. S NDUE=$$GET1^DIQ(90509.4,RMN_",",.1,"I")
. I DUE'="",NDUE'=DUE D
.. I LIMM'="",LIMM>NDUE S BQIUPD(90509.4,RMN_",",.11)=LIMM
;
I $D(BQIUPD) D FILE^DIE("I","BQIUPD","ERROR")
I '$D(^BQI(90509.4,"C",BQDFN,"IMMUNIZATIONS")) Q
;
S NNIEN=""
F S NNIEN=$O(^BQI(90509.4,"C",BQDFN,"IMMUNIZATIONS",NNIEN)) Q:NNIEN="" D
. S RMM=""
. F S RMM=$O(^BQI(90509.4,NNIEN,1,"B",RMM)) Q:RMM="" D
.. S RMN=$O(^BQI(90509.4,NNIEN,1,"B",RMM,""))
.. S IMNM=$P(^BQI(90509.4,NNIEN,1,RMN,0),"^",1),DUE=$P(^(0),"^",2)
.. S IMIEN=$O(^AUTTIMM("AC",IMNM,"")) I IMIEN="" Q
.. S LIMM=$$LIMM^BQIREM(BQDFN,IMIEN),LIMM=$P(LIMM,"^",1)
.. NEW DA,IENS
.. S DA(1)=NNIEN,DA=RMN,IENS=$$IENS^DILF(.DA)
.. I LIMM>DUE S BQIUPD(90509.41,IENS,.03)=LIMM
I $D(BQIUPD) D FILE^DIE("I","BQIUPD","ERROR")
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(BQII),$D(DATA) S BQII=BQII+1,@DATA@(BQII)=$C(31)
Q
;
UPD(DATA,OWNR,PLIEN,BQINOTT,TIUDA,REMCODE,DFN) ; EP - BQI UPDATE REMINDER NOTIFY
NEW UID
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQINOTUP",UID))
K @DATA
;
S BQII=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQINOTR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
S @DATA@(BQII)="I00010RESULT^T01024MSG"_$C(30)
S BQINOTT=$G(BQINOTT,""),TIUDA=$G(TIUDA,""),REMCODE=$G(REMCODE,"")
I $G(OWNR),$G(PLIEN) D
. S PRN=$O(^BQICARE(OWNR,1,PLIEN,10,"B","PROV","")) I PRN="" S PROV="" Q
. S PROV=$P(^BQICARE(OWNR,1,PLIEN,10,PRN,0),U,3)
K ERROR
D LOG(DFN,BQINOTT,TIUDA,$G(IMML),$G(PWHN),REMCODE,PROV)
S RESULT=1_U
I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR","1","TEXT","1"))
S BQII=BQII+1,@DATA@(BQII)=RESULT_$C(30)
S BQII=BQII+1,@DATA@(BQII)=$C(31)
Q
;
REF(DATA,OWNR,PLIEN,REMCODE,DFN) ;EP - BQI REFRESH REMINDER NOTIFY
NEW UID
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
S DATA=$NA(^TMP("BQINOTRF",UID))
K @DATA
S HEADR="I00010DFN^",VALUE=DFN_U
;
S BQII=0
NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQINOTR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
S GIEN=0,CRN=$O(^BQI(90506.5,"C","RE","")),RIEN=REMCODE
F S GIEN=$O(^BQI(90506.5,CRN,10,GIEN)) Q:'GIEN D
. S DIS=$P(^BQI(90506.5,CRN,10,GIEN,0),U,5),STVCD=$P(^(0),U,1)
. I $P(^BQI(90506.5,CRN,10,GIEN,0),U,9)=1 S IFL=1 Q
. S BQDTFRM=$P(^BQI(90506.5,CRN,10,GIEN,0),U,8) S:BQDTFRM="" BQDTFRM="S"
. S RES=$$FND^BQICMUTL(CRN,GIEN,DFN)
. I 'RES S HDR="T00025"_STVCD,VAL="" Q
. I DIS="" S HDR="T00025"_STVCD,VAL=RES
. I DIS="D" D
.. S HDR="T00025"_STVCD
.. S VAL=$S(BQDTFRM="S":$$FMTE^BQIUL1($P(RES,U,2)),1:$$FMTMDY^BQIUL1($P(RES,U,2)))
. I DIS="R" S HDR="T00025"_STVCD,VAL=$P(RES,U,2)
. I DIS="B" D
.. S HDR="T00025"_STVCD
.. S VAL=$S(BQDTFRM="S":$$FMTE^BQIUL1($P(RES,U,2)),1:$$FMTMDY^BQIUL1($P(RES,U,2)))_" "_$P(RES,U,3)
. S HEADR=HEADR_HDR_U
. S VALUE=VALUE_VAL_U
S HEADR=$$TKO^BQIUL1(HEADR,"^")
S VALUE=$$TKO^BQIUL1(VALUE,"^")
;
S @DATA@(BQII)=HEADR_$C(30)
S BQII=BQII+1,@DATA@(BQII)=VALUE_$C(30)
S BQII=BQII+1,@DATA@(BQII)=$C(31)
Q
;
LNOT(BQIDFN) ;EP - Get the last patient's notification information
NEW DATE,NIEN,TYPE,IEN
I $O(^BQI(90509.4,"D",BQIDFN,""))="" Q ""
S DATE=$O(^BQI(90509.4,"D",BQIDFN,""),-1) I DATE="" Q ""
S NIEN=$O(^BQI(90509.4,"D",BQIDFN,DATE,""),-1) I NIEN="" Q ""
S TYPE=$P($G(^BQI(90509.4,NIEN,0)),"^",9) I TYPE="" Q ""
I TYPE["IMMUNIZATION" Q $$FMTE^XLFDT(DATE,"5Z")_" ("_TYPE_")"
I TYPE="PWH" Q $$FMTE^XLFDT(DATE,"5Z")_" (Patient Wellness)"
S IEN=""
I TYPE["_" S IEN=$O(^BQI(90506.1,"B",TYPE,IEN))
I IEN'="" S TYPE=$P(^BQI(90506.1,IEN,0),"^",3)
Q $$FMTE^XLFDT(DATE,"5Z")_$S(TYPE'="":" ("_TYPE_")",1:"")
;
LIMM(BQIDFN) ;EP - Get the last immunization notification for a patient
NEW TYPE,NIEN,DATE
S TYPE="IMMUNIZATIONS"
I $O(^BQI(90509.4,"C",BQIDFN,"IMMUNIZATIONS",""))="" Q ""
S NIEN=$O(^BQI(90509.4,"C",BQIDFN,"IMMUNIZATIONS",""),-1) I NIEN="" Q ""
S DATE=$P(^BQI(90509.4,NIEN,0),"^",4)\1
Q $$FMTE^XLFDT(DATE,"5Z")
BQINOTR ;GDIT/HS/ALA-Reminder Notification Log ; 03 Jan 2013 12:21 PM
+1 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
+2 ;
LOG(DFN,NTYP,TIUP,IMML,PWHN,REM,PROV) ;PEP - Log a notification entry
+1 ; Input
+2 ; DFN - Patient IEN
+3 ; NTYP - Notification Type LETTER, EMAIL, PHONE
+4 ; TIUP - TIU note pointer
+5 ; IMML - Immunization letter pointer
+6 ; PWHN - Patient Wellness Handout pointer (no longer needed)
+7 ; REM - Reminder (IMMUNIZATIONS if from immunization package)
+8 ; PROV - Provider
+9 ;
+10 NEW DDATA
+11 SET DDATA=$PIECE($GET(^DD(90509.4,.02,0)),U,3)
+12 IF DDATA[":MAIL"
Begin DoDot:1
+13 IF NTYP="LETTER"
SET NTYP="MAIL"
End DoDot:1
+14 NEW DIC,DIE,X,DLAYGO,IEN,Y,PTPF,BQIUPD,BQIEXT,RMM,D
+15 SET DIC="^BQI(90509.4,"
SET DIE=DIC
SET X=DFN
+16 SET DLAYGO=90509.4
SET DIC(0)="L"
SET DIC("P")=DLAYGO
+17 KILL DO,DD
DO FILE^DICN
+18 SET IEN=+Y
IF Y=-1
QUIT
+19 SET PTPF=$$GET1^DIQ(9000001,DFN_",",4002,"E")
+20 SET BQIUPD(90509.4,IEN_",",.05)=DUZ
SET BQIUPD(90509.4,IEN_",",.04)=$$NOW^XLFDT()
+21 SET BQIEXT(90509.4,IEN_",",.02)=PTPF
SET BQIEXT(90509.4,IEN_",",.03)=NTYP
+22 SET BQIUPD(90509.4,IEN_",",.06)=$GET(TIUP)
SET BQIUPD(90509.4,IEN_",",.07)=$GET(PWHN)
+23 SET BQIUPD(90509.4,IEN_",",.09)=$GET(REM)
SET BQIUPD(90509.4,IEN_",",.08)=$GET(PROV)
+24 IF REM="IMMUNIZATIONS"
DO IMM(DFN)
+25 IF REM'=""
IF REM'="IMMUNIZATIONS"
DO DUE(DFN,REM)
+26 IF $DATA(BQIEXT)
DO FILE^DIE("E","BQIEXT","ERROR")
+27 IF $DATA(BQIUPD)
DO FILE^DIE("","BQIUPD","ERROR")
+28 QUIT
+29 ;
IMM(BIDFN) ;EP - Expand immunization reminders
+1 NEW FRN,IT,RCDUE,OVDUE,REMDUE
+2 DO IMM^BQIRMIZ(BIDFN)
+3 IF '$DATA(^BQI(90509.4,IEN,1,0))
SET ^BQI(90509.4,IEN,1,0)="^90509.41^^"
+4 SET FRN=""
+5 FOR
SET FRN=$ORDER(^BIPDUE("B",BIDFN,FRN))
IF FRN=""
QUIT
Begin DoDot:1
+6 SET IT=$PIECE(^BIPDUE(FRN,0),"^",2)
+7 SET RCDUE=$PIECE(^BIPDUE(FRN,0),"^",4)
SET OVDUE=$PIECE(^(0),"^",5)
+8 SET REMDUE=$SELECT(RCDUE'="":RCDUE,1:OVDUE)
+9 SET BTYP=$PIECE(^AUTTIMM(IT,0),"^",2)
+10 NEW DA,IENS
+11 SET DA(1)=IEN
SET X=BTYP
SET DIC="^BQI(90509.4,"_DA(1)_",1,"
SET DIC(0)="L"
SET DLAYGO=90509.41
+12 DO ^DIC
SET DA=+Y
+13 SET IENS=$$IENS^DILF(.DA)
SET BQIUPD(90509.41,IENS,.02)=REMDUE
End DoDot:1
+14 IF $DATA(BQIUPD)
DO FILE^DIE("","BQIUPD","ERROR")
+15 QUIT
+16 ;
DUE(BQDFN,REM) ;EP - Reminders from ICARE PATIENT file
+1 NEW RN,DUE
+2 SET RN=$ORDER(^BQIPAT(BQDFN,40,"B",REM,""))
IF RN=""
QUIT
+3 SET DUE=$PIECE(^BQIPAT(BQDFN,40,RN,0),U,4)
+4 SET BQIUPD(90509.4,IEN_",",.1)=DUE
+5 QUIT
+6 ;
COMP(BQDFN,REM) ;EP - Set completion
+1 NEW RN,DUE,RMN,BQIUPD,NNIEN,IMN,LIMM,IMIEN,NDUE
+2 SET RN=$ORDER(^BQIPAT(BQDFN,40,"B",REM,""))
IF RN'=""
Begin DoDot:1
+3 SET DUE=$PIECE(^BQIPAT(BQDFN,40,RN,0),U,4)
SET LIMM=$PIECE(^(0),U,2)
+4 ;
+5 SET RMN=$ORDER(^BQI(90509.4,"C",BQDFN,REM,""),-1)
IF RMN=""
QUIT
+6 SET NDUE=$$GET1^DIQ(90509.4,RMN_",",.1,"I")
+7 IF DUE'=""
IF NDUE'=DUE
Begin DoDot:2
+8 IF LIMM'=""
IF LIMM>NDUE
SET BQIUPD(90509.4,RMN_",",.11)=LIMM
End DoDot:2
End DoDot:1
+9 ;
+10 IF $DATA(BQIUPD)
DO FILE^DIE("I","BQIUPD","ERROR")
+11 IF '$DATA(^BQI(90509.4,"C",BQDFN,"IMMUNIZATIONS"))
QUIT
+12 ;
+13 SET NNIEN=""
+14 FOR
SET NNIEN=$ORDER(^BQI(90509.4,"C",BQDFN,"IMMUNIZATIONS",NNIEN))
IF NNIEN=""
QUIT
Begin DoDot:1
+15 SET RMM=""
+16 FOR
SET RMM=$ORDER(^BQI(90509.4,NNIEN,1,"B",RMM))
IF RMM=""
QUIT
Begin DoDot:2
+17 SET RMN=$ORDER(^BQI(90509.4,NNIEN,1,"B",RMM,""))
+18 SET IMNM=$PIECE(^BQI(90509.4,NNIEN,1,RMN,0),"^",1)
SET DUE=$PIECE(^(0),"^",2)
+19 SET IMIEN=$ORDER(^AUTTIMM("AC",IMNM,""))
IF IMIEN=""
QUIT
+20 SET LIMM=$$LIMM^BQIREM(BQDFN,IMIEN)
SET LIMM=$PIECE(LIMM,"^",1)
+21 NEW DA,IENS
+22 SET DA(1)=NNIEN
SET DA=RMN
SET IENS=$$IENS^DILF(.DA)
+23 IF LIMM>DUE
SET BQIUPD(90509.41,IENS,.03)=LIMM
End DoDot:2
End DoDot:1
+24 IF $DATA(BQIUPD)
DO FILE^DIE("I","BQIUPD","ERROR")
+25 QUIT
+26 ;
ERR ;
+1 DO ^%ZTER
+2 NEW Y,ERRDTM
+3 SET Y=$$NOW^XLFDT()
XECUTE ^DD("DD")
SET ERRDTM=Y
+4 SET BMXSEC="Recording that an error occurred at "_ERRDTM
+5 IF $DATA(BQII)
IF $DATA(DATA)
SET BQII=BQII+1
SET @DATA@(BQII)=$CHAR(31)
+6 QUIT
+7 ;
UPD(DATA,OWNR,PLIEN,BQINOTT,TIUDA,REMCODE,DFN) ; EP - BQI UPDATE REMINDER NOTIFY
+1 NEW UID
+2 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+3 SET DATA=$NAME(^TMP("BQINOTUP",UID))
+4 KILL @DATA
+5 ;
+6 SET BQII=0
+7 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQINOTR D UNWIND^%ZTER"
+8 SET @DATA@(BQII)="I00010RESULT^T01024MSG"_$CHAR(30)
+9 SET BQINOTT=$GET(BQINOTT,"")
SET TIUDA=$GET(TIUDA,"")
SET REMCODE=$GET(REMCODE,"")
+10 IF $GET(OWNR)
IF $GET(PLIEN)
Begin DoDot:1
+11 SET PRN=$ORDER(^BQICARE(OWNR,1,PLIEN,10,"B","PROV",""))
IF PRN=""
SET PROV=""
QUIT
+12 SET PROV=$PIECE(^BQICARE(OWNR,1,PLIEN,10,PRN,0),U,3)
End DoDot:1
+13 KILL ERROR
+14 DO LOG(DFN,BQINOTT,TIUDA,$GET(IMML),$GET(PWHN),REMCODE,PROV)
+15 SET RESULT=1_U
+16 IF $DATA(ERROR)>0
SET RESULT=-1_U_$GET(ERROR("DIERR","1","TEXT","1"))
+17 SET BQII=BQII+1
SET @DATA@(BQII)=RESULT_$CHAR(30)
+18 SET BQII=BQII+1
SET @DATA@(BQII)=$CHAR(31)
+19 QUIT
+20 ;
REF(DATA,OWNR,PLIEN,REMCODE,DFN) ;EP - BQI REFRESH REMINDER NOTIFY
+1 NEW UID
+2 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+3 SET DATA=$NAME(^TMP("BQINOTRF",UID))
+4 KILL @DATA
+5 SET HEADR="I00010DFN^"
SET VALUE=DFN_U
+6 ;
+7 SET BQII=0
+8 ; SAC 2006 2.2.3.3.2
NEW $ESTACK,$ETRAP
SET $ETRAP="D ERR^BQINOTR D UNWIND^%ZTER"
+9 SET GIEN=0
SET CRN=$ORDER(^BQI(90506.5,"C","RE",""))
SET RIEN=REMCODE
+10 FOR
SET GIEN=$ORDER(^BQI(90506.5,CRN,10,GIEN))
IF 'GIEN
QUIT
Begin DoDot:1
+11 SET DIS=$PIECE(^BQI(90506.5,CRN,10,GIEN,0),U,5)
SET STVCD=$PIECE(^(0),U,1)
+12 IF $PIECE(^BQI(90506.5,CRN,10,GIEN,0),U,9)=1
SET IFL=1
QUIT
+13 SET BQDTFRM=$PIECE(^BQI(90506.5,CRN,10,GIEN,0),U,8)
IF BQDTFRM=""
SET BQDTFRM="S"
+14 SET RES=$$FND^BQICMUTL(CRN,GIEN,DFN)
+15 IF 'RES
SET HDR="T00025"_STVCD
SET VAL=""
QUIT
+16 IF DIS=""
SET HDR="T00025"_STVCD
SET VAL=RES
+17 IF DIS="D"
Begin DoDot:2
+18 SET HDR="T00025"_STVCD
+19 SET VAL=$SELECT(BQDTFRM="S":$$FMTE^BQIUL1($PIECE(RES,U,2)),1:$$FMTMDY^BQIUL1($PIECE(RES,U,2)))
End DoDot:2
+20 IF DIS="R"
SET HDR="T00025"_STVCD
SET VAL=$PIECE(RES,U,2)
+21 IF DIS="B"
Begin DoDot:2
+22 SET HDR="T00025"_STVCD
+23 SET VAL=$SELECT(BQDTFRM="S":$$FMTE^BQIUL1($PIECE(RES,U,2)),1:$$FMTMDY^BQIUL1($PIECE(RES,U,2)))_" "_$PIECE(RES,U,3)
End DoDot:2
+24 SET HEADR=HEADR_HDR_U
+25 SET VALUE=VALUE_VAL_U
End DoDot:1
+26 SET HEADR=$$TKO^BQIUL1(HEADR,"^")
+27 SET VALUE=$$TKO^BQIUL1(VALUE,"^")
+28 ;
+29 SET @DATA@(BQII)=HEADR_$CHAR(30)
+30 SET BQII=BQII+1
SET @DATA@(BQII)=VALUE_$CHAR(30)
+31 SET BQII=BQII+1
SET @DATA@(BQII)=$CHAR(31)
+32 QUIT
+33 ;
LNOT(BQIDFN) ;EP - Get the last patient's notification information
+1 NEW DATE,NIEN,TYPE,IEN
+2 IF $ORDER(^BQI(90509.4,"D",BQIDFN,""))=""
QUIT ""
+3 SET DATE=$ORDER(^BQI(90509.4,"D",BQIDFN,""),-1)
IF DATE=""
QUIT ""
+4 SET NIEN=$ORDER(^BQI(90509.4,"D",BQIDFN,DATE,""),-1)
IF NIEN=""
QUIT ""
+5 SET TYPE=$PIECE($GET(^BQI(90509.4,NIEN,0)),"^",9)
IF TYPE=""
QUIT ""
+6 IF TYPE["IMMUNIZATION"
QUIT $$FMTE^XLFDT(DATE,"5Z")_" ("_TYPE_")"
+7 IF TYPE="PWH"
QUIT $$FMTE^XLFDT(DATE,"5Z")_" (Patient Wellness)"
+8 SET IEN=""
+9 IF TYPE["_"
SET IEN=$ORDER(^BQI(90506.1,"B",TYPE,IEN))
+10 IF IEN'=""
SET TYPE=$PIECE(^BQI(90506.1,IEN,0),"^",3)
+11 QUIT $$FMTE^XLFDT(DATE,"5Z")_$SELECT(TYPE'="":" ("_TYPE_")",1:"")
+12 ;
LIMM(BQIDFN) ;EP - Get the last immunization notification for a patient
+1 NEW TYPE,NIEN,DATE
+2 SET TYPE="IMMUNIZATIONS"
+3 IF $ORDER(^BQI(90509.4,"C",BQIDFN,"IMMUNIZATIONS",""))=""
QUIT ""
+4 SET NIEN=$ORDER(^BQI(90509.4,"C",BQIDFN,"IMMUNIZATIONS",""),-1)
IF NIEN=""
QUIT ""
+5 SET DATE=$PIECE(^BQI(90509.4,NIEN,0),"^",4)\1
+6 QUIT $$FMTE^XLFDT(DATE,"5Z")