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

VSITGET.m

Go to the documentation of this file.
  1. VSITGET ;ISD/RJP - Visit Return Search and Match Logic of a Visit ;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. ;
  1. Q ; - not an entry point
  1. ;
  1. LST(VDT,DFN,PRAM,VSIT,VSITGET) ; - search for matches
  1. ; - called by ^VSIT and Supported Direct Call
  1. ;
  1. ; - VSIT & VSITGET are passed by reference
  1. ; - pass {VDT/VSIT("VDT")} = <FM date [and time]>
  1. ; {DFN/VSIT("PAT")} = <patient pointer>
  1. ; [PRAM/VSIT(0)] = <param string>
  1. ; [VSIT("xxx")] = <used in matching logic if VSIT(0)["M">
  1. ; [<fld-value>[^...]] for multiple values
  1. ; .VSITGET = <array passed by reference>
  1. ; - rtns .VSITGET = <number of matches>
  1. ; .VSITGET(<ien>) = <sorted by visit date>
  1. ; (array of selected visits)
  1. K VSITGET
  1. S VSITGET=0
  1. ;
  1. S:$G(VDT)]"" VSIT("VDT")=VDT
  1. S:$G(DFN) VSIT("PAT")=+DFN
  1. S:$G(PRAM)]"" VSIT(0)=PRAM
  1. I '+$G(VSIT("VDT"))!('+$G(VSIT("PAT"))) G QUIT
  1. ;
  1. I '($D(^TMP("VSITDD",$J))\10) D FLD^VSITFLD
  1. N NOD,IEN,VSITDAT,VSITBEG,VSITEND,VSITSORT,VSITIPV
  1. ;
  1. D:$G(VSIT("SVC"))="" CKIP(VSIT("VDT"),VSIT("PAT"))
  1. ;
  1. D RANGE
  1. S VSITDAT=VSITBEG
  1. F S VSITDAT=$O(^AUPNVSIT("AA",+VSIT("PAT"),VSITDAT)) Q:VSITDAT'>0!(VSITDAT>VSITEND) D
  1. . D:$G(VSIT("SVC"))="" CKIP(9999999-$P(VSITDAT,"."),VSIT("PAT"))
  1. . S IEN=0
  1. . F S IEN=$O(^AUPNVSIT("AA",+VSIT("PAT"),VSITDAT,IEN)) Q:IEN'>0 D
  1. .. S NOD=$$MATCH(IEN)
  1. .. S:NOD]"" VSITSORT($P(NOD,"^"),$P(NOD,"^",2),IEN)=IEN_"|"_NOD
  1. .. K:$D(VSITIPV(IEN)) VSITIPV(IEN)
  1. ;
  1. S VSITIPV=0 F S VSITIPV=$O(VSITIPV(VSITIPV)) Q:VSITIPV="" D
  1. . S IEN=VSITIPV
  1. . S NOD=$$MATCH(IEN)
  1. . S:NOD]"" VSITSORT($P(NOD,"^"),$P(NOD,"^",2),IEN)=IEN_"|"_NOD
  1. ;
  1. ;Put into VSITGET in sorted order
  1. S VSITGET=0
  1. S NOD=$Q(VSITSORT(0,0,0))
  1. G:NOD="" QUIT ;no visit found
  1. ;Set first one
  1. S VSITGET=VSITGET+1
  1. S VSITGET(VSITGET)=@NOD
  1. ;Set rest
  1. I NOD]"" F S NOD=$Q(@NOD) Q:NOD="" S VSITGET=VSITGET+1,VSITGET(VSITGET)=@NOD
  1. ;
  1. QUIT ; - exit
  1. ;
  1. Q
  1. ;
  1. CKIP(DATE,PAT) ; - check to see if inpatient over date range but admitted earlier
  1. ;
  1. N IPM,IPV
  1. S IPM=$$IP^VSITCK1(DATE,PAT)
  1. I +IPM,'$P($G(^DIC(150.9,1,0)),"^",5) D
  1. . S IPV=+$P($G(^DGPM(IPM,0)),"^",27)
  1. . S:'$D(VSITIPV(IPV)) VSITIPV(IPV)=""
  1. Q
  1. ;
  1. MATCH(IEN) ; - screen matches using visit array
  1. ;
  1. ; - pass IEN = <internal entry number of visit node>
  1. ; - rtns NOD = <zero node of ien record or null>
  1. ;
  1. Q:'IEN ""
  1. S NOD=$G(^AUPNVSIT(IEN,0))
  1. Q:+$P(NOD,"^",11) ""
  1. I $G(VSIT(0))["M" D
  1. . N X,VSITI,VSITM
  1. . F X="DSS","LOC","INS","TYP" D:$G(VSIT(X))]"" Q:NOD=""
  1. .. S VSITM=0
  1. .. F VSITI=1:1:$L(VSIT(X),"^") S:$P(VSIT(X),"^",VSITI)=$P(NOD,"^",$P(^TMP("VSITDD",$J,X),";",4)) VSITM=1
  1. .. S:'VSITM NOD=""
  1. Q NOD
  1. ;
  1. RANGE ; - date range
  1. ;
  1. ; - pass VSIT("VDT") = <FM date [and time]>
  1. ; VSIT(0) = <param string> ; will assume D1 if not specified
  1. ; - rtns VSITBEG = 9's complement of FM search start date
  1. ; VSITEND = 9's complement of FM search end date
  1. ;
  1. N X,X1,X2
  1. S X1=+VSIT("VDT")
  1. S X2=$F($G(VSIT(0)),"D")
  1. I X2>1 S X2=$E($G(VSIT(0)),$F($G(VSIT(0)),"D"),99),X2=$S(X2>0:-(X2-1),1:0)
  1. E S X2=0
  1. D C^%DTC
  1. S VSITBEG=9999999-$P(+VSIT("VDT"),".")+$S(+$F($G(VSIT(0)),"D0"):"."_$P(+VSIT("VDT"),".",2)-.0000001,1:"-.0000001")
  1. S VSITEND=9999999-$P(+X,".")_$S(+$F($G(VSIT(0)),"D0"):"."_$P(+VSIT("VDT"),".",2)+.0000001,1:".999999")
  1. Q