TIUSRVLV ; SLC/JER - Server fns for lists by Visit ;Jan 26, 2024@07:19
;;1.0;TEXT INTEGRATION UTILITIES;**7,47,100,362**;Jun 20, 1997;Build 3
;
; Reference to ^AUPNVSIT( in ICR #2028
; Reference to FINDVISIT^PXUTLVST in ICR #7435
;
Q
NOTES(TIUY,VISIT,STATUS) ; Gets list of Notes
I $S(+$G(VISIT)'>0:1,'$D(^AUPNVSIT(+$G(VISIT),0)):1,1:0) Q
D LIST(.TIUY,VISIT,3,$G(STATUS))
Q
SUMMARY(TIUY,VISIT,STATUS) ; Gets list of Summaries
I $S(+$G(VISIT)'>0:1,'$D(^AUPNVSIT(+$G(VISIT),0)):1,1:0) Q
D LIST(.TIUY,VISIT,244,$G(STATUS))
Q
LIST(TIUY,VISIT,CLASS,STATUS) ; Get documents for a visit
N TIUDA,TIUTTL,TIUCCLS,TIUCCPN S TIUDA=0
K ^TMP("TIULIST",$J) S TIUY=$NA(^TMP("TIULIST",$J))
S TIUCCLS=+$$CLASS^TIUCNSLT,TIUCCPN=+$$ISA^TIULX(TIUCCLS,3)
I $S(+$G(VISIT)'>0:1,'$D(^AUPNVSIT(+VISIT)):1,+$G(CLASS)'>0:1,1:0) Q
F S TIUDA=$O(^TIU(8925,"V",VISIT,TIUDA)) Q:+TIUDA'>0 D
. N TIUTTL,TIUI,TIUD0,TIUSTS S TIUI=0,TIUD0=$G(^TIU(8925,+TIUDA,0))
. Q:+$P(TIUD0,U,6)
. S TIUTTL=+TIUD0,TIUSTS=$P(TIUD0,U,5) Q:+TIUTTL'>0
. I +$G(STATUS),(TIUSTS'=STATUS) Q
. I +$$ISA^TIULX(TIUTTL,CLASS) D ADDELMNT(TIUDA,TIUI) I 1
. E I CLASS=3,'TIUCCPN,+$$ISA^TIULX(TIUTTL,TIUCCLS) D ADDELMNT(TIUDA,TIUI)
K ^TMP("TIULIST",$J,"INDX")
Q
ADDELMNT(DA,TIUCNT) ; Add each element to the list
N DOC,LOC,PT,AUT,EDT,TIUPT,TIULST4,TIUREC,TIUR0,TIUR12,TIUR13
N STATUS,EDTCNT,LOCTYP,TIUADT,TIUDDT
S TIUR0=$G(^TIU(8925,+DA,0)),TIUR12=$G(^TIU(8925,+DA,12))
S TIUR13=$G(^TIU(8925,+DA,13))
; If doc is an ID Child, return it's parent
I +$G(^TIU(8925,DA,21)) S DA=+$G(^TIU(8925,DA,21))
; Don't return duplicates
I +$O(^TMP("TIULIST",$J,"INDX",DA,0)) Q
S TIUPT=$G(^DPT(+$P(TIUR0,U,2),0)),DOC=$$PNAME^TIULC1(+TIUR0)
I DOC="Addendum" S DOC=DOC_" to "_$$PNAME^TIULC1(+$G(^TIU(8925,+$P(TIUR0,U,6),0)))
S STATUS=$$LOWER^TIULS($P(^TIU(8925.6,+$P(TIUR0,U,5),0),U))
S LOC=$G(^SC(+$P(TIUR12,U,5),0)),LOCTYP=$P(LOC,U,3),LOC=$P(LOC,U)
S TIUADT=$S(LOCTYP="W":"Adm: ",1:"Visit: ")_$$DATE^TIULS($P(TIUR0,U,7),"MM/DD/YY")
S TIUDDT=$S(+$P(TIUR0,U,8):"Dis: ",1:"")_$$DATE^TIULS($P(TIUR0,U,8),"MM/DD/YY")
S PT=$$NAME^TIULS($P(TIUPT,U),"LAST, FIRST MI")
S TIULST4=$E($P(TIUPT,U,9),6,9)
S TIULST4="("_$E(PT)_TIULST4_")"
S AUT=$$SIGNAME^TIULS(+$P(TIUR12,U,2))
S EDT=+TIUR13,EDTCNT=+$G(EDTCNT)+1
F Q:+$D(^TMP("TIULIST",$J,9999999-EDT,EDTCNT))'>0 S EDTCNT=EDTCNT+1
S TIUCNT=+$G(TIUCNT)+1
S TIUREC=DA_U_DOC_U_EDT_U_PT_" "_TIULST4_U_AUT_U_LOC_U_STATUS_U_TIUADT_U_TIUDDT
S ^TMP("TIULIST",$J,9999999-EDT,EDTCNT)=TIUREC
S ^TMP("TIULIST",$J,"INDX",DA,EDTCNT)=""
Q
DOCCNT(TIUY,DFN,VSTR,VSIT,CNTSCND) ; Get # of Documents for a given visit
;
; DFN = Patient IEN (#2)
; VSTR = Visit String
; VSIT = Visit IEN (#9000010)
; CNTSCND = Count also documents that reference the Visit via the SECONDARY VISIT field.
; (Possible values: 1/0; Optional; Defaults to 0)
;
; Must either pass in VSIT, or must pass in the DFN and VSTR.
; It is best to pass in VSIT. DFN and VSTR are only included for backward compatability.
;
N VISITLIST,NOTEINDEX,TIUNOTE,TIUVST
;
S TIUY=0
I '$G(VSIT),('$G(DFN)!($G(VSTR)="")) Q
;
I '$G(VSIT) D
. D FINDVISIT^PXUTLVST(DFN,$P(VSTR,";",2),$P(VSTR,";"),"","","",$P(VSTR,";",3),"",1,.VISITLIST)
. I $G(VISITLIST(0))=1 S VSIT=$G(VISITLIST(1))
;
I +$G(VSIT) D
. S TIUNOTE=0
. F S TIUNOTE=$O(^TIU(8925,"V",+VSIT,TIUNOTE)) Q:TIUNOTE'>0 D
. . S TIUY=TIUY+1
. . S NOTEINDEX(TIUNOTE)=""
;
I '$G(VSIT) D
. S TIUVST=0
. F S TIUVST=$O(^TIU(8925,"AVSTRV",DFN,VSTR,TIUVST)) Q:TIUVST'>0 D
. . S TIUNOTE=0
. . F S TIUNOTE=$O(^TIU(8925,"AVSTRV",DFN,VSTR,TIUVST,TIUNOTE)) Q:TIUNOTE'>0 D
. . . S TIUY=TIUY+1
. . . S NOTEINDEX(TIUNOTE)=""
;
I $G(CNTSCND)'=1 Q
I '$G(VSIT) Q
;
S TIUNOTE=0
F S TIUNOTE=$O(^TIU(8925,"VS",VSIT,TIUNOTE)) Q:TIUNOTE'>0 D
. I $D(NOTEINDEX(TIUNOTE)) Q
. S TIUY=TIUY+1
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIUSRVLV 3929 printed Oct 16, 2024@18:46:30 Page 2
TIUSRVLV ; SLC/JER - Server fns for lists by Visit ;Jan 26, 2024@07:19
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**7,47,100,362**;Jun 20, 1997;Build 3
+2 ;
+3 ; Reference to ^AUPNVSIT( in ICR #2028
+4 ; Reference to FINDVISIT^PXUTLVST in ICR #7435
+5 ;
+6 QUIT
NOTES(TIUY,VISIT,STATUS) ; Gets list of Notes
+1 IF $SELECT(+$GET(VISIT)'>0:1,'$DATA(^AUPNVSIT(+$GET(VISIT),0)):1,1:0)
QUIT
+2 DO LIST(.TIUY,VISIT,3,$GET(STATUS))
+3 QUIT
SUMMARY(TIUY,VISIT,STATUS) ; Gets list of Summaries
+1 IF $SELECT(+$GET(VISIT)'>0:1,'$DATA(^AUPNVSIT(+$GET(VISIT),0)):1,1:0)
QUIT
+2 DO LIST(.TIUY,VISIT,244,$GET(STATUS))
+3 QUIT
LIST(TIUY,VISIT,CLASS,STATUS) ; Get documents for a visit
+1 NEW TIUDA,TIUTTL,TIUCCLS,TIUCCPN
SET TIUDA=0
+2 KILL ^TMP("TIULIST",$JOB)
SET TIUY=$NAME(^TMP("TIULIST",$JOB))
+3 SET TIUCCLS=+$$CLASS^TIUCNSLT
SET TIUCCPN=+$$ISA^TIULX(TIUCCLS,3)
+4 IF $SELECT(+$GET(VISIT)'>0:1,'$DATA(^AUPNVSIT(+VISIT)):1,+$GET(CLASS)'>0:1,1:0)
QUIT
+5 FOR
SET TIUDA=$ORDER(^TIU(8925,"V",VISIT,TIUDA))
if +TIUDA'>0
QUIT
Begin DoDot:1
+6 NEW TIUTTL,TIUI,TIUD0,TIUSTS
SET TIUI=0
SET TIUD0=$GET(^TIU(8925,+TIUDA,0))
+7 if +$PIECE(TIUD0,U,6)
QUIT
+8 SET TIUTTL=+TIUD0
SET TIUSTS=$PIECE(TIUD0,U,5)
if +TIUTTL'>0
QUIT
+9 IF +$GET(STATUS)
IF (TIUSTS'=STATUS)
QUIT
+10 IF +$$ISA^TIULX(TIUTTL,CLASS)
DO ADDELMNT(TIUDA,TIUI)
IF 1
+11 IF '$TEST
IF CLASS=3
IF 'TIUCCPN
IF +$$ISA^TIULX(TIUTTL,TIUCCLS)
DO ADDELMNT(TIUDA,TIUI)
End DoDot:1
+12 KILL ^TMP("TIULIST",$JOB,"INDX")
+13 QUIT
ADDELMNT(DA,TIUCNT) ; Add each element to the list
+1 NEW DOC,LOC,PT,AUT,EDT,TIUPT,TIULST4,TIUREC,TIUR0,TIUR12,TIUR13
+2 NEW STATUS,EDTCNT,LOCTYP,TIUADT,TIUDDT
+3 SET TIUR0=$GET(^TIU(8925,+DA,0))
SET TIUR12=$GET(^TIU(8925,+DA,12))
+4 SET TIUR13=$GET(^TIU(8925,+DA,13))
+5 ; If doc is an ID Child, return it's parent
+6 IF +$GET(^TIU(8925,DA,21))
SET DA=+$GET(^TIU(8925,DA,21))
+7 ; Don't return duplicates
+8 IF +$ORDER(^TMP("TIULIST",$JOB,"INDX",DA,0))
QUIT
+9 SET TIUPT=$GET(^DPT(+$PIECE(TIUR0,U,2),0))
SET DOC=$$PNAME^TIULC1(+TIUR0)
+10 IF DOC="Addendum"
SET DOC=DOC_" to "_$$PNAME^TIULC1(+$GET(^TIU(8925,+$PIECE(TIUR0,U,6),0)))
+11 SET STATUS=$$LOWER^TIULS($PIECE(^TIU(8925.6,+$PIECE(TIUR0,U,5),0),U))
+12 SET LOC=$GET(^SC(+$PIECE(TIUR12,U,5),0))
SET LOCTYP=$PIECE(LOC,U,3)
SET LOC=$PIECE(LOC,U)
+13 SET TIUADT=$SELECT(LOCTYP="W":"Adm: ",1:"Visit: ")_$$DATE^TIULS($PIECE(TIUR0,U,7),"MM/DD/YY")
+14 SET TIUDDT=$SELECT(+$PIECE(TIUR0,U,8):"Dis: ",1:"")_$$DATE^TIULS($PIECE(TIUR0,U,8),"MM/DD/YY")
+15 SET PT=$$NAME^TIULS($PIECE(TIUPT,U),"LAST, FIRST MI")
+16 SET TIULST4=$EXTRACT($PIECE(TIUPT,U,9),6,9)
+17 SET TIULST4="("_$EXTRACT(PT)_TIULST4_")"
+18 SET AUT=$$SIGNAME^TIULS(+$PIECE(TIUR12,U,2))
+19 SET EDT=+TIUR13
SET EDTCNT=+$GET(EDTCNT)+1
+20 FOR
if +$DATA(^TMP("TIULIST",$JOB,9999999-EDT,EDTCNT))'>0
QUIT
SET EDTCNT=EDTCNT+1
+21 SET TIUCNT=+$GET(TIUCNT)+1
+22 SET TIUREC=DA_U_DOC_U_EDT_U_PT_" "_TIULST4_U_AUT_U_LOC_U_STATUS_U_TIUADT_U_TIUDDT
+23 SET ^TMP("TIULIST",$JOB,9999999-EDT,EDTCNT)=TIUREC
+24 SET ^TMP("TIULIST",$JOB,"INDX",DA,EDTCNT)=""
+25 QUIT
DOCCNT(TIUY,DFN,VSTR,VSIT,CNTSCND) ; Get # of Documents for a given visit
+1 ;
+2 ; DFN = Patient IEN (#2)
+3 ; VSTR = Visit String
+4 ; VSIT = Visit IEN (#9000010)
+5 ; CNTSCND = Count also documents that reference the Visit via the SECONDARY VISIT field.
+6 ; (Possible values: 1/0; Optional; Defaults to 0)
+7 ;
+8 ; Must either pass in VSIT, or must pass in the DFN and VSTR.
+9 ; It is best to pass in VSIT. DFN and VSTR are only included for backward compatability.
+10 ;
+11 NEW VISITLIST,NOTEINDEX,TIUNOTE,TIUVST
+12 ;
+13 SET TIUY=0
+14 IF '$GET(VSIT)
IF ('$GET(DFN)!($GET(VSTR)=""))
QUIT
+15 ;
+16 IF '$GET(VSIT)
Begin DoDot:1
+17 DO FINDVISIT^PXUTLVST(DFN,$PIECE(VSTR,";",2),$PIECE(VSTR,";"),"","","",$PIECE(VSTR,";",3),"",1,.VISITLIST)
+18 IF $GET(VISITLIST(0))=1
SET VSIT=$GET(VISITLIST(1))
End DoDot:1
+19 ;
+20 IF +$GET(VSIT)
Begin DoDot:1
+21 SET TIUNOTE=0
+22 FOR
SET TIUNOTE=$ORDER(^TIU(8925,"V",+VSIT,TIUNOTE))
if TIUNOTE'>0
QUIT
Begin DoDot:2
+23 SET TIUY=TIUY+1
+24 SET NOTEINDEX(TIUNOTE)=""
End DoDot:2
End DoDot:1
+25 ;
+26 IF '$GET(VSIT)
Begin DoDot:1
+27 SET TIUVST=0
+28 FOR
SET TIUVST=$ORDER(^TIU(8925,"AVSTRV",DFN,VSTR,TIUVST))
if TIUVST'>0
QUIT
Begin DoDot:2
+29 SET TIUNOTE=0
+30 FOR
SET TIUNOTE=$ORDER(^TIU(8925,"AVSTRV",DFN,VSTR,TIUVST,TIUNOTE))
if TIUNOTE'>0
QUIT
Begin DoDot:3
+31 SET TIUY=TIUY+1
+32 SET NOTEINDEX(TIUNOTE)=""
End DoDot:3
End DoDot:2
End DoDot:1
+33 ;
+34 IF $GET(CNTSCND)'=1
QUIT
+35 IF '$GET(VSIT)
QUIT
+36 ;
+37 SET TIUNOTE=0
+38 FOR
SET TIUNOTE=$ORDER(^TIU(8925,"VS",VSIT,TIUNOTE))
if TIUNOTE'>0
QUIT
Begin DoDot:1
+39 IF $DATA(NOTEINDEX(TIUNOTE))
QUIT
+40 SET TIUY=TIUY+1
End DoDot:1
+41 ;
+42 QUIT