BQIUL4 ;GDHS/HCD/ALA-Miscellaneous BQI utilities ; 21 Jul 2016 8:41 AM
;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
;
;
NNAD(DFN,NUM) ;EP -- Get patient's next appt date
;Input
; DFN - Patient internal entry number
; NUM - Number of appts
NEW NAPTM,CNT
S NAPTM=$$NOW^XLFDT(),RESULT="",CNT=0
F S NAPTM=$O(^DPT(DFN,"S",NAPTM)) Q:NAPTM="" D
. I $P(^DPT(DFN,"S",NAPTM,0),"^",2)'="" Q
. S CNT=CNT+1 I CNT>NUM Q
. S RESULT=RESULT_$$FMTMDY^BQIUL1(NAPTM\1)_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
NNAPT(DFN,NUM) ;EP -- Get patient's next appt
;Input
; DFN - Patient internal entry number
NEW NAPTM
S NAPTM=$$NOW^XLFDT()
Q $O(^DPT(DFN,"S",NAPTM))
;
NNAC(DFN,NUM) ;EP -- Get patient's next appt date's clinic
;Input
; DFN - Patient internal entry number
;
NEW NAPTM,IENS,DA,NAN,CSTCD,CST,CNT
S NAPTM=$$NOW^XLFDT(),RESULT="",CNT=0
F S NAPTM=$O(^DPT(DFN,"S",NAPTM)) Q:NAPTM="" D
. I $P(^DPT(DFN,"S",NAPTM,0),"^",2)'="" Q
. S CNT=CNT+1 I CNT>NUM Q
. S DA(1)=DFN,DA=NAPTM,IENS=$$IENS^DILF(.DA)
. S NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
. I NAN="" Q
. S CST=$$GET1^DIQ(44,NAN_",",8,"I"),CSTCD=""
. I CST'="" S CSTCD=$$GET1^DIQ(40.7,CST_",",1,"E")
. S RESULT=RESULT_$$GET1^DIQ(2.98,IENS,.01,"E")_" "_CSTCD_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
NNAPV(DFN,NUM) ;EP -- Get patient's next appt provider
;Input
; DFN - Patient internal entry number
;
NEW NAPTM,IENS,DA,NAN,CSTCD,CST,PRNAME,PRNM,PRN
S NAPTM=$$NOW^XLFDT(),RESULT="",CNT=0
F S NAPTM=$O(^DPT(DFN,"S",NAPTM)) Q:NAPTM="" D
. I $P(^DPT(DFN,"S",NAPTM,0),"^",2)'="" Q
. S CNT=CNT+1 I CNT>NUM Q
. S DA(1)=DFN,DA=NAPTM,IENS=$$IENS^DILF(.DA)
. S NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
. I NAN="" Q
. S PRNAME=$$GET1^DIQ(44,NAN_",",16,"E")
. I PRNAME="" D
.. S PRN=0
.. F S PRN=$O(^SC(NAN,"PR",PRN)) Q:'PRN D
... I $P($G(^SC(NAN,"PR",PRN,0)),U,2)=1 D
.... S PRNM=$P($G(^SC(NAN,"PR",PRN,0)),U,1)
.... S PRNAME=$$GET1^DIQ(200,PRNM_",",.01,"E")
. S RESULT=RESULT_PRNAME_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
LNAD(DFN,NUM) ;EP -- Get patient's last # appts date
;Input
; DFN - Patient internal entry number
; NUM - Number of appts
NEW NAPTM,CNT,QFL
S NAPTM=$$NOW^XLFDT(),RESULT="",CNT=0,QFL=0
F S NAPTM=$O(^DPT(DFN,"S",NAPTM),-1) Q:NAPTM="" D Q:QFL
. I $P(^DPT(DFN,"S",NAPTM,0),"^",2)'="" Q
. S CNT=CNT+1 I CNT>NUM S QFL=1 Q
. S RESULT=RESULT_$$FMTMDY^BQIUL1(NAPTM\1)_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
LNAC(DFN,NUM) ;EP -- Get patient's last # appt date's clinic
;Input
; DFN - Patient internal entry number
; NUM - Number of appts
;
NEW NAPTM,IENS,DA,NAN,CSTCD,CST,CNT,QFL
S NAPTM=$$NOW^XLFDT(),RESULT="",CNT=0,QFL=0
F S NAPTM=$O(^DPT(DFN,"S",NAPTM),-1) Q:NAPTM="" D Q:QFL
. I $P(^DPT(DFN,"S",NAPTM,0),"^",2)'="" Q
. S CNT=CNT+1 I CNT>NUM S QFL=1 Q
. S DA(1)=DFN,DA=NAPTM,IENS=$$IENS^DILF(.DA)
. S NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
. I NAN="" Q
. S CST=$$GET1^DIQ(44,NAN_",",8,"I"),CSTCD=""
. I CST'="" S CSTCD=$$GET1^DIQ(40.7,CST_",",1,"E")
. S RESULT=RESULT_$$GET1^DIQ(2.98,IENS,.01,"E")_" "_CSTCD_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
MADD(USR,PANEL,DFN) ;EP -- Get who added patient to panel date/time
;Input
; DFN - Patient internal entry number
; USR - User internal entry number
; PANEL - Panel internal entry number
NEW DA,IENS,WHO
S WHO=""
I $G(USR)="" Q WHO
I $G(PANEL)="" Q WHO
I $G(DFN)="" Q WHO
S DA(2)=USR,DA(1)=PANEL,DA=DFN,IENS=$$IENS^DILF(.DA)
S WHO=$$GET1^DIQ(90505.04,IENS,.03,"I")
I WHO'="" S WHO=$P($G(^VA(200,WHO,0)),"^",1)
Q WHO
;
LNVD(DFN,NUM) ;EP - Last # of visits' dates
NEW RVDT
S RESULT="",CNT=0,QFL=0,RVDT=""
F S RVDT=$O(^AUPNVSIT("AA",DFN,RVDT)) Q:RVDT=""!(QFL) D
. S VIEN=""
. S VIEN=$O(^AUPNVSIT("AA",DFN,RVDT,VIEN),-1) Q:VIEN="" D Q:QFL
.. S VSDTM=$P($G(^AUPNVSIT(VIEN,0)),"^",1)\1 I VSDTM=0 Q
.. S CNT=CNT+1 I CNT>NUM S QFL=1 Q
.. S RESULT=RESULT_$$FMTMDY^BQIUL1(VSDTM)_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
;
LNVC(DFN,NUM) ;EP - Last # of visits' clinics
NEW RVDT
S RESULT="",CNT=0,QFL=0,RVDT=""
F S RVDT=$O(^AUPNVSIT("AA",DFN,RVDT)) Q:RVDT=""!(QFL) D
. S VIEN=""
. S VIEN=$O(^AUPNVSIT("AA",DFN,RVDT,VIEN),-1) Q:VIEN="" D Q:QFL
.. S VSDTM=$P($G(^AUPNVSIT(VIEN,0)),"^",1)\1 I VSDTM=0 Q
.. S CNT=CNT+1 I CNT>NUM S QFL=1 Q
. S RESULT=RESULT_$$GET1^DIQ(9000010,VIEN_",",.22,"E")_$C(13)_$C(10)
Q $$TKO^BQIUL1(RESULT,$C(13)_$C(10))
BQIUL4 ;GDHS/HCD/ALA-Miscellaneous BQI utilities ; 21 Jul 2016 8:41 AM
+1 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
+2 ;
+3 ;
NNAD(DFN,NUM) ;EP -- Get patient's next appt date
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ; NUM - Number of appts
+4 NEW NAPTM,CNT
+5 SET NAPTM=$$NOW^XLFDT()
SET RESULT=""
SET CNT=0
+6 FOR
SET NAPTM=$ORDER(^DPT(DFN,"S",NAPTM))
IF NAPTM=""
QUIT
Begin DoDot:1
+7 IF $PIECE(^DPT(DFN,"S",NAPTM,0),"^",2)'=""
QUIT
+8 SET CNT=CNT+1
IF CNT>NUM
QUIT
+9 SET RESULT=RESULT_$$FMTMDY^BQIUL1(NAPTM\1)_$CHAR(13)_$CHAR(10)
End DoDot:1
+10 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+11 ;
NNAPT(DFN,NUM) ;EP -- Get patient's next appt
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW NAPTM
+4 SET NAPTM=$$NOW^XLFDT()
+5 QUIT $ORDER(^DPT(DFN,"S",NAPTM))
+6 ;
NNAC(DFN,NUM) ;EP -- Get patient's next appt date's clinic
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ;
+4 NEW NAPTM,IENS,DA,NAN,CSTCD,CST,CNT
+5 SET NAPTM=$$NOW^XLFDT()
SET RESULT=""
SET CNT=0
+6 FOR
SET NAPTM=$ORDER(^DPT(DFN,"S",NAPTM))
IF NAPTM=""
QUIT
Begin DoDot:1
+7 IF $PIECE(^DPT(DFN,"S",NAPTM,0),"^",2)'=""
QUIT
+8 SET CNT=CNT+1
IF CNT>NUM
QUIT
+9 SET DA(1)=DFN
SET DA=NAPTM
SET IENS=$$IENS^DILF(.DA)
+10 SET NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
+11 IF NAN=""
QUIT
+12 SET CST=$$GET1^DIQ(44,NAN_",",8,"I")
SET CSTCD=""
+13 IF CST'=""
SET CSTCD=$$GET1^DIQ(40.7,CST_",",1,"E")
+14 SET RESULT=RESULT_$$GET1^DIQ(2.98,IENS,.01,"E")_" "_CSTCD_$CHAR(13)_$CHAR(10)
End DoDot:1
+15 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+16 ;
NNAPV(DFN,NUM) ;EP -- Get patient's next appt provider
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ;
+4 NEW NAPTM,IENS,DA,NAN,CSTCD,CST,PRNAME,PRNM,PRN
+5 SET NAPTM=$$NOW^XLFDT()
SET RESULT=""
SET CNT=0
+6 FOR
SET NAPTM=$ORDER(^DPT(DFN,"S",NAPTM))
IF NAPTM=""
QUIT
Begin DoDot:1
+7 IF $PIECE(^DPT(DFN,"S",NAPTM,0),"^",2)'=""
QUIT
+8 SET CNT=CNT+1
IF CNT>NUM
QUIT
+9 SET DA(1)=DFN
SET DA=NAPTM
SET IENS=$$IENS^DILF(.DA)
+10 SET NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
+11 IF NAN=""
QUIT
+12 SET PRNAME=$$GET1^DIQ(44,NAN_",",16,"E")
+13 IF PRNAME=""
Begin DoDot:2
+14 SET PRN=0
+15 FOR
SET PRN=$ORDER(^SC(NAN,"PR",PRN))
IF 'PRN
QUIT
Begin DoDot:3
+16 IF $PIECE($GET(^SC(NAN,"PR",PRN,0)),U,2)=1
Begin DoDot:4
+17 SET PRNM=$PIECE($GET(^SC(NAN,"PR",PRN,0)),U,1)
+18 SET PRNAME=$$GET1^DIQ(200,PRNM_",",.01,"E")
End DoDot:4
End DoDot:3
End DoDot:2
+19 SET RESULT=RESULT_PRNAME_$CHAR(13)_$CHAR(10)
End DoDot:1
+20 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+21 ;
LNAD(DFN,NUM) ;EP -- Get patient's last # appts date
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ; NUM - Number of appts
+4 NEW NAPTM,CNT,QFL
+5 SET NAPTM=$$NOW^XLFDT()
SET RESULT=""
SET CNT=0
SET QFL=0
+6 FOR
SET NAPTM=$ORDER(^DPT(DFN,"S",NAPTM),-1)
IF NAPTM=""
QUIT
Begin DoDot:1
+7 IF $PIECE(^DPT(DFN,"S",NAPTM,0),"^",2)'=""
QUIT
+8 SET CNT=CNT+1
IF CNT>NUM
SET QFL=1
QUIT
+9 SET RESULT=RESULT_$$FMTMDY^BQIUL1(NAPTM\1)_$CHAR(13)_$CHAR(10)
End DoDot:1
IF QFL
QUIT
+10 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+11 ;
LNAC(DFN,NUM) ;EP -- Get patient's last # appt date's clinic
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ; NUM - Number of appts
+4 ;
+5 NEW NAPTM,IENS,DA,NAN,CSTCD,CST,CNT,QFL
+6 SET NAPTM=$$NOW^XLFDT()
SET RESULT=""
SET CNT=0
SET QFL=0
+7 FOR
SET NAPTM=$ORDER(^DPT(DFN,"S",NAPTM),-1)
IF NAPTM=""
QUIT
Begin DoDot:1
+8 IF $PIECE(^DPT(DFN,"S",NAPTM,0),"^",2)'=""
QUIT
+9 SET CNT=CNT+1
IF CNT>NUM
SET QFL=1
QUIT
+10 SET DA(1)=DFN
SET DA=NAPTM
SET IENS=$$IENS^DILF(.DA)
+11 SET NAN=$$GET1^DIQ(2.98,IENS,.01,"I")
+12 IF NAN=""
QUIT
+13 SET CST=$$GET1^DIQ(44,NAN_",",8,"I")
SET CSTCD=""
+14 IF CST'=""
SET CSTCD=$$GET1^DIQ(40.7,CST_",",1,"E")
+15 SET RESULT=RESULT_$$GET1^DIQ(2.98,IENS,.01,"E")_" "_CSTCD_$CHAR(13)_$CHAR(10)
End DoDot:1
IF QFL
QUIT
+16 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+17 ;
MADD(USR,PANEL,DFN) ;EP -- Get who added patient to panel date/time
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ; USR - User internal entry number
+4 ; PANEL - Panel internal entry number
+5 NEW DA,IENS,WHO
+6 SET WHO=""
+7 IF $GET(USR)=""
QUIT WHO
+8 IF $GET(PANEL)=""
QUIT WHO
+9 IF $GET(DFN)=""
QUIT WHO
+10 SET DA(2)=USR
SET DA(1)=PANEL
SET DA=DFN
SET IENS=$$IENS^DILF(.DA)
+11 SET WHO=$$GET1^DIQ(90505.04,IENS,.03,"I")
+12 IF WHO'=""
SET WHO=$PIECE($GET(^VA(200,WHO,0)),"^",1)
+13 QUIT WHO
+14 ;
LNVD(DFN,NUM) ;EP - Last # of visits' dates
+1 NEW RVDT
+2 SET RESULT=""
SET CNT=0
SET QFL=0
SET RVDT=""
+3 FOR
SET RVDT=$ORDER(^AUPNVSIT("AA",DFN,RVDT))
IF RVDT=""!(QFL)
QUIT
Begin DoDot:1
+4 SET VIEN=""
+5 SET VIEN=$ORDER(^AUPNVSIT("AA",DFN,RVDT,VIEN),-1)
IF VIEN=""
QUIT
Begin DoDot:2
+6 SET VSDTM=$PIECE($GET(^AUPNVSIT(VIEN,0)),"^",1)\1
IF VSDTM=0
QUIT
+7 SET CNT=CNT+1
IF CNT>NUM
SET QFL=1
QUIT
+8 SET RESULT=RESULT_$$FMTMDY^BQIUL1(VSDTM)_$CHAR(13)_$CHAR(10)
End DoDot:2
IF QFL
QUIT
End DoDot:1
+9 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))
+10 ;
LNVC(DFN,NUM) ;EP - Last # of visits' clinics
+1 NEW RVDT
+2 SET RESULT=""
SET CNT=0
SET QFL=0
SET RVDT=""
+3 FOR
SET RVDT=$ORDER(^AUPNVSIT("AA",DFN,RVDT))
IF RVDT=""!(QFL)
QUIT
Begin DoDot:1
+4 SET VIEN=""
+5 SET VIEN=$ORDER(^AUPNVSIT("AA",DFN,RVDT,VIEN),-1)
IF VIEN=""
QUIT
Begin DoDot:2
+6 SET VSDTM=$PIECE($GET(^AUPNVSIT(VIEN,0)),"^",1)\1
IF VSDTM=0
QUIT
+7 SET CNT=CNT+1
IF CNT>NUM
SET QFL=1
QUIT
End DoDot:2
IF QFL
QUIT
+8 SET RESULT=RESULT_$$GET1^DIQ(9000010,VIEN_",",.22,"E")_$CHAR(13)_$CHAR(10)
End DoDot:1
+9 QUIT $$TKO^BQIUL1(RESULT,$CHAR(13)_$CHAR(10))