VSITOE ;ISL/ARS - VISIT TRACKING API UTILITIES FOR OE ;6/20/96
;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
; 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;;Aug 12, 1996
Q
;
VSITAPI(DFN,SDT,EDT,HOSLOC,ENCTYPE,NENCTYPE,SERVCAT,NSERVCAT,LASTN) ;
;pass (DFN, Start Date, End Date, Hospital Location,
; Enounter types, Not Encounter types,
; Service Categories, Not Service Categories,
; How many starting with the End Date an going backwards)
;ONLY THE DFN IS REQUIRED
; Encounter types is a string of all the encounter types wanted.
; e.g. "OA" for only Ancillary and Occasion of service
; Not Encounter types is a string of all the encounter types not wanted.
; e.g. "T" for do not include Telephone
; If Encounter types and Not Encounter types are null or not passed
; then all encounter types will be included.
; Service Categories is a string of all the service categories to
; include. If non is passed all is assumed.
; e.g. "H" for just historical.
; "T" for just Telephone.
; "AIT" for ambulatory (in and out patient) and Telephone.
; Not Service categories is a string of all the service categories to
; not include.
;Returns:: ^TMP("VSIT",$J,vsit ien,#)=
;Piece 1:: Date and Time from the Vsit File Entry
;Piece 2:: Hospital Location ien(pointer to file#44) ";" External Value
; :: If service category = "H" then this Piece becomes the followi
; :: Location of Encounter ien(Pointer to file #9999999.06) ";"
; :: External Value
;Piece 3:: Service Category (Value of field .07 set of codes)
;Piece 4:: Service Connected (Value of field 80001 External Value)
;Piece 5:: Patient Status in/out (Value of field 15002 set of codes)
;Piece 6:: Clinic Stop ien (Pointer to file # 40.7) ";" External value)
;
K ^TMP("VSIT",$J)
Q:'$G(DFN) ;-1
;
N VSITPAT,VSITSDT,VSITEDT,VSITHLOC,VSITLAST
N VSITSTOP,VSITNUM,VSITODT,VSITLOC,VSITETYP,VSITIEN
;
S VSITPAT=$G(DFN),VSITSDT=$G(SDT),VSITEDT=$G(EDT)
S VSITHLOC=+$G(HOSLOC),VSITLAST=+$G(LASTN)
;if now encounter type then use "P"
S ENCTYPE=$G(ENCTYPE)
S NENCTYPE=$G(NENCTYPE)
S SERVCAT=$G(SERVCAT)
S NSERVCAT=$G(NSERVCAT)
I VSITSDT>.0001 S VSITSDT=VSITSDT-.0000001
E S VSITSDT=.0000001
I VSITEDT>0 S VSITEDT=VSITEDT+$S(VSITEDT#1:.0000001,1:.7)
E S VSITEDT=9999999
;
S VSITSTOP=0
S VSITNUM=0
S VSITODT=VSITEDT
F S VSITODT=$O(^AUPNVSIT("AET",VSITPAT,VSITODT),-1) Q:VSITODT<VSITSDT D Q:VSITSTOP
.S VSITLOC=0
.F S VSITLOC=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC)) Q:'VSITLOC D
..I VSITHLOC'=0,VSITLOC'=VSITHLOC Q
..S VSITETYP=""
..F S VSITETYP=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP)) Q:VSITETYP="" D Q:VSITSTOP
...I ENCTYPE'="",ENCTYPE'[VSITETYP Q
...I NENCTYPE'="",NENCTYPE[VSITETYP Q
...S VSITIEN=0
...F S VSITIEN=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP,VSITIEN)) Q:'VSITIEN D Q:VSITSTOP
....I NSERVCAT'="",NSERVCAT[$P($G(^AUPNVSIT(VSITIEN,0)),"^",7) Q
....I SERVCAT'="",SERVCAT'[$P($G(^AUPNVSIT(VSITIEN,0)),"^",7) Q
....S VSITNUM=VSITNUM+1
....D OUTPUT(VSITIEN,VSITNUM)
....I VSITLAST,VSITLAST'>VSITNUM S VSITSTOP=1
;
Q ;VSITNUM
;
OUTPUT(VSITIEN,VSITNUM) ;
N VSIT0,VSITDILF,VSITDSS,VSITSCAT,VSITLOC,VSITSC
S VSIT0=$G(^AUPNVSIT(VSITIEN,0))
;
; -- Clinic
S VSITDSS=$$EXTERNAL^DILFD(9000010,.08,"",$P(VSIT0,"^",8),"VSITDILF")
I VSITDSS]"" S VSITDSS=$P(VSIT0,"^",8)_";"_VSITDSS
;
; -- Service Category
S VSITSCAT=$P(VSIT0,U,7)
;
; -- Location of Encounter
I VSITSCAT="H" D
. S VSITLOC=$$EXTERNAL^DILFD(9000010,.06,"",$P(VSIT0,"^",6),"VSITDILF")
. I VSITLOC]"" S VSITLOC=$P(VSIT0,"^",6)_";"_VSITLOC
E D
. ; -- Hospital Location
. S VSITLOC=$$EXTERNAL^DILFD(9000010,.22,"",$P(VSIT0,"^",22),"VSITDILF")
. I VSITLOC]"" S VSITLOC=$P(VSIT0,"^",22)_";"_VSITLOC
;
;--Service Connected
S VSITSC=$$EXTERNAL^DILFD(9000010,80001,"",$P($G(^AUPNVSIT(VSITIEN,800)),"^",1),"VSITDILF")
;I VSITSC]"" S VSITSC=$P($G(^AUPNVSIT(VSITIEN,800)),"^",1)_";"_VSITSC
;
; -- Set Tmp node
S ^TMP("VSIT",$J,VSITIEN,VSITNUM)=$P(VSIT0,U,1)_"^"_VSITLOC_"^"_VSITSCAT_"^"_VSITSC_"^"_$P($G(^AUPNVSIT(VSITIEN,150)),U,2)_"^"_VSITDSS
;
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVSITOE 4461 printed Dec 13, 2024@02:32:38 Page 2
VSITOE ;ISL/ARS - VISIT TRACKING API UTILITIES FOR OE ;6/20/96
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
+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;;Aug 12, 1996
+8 QUIT
+9 ;
VSITAPI(DFN,SDT,EDT,HOSLOC,ENCTYPE,NENCTYPE,SERVCAT,NSERVCAT,LASTN) ;
+1 ;pass (DFN, Start Date, End Date, Hospital Location,
+2 ; Enounter types, Not Encounter types,
+3 ; Service Categories, Not Service Categories,
+4 ; How many starting with the End Date an going backwards)
+5 ;ONLY THE DFN IS REQUIRED
+6 ; Encounter types is a string of all the encounter types wanted.
+7 ; e.g. "OA" for only Ancillary and Occasion of service
+8 ; Not Encounter types is a string of all the encounter types not wanted.
+9 ; e.g. "T" for do not include Telephone
+10 ; If Encounter types and Not Encounter types are null or not passed
+11 ; then all encounter types will be included.
+12 ; Service Categories is a string of all the service categories to
+13 ; include. If non is passed all is assumed.
+14 ; e.g. "H" for just historical.
+15 ; "T" for just Telephone.
+16 ; "AIT" for ambulatory (in and out patient) and Telephone.
+17 ; Not Service categories is a string of all the service categories to
+18 ; not include.
+19 ;Returns:: ^TMP("VSIT",$J,vsit ien,#)=
+20 ;Piece 1:: Date and Time from the Vsit File Entry
+21 ;Piece 2:: Hospital Location ien(pointer to file#44) ";" External Value
+22 ; :: If service category = "H" then this Piece becomes the followi
+23 ; :: Location of Encounter ien(Pointer to file #9999999.06) ";"
+24 ; :: External Value
+25 ;Piece 3:: Service Category (Value of field .07 set of codes)
+26 ;Piece 4:: Service Connected (Value of field 80001 External Value)
+27 ;Piece 5:: Patient Status in/out (Value of field 15002 set of codes)
+28 ;Piece 6:: Clinic Stop ien (Pointer to file # 40.7) ";" External value)
+29 ;
+30 KILL ^TMP("VSIT",$JOB)
+31 ;-1
if '$GET(DFN)
QUIT
+32 ;
+33 NEW VSITPAT,VSITSDT,VSITEDT,VSITHLOC,VSITLAST
+34 NEW VSITSTOP,VSITNUM,VSITODT,VSITLOC,VSITETYP,VSITIEN
+35 ;
+36 SET VSITPAT=$GET(DFN)
SET VSITSDT=$GET(SDT)
SET VSITEDT=$GET(EDT)
+37 SET VSITHLOC=+$GET(HOSLOC)
SET VSITLAST=+$GET(LASTN)
+38 ;if now encounter type then use "P"
+39 SET ENCTYPE=$GET(ENCTYPE)
+40 SET NENCTYPE=$GET(NENCTYPE)
+41 SET SERVCAT=$GET(SERVCAT)
+42 SET NSERVCAT=$GET(NSERVCAT)
+43 IF VSITSDT>.0001
SET VSITSDT=VSITSDT-.0000001
+44 IF '$TEST
SET VSITSDT=.0000001
+45 IF VSITEDT>0
SET VSITEDT=VSITEDT+$SELECT(VSITEDT#1:.0000001,1:.7)
+46 IF '$TEST
SET VSITEDT=9999999
+47 ;
+48 SET VSITSTOP=0
+49 SET VSITNUM=0
+50 SET VSITODT=VSITEDT
+51 FOR
SET VSITODT=$ORDER(^AUPNVSIT("AET",VSITPAT,VSITODT),-1)
if VSITODT<VSITSDT
QUIT
Begin DoDot:1
+52 SET VSITLOC=0
+53 FOR
SET VSITLOC=$ORDER(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC))
if 'VSITLOC
QUIT
Begin DoDot:2
+54 IF VSITHLOC'=0
IF VSITLOC'=VSITHLOC
QUIT
+55 SET VSITETYP=""
+56 FOR
SET VSITETYP=$ORDER(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP))
if VSITETYP=""
QUIT
Begin DoDot:3
+57 IF ENCTYPE'=""
IF ENCTYPE'[VSITETYP
QUIT
+58 IF NENCTYPE'=""
IF NENCTYPE[VSITETYP
QUIT
+59 SET VSITIEN=0
+60 FOR
SET VSITIEN=$ORDER(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP,VSITIEN))
if 'VSITIEN
QUIT
Begin DoDot:4
+61 IF NSERVCAT'=""
IF NSERVCAT[$PIECE($GET(^AUPNVSIT(VSITIEN,0)),"^",7)
QUIT
+62 IF SERVCAT'=""
IF SERVCAT'[$PIECE($GET(^AUPNVSIT(VSITIEN,0)),"^",7)
QUIT
+63 SET VSITNUM=VSITNUM+1
+64 DO OUTPUT(VSITIEN,VSITNUM)
+65 IF VSITLAST
IF VSITLAST'>VSITNUM
SET VSITSTOP=1
End DoDot:4
if VSITSTOP
QUIT
End DoDot:3
if VSITSTOP
QUIT
End DoDot:2
End DoDot:1
if VSITSTOP
QUIT
+66 ;
+67 ;VSITNUM
QUIT
+68 ;
OUTPUT(VSITIEN,VSITNUM) ;
+1 NEW VSIT0,VSITDILF,VSITDSS,VSITSCAT,VSITLOC,VSITSC
+2 SET VSIT0=$GET(^AUPNVSIT(VSITIEN,0))
+3 ;
+4 ; -- Clinic
+5 SET VSITDSS=$$EXTERNAL^DILFD(9000010,.08,"",$PIECE(VSIT0,"^",8),"VSITDILF")
+6 IF VSITDSS]""
SET VSITDSS=$PIECE(VSIT0,"^",8)_";"_VSITDSS
+7 ;
+8 ; -- Service Category
+9 SET VSITSCAT=$PIECE(VSIT0,U,7)
+10 ;
+11 ; -- Location of Encounter
+12 IF VSITSCAT="H"
Begin DoDot:1
+13 SET VSITLOC=$$EXTERNAL^DILFD(9000010,.06,"",$PIECE(VSIT0,"^",6),"VSITDILF")
+14 IF VSITLOC]""
SET VSITLOC=$PIECE(VSIT0,"^",6)_";"_VSITLOC
End DoDot:1
+15 IF '$TEST
Begin DoDot:1
+16 ; -- Hospital Location
+17 SET VSITLOC=$$EXTERNAL^DILFD(9000010,.22,"",$PIECE(VSIT0,"^",22),"VSITDILF")
+18 IF VSITLOC]""
SET VSITLOC=$PIECE(VSIT0,"^",22)_";"_VSITLOC
End DoDot:1
+19 ;
+20 ;--Service Connected
+21 SET VSITSC=$$EXTERNAL^DILFD(9000010,80001,"",$PIECE($GET(^AUPNVSIT(VSITIEN,800)),"^",1),"VSITDILF")
+22 ;I VSITSC]"" S VSITSC=$P($G(^AUPNVSIT(VSITIEN,800)),"^",1)_";"_VSITSC
+23 ;
+24 ; -- Set Tmp node
+25 SET ^TMP("VSIT",$JOB,VSITIEN,VSITNUM)=$PIECE(VSIT0,U,1)_"^"_VSITLOC_"^"_VSITSCAT_"^"_VSITSC_"^"_$PIECE($GET(^AUPNVSIT(VSITIEN,150)),U,2)_"^"_VSITDSS
+26 ;
+27 QUIT
+28 ;