Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: TIUSRVLV

TIUSRVLV.m

Go to the documentation of this file.
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