source: FOIAVistA/trunk/r/GEN_MED_OTHER-GMV/GMVRPCHL.m@ 1722

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

initial load of FOIAVistA 6/30/08 version

File size: 5.2 KB
Line 
1GMVRPCHL ;HIOFO/FT-RPC FOR HOSPITAL LOCATION SELECTION ;12/7/05 10:32
2 ;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
3 ;
4 ; This routine uses the following IAs:
5 ; #1378 - DGPM references (controlled)
6 ; #2965 - FILE 405.1 references (controlled)
7 ; #10039 - FILE 42 references (supported)
8 ; #10040 - FILE 44 references (supported)
9 ; #10061 - ^VADPT calls (supported)
10 ; #10103 - ^XLFDT calls (supported)
11 ;
12 ; This routine supports the following IAs:
13 ; #4461 - GMV LOCATION SELECT RPC is called at RPC (private)
14 ;
15RPC(RESULTS,OPTION,DATA) ; [Procedure] Main RPC call tag
16 ; RPC: [GMV LOCATION SELECT]
17 ;
18 ; Input parameters
19 ; 1. RESULTS [Reference/Required] RPC Return array
20 ; 2. OPTION [Literal/Required] RPC Option to execute
21 ; 3. DATA [Literal/Required] Other data as required for call
22 ;
23 S RESULTS=$NA(^TMP("GMVHLOC",$J)) K @RESULTS
24 D:$T(@OPTION)]"" @OPTION
25 S:'$D(@RESULTS) @RESULTS@(0)="-1^No results returned"
26 D CLEAN^DILF,KVAR^VADPT
27 Q
28NAME ; Return list of clinics and wards by name
29 ; DATA=pieceA^pieceB^pieceC
30 ; where pieceA - file number (required)
31 ; pieceB - value to begin search with (required)
32 ; pieceC - field(s) to do the look-up on (optional, defaults to .01 field)
33 ;
34 ; RESULTS(0)=piece1^piece2
35 ; RESULTS(n)=piece3
36 ; where piece1 - -1 if error OR number of entries found
37 ; piece2 - error message if piece1=-1
38 ; piece3 - field values requested.
39 ; n - sequential number starting with 1
40 ;
41 N GMVSCRN,GMVFLD,X
42 S DATA=$G(DATA)
43 I +DATA'>0 D Q
44 .S @RESULTS@(0)="-1^Not a valid file number"
45 .Q
46 S GMVSCRN=$S(+DATA=44:"I $P(^(0),U,3)'=""Z""",1:"")
47 I $P(DATA,"^",3)="" S GMVFLD="@;.01"
48 E S GMVFLD="@;"_$P(DATA,"^",3)
49 S GMVFLD=$P(GMVFLD,";",1,5) ; Limit lookup to 4 display fields
50 D FIND^DIC(+DATA,"",GMVFLD,"P",$P(DATA,"^",2),"","",GMVSCRN)
51 I $D(^TMP("DIERR",$J)) D Q
52 .S @RESULTS@(0)="-1^"_$G(^TMP("DIERR",$J,1,"TEXT",1))
53 .Q
54 I ^TMP("DILIST",$J,0)<1 D Q
55 .S @RESULTS@(0)="-1^No entries found matching '"_$P(DATA,U,2)_"'."
56 .Q
57 ;I ^TMP("DILIST",$J,0)>60 D Q
58 ;.S @RESULTS@(0)="-1^Too many matches found, please be more specific."
59 ;.Q
60 F X=0:0 S X=$O(^TMP("DILIST",$J,X)) Q:'X D
61 .S @RESULTS@(X)=+DATA_";"_^TMP("DILIST",$J,X,0)
62 .Q
63 S @RESULTS@(0)=+$O(@RESULTS@(""),-1)
64 Q
65APPT ; Get patient appointments using SDA^VADPT
66 ; DATA=GMVDFN^GMVFROM^GMVTO^GMVFLAG
67 ; GMVDFN - DFN (required)
68 ; GMVFROM - Start date of search (optional)
69 ; GMVTO - End date of search (optional)
70 ; GMVFLAG - kind of appt flag (optional)
71 ; RESULTS(0)=piece1^piece2
72 ; RESULTS(n)=piece3^piece4^piece5^piece6^piece7^piece8^piece9^piece10
73 ;
74 ; where piece1 - -1 if an error OR the number of records returned
75 ; piece2 - an error message if piece1 = -1
76 ; piece3 - appointment date/time (FM internal)
77 ; piece4 - appointment date/time (external)
78 ; piece5 - clinic (internal)
79 ; piece6 - clinic (external)
80 ; piece7 - status (internal)
81 ; piece8 - status (external)
82 ; piece9 - appointment type (external)
83 ; piece10 - appointment type (external)
84 ; n - a sequential number starting with 1
85 ;
86 N GMVARRAY,GMVCNT,GMVE,GMVI,GMVLOOP,GMVDFN,GMVFROM,GMVTO,GMVFLAG
87 N DFN,VAERR,VASD
88 S DATA=$G(DATA)
89 S GMVDFN=$P(DATA,U,1),GMVFROM=$P(DATA,U,2),GMVTO=$P(DATA,U,3),GMVFLAG=$P(DATA,U,4)
90 S GMVDFN=+$G(GMVDFN)
91 I '$G(GMVDFN) S @RESULTS@(0)="-1^Patient ID is missing" Q
92 I $G(GMVFROM)="" S GMVFROM=$$FMADD^XLFDT(DT,-365)
93 I $G(GMVTO)="" S GMVTO=DT_".235959"
94 S:GMVFLAG="" VASD("W")="123456789"
95 S DFN=GMVDFN,VASD("T")=GMVTO,VASD("F")=GMVFROM
96 D SDA^VADPT
97 I $G(VAERR)=1 S @RESULTS@(0)="-1^DFN or ^DPT(DFN,0) is not defined" Q
98 S @RESULTS@(0)=0
99 I '$D(^UTILITY("VASD",$J)) Q
100 S (GMVCNT,GMVLOOP)=0
101 F S GMVLOOP=$O(^UTILITY("VASD",$J,GMVLOOP)) Q:'GMVLOOP D
102 .S GMVE=$G(^UTILITY("VASD",$J,GMVLOOP,"E"))
103 .S GMVI=$G(^UTILITY("VASD",$J,GMVLOOP,"I"))
104 .Q:'$P(GMVI,U,1)
105 .S GMVCNT=GMVCNT+1
106 .S GMVARRAY(9999999.999999-$P(GMVI,U,1))=$P(GMVI,U,1)_U_$P(GMVE,U,1)_U_$P(GMVI,U,2)_U_$P(GMVE,U,2)_U_$P(GMVI,U,3)_U_$P(GMVE,U,3)_U_$P(GMVI,U,4)_U_$P(GMVE,U,4)
107 .Q
108 S $P(@RESULTS@(0),U,1)=GMVCNT
109 K ^UTILITY("VASD",$J)
110 S (GMVCNT,GMVLOOP)=0
111 F S GMVLOOP=$O(GMVARRAY(GMVLOOP)) Q:'GMVLOOP D
112 .S GMVCNT=GMVCNT+1
113 .S @RESULTS@(GMVCNT)=$G(GMVARRAY(GMVLOOP))
114 .Q
115 Q
116ADMIT ; return a list of admissions
117 ; DATA=DFN
118 ; RESULTS(0)=piece1
119 ; RESULTS(n)=piece2^piece3^piece4^piece5^piece6
120 ; where piece1 - number of records returned
121 ; piece2 - movement date/time (external)
122 ; piece3 - location ien (FILE 44)
123 ; piece4 - location name (FILE 44, Field .01)
124 ; piece5 - type of move
125 ; PIECE6 - movement ien
126 ; n - a sequential number starting with 1
127 ;
128 N DFN,TIM,MOV,X0,MTIM,XTYP,XLOC,HLOC,ILST
129 S DFN=DATA,ILST=0,TIM=""
130 I '$G(DFN) Q
131 F S TIM=$O(^DGPM("ATID1",DFN,TIM)) Q:TIM'>0 D
132 .S MOV=0
133 .F S MOV=$O(^DGPM("ATID1",DFN,TIM,MOV)) Q:MOV'>0 D
134 ..S X0=$G(^DGPM(MOV,0)) I X0']"" Q
135 ..S MTIM=$P(X0,U),MTIM=$$FMTE^XLFDT(MTIM,"1P")
136 ..S XTYP=$P($G(^DG(405.1,+$P(X0,U,4),0)),U,1)
137 ..S XLOC=$P($G(^DIC(42,+$P(X0,U,6),0)),U,1),HLOC=+$G(^(44))
138 ..S ILST=ILST+1,@RESULTS@(ILST)=MTIM_U_HLOC_U_XLOC_U_XTYP_U_MOV
139 ..Q
140 .Q
141 S @RESULTS@(0)=ILST
142 Q
Note: See TracBrowser for help on using the repository browser.