source: WorldVistAEHR/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/VSITGET.m@ 1618

Last change on this file since 1618 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.5 KB
Line 
1VSITGET ;ISD/RJP - Visit Return Search and Match Logic of a Visit ;6/20/96
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
3 ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
4 ; the incorporation of the module into PCE. For historical reference,
5 ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
6 ; patches.
7 ;
8 ;;2.0;VISIT TRACKING;;Aug 12, 1996;
9 ;
10 Q ; - not an entry point
11 ;
12LST(VDT,DFN,PRAM,VSIT,VSITGET) ; - search for matches
13 ; - called by ^VSIT and Supported Direct Call
14 ;
15 ; - VSIT & VSITGET are passed by reference
16 ; - pass {VDT/VSIT("VDT")} = <FM date [and time]>
17 ; {DFN/VSIT("PAT")} = <patient pointer>
18 ; [PRAM/VSIT(0)] = <param string>
19 ; [VSIT("xxx")] = <used in matching logic if VSIT(0)["M">
20 ; [<fld-value>[^...]] for multiple values
21 ; .VSITGET = <array passed by reference>
22 ; - rtns .VSITGET = <number of matches>
23 ; .VSITGET(<ien>) = <sorted by visit date>
24 ; (array of selected visits)
25 K VSITGET
26 S VSITGET=0
27 ;
28 S:$G(VDT)]"" VSIT("VDT")=VDT
29 S:$G(DFN) VSIT("PAT")=+DFN
30 S:$G(PRAM)]"" VSIT(0)=PRAM
31 I '+$G(VSIT("VDT"))!('+$G(VSIT("PAT"))) G QUIT
32 ;
33 I '($D(^TMP("VSITDD",$J))\10) D FLD^VSITFLD
34 N NOD,IEN,VSITDAT,VSITBEG,VSITEND,VSITSORT,VSITIPV
35 ;
36 D:$G(VSIT("SVC"))="" CKIP(VSIT("VDT"),VSIT("PAT"))
37 ;
38 D RANGE
39 S VSITDAT=VSITBEG
40 F S VSITDAT=$O(^AUPNVSIT("AA",+VSIT("PAT"),VSITDAT)) Q:VSITDAT'>0!(VSITDAT>VSITEND) D
41 . D:$G(VSIT("SVC"))="" CKIP(9999999-$P(VSITDAT,"."),VSIT("PAT"))
42 . S IEN=0
43 . F S IEN=$O(^AUPNVSIT("AA",+VSIT("PAT"),VSITDAT,IEN)) Q:IEN'>0 D
44 .. S NOD=$$MATCH(IEN)
45 .. S:NOD]"" VSITSORT($P(NOD,"^"),$P(NOD,"^",2),IEN)=IEN_"|"_NOD
46 .. K:$D(VSITIPV(IEN)) VSITIPV(IEN)
47 ;
48 S VSITIPV=0 F S VSITIPV=$O(VSITIPV(VSITIPV)) Q:VSITIPV="" D
49 . S IEN=VSITIPV
50 . S NOD=$$MATCH(IEN)
51 . S:NOD]"" VSITSORT($P(NOD,"^"),$P(NOD,"^",2),IEN)=IEN_"|"_NOD
52 ;
53 ;Put into VSITGET in sorted order
54 S VSITGET=0
55 S NOD=$Q(VSITSORT(0,0,0))
56 G:NOD="" QUIT ;no visit found
57 ;Set first one
58 S VSITGET=VSITGET+1
59 S VSITGET(VSITGET)=@NOD
60 ;Set rest
61 I NOD]"" F S NOD=$Q(@NOD) Q:NOD="" S VSITGET=VSITGET+1,VSITGET(VSITGET)=@NOD
62 ;
63QUIT ; - exit
64 ;
65 Q
66 ;
67CKIP(DATE,PAT) ; - check to see if inpatient over date range but admitted earlier
68 ;
69 N IPM,IPV
70 S IPM=$$IP^VSITCK1(DATE,PAT)
71 I +IPM,'$P($G(^DIC(150.9,1,0)),"^",5) D
72 . S IPV=+$P($G(^DGPM(IPM,0)),"^",27)
73 . S:'$D(VSITIPV(IPV)) VSITIPV(IPV)=""
74 Q
75 ;
76MATCH(IEN) ; - screen matches using visit array
77 ;
78 ; - pass IEN = <internal entry number of visit node>
79 ; - rtns NOD = <zero node of ien record or null>
80 ;
81 Q:'IEN ""
82 S NOD=$G(^AUPNVSIT(IEN,0))
83 Q:+$P(NOD,"^",11) ""
84 I $G(VSIT(0))["M" D
85 . N X,VSITI,VSITM
86 . F X="DSS","LOC","INS","TYP" D:$G(VSIT(X))]"" Q:NOD=""
87 .. S VSITM=0
88 .. F VSITI=1:1:$L(VSIT(X),"^") S:$P(VSIT(X),"^",VSITI)=$P(NOD,"^",$P(^TMP("VSITDD",$J,X),";",4)) VSITM=1
89 .. S:'VSITM NOD=""
90 Q NOD
91 ;
92RANGE ; - date range
93 ;
94 ; - pass VSIT("VDT") = <FM date [and time]>
95 ; VSIT(0) = <param string> ; will assume D1 if not specified
96 ; - rtns VSITBEG = 9's complement of FM search start date
97 ; VSITEND = 9's complement of FM search end date
98 ;
99 N X,X1,X2
100 S X1=+VSIT("VDT")
101 S X2=$F($G(VSIT(0)),"D")
102 I X2>1 S X2=$E($G(VSIT(0)),$F($G(VSIT(0)),"D"),99),X2=$S(X2>0:-(X2-1),1:0)
103 E S X2=0
104 D C^%DTC
105 S VSITBEG=9999999-$P(+VSIT("VDT"),".")+$S(+$F($G(VSIT(0)),"D0"):"."_$P(+VSIT("VDT"),".",2)-.0000001,1:"-.0000001")
106 S VSITEND=9999999-$P(+X,".")_$S(+$F($G(VSIT(0)),"D0"):"."_$P(+VSIT("VDT"),".",2)+.0000001,1:".999999")
107 Q
Note: See TracBrowser for help on using the repository browser.