source: cprs/branches/tmg-cprs/m_files/TMGRPCS1.m@ 1035

Last change on this file since 1035 was 895, checked in by Kevin Toppenberg, 14 years ago

fixing soft links

File size: 8.1 KB
RevLine 
[895]1TMGRPCS1 ;TMG/kst/RPC entry points for Search PT DOCS API ; 6/20/10
2 ;;1.0;TMG-LIB;**1**;05/20/10
3 ;
4 ;"RPC ENTRY POINTS FOR TMG PATIENT DOCUMENTS SEARCH
5 ;
6 ;"Copyright Kevin Toppenberg MD 6/20/10
7 ;"Released under GNU General Public License (GPL)
8 ;"
9 ;"=======================================================================
10 ;" RPC -- Public Functions.
11 ;"=======================================================================
12 ;"PDSRCH(TMGRESULT,TMGPARAMS) -- launch a background search in documents for 1 patient
13 ;"PDSTATUS(TMGRESULT,TMGPARAMS) -- Get status of background search
14 ;"PDRESULT(TMGRESULT,TMGPARAMS) -- Get result from background search
15 ;"PDCLEAR(TMGRESULT,TMGPARAMS) -- Tell background task to stop, and clear data array
16 ;"PDSTOP(TMGRESULT,TMGPARAMS) -- Tell background task to stop searching
17 ;"PDPREPSS^TMGRPCS1(TMGRESULT,TMGPARAMS) -- Prep for Subset of List for TORCombobox
18 ;"PDGETSS^TMGRPCS1(TMGRESULT,TMGPARAMS) -- Get a subset of list for TORCombobox
19
20 ;"=======================================================================
21 ;"PRIVATE API FUNCTIONS
22 ;"=======================================================================
23 ;"
24 ;"=======================================================================
25 ;"=======================================================================
26 ;"Dependencies: TMGSRCH2
27 ;"=======================================================================
28 ;"=======================================================================
29 ;
30PDSRCH(TMGRESULT,TMGPARAMS) ;
31 ;"Purpose: Handle PT DOCS SEARCH -- launch a background search in documents for 1 patient
32 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
33 ;" TMGPARAMS -- Input: PatientEIN^SearchString
34 ;" Search string notes:
35 ;" Each word (or partial word) to look up is separated by spaces
36 ;" All words are combined in AND fashion
37 ;" Search is NOT case sensitive.
38 ;" Exact pharases can be specified by quotes.
39 ;" Example: 'dog cat monkey "in a barrel"
40 ;"Note: this function can ALSO be used to allow the CHANGE the search.
41 ;" This will allow the search to begin while the user is still
42 ;" entering the search terms. If the new search is just an
43 ;" extension to the prior search, then the prior search will be
44 ;" added on rather than starting over.
45 ;
46 ;"Results: TMGRESULT(0)="1^Success", OR -1^ErrorMsg
47 NEW DFN SET DFN=+$PIECE(TMGPARAMS,"^",1)
48 IF DFN'>0 DO GOTO PDSDN
49 . SET TMGRESULT(0)="-1^Invalid Patient IEN"
50 NEW TMGSRCH SET TMGSRCH=$PIECE(TMGPARAMS,"^",2)
51 IF TMGSRCH="" DO GOTO PDSDN
52 . SET TMGRESULT(0)="-1^No search terms provided."
53 DO LAUNCHSR^TMGSRCH2(DFN,TMGSRCH) ;
54 SET TMGRESULT(0)="1^SUCCESS"
55PDSDN QUIT
56 ;
57PDSTATUS(TMGRESULT,TMGPARAMS) ;
58 ;"Purpose: Handle PT DOCS STATUS -- Get status of background search
59 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
60 ;" TMGPARAMS -- Input: NOT USED
61 ;"Results: TMGRESULT(0)=1^Status or -1^ErrorMessage
62 SET TMGRESULT(0)=$$STATUS^TMGSRCH2() ;
63 QUIT
64 ;
65PDRESULT(TMGRESULT,TMGPARAMS) ;
66 ;"Purpose: Handle PT DOCS GET RESULTS -- get result from background search
67 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
68 ;" TMGPARAMS -- Input: NOT USED
69 ;"Results: TMGRESULT(0)=FoundCount^Success, or -1^Message
70 ;" TMGRESULT(1)=IEN1
71 ;" TMGRESULT(2)=IEN2 ... etc.
72 DO RESULTS^TMGSRCH2(.TMGRESULT)
73 QUIT
74 ;
75PDCLEAR(TMGRESULT,TMGPARAMS) ;
76 ;"Purpose: PT DOCS CLEAR -- Tell background task to stop, and clear data array
77 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
78 ;" TMGPARAMS -- Input: NOT USED
79 ;"Results: TMGRESULT(0)="1^Success
80 DO CLEAR^TMGSRCH2
81 SET TMGRESULT(0)="1^Success"
82 QUIT
83 ;
84PDSTOP(TMGRESULT,TMGPARAMS) ;
85 ;"Purpose: Handle PT DOCS STOP -- Tell background task to stop searching
86 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
87 ;" TMGPARAMS -- Input: NOT USED
88 ;"Results: TMGRESULT(0)=
89 ;"Results: TMGRESULT(0)="1^Success
90 DO STOP^TMGSRCH2
91 SET TMGRESULT(0)="1^Success"
92 QUIT
93 ;
94PDPREPSS(TMGRESULT,TMGPARAMS) ;
95 ;"Purpose -- Prep for Subset of List for TORCombobox
96 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
97 ;" TMGPARAMS -- Input: NOT USED
98 ;"Results: TMGRESULT(0)="1^Success", OR -1^ErrorMsg
99 NEW LIST
100 NEW ABORT SET ABORT=0
101 DO PDRESULT(.LIST) ;
102 NEW REF SET REF=$NAME(^TMG("TMP","SEARCH","SRCHTIU",$J,"OR LIST"))
103 KILL @REF
104 IF +$GET(LIST(0))'>0 SET TMGRESULT(0)=LIST(0) GOTO PSSDN
105 NEW I SET I=0
106 FOR SET I=$ORDER(LIST(I)) QUIT:(+I'>0)!ABORT DO
107 . NEW IEN SET IEN=+$GET(LIST(I)) QUIT:IEN'>0
108 . NEW NAME SET NAME=$$FORMAT(IEN)
109 . IF +NAME=-1 SET ABORT=1,TMGRESULT(0)=NAME QUIT
110 . SET @REF@(NAME,IEN)=""
111PSSDN QUIT
112 ;
113 ;
114FORMAT(IEN) ;
115 ;"Purpose: Return a string describing note title
116 ;"Input: IEN -- The IEN in file 8925
117 ;"Result: July 15, 2010 -- NOTE TITLE -- AUTHOR
118 SET IEN=+$GET(IEN)
119 NEW RESULT
120 IF (IEN'>0)!($DATA(^TIU(8925,IEN))=0) DO GOTO FMTDN
121 . SET RESULT="-1^<Note "_IEN_" Doesn't Exist>"
122 NEW TMGOUT,TMGMSG,TMGIENS
123 SET TMGIENS=IEN_","
124 DO GETS^DIQ(8925,TMGIENS,".01;1202","","TMGOUT","TMGMSG")
125 IF $DATA(TMGMSG("DIERR")) DO GOTO FMTDN
126 . SET RESULT="-1^<Error getting information for record "_IEN_">"
127 NEW TITLE SET TITLE=$GET(TMGOUT(8925,TMGIENS,.01),"? TITLE")
128 NEW AUTHOR SET AUTHOR=$GET(TMGOUT(8925,TMGIENS,1202),"? AUTHOR")
129 NEW DATE SET DATE=$PIECE($GET(^TIU(8925,IEN,0)),"^",7) ;"Custom formatting
130 SET DATE=$$FMTE^XLFDT(DATE,7) ;"7 --> YYYY/MM/DD@time
131 SET DATE=$PIECE(DATE,"@",1) ;"remove time
132 NEW MONTH SET MONTH=$PIECE(DATE,"/",2)
133 IF $LENGTH(MONTH)=1 SET MONTH="0"_MONTH SET $PIECE(DATE,"/",2)=MONTH
134 NEW DAY SET DAY=$PIECE(DATE,"/",3)
135 IF $LENGTH(DAY)=1 SET DAY="0"_DAY SET $PIECE(DATE,"/",3)=DAY
136 SET RESULT=DATE_"; "_TITLE_" - "_AUTHOR
137FMTDN QUIT RESULT
138 ;
139PDGETSS(TMGRESULT,TMGPARAMS) ;
140 ;"Purpose -- Get a subset of list for TORCombobox
141 ;" NOTE: This should only be called after a successful call to
142 ;" PDPREPSS^TMGRPCS1 which will prepair the list.
143 ;"Input: TMGRESULT -- PASS BY REFERENCE. AN OUT PARAMETER
144 ;" TMGPARAMS -- Input: StartFrom^Direction^MaxCount
145 ;" StartFrom -- OPTIONAL -- text to $ORDER() from
146 ;" Direction -- $ORDER(xx,Direction) direction (should be 1 or -1) -- OPTIONAL
147 ;" MaxCount -- OPTIONAL. Default is 44 values returned.
148 ;"Results: TMGRESULT(0)="1^Success" or "-1^Message"
149 ;" TMGRESULT(1)=IEN^2010/6/10; OFFICE NOTE - TOPPENBERG,KEVIN <-- Example
150 ;" TMGRESULT(2)=IEN^A_Note_Identifier
151 ;
152 NEW TMGFROM SET TMGFROM=$PIECE(TMGPARAMS,"^",1)
153 NEW TMGDIR SET TMGDIR=$PIECE(TMGPARAMS,"^",2)
154 IF TMGDIR'=-1 SET TMGDIR=1
155 NEW TMGMAXCT SET TMGMAXCT=+$PIECE(TMGPARAMS,"^",3)
156 IF TMGMAXCT=0 SET TMGMAXCT=44
157 ;
158 NEW TMGREF SET TMGREF=$NAME(^TMG("TMP","SEARCH","SRCHTIU",$J,"OR LIST"))
159 NEW TMGI SET TMGI=0
160 FOR SET TMGFROM=$ORDER(@TMGREF@(TMGFROM),TMGDIR) QUIT:(TMGFROM="")!(TMGI'<TMGMAXCT) DO
161 . NEW TMGIEN SET TMGIEN=""
162 . FOR SET TMGIEN=$ORDER(@TMGREF@(TMGFROM,TMGIEN),TMGDIR) QUIT:(+TMGIEN'>0)!(TMGI'<TMGMAXCT) DO
163 . . SET TMGI=TMGI+1
164 . . SET TMGRESULT(TMGI)=TMGIEN_"^"_TMGFROM
165 ;
166 IF $DATA(TMGRESULT)=0 SET TMGRESULT(0)="-1^NO RESULTS"
167 ELSE SET TMGRESULT(0)="1^Success"
168 QUIT
169 ;
170
171
Note: See TracBrowser for help on using the repository browser.