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

VSITOE.m

Go to the documentation of this file.
  1. VSITOE ;ISL/ARS - VISIT TRACKING API UTILITIES FOR OE ;6/20/96
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
  1. ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
  1. ; the incorporation of the module into PCE. For historical reference,
  1. ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
  1. ; patches.
  1. ;
  1. ;;2.0;VISIT TRACKING;;Aug 12, 1996
  1. Q
  1. ;
  1. VSITAPI(DFN,SDT,EDT,HOSLOC,ENCTYPE,NENCTYPE,SERVCAT,NSERVCAT,LASTN) ;
  1. ;pass (DFN, Start Date, End Date, Hospital Location,
  1. ; Enounter types, Not Encounter types,
  1. ; Service Categories, Not Service Categories,
  1. ; How many starting with the End Date an going backwards)
  1. ;ONLY THE DFN IS REQUIRED
  1. ; Encounter types is a string of all the encounter types wanted.
  1. ; e.g. "OA" for only Ancillary and Occasion of service
  1. ; Not Encounter types is a string of all the encounter types not wanted.
  1. ; e.g. "T" for do not include Telephone
  1. ; If Encounter types and Not Encounter types are null or not passed
  1. ; then all encounter types will be included.
  1. ; Service Categories is a string of all the service categories to
  1. ; include. If non is passed all is assumed.
  1. ; e.g. "H" for just historical.
  1. ; "T" for just Telephone.
  1. ; "AIT" for ambulatory (in and out patient) and Telephone.
  1. ; Not Service categories is a string of all the service categories to
  1. ; not include.
  1. ;Returns:: ^TMP("VSIT",$J,vsit ien,#)=
  1. ;Piece 1:: Date and Time from the Vsit File Entry
  1. ;Piece 2:: Hospital Location ien(pointer to file#44) ";" External Value
  1. ; :: If service category = "H" then this Piece becomes the followi
  1. ; :: Location of Encounter ien(Pointer to file #9999999.06) ";"
  1. ; :: External Value
  1. ;Piece 3:: Service Category (Value of field .07 set of codes)
  1. ;Piece 4:: Service Connected (Value of field 80001 External Value)
  1. ;Piece 5:: Patient Status in/out (Value of field 15002 set of codes)
  1. ;Piece 6:: Clinic Stop ien (Pointer to file # 40.7) ";" External value)
  1. ;
  1. K ^TMP("VSIT",$J)
  1. Q:'$G(DFN) ;-1
  1. ;
  1. N VSITPAT,VSITSDT,VSITEDT,VSITHLOC,VSITLAST
  1. N VSITSTOP,VSITNUM,VSITODT,VSITLOC,VSITETYP,VSITIEN
  1. ;
  1. S VSITPAT=$G(DFN),VSITSDT=$G(SDT),VSITEDT=$G(EDT)
  1. S VSITHLOC=+$G(HOSLOC),VSITLAST=+$G(LASTN)
  1. ;if now encounter type then use "P"
  1. S ENCTYPE=$G(ENCTYPE)
  1. S NENCTYPE=$G(NENCTYPE)
  1. S SERVCAT=$G(SERVCAT)
  1. S NSERVCAT=$G(NSERVCAT)
  1. I VSITSDT>.0001 S VSITSDT=VSITSDT-.0000001
  1. E S VSITSDT=.0000001
  1. I VSITEDT>0 S VSITEDT=VSITEDT+$S(VSITEDT#1:.0000001,1:.7)
  1. E S VSITEDT=9999999
  1. ;
  1. S VSITSTOP=0
  1. S VSITNUM=0
  1. S VSITODT=VSITEDT
  1. F S VSITODT=$O(^AUPNVSIT("AET",VSITPAT,VSITODT),-1) Q:VSITODT<VSITSDT D Q:VSITSTOP
  1. .S VSITLOC=0
  1. .F S VSITLOC=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC)) Q:'VSITLOC D
  1. ..I VSITHLOC'=0,VSITLOC'=VSITHLOC Q
  1. ..S VSITETYP=""
  1. ..F S VSITETYP=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP)) Q:VSITETYP="" D Q:VSITSTOP
  1. ...I ENCTYPE'="",ENCTYPE'[VSITETYP Q
  1. ...I NENCTYPE'="",NENCTYPE[VSITETYP Q
  1. ...S VSITIEN=0
  1. ...F S VSITIEN=$O(^AUPNVSIT("AET",VSITPAT,VSITODT,VSITLOC,VSITETYP,VSITIEN)) Q:'VSITIEN D Q:VSITSTOP
  1. ....I NSERVCAT'="",NSERVCAT[$P($G(^AUPNVSIT(VSITIEN,0)),"^",7) Q
  1. ....I SERVCAT'="",SERVCAT'[$P($G(^AUPNVSIT(VSITIEN,0)),"^",7) Q
  1. ....S VSITNUM=VSITNUM+1
  1. ....D OUTPUT(VSITIEN,VSITNUM)
  1. ....I VSITLAST,VSITLAST'>VSITNUM S VSITSTOP=1
  1. ;
  1. Q ;VSITNUM
  1. ;
  1. OUTPUT(VSITIEN,VSITNUM) ;
  1. N VSIT0,VSITDILF,VSITDSS,VSITSCAT,VSITLOC,VSITSC
  1. S VSIT0=$G(^AUPNVSIT(VSITIEN,0))
  1. ;
  1. ; -- Clinic
  1. S VSITDSS=$$EXTERNAL^DILFD(9000010,.08,"",$P(VSIT0,"^",8),"VSITDILF")
  1. I VSITDSS]"" S VSITDSS=$P(VSIT0,"^",8)_";"_VSITDSS
  1. ;
  1. ; -- Service Category
  1. S VSITSCAT=$P(VSIT0,U,7)
  1. ;
  1. ; -- Location of Encounter
  1. I VSITSCAT="H" D
  1. . S VSITLOC=$$EXTERNAL^DILFD(9000010,.06,"",$P(VSIT0,"^",6),"VSITDILF")
  1. . I VSITLOC]"" S VSITLOC=$P(VSIT0,"^",6)_";"_VSITLOC
  1. E D
  1. . ; -- Hospital Location
  1. . S VSITLOC=$$EXTERNAL^DILFD(9000010,.22,"",$P(VSIT0,"^",22),"VSITDILF")
  1. . I VSITLOC]"" S VSITLOC=$P(VSIT0,"^",22)_";"_VSITLOC
  1. ;
  1. ;--Service Connected
  1. S VSITSC=$$EXTERNAL^DILFD(9000010,80001,"",$P($G(^AUPNVSIT(VSITIEN,800)),"^",1),"VSITDILF")
  1. ;I VSITSC]"" S VSITSC=$P($G(^AUPNVSIT(VSITIEN,800)),"^",1)_";"_VSITSC
  1. ;
  1. ; -- Set Tmp node
  1. S ^TMP("VSIT",$J,VSITIEN,VSITNUM)=$P(VSIT0,U,1)_"^"_VSITLOC_"^"_VSITSCAT_"^"_VSITSC_"^"_$P($G(^AUPNVSIT(VSITIEN,150)),U,2)_"^"_VSITDSS
  1. ;
  1. Q
  1. ;