BQIUL2 ;PRXM/HC/ALA-Miscellaneous BQI utilities ; 01 Nov 2007 2:20 PM
;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
;
STC(FIL,FLD,VAL) ; EP - Find a value for a set of codes code
; Input Parameters
; FIL = FileMan File Number
; FLD = FileMan Field Number
; VAL = Code Value
;
NEW VEDATA,VEQFL,VEVL,VALUE
S VEDATA=$P(^DD(FIL,FLD,0),U,3),VEQFL=0
;
F I=1:1 S VEVL=$P(VEDATA,";",I) Q:VEVL="" D Q:VEQFL
. S VALUE=$P(VEVL,":",2) I VAL=$P(VEVL,":",1) S VEQFL=1
;
Q VALUE
;
STCC(FIL,FLD,VAL) ; EP - Find a value for a set of codes code
; Input Parameters
; FIL = FileMan File Number
; FLD = FileMan Field Number
; VAL = Code Value
;
NEW VEDATA,VEQFL,VEVL,VALUE
S VEDATA=$P(^DD(FIL,FLD,0),U,3),VEQFL=0
;
F I=1:1 S VEVL=$P(VEDATA,";",I) Q:VEVL="" D Q:VEQFL
. I VAL=$P(VEVL,":",1) S VALUE=$P(VEVL,":",2),VEQFL=1 Q
. I VAL=$P(VEVL,":",2) S VALUE=$P(VEVL,":",1),VEQFL=1
;
Q VALUE
;
PTR(FIL,FLD,VVAL,VPEC) ;EP - Find alternate value for a pointer
;
; Input Parameters
; FIL = FileMan File #
; FLD = FileMan Field #
; VAL = Data Value
; VPEC = Field from pointed to file, defaults to .01 if not defined
;
NEW ARR1,VEDATA,VFILN,VEHDTA,VVALUE,VEPAR,ARR,PEC
I $G(VPEC)="" S VPEC=.01
;
I $G(VVAL)="" Q ""
; Get the Pointer Global Reference
D FIELD^DID(FIL,FLD,"","POINTER","VEPAR")
S VEDATA=$G(VEPAR("POINTER")),VEHDTA="^"_VEDATA_"0)"
S VFILN=$P($G(@VEHDTA),U,2),VFILN=$$UP^XLFSTR(VFILN)
S VFILN=$$STRIP^XLFSTR(VFILN,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
K VEPAR
;
D FIELD^DID(VFILN,VPEC,"N","GLOBAL SUBSCRIPT LOCATION","ARR")
S ARR1=$G(ARR("GLOBAL SUBSCRIPT LOCATION"))
;
I VVAL'="" S VEHDTA="^"_VEDATA_VVAL_","_$P(ARR1,";",1)_")"
;
S PEC=$P(ARR1,";",2)
I VVAL'="" S VVALUE=$P($G(@VEHDTA),U,PEC)
Q VVALUE
;
PRIMVPRV(PXUTVST) ; EP - Returns the primary provider if there is one
; for the passed visit otherwise returns 0.
N PXCATEMP
S PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPRV",0,4)
Q $S(PXCATEMP>0:$P(^AUPNVPRV(PXCATEMP,0),"^"),1:0)
;
PRIMVPOV(PXUTVST) ; EP - Returns the primary diagnosis if there is one
; for the passed visit otherwise returns 0.
N PXCATEMP
S PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPOV",0,12)
Q $S(PXCATEMP>0:$P(^AUPNVPOV(PXCATEMP,0),"^"),1:0)
;
PRIMSEC(PXUTVST,PXUTAUPN,PXUTNODE,PXUPIECE) ; EP - Returns ien of the primary one
; if there is one for the passed visit otherwise returns 0.
; Parameters:
; PXUTVST Pointer to the visit
; PXUTAUPN V-File global e.g. "^AUPNVPRV"
; PXUTNODE The node that the Primary/Secondary field is on
; PXUPIECE The piece of the Primary/Secondary field
;
N PXUTPRIM
S PXUTPRIM=0
F S PXUTPRIM=$O(@(PXUTAUPN_"(""AD"",PXUTVST,PXUTPRIM)")) Q:PXUTPRIM'>0 I "P"=$P(@(PXUTAUPN_"(PXUTPRIM,PXUTNODE)"),"^",PXUPIECE) Q
Q +PXUTPRIM
;
SCD(STRNG,VAL) ;EP - find a description for a code
NEW VEQFL,I,VEVL,VALUE
S VEQFL=0
F I=1:1 S VEVL=$P(STRNG,";",I) Q:VEVL="" D Q:VEQFL
. S VALUE=$P(VEVL,":",2) I $P(VEVL,":",1)=VAL S VEQFL=1
;
Q VALUE
;
MCD(DFN) ;EP - Medicaid Number
NEW IEN,RESULT,MCDN,MN,STATE
S IEN="",RESULT=""
F S IEN=$O(^AUPNMCD("B",DFN,IEN)) Q:IEN="" D
. S MCDN=$$GET1^DIQ(9000004,IEN_",",.03,"E")
. S STATE=$$GET1^DIQ(9000004,IEN_",",.04,"I")
. S MN=0
. F S MN=$O(^AUPNMCD(IEN,11,MN)) Q:'MN D
.. NEW DA,IENS,EFF,EXP
.. S DA(1)=IEN,DA=MN,IENS=$$IENS^DILF(.DA)
.. S EFF=$$GET1^DIQ(9000004.11,IENS,.01,"I")
.. S EXP=$$GET1^DIQ(9000004.11,IENS,.02,"I")
.. I '$$ISACTIVE^BQIPTINS(EFF,EXP) Q
.. S RESULT=MCDN_" ("_$$PTR^BQIUL2(9000004,.04,STATE,1)_")"
Q RESULT
;
NSC(DFN,TMFRAME,TYP) ;EP - Number of no shows and patient cancels
NEW BDT,NSC,PCC,STAT,PAR
I $G(TMFRAME)="" S BDT=$E(DT,1,3)_"0101"
I $G(TMFRAME)'="" S BDT=$$DATE^BQIUL1(TMFRAME)
S NSC=0,PCC=0
F S BDT=$O(^DPT(DFN,"S",BDT)) Q:BDT="" D
. S STAT=$P(^DPT(DFN,"S",BDT,0),"^",2)
. S NCDT=$P(^DPT(DFN,"S",BDT,0),"^",14) I NCDT="" Q
. I (NCDT\1)>DT Q
. S:STAT="N" NSC=NSC+1 S:STAT="PC" PCC=PCC+1
Q $S(TYP="NS":NSC,TYP="PC":PCC,1:(NSC+PCC))
;
OTRIB(DFN) ;EP - List of other tribes
NEW BQTRIB,OTHER,TN,OTRIB
S OTHER=""
S TN=0
F S TN=$O(^AUPNPAT(DFN,43,"B",TN)) Q:TN="" D
. S BQTRIB=$P($G(^AUPNPAT(DFN,11)),U,8)
. I BQTRIB'="",BQTRIB=TN Q
. S OTRIB=$P($G(^AUTTTRI(TN,0)),U,1) I OTRIB="" Q
. S OTHER=OTHER_OTRIB_$C(10)_$C(13)
S OTHER=$$TKO^BQIUL1(OTHER,$C(10)_$C(13))
Q OTHER
;
LAVD(DFN) ;EP -- Get patient's last AMBULATORY visit
;Input
; DFN - Patient internal entry number
;
NEW VIEN,LVISIT,QFL,LVSDT
S VIEN="",LVISIT="",QFL=0,LVSDT=""
S LVSDT=$O(^AUPNVSIT("AA",DFN,LVSDT)) I LVSDT="" Q LVISIT
S LVSDT=""
F S LVSDT=$O(^AUPNVSIT("AA",DFN,LVSDT)) Q:LVSDT="" D Q:QFL
. F S VIEN=$O(^AUPNVSIT("AA",DFN,LVSDT,VIEN)) Q:VIEN="" D Q:QFL
.. I $$GET1^DIQ(9000010,VIEN,.11,"I")=1 Q
.. I $G(^AUPNVSIT(VIEN,0))="" Q
.. I $P(^AUPNVSIT(VIEN,0),U,7)'="A" Q
.. I $P(^AUPNVSIT(VIEN,0),U,9)=1 Q
.. ; Check for Primary Care clinic
.. S CLN=$P(^AUPNVSIT(VIEN,0),U,8)
.. I CLN'="" D Q:QFL
... I $P($G(^DIC(40.7,CLN,9999999)),"^",2)'=1 S QFL=1
.. S LVISIT=VIEN,QFL=1
Q LVISIT
;
LAVDT(DFN) ;EP -- Get patient's last AMBULATORY visit date/time
;Input
; DFN - Patient internal entry number
;
NEW VIEN
S VIEN=$$LAVD(.DFN)
I VIEN="" Q ""
Q $$FMTE^BQIUL1($$GET1^DIQ(9000010,VIEN_",",.01,"I")\1)
;
LAVC(DFN) ;EP -- Get patient's last AMBULATORY visit clinic
;Input
; DFN - Patient internal entry number
NEW VIEN,CST
S VIEN=$$LAVD(.DFN)
I VIEN="" Q ""
S CST=$$GET1^DIQ(9000010,VIEN_",",.08,"I")
I CST="" Q ""
Q $$GET1^DIQ(9000010,VIEN_",",.08,"E")_" "_$$GET1^DIQ(40.7,CST_",",1,"E")
;
LALC(DFN) ;EP -- Get patient's last AMBULATORY visit location
;Input
; DFN - Patient internal entry number
NEW VIEN,CST
S VIEN=$$LAVD(.DFN)
I VIEN="" Q ""
S CST=$$GET1^DIQ(9000010,VIEN_",",.06,"E")
I CST="" Q "UNKNOWN"
Q CST
;
LAVP(DFN) ;EP -- Get patient's last AMBULATORY visit primary provider
;Input
; DFN - Patient internal entry number
NEW VIEN,PRV
S VIEN=$$LAVD(.DFN)
I VIEN="" Q ""
S PRV=$$PRIMVPRV^PXUTL1(VIEN)
I PRV=0 Q ""
Q $$GET1^DIQ(200,PRV_",",.01,"E")
;
LAVDN(DFN) ;EP -- Get patient's last AMBULATORY visit POV narratives
;Input
; DFN - Patient internal entry number
NEW VIEN,TEXT,IEN,POVN
S VIEN=$$LAVD(.DFN),TEXT="",IEN=""
I VIEN="" Q ""
F S IEN=$O(^AUPNVPOV("AD",VIEN,IEN)) Q:IEN="" D
. S POVN=$$GET1^DIQ(9000010.07,IEN_",",".019","E")
. I $L(TEXT)+$L(POVN)>250 Q
. S TEXT=TEXT_POVN_$C(13)_$C(10)
Q $$TKO^BQIUL1(TEXT,$C(13)_$C(10))
;
LAVPN(DFN) ;EP -- Get patient's last AMBULATORY visit provider narratives
;Input
; DFN - Patient internal entry number
NEW VIEN,TEXT,IEN,PRVN
S VIEN=$$LAVD(.DFN),TEXT="",IEN=""
I VIEN="" Q ""
F S IEN=$O(^AUPNVPOV("AD",VIEN,IEN)) Q:IEN="" D
. S PRVN=$$GET1^DIQ(9000010.07,IEN_",",".04","E")
. I $L(TEXT)+$L(PRVN)>250 Q
. S TEXT=TEXT_PRVN_$C(13)_$C(10)
Q $$TKO^BQIUL1(TEXT,$C(13)_$C(10))
BQIUL2 ;PRXM/HC/ALA-Miscellaneous BQI utilities ; 01 Nov 2007 2:20 PM
+1 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
+2 ;
STC(FIL,FLD,VAL) ; EP - Find a value for a set of codes code
+1 ; Input Parameters
+2 ; FIL = FileMan File Number
+3 ; FLD = FileMan Field Number
+4 ; VAL = Code Value
+5 ;
+6 NEW VEDATA,VEQFL,VEVL,VALUE
+7 SET VEDATA=$PIECE(^DD(FIL,FLD,0),U,3)
SET VEQFL=0
+8 ;
+9 FOR I=1:1
SET VEVL=$PIECE(VEDATA,";",I)
IF VEVL=""
QUIT
Begin DoDot:1
+10 SET VALUE=$PIECE(VEVL,":",2)
IF VAL=$PIECE(VEVL,":",1)
SET VEQFL=1
End DoDot:1
IF VEQFL
QUIT
+11 ;
+12 QUIT VALUE
+13 ;
STCC(FIL,FLD,VAL) ; EP - Find a value for a set of codes code
+1 ; Input Parameters
+2 ; FIL = FileMan File Number
+3 ; FLD = FileMan Field Number
+4 ; VAL = Code Value
+5 ;
+6 NEW VEDATA,VEQFL,VEVL,VALUE
+7 SET VEDATA=$PIECE(^DD(FIL,FLD,0),U,3)
SET VEQFL=0
+8 ;
+9 FOR I=1:1
SET VEVL=$PIECE(VEDATA,";",I)
IF VEVL=""
QUIT
Begin DoDot:1
+10 IF VAL=$PIECE(VEVL,":",1)
SET VALUE=$PIECE(VEVL,":",2)
SET VEQFL=1
QUIT
+11 IF VAL=$PIECE(VEVL,":",2)
SET VALUE=$PIECE(VEVL,":",1)
SET VEQFL=1
End DoDot:1
IF VEQFL
QUIT
+12 ;
+13 QUIT VALUE
+14 ;
PTR(FIL,FLD,VVAL,VPEC) ;EP - Find alternate value for a pointer
+1 ;
+2 ; Input Parameters
+3 ; FIL = FileMan File #
+4 ; FLD = FileMan Field #
+5 ; VAL = Data Value
+6 ; VPEC = Field from pointed to file, defaults to .01 if not defined
+7 ;
+8 NEW ARR1,VEDATA,VFILN,VEHDTA,VVALUE,VEPAR,ARR,PEC
+9 IF $GET(VPEC)=""
SET VPEC=.01
+10 ;
+11 IF $GET(VVAL)=""
QUIT ""
+12 ; Get the Pointer Global Reference
+13 DO FIELD^DID(FIL,FLD,"","POINTER","VEPAR")
+14 SET VEDATA=$GET(VEPAR("POINTER"))
SET VEHDTA="^"_VEDATA_"0)"
+15 SET VFILN=$PIECE($GET(@VEHDTA),U,2)
SET VFILN=$$UP^XLFSTR(VFILN)
+16 SET VFILN=$$STRIP^XLFSTR(VFILN,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+17 KILL VEPAR
+18 ;
+19 DO FIELD^DID(VFILN,VPEC,"N","GLOBAL SUBSCRIPT LOCATION","ARR")
+20 SET ARR1=$GET(ARR("GLOBAL SUBSCRIPT LOCATION"))
+21 ;
+22 IF VVAL'=""
SET VEHDTA="^"_VEDATA_VVAL_","_$PIECE(ARR1,";",1)_")"
+23 ;
+24 SET PEC=$PIECE(ARR1,";",2)
+25 IF VVAL'=""
SET VVALUE=$PIECE($GET(@VEHDTA),U,PEC)
+26 QUIT VVALUE
+27 ;
PRIMVPRV(PXUTVST) ; EP - Returns the primary provider if there is one
+1 ; for the passed visit otherwise returns 0.
+2 NEW PXCATEMP
+3 SET PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPRV",0,4)
+4 QUIT $SELECT(PXCATEMP>0:$PIECE(^AUPNVPRV(PXCATEMP,0),"^"),1:0)
+5 ;
PRIMVPOV(PXUTVST) ; EP - Returns the primary diagnosis if there is one
+1 ; for the passed visit otherwise returns 0.
+2 NEW PXCATEMP
+3 SET PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPOV",0,12)
+4 QUIT $SELECT(PXCATEMP>0:$PIECE(^AUPNVPOV(PXCATEMP,0),"^"),1:0)
+5 ;
PRIMSEC(PXUTVST,PXUTAUPN,PXUTNODE,PXUPIECE) ; EP - Returns ien of the primary one
+1 ; if there is one for the passed visit otherwise returns 0.
+2 ; Parameters:
+3 ; PXUTVST Pointer to the visit
+4 ; PXUTAUPN V-File global e.g. "^AUPNVPRV"
+5 ; PXUTNODE The node that the Primary/Secondary field is on
+6 ; PXUPIECE The piece of the Primary/Secondary field
+7 ;
+8 NEW PXUTPRIM
+9 SET PXUTPRIM=0
+10 FOR
SET PXUTPRIM=$ORDER(@(PXUTAUPN_"(""AD"",PXUTVST,PXUTPRIM)"))
IF PXUTPRIM'>0
QUIT
IF "P"=$PIECE(@(PXUTAUPN_"(PXUTPRIM,PXUTNODE)"),"^",PXUPIECE)
QUIT
+11 QUIT +PXUTPRIM
+12 ;
SCD(STRNG,VAL) ;EP - find a description for a code
+1 NEW VEQFL,I,VEVL,VALUE
+2 SET VEQFL=0
+3 FOR I=1:1
SET VEVL=$PIECE(STRNG,";",I)
IF VEVL=""
QUIT
Begin DoDot:1
+4 SET VALUE=$PIECE(VEVL,":",2)
IF $PIECE(VEVL,":",1)=VAL
SET VEQFL=1
End DoDot:1
IF VEQFL
QUIT
+5 ;
+6 QUIT VALUE
+7 ;
MCD(DFN) ;EP - Medicaid Number
+1 NEW IEN,RESULT,MCDN,MN,STATE
+2 SET IEN=""
SET RESULT=""
+3 FOR
SET IEN=$ORDER(^AUPNMCD("B",DFN,IEN))
IF IEN=""
QUIT
Begin DoDot:1
+4 SET MCDN=$$GET1^DIQ(9000004,IEN_",",.03,"E")
+5 SET STATE=$$GET1^DIQ(9000004,IEN_",",.04,"I")
+6 SET MN=0
+7 FOR
SET MN=$ORDER(^AUPNMCD(IEN,11,MN))
IF 'MN
QUIT
Begin DoDot:2
+8 NEW DA,IENS,EFF,EXP
+9 SET DA(1)=IEN
SET DA=MN
SET IENS=$$IENS^DILF(.DA)
+10 SET EFF=$$GET1^DIQ(9000004.11,IENS,.01,"I")
+11 SET EXP=$$GET1^DIQ(9000004.11,IENS,.02,"I")
+12 IF '$$ISACTIVE^BQIPTINS(EFF,EXP)
QUIT
+13 SET RESULT=MCDN_" ("_$$PTR^BQIUL2(9000004,.04,STATE,1)_")"
End DoDot:2
End DoDot:1
+14 QUIT RESULT
+15 ;
NSC(DFN,TMFRAME,TYP) ;EP - Number of no shows and patient cancels
+1 NEW BDT,NSC,PCC,STAT,PAR
+2 IF $GET(TMFRAME)=""
SET BDT=$EXTRACT(DT,1,3)_"0101"
+3 IF $GET(TMFRAME)'=""
SET BDT=$$DATE^BQIUL1(TMFRAME)
+4 SET NSC=0
SET PCC=0
+5 FOR
SET BDT=$ORDER(^DPT(DFN,"S",BDT))
IF BDT=""
QUIT
Begin DoDot:1
+6 SET STAT=$PIECE(^DPT(DFN,"S",BDT,0),"^",2)
+7 SET NCDT=$PIECE(^DPT(DFN,"S",BDT,0),"^",14)
IF NCDT=""
QUIT
+8 IF (NCDT\1)>DT
QUIT
+9 IF STAT="N"
SET NSC=NSC+1
IF STAT="PC"
SET PCC=PCC+1
End DoDot:1
+10 QUIT $SELECT(TYP="NS":NSC,TYP="PC":PCC,1:(NSC+PCC))
+11 ;
OTRIB(DFN) ;EP - List of other tribes
+1 NEW BQTRIB,OTHER,TN,OTRIB
+2 SET OTHER=""
+3 SET TN=0
+4 FOR
SET TN=$ORDER(^AUPNPAT(DFN,43,"B",TN))
IF TN=""
QUIT
Begin DoDot:1
+5 SET BQTRIB=$PIECE($GET(^AUPNPAT(DFN,11)),U,8)
+6 IF BQTRIB'=""
IF BQTRIB=TN
QUIT
+7 SET OTRIB=$PIECE($GET(^AUTTTRI(TN,0)),U,1)
IF OTRIB=""
QUIT
+8 SET OTHER=OTHER_OTRIB_$CHAR(10)_$CHAR(13)
End DoDot:1
+9 SET OTHER=$$TKO^BQIUL1(OTHER,$CHAR(10)_$CHAR(13))
+10 QUIT OTHER
+11 ;
LAVD(DFN) ;EP -- Get patient's last AMBULATORY visit
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ;
+4 NEW VIEN,LVISIT,QFL,LVSDT
+5 SET VIEN=""
SET LVISIT=""
SET QFL=0
SET LVSDT=""
+6 SET LVSDT=$ORDER(^AUPNVSIT("AA",DFN,LVSDT))
IF LVSDT=""
QUIT LVISIT
+7 SET LVSDT=""
+8 FOR
SET LVSDT=$ORDER(^AUPNVSIT("AA",DFN,LVSDT))
IF LVSDT=""
QUIT
Begin DoDot:1
+9 FOR
SET VIEN=$ORDER(^AUPNVSIT("AA",DFN,LVSDT,VIEN))
IF VIEN=""
QUIT
Begin DoDot:2
+10 IF $$GET1^DIQ(9000010,VIEN,.11,"I")=1
QUIT
+11 IF $GET(^AUPNVSIT(VIEN,0))=""
QUIT
+12 IF $PIECE(^AUPNVSIT(VIEN,0),U,7)'="A"
QUIT
+13 IF $PIECE(^AUPNVSIT(VIEN,0),U,9)=1
QUIT
+14 ; Check for Primary Care clinic
+15 SET CLN=$PIECE(^AUPNVSIT(VIEN,0),U,8)
+16 IF CLN'=""
Begin DoDot:3
+17 IF $PIECE($GET(^DIC(40.7,CLN,9999999)),"^",2)'=1
SET QFL=1
End DoDot:3
IF QFL
QUIT
+18 SET LVISIT=VIEN
SET QFL=1
End DoDot:2
IF QFL
QUIT
End DoDot:1
IF QFL
QUIT
+19 QUIT LVISIT
+20 ;
LAVDT(DFN) ;EP -- Get patient's last AMBULATORY visit date/time
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 ;
+4 NEW VIEN
+5 SET VIEN=$$LAVD(.DFN)
+6 IF VIEN=""
QUIT ""
+7 QUIT $$FMTE^BQIUL1($$GET1^DIQ(9000010,VIEN_",",.01,"I")\1)
+8 ;
LAVC(DFN) ;EP -- Get patient's last AMBULATORY visit clinic
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW VIEN,CST
+4 SET VIEN=$$LAVD(.DFN)
+5 IF VIEN=""
QUIT ""
+6 SET CST=$$GET1^DIQ(9000010,VIEN_",",.08,"I")
+7 IF CST=""
QUIT ""
+8 QUIT $$GET1^DIQ(9000010,VIEN_",",.08,"E")_" "_$$GET1^DIQ(40.7,CST_",",1,"E")
+9 ;
LALC(DFN) ;EP -- Get patient's last AMBULATORY visit location
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW VIEN,CST
+4 SET VIEN=$$LAVD(.DFN)
+5 IF VIEN=""
QUIT ""
+6 SET CST=$$GET1^DIQ(9000010,VIEN_",",.06,"E")
+7 IF CST=""
QUIT "UNKNOWN"
+8 QUIT CST
+9 ;
LAVP(DFN) ;EP -- Get patient's last AMBULATORY visit primary provider
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW VIEN,PRV
+4 SET VIEN=$$LAVD(.DFN)
+5 IF VIEN=""
QUIT ""
+6 SET PRV=$$PRIMVPRV^PXUTL1(VIEN)
+7 IF PRV=0
QUIT ""
+8 QUIT $$GET1^DIQ(200,PRV_",",.01,"E")
+9 ;
LAVDN(DFN) ;EP -- Get patient's last AMBULATORY visit POV narratives
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW VIEN,TEXT,IEN,POVN
+4 SET VIEN=$$LAVD(.DFN)
SET TEXT=""
SET IEN=""
+5 IF VIEN=""
QUIT ""
+6 FOR
SET IEN=$ORDER(^AUPNVPOV("AD",VIEN,IEN))
IF IEN=""
QUIT
Begin DoDot:1
+7 SET POVN=$$GET1^DIQ(9000010.07,IEN_",",".019","E")
+8 IF $LENGTH(TEXT)+$LENGTH(POVN)>250
QUIT
+9 SET TEXT=TEXT_POVN_$CHAR(13)_$CHAR(10)
End DoDot:1
+10 QUIT $$TKO^BQIUL1(TEXT,$CHAR(13)_$CHAR(10))
+11 ;
LAVPN(DFN) ;EP -- Get patient's last AMBULATORY visit provider narratives
+1 ;Input
+2 ; DFN - Patient internal entry number
+3 NEW VIEN,TEXT,IEN,PRVN
+4 SET VIEN=$$LAVD(.DFN)
SET TEXT=""
SET IEN=""
+5 IF VIEN=""
QUIT ""
+6 FOR
SET IEN=$ORDER(^AUPNVPOV("AD",VIEN,IEN))
IF IEN=""
QUIT
Begin DoDot:1
+7 SET PRVN=$$GET1^DIQ(9000010.07,IEN_",",".04","E")
+8 IF $LENGTH(TEXT)+$LENGTH(PRVN)>250
QUIT
+9 SET TEXT=TEXT_PRVN_$CHAR(13)_$CHAR(10)
End DoDot:1
+10 QUIT $$TKO^BQIUL1(TEXT,$CHAR(13)_$CHAR(10))