VSIT ;ISD/MRL,RJP,PKR - Visit Tracking ;03/29/2018
;;1.0;PCE PATIENT CARE ENCOUNTER;**76,111,118,164,211**;Aug 12, 1996;Build 454
; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
; the incorporation of the module into PCE. For historical reference,
; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
; patches.
;
;;2.0;VISIT TRACKING;**1**;Aug 12, 1996
;
; - pass VSIT = <visit date [and time] in FM format>
; DFN = <patient file pointer>
; [VSIT(0)] = <functional parameters>
; [VSIT("xxx")] = <used in match logic if VSIT(0)["M">
; - rtns VSIT("IEN") = <visit record # in format as Y w/ ^DIC>
; VSIT(##,"XXX") = visit values passed by mnemonics
; If VSIT("IEN") = -1 Error in creation/lookup.
; If Vsit("IEN") = -2 Package is turned off or not defined in the
; Visit Tracking Parameters file.
S VSIT("IEN")=$$GET($G(VSIT),$G(DFN),$G(VSIT(0)),.VSIT)
EXIT ;
Q
;
GET(VDT,DFN,PRAM,VSIT) ; find or create a visit
;
; - pass {VDT/VSIT("VDT")} = <visit date [and time] in FM format>
; {DFN/VSIT("PAT")} = <patient file pointer>
; [PRAM/VSIT(0)] = <functional parameters>
; [VSIT("xxx")] = <array w/ mnemonic subscript>
; <used in match logic if VISIT(O)["M">
; <for SVC, TYP, INS, DSS, ELG , LOC>
; - rtns = <visit record # in format as Y w/ ^DIC>
I $G(VSITPKG)]"" S VSIT("PKG")=VSITPKG
E S (VSITPKG,VSIT("PKG"))=$G(VSIT("PKG"))
N PKGP
S PKGP=$$PKG2IEN^VSIT0($G(VSITPKG))
I PKGP=-1 S VSIT("IEN")=-2 G DONE
;Get the site part of the VISIT ID
I $P($G(^DIC(150.9,1,4)),"^",2)<1 S VSIT("IEN")=-1 G DONE
;
K VSIT("IEN"),^TMP("VSITDD",$J),^TMP($J,"VSIT-ERROR")
S:$G(VDT)]"" VSIT("VDT")=VDT
S:$G(DFN) VSIT("PAT")=+DFN
S:$G(PRAM)]"" VSIT(0)=PRAM
;See if the old CLN nodes needs moved into the DSS node.
I '($D(VSIT("DSS"))#2),$D(VSIT("CLN"))#2 S VSIT("DSS")=VSIT("CLN")
;
D FLD^VSITFLD
;Set all of the VSIT nodes with $GET
D SETALL^VSITCK
;
;Inpatient movement
N VSITIPM S VSITIPM=+$$IP^VSITCK1(+VSIT("VDT"),+VSIT("PAT"))
;Do the defaulting of the fields that need to be defaulted for lookup
I $$REQUIRED^VSITDEF S VSIT("IEN")=-1 G DONE
;
D:'$D(DT) DT^DICRW
;
;If Force new visit, make the visit and exit
I VSIT(0)["F" D G QUIT
. D DEFAULTS^VSITDEF
. D ^VSITPUT
;
;If not forcing new visit try to look up the visit
D LST^VSITGET("","","",.VSIT,.VSITGET)
I $$SWSTAT^IBBAPI(),+$G(VSITGET)=1 D ;PX*1.0*164
. N ACT
. I $G(VSIT("ACT"))']0 S VSIT("ACT")=$P($G(^AUPNVSIT(+VSITGET(1),0)),"^",26) Q
. I $G(VSIT("ACT"))]0 S ACT=VSIT("ACT") K VSIT S VSIT("IEN")=+$P(VSITGET(1),"^"),VSIT("ACT")=ACT D UPD^VSIT ;PX*1.0*164
;
I +$G(VSITGET)=0,VSIT(0)["N" D G QUIT
. D DEFAULTS^VSITDEF
. D ^VSITPUT
I +$G(VSITGET)=1 S VSIT("IEN")=$P(VSITGET(1),"|")_"^"_$P($P(VSITGET(1),"^"),"|",2) G QUIT
I +$G(VSITGET)>1,VSIT(0)["I" S Y=$$VSIT^VSITASK(VSIT("PAT"),.VSITGET) S:'+Y Y=1 S VSIT("IEN")=$P(VSITGET(+Y),"|")_"^"_$P($P(VSITGET(+Y),"^"),"|",2) G QUIT
I +$G(VSITGET)>1,VSIT(0)'["I" S VSIT("IEN")=$P(VSITGET(1),"|")_"^"_$P($P(VSITGET(1),"^"),"|",2) G QUIT
S VSIT("IEN")=-1
;
QUIT ; - end of job
; set vsit api
I +$G(VSIT("IEN"))=0 S VSIT("IEN")=-1
D:VSIT("IEN")>0 ALL^VSITVAR(+VSIT("IEN"),"B",1)
;
DONE I $D(^TMP($J,"VSIT-ERROR")),$G(VSIT("IEN"))'>0,VSIT(0)["N"!(VSIT(0)["F") D SND^VSITBUL
K VSITGET
K ^TMP("VSITDD",$J)
Q VSIT("IEN")
;
ADD ; - add to dependency count
; called via cross references on pointer files
D ADD^AUPNVSIT
Q
;
SUB ; - subtract from dependency count
; called via cross references on pointer files
D SUB^AUPNVSIT
Q
;
UPD ;Update Visit File
Q:$G(VSIT("IEN"))<1
Q:'$D(^AUPNVSIT(VSIT("IEN"),0))
N FDA,HNC,IENS,MSG,VSITDR,VSITFLD
S IENS=VSIT("IEN")_","
S VSIT("MDT")=$$NOW^XLFDT
D FLD^VSITFLD
S VSITDR=""
F S VSITDR=$O(VSIT(VSITDR)) Q:VSITDR="" D
. I $G(^TMP("VSITDD",$J,VSITDR))="" Q
. S VSITFLD=$P(^TMP("VSITDD",$J,VSITDR),";",2) ;Field
. S FDA(9000010,IENS,VSITFLD)=VSIT(VSITDR)
L +^AUPNVSIT(+VSIT("IEN")):DILOCKTM
D FILE^DIE("","FDA","MSG")
L -^AUPNVSIT(+VSIT("IEN"))
I $D(MSG) D Q
. N SUBJECT
. S SUBJECT="UPD^VSIT failed for Visit IEN="_VSIT("IEN")
. D SENDEMSG^PXMCLINK(SUBJECT,.MSG)
K ^TMP("VSITDD",$J)
;
;PX*1*111 - Update NTR file for Head & Neck
S HNC=$P($G(^AUPNVSIT(VSIT("IEN"),800)),U,6)
I HNC'=1 Q
N DGARR,PXDFN,SDRES
S PXDFN=$P(^AUPNVSIT(VSIT("IEN"),0),U,5)
I PXDFN="" Q
S SDRES=$$GETCUR^DGNTAPI(PXDFN,"DGARR")
I +$G(DGARR("STAT"))'=3 Q ;NTR File does not require editing
S SDRES=$$FILEHNC^DGNTAPI1(PXDFN)
Q
;
PKG2IEN(PKG) ;Pass in package name space and
; returns pointer to the package in the Package file #9.4
Q $$PKG2IEN^VSIT0($G(PKG))
;
PKG(PKG,VALUE) ;-Entry point to add package to multiple in tracking parameters
;-PKG=Package Name Space
;-VALUE=Value on the ON/OFF flag under package multiple
;--1=ON 0=OFF
Q $$PKG^VSIT0($G(PKG),$G(VALUE))
;
PKGON(PKG) ; -- Returns the active flag for the package
; 1 the package can create visits
; 0 the package cannot create visits
; -1 called wrong or could not find package in VT parameters file
Q $$PKGON^VSIT0($G(PKG))
;
IEN2VID(IEN) ; -- Call with Visit IEN and returns the Visit ID
Q:'($D(^AUPNVSIT(+IEN,150))#2) -1
Q $P(^AUPNVSIT(IEN,150),"^",1)
;
VID2IEN(VID) ; -- Call with Visit's ID and returns the Visit IEN
N IEN
S IEN=$O(^AUPNVSIT("VID",VID,0))
Q $S(IEN]"":IEN,1:-1)
;
LOOKUP(IEN,FMT,WITHIEN) ; -- Lookup a visit and return all of its information
;DBIA #: 1906
;Parameters:
; IEN is the IEN for the Visit OR the Visit's ID
; FMT is the format that you want the output where
; I ::= internal format
; E ::= external format
; B ::= both internal and external format
; B is the default if FMT is anything other than "I" or "E"
; WITHIEN is 0 if you do not want the IEN of the VSIT( as the first
; subscript and 1 if you do. "1" is the default.
;
;Return: -1 if IEN was not a valid IEN or Visit ID
; otherwise returns IEN
; VSIT( an array VSIT(Visit IEN,field) or VSIT(field) depending
; on the value of WITHIEN. The array is all of the fields
; in the visit file. If B(oth) internal and external format
; are returned the format is: internal^external.
; If I(nternal) format is requested only the internal part
; is returned.
; If E(xternal) format is requested the format is: ^external
; External values, if requested, are always returned in the
; second pieces of the array elements.
;
Q:$G(IEN)']"" -1
S:+IEN'=IEN IEN=$$VID2IEN(IEN) ;PX*1.0*118
Q:'($D(^AUPNVSIT(+IEN,0))#2) -1
S FMT=$G(FMT)
S FMT=$S(FMT["B":"B",FMT["I":"I",FMT["E":"E",1:"B")
S WITHIEN=$S($G(WITHIEN)=0:0,1:1)
D ALL^VSITVAR(IEN,FMT,WITHIEN)
Q IEN
;
SELECTED(DFN,SDT,EDT,HOSLOC,ENCTYPE,NENCTYPE,SERVCAT,NSERVCAT,LASTN) ;
; -- Returns selected visits depending on screens passed in.
D VSITAPI^VSITOE($G(DFN),$G(SDT),$G(EDT),$G(HOSLOC),$G(ENCTYPE),$G(NENCTYPE),$G(SERVCAT),$G(NSERVCAT),$G(LASTN))
Q
;
HISTORIC(IEN) ; -- Returns 1 if it is an Historical visit ("E" in #.07)
; 0 if it is not an Historical visit.
; -1 if the IEN is bad
Q $S('($D(^AUPNVSIT(IEN,0))#2):-1,1:$P($G(^AUPNVSIT(IEN,0)),"^",7)="E")
;
MODIFIED(IEN) ;Sets the Date Last Modified (.13) field to NOW
;
N VSIT
S VSIT("IEN")=IEN
D UPD
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVSIT 7740 printed Dec 13, 2024@02:32:23 Page 2
VSIT ;ISD/MRL,RJP,PKR - Visit Tracking ;03/29/2018
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**76,111,118,164,211**;Aug 12, 1996;Build 454
+2 ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
+3 ; the incorporation of the module into PCE. For historical reference,
+4 ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
+5 ; patches.
+6 ;
+7 ;;2.0;VISIT TRACKING;**1**;Aug 12, 1996
+8 ;
+9 ; - pass VSIT = <visit date [and time] in FM format>
+10 ; DFN = <patient file pointer>
+11 ; [VSIT(0)] = <functional parameters>
+12 ; [VSIT("xxx")] = <used in match logic if VSIT(0)["M">
+13 ; - rtns VSIT("IEN") = <visit record # in format as Y w/ ^DIC>
+14 ; VSIT(##,"XXX") = visit values passed by mnemonics
+15 ; If VSIT("IEN") = -1 Error in creation/lookup.
+16 ; If Vsit("IEN") = -2 Package is turned off or not defined in the
+17 ; Visit Tracking Parameters file.
+18 SET VSIT("IEN")=$$GET($GET(VSIT),$GET(DFN),$GET(VSIT(0)),.VSIT)
EXIT ;
+1 QUIT
+2 ;
GET(VDT,DFN,PRAM,VSIT) ; find or create a visit
+1 ;
+2 ; - pass {VDT/VSIT("VDT")} = <visit date [and time] in FM format>
+3 ; {DFN/VSIT("PAT")} = <patient file pointer>
+4 ; [PRAM/VSIT(0)] = <functional parameters>
+5 ; [VSIT("xxx")] = <array w/ mnemonic subscript>
+6 ; <used in match logic if VISIT(O)["M">
+7 ; <for SVC, TYP, INS, DSS, ELG , LOC>
+8 ; - rtns = <visit record # in format as Y w/ ^DIC>
+9 IF $GET(VSITPKG)]""
SET VSIT("PKG")=VSITPKG
+10 IF '$TEST
SET (VSITPKG,VSIT("PKG"))=$GET(VSIT("PKG"))
+11 NEW PKGP
+12 SET PKGP=$$PKG2IEN^VSIT0($GET(VSITPKG))
+13 IF PKGP=-1
SET VSIT("IEN")=-2
GOTO DONE
+14 ;Get the site part of the VISIT ID
+15 IF $PIECE($GET(^DIC(150.9,1,4)),"^",2)<1
SET VSIT("IEN")=-1
GOTO DONE
+16 ;
+17 KILL VSIT("IEN"),^TMP("VSITDD",$JOB),^TMP($JOB,"VSIT-ERROR")
+18 if $GET(VDT)]""
SET VSIT("VDT")=VDT
+19 if $GET(DFN)
SET VSIT("PAT")=+DFN
+20 if $GET(PRAM)]""
SET VSIT(0)=PRAM
+21 ;See if the old CLN nodes needs moved into the DSS node.
+22 IF '($DATA(VSIT("DSS"))#2)
IF $DATA(VSIT("CLN"))#2
SET VSIT("DSS")=VSIT("CLN")
+23 ;
+24 DO FLD^VSITFLD
+25 ;Set all of the VSIT nodes with $GET
+26 DO SETALL^VSITCK
+27 ;
+28 ;Inpatient movement
+29 NEW VSITIPM
SET VSITIPM=+$$IP^VSITCK1(+VSIT("VDT"),+VSIT("PAT"))
+30 ;Do the defaulting of the fields that need to be defaulted for lookup
+31 IF $$REQUIRED^VSITDEF
SET VSIT("IEN")=-1
GOTO DONE
+32 ;
+33 if '$DATA(DT)
DO DT^DICRW
+34 ;
+35 ;If Force new visit, make the visit and exit
+36 IF VSIT(0)["F"
Begin DoDot:1
+37 DO DEFAULTS^VSITDEF
+38 DO ^VSITPUT
End DoDot:1
GOTO QUIT
+39 ;
+40 ;If not forcing new visit try to look up the visit
+41 DO LST^VSITGET("","","",.VSIT,.VSITGET)
+42 ;PX*1.0*164
IF $$SWSTAT^IBBAPI()
IF +$GET(VSITGET)=1
Begin DoDot:1
+43 NEW ACT
+44 IF $GET(VSIT("ACT"))']0
SET VSIT("ACT")=$PIECE($GET(^AUPNVSIT(+VSITGET(1),0)),"^",26)
QUIT
+45 ;PX*1.0*164
IF $GET(VSIT("ACT"))]0
SET ACT=VSIT("ACT")
KILL VSIT
SET VSIT("IEN")=+$PIECE(VSITGET(1),"^")
SET VSIT("ACT")=ACT
DO UPD^VSIT
End DoDot:1
+46 ;
+47 IF +$GET(VSITGET)=0
IF VSIT(0)["N"
Begin DoDot:1
+48 DO DEFAULTS^VSITDEF
+49 DO ^VSITPUT
End DoDot:1
GOTO QUIT
+50 IF +$GET(VSITGET)=1
SET VSIT("IEN")=$PIECE(VSITGET(1),"|")_"^"_$PIECE($PIECE(VSITGET(1),"^"),"|",2)
GOTO QUIT
+51 IF +$GET(VSITGET)>1
IF VSIT(0)["I"
SET Y=$$VSIT^VSITASK(VSIT("PAT"),.VSITGET)
if '+Y
SET Y=1
SET VSIT("IEN")=$PIECE(VSITGET(+Y),"|")_"^"_$PIECE($PIECE(VSITGET(+Y),"^"),"|",2)
GOTO QUIT
+52 IF +$GET(VSITGET)>1
IF VSIT(0)'["I"
SET VSIT("IEN")=$PIECE(VSITGET(1),"|")_"^"_$PIECE($PIECE(VSITGET(1),"^"),"|",2)
GOTO QUIT
+53 SET VSIT("IEN")=-1
+54 ;
QUIT ; - end of job
+1 ; set vsit api
+2 IF +$GET(VSIT("IEN"))=0
SET VSIT("IEN")=-1
+3 if VSIT("IEN")>0
DO ALL^VSITVAR(+VSIT("IEN"),"B",1)
+4 ;
DONE IF $DATA(^TMP($JOB,"VSIT-ERROR"))
IF $GET(VSIT("IEN"))'>0
IF VSIT(0)["N"!(VSIT(0)["F")
DO SND^VSITBUL
+1 KILL VSITGET
+2 KILL ^TMP("VSITDD",$JOB)
+3 QUIT VSIT("IEN")
+4 ;
ADD ; - add to dependency count
+1 ; called via cross references on pointer files
+2 DO ADD^AUPNVSIT
+3 QUIT
+4 ;
SUB ; - subtract from dependency count
+1 ; called via cross references on pointer files
+2 DO SUB^AUPNVSIT
+3 QUIT
+4 ;
UPD ;Update Visit File
+1 if $GET(VSIT("IEN"))<1
QUIT
+2 if '$DATA(^AUPNVSIT(VSIT("IEN"),0))
QUIT
+3 NEW FDA,HNC,IENS,MSG,VSITDR,VSITFLD
+4 SET IENS=VSIT("IEN")_","
+5 SET VSIT("MDT")=$$NOW^XLFDT
+6 DO FLD^VSITFLD
+7 SET VSITDR=""
+8 FOR
SET VSITDR=$ORDER(VSIT(VSITDR))
if VSITDR=""
QUIT
Begin DoDot:1
+9 IF $GET(^TMP("VSITDD",$JOB,VSITDR))=""
QUIT
+10 ;Field
SET VSITFLD=$PIECE(^TMP("VSITDD",$JOB,VSITDR),";",2)
+11 SET FDA(9000010,IENS,VSITFLD)=VSIT(VSITDR)
End DoDot:1
+12 LOCK +^AUPNVSIT(+VSIT("IEN")):DILOCKTM
+13 DO FILE^DIE("","FDA","MSG")
+14 LOCK -^AUPNVSIT(+VSIT("IEN"))
+15 IF $DATA(MSG)
Begin DoDot:1
+16 NEW SUBJECT
+17 SET SUBJECT="UPD^VSIT failed for Visit IEN="_VSIT("IEN")
+18 DO SENDEMSG^PXMCLINK(SUBJECT,.MSG)
End DoDot:1
QUIT
+19 KILL ^TMP("VSITDD",$JOB)
+20 ;
+21 ;PX*1*111 - Update NTR file for Head & Neck
+22 SET HNC=$PIECE($GET(^AUPNVSIT(VSIT("IEN"),800)),U,6)
+23 IF HNC'=1
QUIT
+24 NEW DGARR,PXDFN,SDRES
+25 SET PXDFN=$PIECE(^AUPNVSIT(VSIT("IEN"),0),U,5)
+26 IF PXDFN=""
QUIT
+27 SET SDRES=$$GETCUR^DGNTAPI(PXDFN,"DGARR")
+28 ;NTR File does not require editing
IF +$GET(DGARR("STAT"))'=3
QUIT
+29 SET SDRES=$$FILEHNC^DGNTAPI1(PXDFN)
+30 QUIT
+31 ;
PKG2IEN(PKG) ;Pass in package name space and
+1 ; returns pointer to the package in the Package file #9.4
+2 QUIT $$PKG2IEN^VSIT0($GET(PKG))
+3 ;
PKG(PKG,VALUE) ;-Entry point to add package to multiple in tracking parameters
+1 ;-PKG=Package Name Space
+2 ;-VALUE=Value on the ON/OFF flag under package multiple
+3 ;--1=ON 0=OFF
+4 QUIT $$PKG^VSIT0($GET(PKG),$GET(VALUE))
+5 ;
PKGON(PKG) ; -- Returns the active flag for the package
+1 ; 1 the package can create visits
+2 ; 0 the package cannot create visits
+3 ; -1 called wrong or could not find package in VT parameters file
+4 QUIT $$PKGON^VSIT0($GET(PKG))
+5 ;
IEN2VID(IEN) ; -- Call with Visit IEN and returns the Visit ID
+1 if '($DATA(^AUPNVSIT(+IEN,150))#2)
QUIT -1
+2 QUIT $PIECE(^AUPNVSIT(IEN,150),"^",1)
+3 ;
VID2IEN(VID) ; -- Call with Visit's ID and returns the Visit IEN
+1 NEW IEN
+2 SET IEN=$ORDER(^AUPNVSIT("VID",VID,0))
+3 QUIT $SELECT(IEN]"":IEN,1:-1)
+4 ;
LOOKUP(IEN,FMT,WITHIEN) ; -- Lookup a visit and return all of its information
+1 ;DBIA #: 1906
+2 ;Parameters:
+3 ; IEN is the IEN for the Visit OR the Visit's ID
+4 ; FMT is the format that you want the output where
+5 ; I ::= internal format
+6 ; E ::= external format
+7 ; B ::= both internal and external format
+8 ; B is the default if FMT is anything other than "I" or "E"
+9 ; WITHIEN is 0 if you do not want the IEN of the VSIT( as the first
+10 ; subscript and 1 if you do. "1" is the default.
+11 ;
+12 ;Return: -1 if IEN was not a valid IEN or Visit ID
+13 ; otherwise returns IEN
+14 ; VSIT( an array VSIT(Visit IEN,field) or VSIT(field) depending
+15 ; on the value of WITHIEN. The array is all of the fields
+16 ; in the visit file. If B(oth) internal and external format
+17 ; are returned the format is: internal^external.
+18 ; If I(nternal) format is requested only the internal part
+19 ; is returned.
+20 ; If E(xternal) format is requested the format is: ^external
+21 ; External values, if requested, are always returned in the
+22 ; second pieces of the array elements.
+23 ;
+24 if $GET(IEN)']""
QUIT -1
+25 ;PX*1.0*118
if +IEN'=IEN
SET IEN=$$VID2IEN(IEN)
+26 if '($DATA(^AUPNVSIT(+IEN,0))#2)
QUIT -1
+27 SET FMT=$GET(FMT)
+28 SET FMT=$SELECT(FMT["B":"B",FMT["I":"I",FMT["E":"E",1:"B")
+29 SET WITHIEN=$SELECT($GET(WITHIEN)=0:0,1:1)
+30 DO ALL^VSITVAR(IEN,FMT,WITHIEN)
+31 QUIT IEN
+32 ;
SELECTED(DFN,SDT,EDT,HOSLOC,ENCTYPE,NENCTYPE,SERVCAT,NSERVCAT,LASTN) ;
+1 ; -- Returns selected visits depending on screens passed in.
+2 DO VSITAPI^VSITOE($GET(DFN),$GET(SDT),$GET(EDT),$GET(HOSLOC),$GET(ENCTYPE),$GET(NENCTYPE),$GET(SERVCAT),$GET(NSERVCAT),$GET(LASTN))
+3 QUIT
+4 ;
HISTORIC(IEN) ; -- Returns 1 if it is an Historical visit ("E" in #.07)
+1 ; 0 if it is not an Historical visit.
+2 ; -1 if the IEN is bad
+3 QUIT $SELECT('($DATA(^AUPNVSIT(IEN,0))#2):-1,1:$PIECE($GET(^AUPNVSIT(IEN,0)),"^",7)="E")
+4 ;
MODIFIED(IEN) ;Sets the Date Last Modified (.13) field to NOW
+1 ;
+2 NEW VSIT
+3 SET VSIT("IEN")=IEN
+4 DO UPD
+5 QUIT
+6 ;