BQIDCAH2 ;VNGT/HS/ALA-Ad Hoc Search continued ; 03 Apr 2009 3:56 PM
;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
;
PROV(FGLOB,TGLOB,PROV) ;EP - Provider search
I $G(TGLOB)="" Q
I $G(PROV)="" Q
;
NEW DFN,IEN,RIEN,VIS
S IEN=0
;
I $G(FGLOB)'="",$G(FROM)'="" D Q
. S DFN=""
. F S DFN=$O(@FGLOB@(DFN)) Q:DFN="" D
.. I '$D(@VODATA@(DFN,"PRV",PROV)) K @FGLOB@(DFN) Q
.. ; Check for NUMVIS
.. I $G(NUMVIS)'="" D Q
... I @(@VODATA@(DFN,"PRV",PROV)_NUMVIS) S @TGLOB@(DFN)="" Q
... Q
.. I $D(MPARMS("NUMVIS")) D Q
... S VCRIT1=$O(MPARMS("NUMVIS","")),VCRIT2=$O(MPARMS("NUMVIS",VCRIT1))
... ; If criteria includes a "not" it is inclusive and both must be true
... I $E(VCRIT1)="'",@(@VODATA@(DFN,"PRV",PROV)_VCRIT1),@(@VODATA@(DFN,"PRV",PROV)_VCRIT2) S @TGLOB@(DFN)="" Q
... ; If criteria does not includes a "not" it is exclusive and one must be true
... I $E(VCRIT1)'="'",@(@VODATA@(DFN,"PRV",PROV)_VCRIT1_"!("_(@VODATA@(DFN,"PRV",PROV)_VCRIT2)_")") S @TGLOB@(DFN)="" Q
... Q
.. S @TGLOB@(DFN)=""
. K @FGLOB
;
I $G(FGLOB)'="" D
. S RIEN=""
. F S RIEN=$O(^AUPNVPRV("B",PROV,RIEN)) Q:'RIEN D
.. S DFN=$$GET1^DIQ(9000010.06,RIEN_",",.02,"I") I DFN="" Q
.. I '$D(@FGLOB@(DFN)) Q
.. S @TGLOB@(DFN)=""
;
I $G(FGLOB)="" D
. S RIEN=""
. F S RIEN=$O(^AUPNVPRV("B",PROV,RIEN)) Q:'RIEN D
.. S DFN=$$GET1^DIQ(9000010.06,RIEN_",",.02,"I") I DFN="" Q
.. S @TGLOB@(DFN)=""
Q
;
PRVS(TGLOB,PROV,FROM,THRU) ;EP
; this cross-reference does not really exist yet, it is a test to determine
; a more efficient cross-reference
S FDT=FROM
F S FDT=$O(^AUPNVPRV("AF",PROV,FDT)) Q:FDT=""!(FDT\1>THRU) D
. S DFN=""
. F S DFN=$O(^AUPNVPRV("AF",PROV,FDT,DFN)) Q:DFN="" S @TGLOB@(DFN)=""
;
Q
;
VIS(FGLOB,TGLOB,FDT,TDT,MAPARMS) ;EP - Visit search
I $G(TGLOB)="" Q
;
NEW DFN,IEN,RIEN,CLNFLG,PRVFLG,VCLIN,PRIEN,VPRV,OK,NOVST,VDCLIN
NEW VNDATA,VDDATA,VDCLPR,VDPROV,VDAND
;
; Clinic only data
S VDCLIN=$NA(^TMP("BQIVISCLN",UID))
S VNDATA=$NA(^TMP("BQINOVIS",UID))
; Patient only data
S VDDATA=$NA(^TMP("BQIVISONLY",UID))
; Clinic and provider data
S VDCLPR=$NA(^TMP("BQIVISCLPR",UID))
; Provider only data
S VDPROV=$NA(^TMP("BQIVISPRV",UID))
; 'AND' data
S VDAND=$NA(^TMP("BQIVISAND",UID))
K @VDCLIN,@VNDATA,@VDCLPR,@VDDATA,@VDAND,@VDPROV
;
S FDT=$S(FDT'="":FDT-.001,1:FDT),TDT=$S(TDT'="":TDT,1:DT)
F S FDT=$O(^AUPNVSIT("B",FDT)) Q:FDT=""!(FDT\1>TDT) D
. S RIEN=""
. F S RIEN=$O(^AUPNVSIT("B",FDT,RIEN)) Q:'RIEN D
.. ; If the visit is deleted, quit
.. I $$GET1^DIQ(9000010,RIEN_",",.11,"I")=1 Q
.. S DFN=$$GET1^DIQ(9000010,RIEN_",",.05,"I") I DFN="" Q
.. Q:"DXCTI"[$P(^AUPNVSIT(RIEN,0),U,7)
.. S @VDDATA@(DFN)=$G(@VDDATA@(DFN))+1
.. S VCLIN=$$GET1^DIQ(9000010,RIEN_",",.08,"I")
.. I VCLIN'="" D
... S @VDCLIN@(VCLIN,DFN)=$G(@VDCLIN@(VCLIN,DFN))+1
... S @VDCLIN@(VCLIN)=$G(@VDCLIN@(VCLIN))+1
.. ;Find associated providers
.. S PRIEN="" F S PRIEN=$O(^AUPNVPRV("AD",RIEN,PRIEN)) Q:PRIEN="" D
... S VPRV=$$GET1^DIQ(9000010.06,PRIEN_",",.01,"I") Q:VPRV=""
... I VCLIN'="" D
.... S @VDCLPR@(VCLIN,VPRV,DFN)=$G(@VDCLPR@(VCLIN,VPRV,DFN))+1
.... S @VDCLPR@(VCLIN,VPRV)=$G(@VDCLPR@(VCLIN,VPRV))+1
... S @VDPROV@(VPRV,DFN)=$G(@VDPROV@(VPRV,DFN))+1
;
I $D(MAPARMS) D
. S MN="",TOT=0
. F S MN=$O(MAPARMS(MN)) Q:MN="" D
.. S NUMVIS=$G(MAPARMS(MN,"NUMVIS")),CLIN=$G(MAPARMS(MN,"CLIN")),PROV=$G(MAPARMS(MN,"PROV"))
.. D CALB(NUMVIS,CLIN,PROV,VISOP)
;
I '$D(MAPARMS) D
. S TOT=0
. I $D(APARMS) D Q
.. S NUMVIS=""
.. F S NUMVIS=$O(APARMS("NUMVIS",NUMVIS)) Q:NUMVIS="" D
... S PROV=$G(APARMS("NUMVIS",NUMVIS,"PROV"))
... S CLIN=$G(APARMS("NUMVIS",NUMVIS,"CLIN"))
... D CALB($G(NUMVIS),$G(CLIN),$G(PROV),$G(VISOP))
. D CALB($G(NUMVIS),$G(CLIN),$G(PROV),$G(VISOP))
;
;no visits, so if have visits, exclude
I $G(FGLOB)="" D
. I $D(@VNDATA) S IEN=0 F S IEN=$O(^AUPNPAT(IEN)) Q:'IEN I '$D(@VNDATA@(IEN)),$G(^AUPNPAT(IEN,0))'="" S @TGLOB@(IEN)=""
I $G(FGLOB)'="" D
. I $D(@VNDATA) S IEN="" F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" I '$D(@VNDATA@(IEN)) S @TGLOB@(IEN)=""
;
I VISOP="&" D
. S IEN="" F S IEN=$O(@VDAND@(IEN)) Q:IEN="" I @VDAND@(IEN)'=TOT K @VDAND@(IEN)
. S IEN="" F S IEN=$O(@VDAND@(IEN)) Q:IEN="" S @TGLOB@(IEN)=""
;
K @VDCLIN,@VNDATA,@VDCLPR,@VDDATA,@VDAND,@VDPROV
Q
;
CALC(NUMVIS,CLIN,PROV) ; EP
; Single numvis value, not inclusive or exclusive
I NUMVIS'["~" D
. I $G(FGLOB)'="" D
.. I CLIN="",PROV="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" I @(@VDDATA@(IEN)_NUMVIS) S @TGLOB@(IEN)=""
.. I CLIN="",PROV'="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" I @(@VDPROV@(PROV,IEN)_NUMVIS) S @TGLOB@(IEN)=""
... S IEN=""
.. I CLIN'="",PROV="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" I @(@VDCLIN@(CLIN,IEN)_NUMVIS) S @TGLOB@(IEN)=""
.. I CLIN'="",PROV'="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" I @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS) S @TGLOB@(IEN)=""
. I $G(FGLOB)="" D
.. I CLIN="",PROV="" D
... S IEN=""
... F S IEN=$O(@VDDATA@(IEN)) Q:IEN="" I @(@VDDATA@(IEN)_NUMVIS) S @TGLOB@(IEN)=""
.. I CLIN="",PROV'="" D
... S IEN=""
... F S IEN=$O(@VDPROV@(PROV,IEN)) Q:IEN="" I @(@VDPROV@(PROV,IEN)_NUMVIS) S @TGLOB@(IEN)=""
.. I CLIN'="",PROV="" D
... S IEN=""
... F S IEN=$O(@VDCLIN@(CLIN,IEN)) Q:IEN="" I @(@VDCLIN@(CLIN,IEN)_NUMVIS) S @TGLOB@(IEN)=""
.. I CLIN'="",PROV'="" D
... S IEN=""
... F S IEN=$O(@VDCLPR@(CLIN,PROV,IEN)) Q:IEN="" I @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS) S @TGLOB@(IEN)=""
;
I NUMVIS["~" D
. S VCRIT1=$P(NUMVIS,"~",1),VCRIT2=$P(NUMVIS,"~",2)
. I $G(FGLOB)'="" D
.. I CLIN="",PROV="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDDATA@(IEN)_VCRIT1),@(@VDDATA@(IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN="",PROV'="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDPROV@(PROV,IEN)_VCRIT1),@(@VDPROV@(PROV,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN'="",PROV="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1),@(@VDCLIN@(CLIN,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN'="",PROV'="" D
... S IEN=""
... F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1),@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
. ;
. I $G(FGLOB)="" D
.. I CLIN="",PROV="" D
... S IEN=""
... F S IEN=$O(@VDDATA@(IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDDATA@(IEN)_VCRIT1),@(@VDDATA@(IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN="",PROV'="" D
... S IEN=""
... F S IEN=$O(@VDPROV@(PROV,IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDPROV@(PROV,IEN)_VCRIT1),@(@VDPROV@(PROV,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN'="",PROV="" D
... S IEN=""
... F S IEN=$O(@VDCLIN@(CLIN,IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1),@(@VDCLIN@(CLIN,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
.. I CLIN'="",PROV'="" D
... S IEN=""
... F S IEN=$O(@VDCLPR@(CLIN,PROV,IEN)) Q:IEN="" D
.... ; If criteria includes a "not" it is inclusive and both must be true
.... I $E(VCRIT1)="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1),@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2) S @TGLOB@(IEN)="" Q
.... ; If criteria does not includes a "not" it is exclusive and one must be true
.... I $E(VCRIT1)'="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")") S @TGLOB@(IEN)="" Q
Q
;
CALB(NUMVIS,CLIN,PROV,VISOP) ;EP
S TOT=TOT+1,NOVST=0
I NUMVIS="=0"!(NUMVIS="<0")!(NUMVIS="<1")!(NUMVIS="'>0") S NOVST=1
I NUMVIS["~" S VCRIT1=$P(NUMVIS,"~",1),VCRIT2=$P(NUMVIS,"~",2)
I NUMVIS'["~" S VCRIT1="",VCRIT2=""
I $G(FGLOB)'="" D
. S IEN=""
. F S IEN=$O(@FGLOB@(IEN)) Q:IEN="" D
.. I CLIN="",PROV="" D VDD
.. I CLIN'="",PROV="" D VDC
.. I CLIN="",PROV'="" D VDP
.. I CLIN'="",PROV'="" D VDBT
;
I $G(FGLOB)="" D
. I CLIN="",PROV="" S IEN="" F S IEN=$O(@VDDATA@(IEN)) Q:IEN="" D VDD
. I CLIN'="",PROV="" S IEN="" F S IEN=$O(@VDCLIN@(CLIN,IEN)) Q:IEN="" D VDC
. I CLIN="",PROV'="" S IEN="" F S IEN=$O(@VDPROV@(PROV,IEN)) Q:IEN="" D VDP
. I CLIN'="",PROV'="" S IEN="" F S IEN=$O(@VDCLPR@(CLIN,PROV,IEN)) Q:IEN="" D VDBT
Q
;
VDD ; Visit Only
I NOVST,$D(@VDDATA@(IEN)) S @VNDATA@(IEN)="" Q
I '$D(@VDDATA@(IEN)) Q
I VCRIT1="" D Q
. I @(@VDDATA@(IEN)_NUMVIS) D
.. I VISOP="!" S @TGLOB@(IEN)="" Q
.. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria includes a "not" it is inclusive and both must be true
I $E(VCRIT1)="'",@(@VDDATA@(IEN)_VCRIT1),@(@VDDATA@(IEN)_VCRIT2) D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria does not includes a "not" it is exclusive and one must be true
I $E(VCRIT1)'="'",@(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")") D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
Q
;
VDC ; Clinic Only
I NOVST,$D(@VDCLIN@(CLIN,IEN)) S @VNDATA@(IEN)="" Q
I '$D(@VDCLIN@(CLIN,IEN)) Q
I VCRIT1="" D Q
. I @(@VDCLIN@(CLIN,IEN)_NUMVIS) D
.. I VISOP="!" S @TGLOB@(IEN)="" Q
.. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria includes a "not" it is inclusive and both must be true
I $E(VCRIT1)="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1),@(@VDCLIN@(CLIN,IEN)_VCRIT2) D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria does not includes a "not" it is exclusive and one must be true
I $E(VCRIT1)'="'",@(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")") D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
Q
;
VDP ; Provider Only
I NOVST,$D(@VDPROV@(PROV,IEN)) S @VNDATA@(IEN)="" Q
I '$D(@VDPROV@(PROV,IEN)) Q
I VCRIT1="" D Q
. I @(@VDPROV@(PROV,IEN)_NUMVIS) D
.. I VISOP="!" S @TGLOB@(IEN)="" Q
.. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria includes a "not" it is inclusive and both must be true
I $E(VCRIT1)="'",@(@VDPROV@(PROV,IEN)_VCRIT1),@(@VDPROV@(PROV,IEN)_VCRIT2) D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria does not includes a "not" it is exclusive and one must be true
I $E(VCRIT1)'="'",@(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")") D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
Q
;
VDBT ; Clinic and Provider
I NOVST,$D(@VDCLPR@(CLIN,PROV,IEN)) S @VNDATA@(IEN)="" Q
I '$D(@VDCLPR@(CLIN,PROV,IEN)) Q
I VCRIT1="" D Q
. I @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS) D
.. I VISOP="!" S @TGLOB@(IEN)=""
.. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria includes a "not" it is inclusive and both must be true
I $E(VCRIT1)="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1),@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2) D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
; If criteria does not includes a "not" it is exclusive and one must be true
I $E(VCRIT1)'="'",@(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")") D
. I VISOP="!" S @TGLOB@(IEN)="" Q
. I VISOP="&" S @VDAND@(IEN)=$G(@VDAND@(IEN))+1
Q
BQIDCAH2 ;VNGT/HS/ALA-Ad Hoc Search continued ; 03 Apr 2009 3:56 PM
+1 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
+2 ;
PROV(FGLOB,TGLOB,PROV) ;EP - Provider search
+1 IF $GET(TGLOB)=""
QUIT
+2 IF $GET(PROV)=""
QUIT
+3 ;
+4 NEW DFN,IEN,RIEN,VIS
+5 SET IEN=0
+6 ;
+7 IF $GET(FGLOB)'=""
IF $GET(FROM)'=""
Begin DoDot:1
+8 SET DFN=""
+9 FOR
SET DFN=$ORDER(@FGLOB@(DFN))
IF DFN=""
QUIT
Begin DoDot:2
+10 IF '$DATA(@VODATA@(DFN,"PRV",PROV))
KILL @FGLOB@(DFN)
QUIT
+11 ; Check for NUMVIS
+12 IF $GET(NUMVIS)'=""
Begin DoDot:3
+13 IF @(@VODATA@(DFN,"PRV",PROV)_NUMVIS)
SET @TGLOB@(DFN)=""
QUIT
+14 QUIT
End DoDot:3
QUIT
+15 IF $DATA(MPARMS("NUMVIS"))
Begin DoDot:3
+16 SET VCRIT1=$ORDER(MPARMS("NUMVIS",""))
SET VCRIT2=$ORDER(MPARMS("NUMVIS",VCRIT1))
+17 ; If criteria includes a "not" it is inclusive and both must be true
+18 IF $EXTRACT(VCRIT1)="'"
IF @(@VODATA@(DFN,"PRV",PROV)_VCRIT1)
IF @(@VODATA@(DFN,"PRV",PROV)_VCRIT2)
SET @TGLOB@(DFN)=""
QUIT
+19 ; If criteria does not includes a "not" it is exclusive and one must be true
+20 IF $EXTRACT(VCRIT1)'="'"
IF @(@VODATA@(DFN,"PRV",PROV)_VCRIT1_"!("_(@VODATA@(DFN,"PRV",PROV)_VCRIT2)_")")
SET @TGLOB@(DFN)=""
QUIT
+21 QUIT
End DoDot:3
QUIT
+22 SET @TGLOB@(DFN)=""
End DoDot:2
+23 KILL @FGLOB
End DoDot:1
QUIT
+24 ;
+25 IF $GET(FGLOB)'=""
Begin DoDot:1
+26 SET RIEN=""
+27 FOR
SET RIEN=$ORDER(^AUPNVPRV("B",PROV,RIEN))
IF 'RIEN
QUIT
Begin DoDot:2
+28 SET DFN=$$GET1^DIQ(9000010.06,RIEN_",",.02,"I")
IF DFN=""
QUIT
+29 IF '$DATA(@FGLOB@(DFN))
QUIT
+30 SET @TGLOB@(DFN)=""
End DoDot:2
End DoDot:1
+31 ;
+32 IF $GET(FGLOB)=""
Begin DoDot:1
+33 SET RIEN=""
+34 FOR
SET RIEN=$ORDER(^AUPNVPRV("B",PROV,RIEN))
IF 'RIEN
QUIT
Begin DoDot:2
+35 SET DFN=$$GET1^DIQ(9000010.06,RIEN_",",.02,"I")
IF DFN=""
QUIT
+36 SET @TGLOB@(DFN)=""
End DoDot:2
End DoDot:1
+37 QUIT
+38 ;
PRVS(TGLOB,PROV,FROM,THRU) ;EP
+1 ; this cross-reference does not really exist yet, it is a test to determine
+2 ; a more efficient cross-reference
+3 SET FDT=FROM
+4 FOR
SET FDT=$ORDER(^AUPNVPRV("AF",PROV,FDT))
IF FDT=""!(FDT\1>THRU)
QUIT
Begin DoDot:1
+5 SET DFN=""
+6 FOR
SET DFN=$ORDER(^AUPNVPRV("AF",PROV,FDT,DFN))
IF DFN=""
QUIT
SET @TGLOB@(DFN)=""
End DoDot:1
+7 ;
+8 QUIT
+9 ;
VIS(FGLOB,TGLOB,FDT,TDT,MAPARMS) ;EP - Visit search
+1 IF $GET(TGLOB)=""
QUIT
+2 ;
+3 NEW DFN,IEN,RIEN,CLNFLG,PRVFLG,VCLIN,PRIEN,VPRV,OK,NOVST,VDCLIN
+4 NEW VNDATA,VDDATA,VDCLPR,VDPROV,VDAND
+5 ;
+6 ; Clinic only data
+7 SET VDCLIN=$NAME(^TMP("BQIVISCLN",UID))
+8 SET VNDATA=$NAME(^TMP("BQINOVIS",UID))
+9 ; Patient only data
+10 SET VDDATA=$NAME(^TMP("BQIVISONLY",UID))
+11 ; Clinic and provider data
+12 SET VDCLPR=$NAME(^TMP("BQIVISCLPR",UID))
+13 ; Provider only data
+14 SET VDPROV=$NAME(^TMP("BQIVISPRV",UID))
+15 ; 'AND' data
+16 SET VDAND=$NAME(^TMP("BQIVISAND",UID))
+17 KILL @VDCLIN,@VNDATA,@VDCLPR,@VDDATA,@VDAND,@VDPROV
+18 ;
+19 SET FDT=$SELECT(FDT'="":FDT-.001,1:FDT)
SET TDT=$SELECT(TDT'="":TDT,1:DT)
+20 FOR
SET FDT=$ORDER(^AUPNVSIT("B",FDT))
IF FDT=""!(FDT\1>TDT)
QUIT
Begin DoDot:1
+21 SET RIEN=""
+22 FOR
SET RIEN=$ORDER(^AUPNVSIT("B",FDT,RIEN))
IF 'RIEN
QUIT
Begin DoDot:2
+23 ; If the visit is deleted, quit
+24 IF $$GET1^DIQ(9000010,RIEN_",",.11,"I")=1
QUIT
+25 SET DFN=$$GET1^DIQ(9000010,RIEN_",",.05,"I")
IF DFN=""
QUIT
+26 IF "DXCTI"[$PIECE(^AUPNVSIT(RIEN,0),U,7)
QUIT
+27 SET @VDDATA@(DFN)=$GET(@VDDATA@(DFN))+1
+28 SET VCLIN=$$GET1^DIQ(9000010,RIEN_",",.08,"I")
+29 IF VCLIN'=""
Begin DoDot:3
+30 SET @VDCLIN@(VCLIN,DFN)=$GET(@VDCLIN@(VCLIN,DFN))+1
+31 SET @VDCLIN@(VCLIN)=$GET(@VDCLIN@(VCLIN))+1
End DoDot:3
+32 ;Find associated providers
+33 SET PRIEN=""
FOR
SET PRIEN=$ORDER(^AUPNVPRV("AD",RIEN,PRIEN))
IF PRIEN=""
QUIT
Begin DoDot:3
+34 SET VPRV=$$GET1^DIQ(9000010.06,PRIEN_",",.01,"I")
IF VPRV=""
QUIT
+35 IF VCLIN'=""
Begin DoDot:4
+36 SET @VDCLPR@(VCLIN,VPRV,DFN)=$GET(@VDCLPR@(VCLIN,VPRV,DFN))+1
+37 SET @VDCLPR@(VCLIN,VPRV)=$GET(@VDCLPR@(VCLIN,VPRV))+1
End DoDot:4
+38 SET @VDPROV@(VPRV,DFN)=$GET(@VDPROV@(VPRV,DFN))+1
End DoDot:3
End DoDot:2
End DoDot:1
+39 ;
+40 IF $DATA(MAPARMS)
Begin DoDot:1
+41 SET MN=""
SET TOT=0
+42 FOR
SET MN=$ORDER(MAPARMS(MN))
IF MN=""
QUIT
Begin DoDot:2
+43 SET NUMVIS=$GET(MAPARMS(MN,"NUMVIS"))
SET CLIN=$GET(MAPARMS(MN,"CLIN"))
SET PROV=$GET(MAPARMS(MN,"PROV"))
+44 DO CALB(NUMVIS,CLIN,PROV,VISOP)
End DoDot:2
End DoDot:1
+45 ;
+46 IF '$DATA(MAPARMS)
Begin DoDot:1
+47 SET TOT=0
+48 IF $DATA(APARMS)
Begin DoDot:2
+49 SET NUMVIS=""
+50 FOR
SET NUMVIS=$ORDER(APARMS("NUMVIS",NUMVIS))
IF NUMVIS=""
QUIT
Begin DoDot:3
+51 SET PROV=$GET(APARMS("NUMVIS",NUMVIS,"PROV"))
+52 SET CLIN=$GET(APARMS("NUMVIS",NUMVIS,"CLIN"))
+53 DO CALB($GET(NUMVIS),$GET(CLIN),$GET(PROV),$GET(VISOP))
End DoDot:3
End DoDot:2
QUIT
+54 DO CALB($GET(NUMVIS),$GET(CLIN),$GET(PROV),$GET(VISOP))
End DoDot:1
+55 ;
+56 ;no visits, so if have visits, exclude
+57 IF $GET(FGLOB)=""
Begin DoDot:1
+58 IF $DATA(@VNDATA)
SET IEN=0
FOR
SET IEN=$ORDER(^AUPNPAT(IEN))
IF 'IEN
QUIT
IF '$DATA(@VNDATA@(IEN))
IF $GET(^AUPNPAT(IEN,0))'=""
SET @TGLOB@(IEN)=""
End DoDot:1
+59 IF $GET(FGLOB)'=""
Begin DoDot:1
+60 IF $DATA(@VNDATA)
SET IEN=""
FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
IF '$DATA(@VNDATA@(IEN))
SET @TGLOB@(IEN)=""
End DoDot:1
+61 ;
+62 IF VISOP="&"
Begin DoDot:1
+63 SET IEN=""
FOR
SET IEN=$ORDER(@VDAND@(IEN))
IF IEN=""
QUIT
IF @VDAND@(IEN)'=TOT
KILL @VDAND@(IEN)
+64 SET IEN=""
FOR
SET IEN=$ORDER(@VDAND@(IEN))
IF IEN=""
QUIT
SET @TGLOB@(IEN)=""
End DoDot:1
+65 ;
+66 KILL @VDCLIN,@VNDATA,@VDCLPR,@VDDATA,@VDAND,@VDPROV
+67 QUIT
+68 ;
CALC(NUMVIS,CLIN,PROV) ; EP
+1 ; Single numvis value, not inclusive or exclusive
+2 IF NUMVIS'["~"
Begin DoDot:1
+3 IF $GET(FGLOB)'=""
Begin DoDot:2
+4 IF CLIN=""
IF PROV=""
Begin DoDot:3
+5 SET IEN=""
+6 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
IF @(@VDDATA@(IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
+7 IF CLIN=""
IF PROV'=""
Begin DoDot:3
+8 SET IEN=""
+9 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
IF @(@VDPROV@(PROV,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
+10 SET IEN=""
End DoDot:3
+11 IF CLIN'=""
IF PROV=""
Begin DoDot:3
+12 SET IEN=""
+13 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
IF @(@VDCLIN@(CLIN,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
+14 IF CLIN'=""
IF PROV'=""
Begin DoDot:3
+15 SET IEN=""
+16 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
IF @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
End DoDot:2
+17 IF $GET(FGLOB)=""
Begin DoDot:2
+18 IF CLIN=""
IF PROV=""
Begin DoDot:3
+19 SET IEN=""
+20 FOR
SET IEN=$ORDER(@VDDATA@(IEN))
IF IEN=""
QUIT
IF @(@VDDATA@(IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
+21 IF CLIN=""
IF PROV'=""
Begin DoDot:3
+22 SET IEN=""
+23 FOR
SET IEN=$ORDER(@VDPROV@(PROV,IEN))
IF IEN=""
QUIT
IF @(@VDPROV@(PROV,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
+24 IF CLIN'=""
IF PROV=""
Begin DoDot:3
+25 SET IEN=""
+26 FOR
SET IEN=$ORDER(@VDCLIN@(CLIN,IEN))
IF IEN=""
QUIT
IF @(@VDCLIN@(CLIN,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
+27 IF CLIN'=""
IF PROV'=""
Begin DoDot:3
+28 SET IEN=""
+29 FOR
SET IEN=$ORDER(@VDCLPR@(CLIN,PROV,IEN))
IF IEN=""
QUIT
IF @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS)
SET @TGLOB@(IEN)=""
End DoDot:3
End DoDot:2
End DoDot:1
+30 ;
+31 IF NUMVIS["~"
Begin DoDot:1
+32 SET VCRIT1=$PIECE(NUMVIS,"~",1)
SET VCRIT2=$PIECE(NUMVIS,"~",2)
+33 IF $GET(FGLOB)'=""
Begin DoDot:2
+34 IF CLIN=""
IF PROV=""
Begin DoDot:3
+35 SET IEN=""
+36 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
Begin DoDot:4
+37 ; If criteria includes a "not" it is inclusive and both must be true
+38 IF $EXTRACT(VCRIT1)="'"
IF @(@VDDATA@(IEN)_VCRIT1)
IF @(@VDDATA@(IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+39 ; If criteria does not includes a "not" it is exclusive and one must be true
+40 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+41 IF CLIN=""
IF PROV'=""
Begin DoDot:3
+42 SET IEN=""
+43 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
Begin DoDot:4
+44 ; If criteria includes a "not" it is inclusive and both must be true
+45 IF $EXTRACT(VCRIT1)="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1)
IF @(@VDPROV@(PROV,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+46 ; If criteria does not includes a "not" it is exclusive and one must be true
+47 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+48 IF CLIN'=""
IF PROV=""
Begin DoDot:3
+49 SET IEN=""
+50 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
Begin DoDot:4
+51 ; If criteria includes a "not" it is inclusive and both must be true
+52 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1)
IF @(@VDCLIN@(CLIN,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+53 ; If criteria does not includes a "not" it is exclusive and one must be true
+54 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+55 IF CLIN'=""
IF PROV'=""
Begin DoDot:3
+56 SET IEN=""
+57 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
Begin DoDot:4
+58 ; If criteria includes a "not" it is inclusive and both must be true
+59 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1)
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+60 ; If criteria does not includes a "not" it is exclusive and one must be true
+61 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
End DoDot:2
+62 ;
+63 IF $GET(FGLOB)=""
Begin DoDot:2
+64 IF CLIN=""
IF PROV=""
Begin DoDot:3
+65 SET IEN=""
+66 FOR
SET IEN=$ORDER(@VDDATA@(IEN))
IF IEN=""
QUIT
Begin DoDot:4
+67 ; If criteria includes a "not" it is inclusive and both must be true
+68 IF $EXTRACT(VCRIT1)="'"
IF @(@VDDATA@(IEN)_VCRIT1)
IF @(@VDDATA@(IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+69 ; If criteria does not includes a "not" it is exclusive and one must be true
+70 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+71 IF CLIN=""
IF PROV'=""
Begin DoDot:3
+72 SET IEN=""
+73 FOR
SET IEN=$ORDER(@VDPROV@(PROV,IEN))
IF IEN=""
QUIT
Begin DoDot:4
+74 ; If criteria includes a "not" it is inclusive and both must be true
+75 IF $EXTRACT(VCRIT1)="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1)
IF @(@VDPROV@(PROV,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+76 ; If criteria does not includes a "not" it is exclusive and one must be true
+77 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+78 IF CLIN'=""
IF PROV=""
Begin DoDot:3
+79 SET IEN=""
+80 FOR
SET IEN=$ORDER(@VDCLIN@(CLIN,IEN))
IF IEN=""
QUIT
Begin DoDot:4
+81 ; If criteria includes a "not" it is inclusive and both must be true
+82 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1)
IF @(@VDCLIN@(CLIN,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+83 ; If criteria does not includes a "not" it is exclusive and one must be true
+84 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
+85 IF CLIN'=""
IF PROV'=""
Begin DoDot:3
+86 SET IEN=""
+87 FOR
SET IEN=$ORDER(@VDCLPR@(CLIN,PROV,IEN))
IF IEN=""
QUIT
Begin DoDot:4
+88 ; If criteria includes a "not" it is inclusive and both must be true
+89 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1)
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)
SET @TGLOB@(IEN)=""
QUIT
+90 ; If criteria does not includes a "not" it is exclusive and one must be true
+91 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")")
SET @TGLOB@(IEN)=""
QUIT
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+92 QUIT
+93 ;
CALB(NUMVIS,CLIN,PROV,VISOP) ;EP
+1 SET TOT=TOT+1
SET NOVST=0
+2 IF NUMVIS="=0"!(NUMVIS="<0")!(NUMVIS="<1")!(NUMVIS="'>0")
SET NOVST=1
+3 IF NUMVIS["~"
SET VCRIT1=$PIECE(NUMVIS,"~",1)
SET VCRIT2=$PIECE(NUMVIS,"~",2)
+4 IF NUMVIS'["~"
SET VCRIT1=""
SET VCRIT2=""
+5 IF $GET(FGLOB)'=""
Begin DoDot:1
+6 SET IEN=""
+7 FOR
SET IEN=$ORDER(@FGLOB@(IEN))
IF IEN=""
QUIT
Begin DoDot:2
+8 IF CLIN=""
IF PROV=""
DO VDD
+9 IF CLIN'=""
IF PROV=""
DO VDC
+10 IF CLIN=""
IF PROV'=""
DO VDP
+11 IF CLIN'=""
IF PROV'=""
DO VDBT
End DoDot:2
End DoDot:1
+12 ;
+13 IF $GET(FGLOB)=""
Begin DoDot:1
+14 IF CLIN=""
IF PROV=""
SET IEN=""
FOR
SET IEN=$ORDER(@VDDATA@(IEN))
IF IEN=""
QUIT
DO VDD
+15 IF CLIN'=""
IF PROV=""
SET IEN=""
FOR
SET IEN=$ORDER(@VDCLIN@(CLIN,IEN))
IF IEN=""
QUIT
DO VDC
+16 IF CLIN=""
IF PROV'=""
SET IEN=""
FOR
SET IEN=$ORDER(@VDPROV@(PROV,IEN))
IF IEN=""
QUIT
DO VDP
+17 IF CLIN'=""
IF PROV'=""
SET IEN=""
FOR
SET IEN=$ORDER(@VDCLPR@(CLIN,PROV,IEN))
IF IEN=""
QUIT
DO VDBT
End DoDot:1
+18 QUIT
+19 ;
VDD ; Visit Only
+1 IF NOVST
IF $DATA(@VDDATA@(IEN))
SET @VNDATA@(IEN)=""
QUIT
+2 IF '$DATA(@VDDATA@(IEN))
QUIT
+3 IF VCRIT1=""
Begin DoDot:1
+4 IF @(@VDDATA@(IEN)_NUMVIS)
Begin DoDot:2
+5 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+6 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:2
End DoDot:1
QUIT
+7 ; If criteria includes a "not" it is inclusive and both must be true
+8 IF $EXTRACT(VCRIT1)="'"
IF @(@VDDATA@(IEN)_VCRIT1)
IF @(@VDDATA@(IEN)_VCRIT2)
Begin DoDot:1
+9 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+10 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+11 ; If criteria does not includes a "not" it is exclusive and one must be true
+12 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDDATA@(IEN)_VCRIT1_"!("_(@VDDATA@(IEN)_VCRIT2)_")")
Begin DoDot:1
+13 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+14 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+15 QUIT
+16 ;
VDC ; Clinic Only
+1 IF NOVST
IF $DATA(@VDCLIN@(CLIN,IEN))
SET @VNDATA@(IEN)=""
QUIT
+2 IF '$DATA(@VDCLIN@(CLIN,IEN))
QUIT
+3 IF VCRIT1=""
Begin DoDot:1
+4 IF @(@VDCLIN@(CLIN,IEN)_NUMVIS)
Begin DoDot:2
+5 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+6 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:2
End DoDot:1
QUIT
+7 ; If criteria includes a "not" it is inclusive and both must be true
+8 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1)
IF @(@VDCLIN@(CLIN,IEN)_VCRIT2)
Begin DoDot:1
+9 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+10 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+11 ; If criteria does not includes a "not" it is exclusive and one must be true
+12 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLIN@(CLIN,IEN)_VCRIT1_"!("_(@VDCLIN@(CLIN,IEN)_VCRIT2)_")")
Begin DoDot:1
+13 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+14 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+15 QUIT
+16 ;
VDP ; Provider Only
+1 IF NOVST
IF $DATA(@VDPROV@(PROV,IEN))
SET @VNDATA@(IEN)=""
QUIT
+2 IF '$DATA(@VDPROV@(PROV,IEN))
QUIT
+3 IF VCRIT1=""
Begin DoDot:1
+4 IF @(@VDPROV@(PROV,IEN)_NUMVIS)
Begin DoDot:2
+5 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+6 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:2
End DoDot:1
QUIT
+7 ; If criteria includes a "not" it is inclusive and both must be true
+8 IF $EXTRACT(VCRIT1)="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1)
IF @(@VDPROV@(PROV,IEN)_VCRIT2)
Begin DoDot:1
+9 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+10 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+11 ; If criteria does not includes a "not" it is exclusive and one must be true
+12 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDPROV@(PROV,IEN)_VCRIT1_"!("_(@VDPROV@(PROV,IEN)_VCRIT2)_")")
Begin DoDot:1
+13 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+14 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+15 QUIT
+16 ;
VDBT ; Clinic and Provider
+1 IF NOVST
IF $DATA(@VDCLPR@(CLIN,PROV,IEN))
SET @VNDATA@(IEN)=""
QUIT
+2 IF '$DATA(@VDCLPR@(CLIN,PROV,IEN))
QUIT
+3 IF VCRIT1=""
Begin DoDot:1
+4 IF @(@VDCLPR@(CLIN,PROV,IEN)_NUMVIS)
Begin DoDot:2
+5 IF VISOP="!"
SET @TGLOB@(IEN)=""
+6 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:2
End DoDot:1
QUIT
+7 ; If criteria includes a "not" it is inclusive and both must be true
+8 IF $EXTRACT(VCRIT1)="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1)
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)
Begin DoDot:1
+9 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+10 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+11 ; If criteria does not includes a "not" it is exclusive and one must be true
+12 IF $EXTRACT(VCRIT1)'="'"
IF @(@VDCLPR@(CLIN,PROV,IEN)_VCRIT1_"!("_(@VDCLPR@(CLIN,PROV,IEN)_VCRIT2)_")")
Begin DoDot:1
+13 IF VISOP="!"
SET @TGLOB@(IEN)=""
QUIT
+14 IF VISOP="&"
SET @VDAND@(IEN)=$GET(@VDAND@(IEN))+1
End DoDot:1
+15 QUIT