| 1 | TMGNDF2A ;TMG/kst/FDA Import: Work with Drug Forms ;03/25/06 | 
|---|
| 2 | ;;1.0;TMG-LIB;**1**;11/21/06 | 
|---|
| 3 |  | 
|---|
| 4 | ;" FDA - NATIONAL DRUG FILES COMPILING FUNCTIONS | 
|---|
| 5 | ;"      -- Working with Dosage Forms | 
|---|
| 6 | ;"Kevin Toppenberg MD | 
|---|
| 7 | ;"GNU General Public License (GPL) applies | 
|---|
| 8 | ;"11-21-2006 | 
|---|
| 9 |  | 
|---|
| 10 | ;"======================================================================= | 
|---|
| 11 | ;" API -- Public Functions. | 
|---|
| 12 | ;"======================================================================= | 
|---|
| 13 | ;"Menu | 
|---|
| 14 |  | 
|---|
| 15 | ;"======================================================================= | 
|---|
| 16 | ;" Private Functions. | 
|---|
| 17 | ;"======================================================================= | 
|---|
| 18 | ;"FillRxFormRoute  -- ensure that there is a dosage form in all records in TMG FDA IMPORT COMPILED | 
|---|
| 19 | ;"              (that are not marked to be skipped) | 
|---|
| 20 | ;"GetRxForms(Array) -- scan file 22706.2 (TMG FDA DOSAGE FORMS) and compile a list of all dosage forms | 
|---|
| 21 | ;"DisplayForms(Answers) -- display the list of Dosage forms that don't have a corresponding VA DOSE FORM | 
|---|
| 22 | ;"HandleLinks -- interact with user and find a link between FDA dosage forms, and VA dosage forms | 
|---|
| 23 | ;"ShowHelp | 
|---|
| 24 | ;"DoLink(InputNum,Answers) -- try to establish a link between 1 FDA Dosage form and a VA DOSAGE form | 
|---|
| 25 | ;"Unlock50dot606 | 
|---|
| 26 | ;"Lock50dot606 | 
|---|
| 27 | ;"DoRemove(InputNum,Answers) -- remove an unwanted item from list. | 
|---|
| 28 | ;"ShowExamples(InputNum,Answers) -- show all entries using dosage form specified | 
|---|
| 29 | ;"FormatDrug(Array) | 
|---|
| 30 | ;"SelEditForms -- use the Selector to browse and edit the DOSAGE FORM | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | ;"======================================================================= | 
|---|
| 34 | ;"======================================================================= | 
|---|
| 35 |  | 
|---|
| 36 | Menu | 
|---|
| 37 | ;"Purpose: To give an interactive menu of tools to clean up data. | 
|---|
| 38 |  | 
|---|
| 39 | new Menu,UsrSlct | 
|---|
| 40 | set Menu(0)="Pick Option for Managing Import Dosage FORMS (2A)" | 
|---|
| 41 | new i set i=1 | 
|---|
| 42 | set Menu(i)="Find new FDA dosage FORMS"_$char(9)_"FINDNEW" set i=i+1 | 
|---|
| 43 | set Menu(i)="Match import FORMS --> VA FORMS"_$char(9)_"MATCH" set i=i+1 | 
|---|
| 44 | set Menu(i)="Fix Tradenames with MISSING FORMS"_$char(9)_"FixTrade" set i=i+1 | 
|---|
| 45 | set Menu(i)="Screen ALL imports for INCORRECT FORM (IF NEEDED)"_$char(9)_"MANUAL" set i=i+1 | 
|---|
| 46 | set Menu(i)="Preselect missing and manually edit FORMS"_$char(9)_"MANUAL3" set i=i+1 | 
|---|
| 47 | set Menu(i)="Manually edit match file (IF NEEDED)"_$char(9)_"MANUAL2" set i=i+1 | 
|---|
| 48 | set Menu(i)="Edit VA forms (file 50.606) (ONLY IF NEEDED)"_$char(9)_"EDITVA" set i=i+1 | 
|---|
| 49 | set Menu(i)="USE links for import FORM --> VA FORM (DO THIS LAST)"_$char(9)_"FILL" set i=i+1 | 
|---|
| 50 | set Menu("P")="Prev Stage"_$char(9)_"Prev" | 
|---|
| 51 | set Menu("N")="Next Stage"_$char(9)_"Next" | 
|---|
| 52 |  | 
|---|
| 53 | set Menu("?")="HELP"_$char(9)_"?" | 
|---|
| 54 |  | 
|---|
| 55 | CD1 | 
|---|
| 56 | write # | 
|---|
| 57 | set UsrSlct=$$Menu^TMGUSRIF(.Menu,"^") | 
|---|
| 58 | if UsrSlct="^" goto CDDone | 
|---|
| 59 | if UsrSlct=0 set UsrSlct="" | 
|---|
| 60 |  | 
|---|
| 61 | if UsrSlct="Prev" goto Menu^TMGNDF1F  ;"quit can occur from there... | 
|---|
| 62 | if UsrSlct="Next" goto Menu^TMGNDF2C  ;"quit can occur from there... | 
|---|
| 63 | if UsrSlct="FILL" do FillRxFormRoute goto CD1 | 
|---|
| 64 | if UsrSlct="FixTrade" do FixNoForm goto CD1 | 
|---|
| 65 | if UsrSlct="FINDNEW" do FindUnmatched goto CD1 | 
|---|
| 66 | if UsrSlct="MATCH" do HandleLinks goto CD1 | 
|---|
| 67 | if UsrSlct="MANUAL" do SelEditForms() goto CD1 | 
|---|
| 68 | if UsrSlct="MANUAL2" do SelFormMap goto CD1 | 
|---|
| 69 | if UsrSlct="MANUAL3" do SelMissing goto CD1 | 
|---|
| 70 | if UsrSlct="EDITVA" do EditForms goto CD1 | 
|---|
| 71 | if UsrSlct="?" do ShowHelp goto CD1 | 
|---|
| 72 | goto CD1 | 
|---|
| 73 | CDDone | 
|---|
| 74 | quit | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 |  | 
|---|
| 78 | FillRxFormRoute | 
|---|
| 79 | ;"Purpose: To ensure that there is a dosage form and route | 
|---|
| 80 | ;"         in all records in TMG FDA IMPORT COMPILED | 
|---|
| 81 | ;"              (that are not marked to be skipped) | 
|---|
| 82 |  | 
|---|
| 83 | new % set %=2 | 
|---|
| 84 | ;"write !,"Fill all TMG FDA IMPORT COMPILED records using current" | 
|---|
| 85 | ;"write "mapping FDA dosage forms <--> VA dosage forms" | 
|---|
| 86 | ;"do YN^DICN write ! | 
|---|
| 87 | ;"if %'=1 goto FRFDone | 
|---|
| 88 |  | 
|---|
| 89 | new Itr,IEN,abort,count | 
|---|
| 90 | set abort=0,count=0 | 
|---|
| 91 | set IEN=$$ItrInit^TMGITR(22706.9,.Itr) | 
|---|
| 92 | do PrepProgress^TMGITR(.Itr,20,0,"IEN") | 
|---|
| 93 | if IEN'="" for  do  quit:($$ItrNext^TMGITR(.Itr,.IEN)'>0)!abort | 
|---|
| 94 | . if $piece($get(^TMG(22706.9,IEN,1)),"^",4)=1 quit  ;"1=SKIP | 
|---|
| 95 | . if $$UserAborted^TMGUSRIF set abort=1 quit | 
|---|
| 96 | . new currentIEN set currentIEN=+$piece($get(^TMG(22706.9,IEN,0)),"^",7) ;"0;7 = VA DOSAGE FORM, file 50.606 | 
|---|
| 97 | . new FDAForm set FDAForm=$piece($get(^TMG(22706.9,IEN,6)),"^",1) ;"text field | 
|---|
| 98 | . if FDAForm="" do  quit | 
|---|
| 99 | . . if currentIEN'=0 quit | 
|---|
| 100 | . . write !,"No FDA dose form found for drug in record #",IEN,! | 
|---|
| 101 | . new mapIEN set mapIEN=+$order(^TMG(22706.8,"B",$extract(FDAForm,1,30),"")) | 
|---|
| 102 | . new VistaIEN set VistaIEN=+$piece($get(^TMG(22706.8,mapIEN,0)),"^",2) | 
|---|
| 103 | . if (currentIEN=VistaIEN)&(VistaIEN'=0) quit | 
|---|
| 104 | . if VistaIEN=0 do  quit | 
|---|
| 105 | . . write !,"Mapping to VA FORM incomplete:  ",FDAForm," --> ??.  Edit Match File.",! | 
|---|
| 106 | . new VistaRouteIEN set VistaRouteIEN=+$piece($get(^TMG(22706.8,mapIEN,0)),"^",3) | 
|---|
| 107 | . if VistaIEN=0 do  quit | 
|---|
| 108 | . . write !,"Mapping to VA ROUTE incomplete:  ",FDAForm," --> ??.  Edit Match File.",! | 
|---|
| 109 | . new TMGFDA,TMGMSG | 
|---|
| 110 | . set TMGFDA(22706.9,IEN_",",3.5)=VistaIEN | 
|---|
| 111 | . do FILE^DIE("K","TMGFDA","TMGMSG") | 
|---|
| 112 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 113 | . ;"write !,IEN," field 3.5 set to `",VistaIEN,! | 
|---|
| 114 | . set count=count+1 | 
|---|
| 115 |  | 
|---|
| 116 | write !,count," records changed",! | 
|---|
| 117 | do PressToCont^TMGUSRIF | 
|---|
| 118 |  | 
|---|
| 119 | FRFDone | 
|---|
| 120 | quit | 
|---|
| 121 |  | 
|---|
| 122 |  | 
|---|
| 123 | FindUnmatched | 
|---|
| 124 | ;"Purpose: Find new, unhandled, FDA dosage forms, and create a new record in | 
|---|
| 125 | ;"         TMG NDF FORMS VISTA EQUIVALENTS | 
|---|
| 126 |  | 
|---|
| 127 | new Array | 
|---|
| 128 | write !,"Checking compiled FDA import records for new FDA drug FORMS...",! | 
|---|
| 129 | do GetFDARxForms(.Array) | 
|---|
| 130 | do TrimFoundForms(.Array) | 
|---|
| 131 | if $data(Array) do | 
|---|
| 132 | . do StubInNewRec(.Array) | 
|---|
| 133 | . do HandleLinks | 
|---|
| 134 | else  do | 
|---|
| 135 | . write !,"No new FDA drug FORMS found",! | 
|---|
| 136 |  | 
|---|
| 137 | do PressToCont^TMGUSRIF | 
|---|
| 138 |  | 
|---|
| 139 | quit | 
|---|
| 140 |  | 
|---|
| 141 |  | 
|---|
| 142 | GetFDARxForms(Array) | 
|---|
| 143 | ;"Purpose: to scan file 22706.9 (TMG FDA IMPORT COMPILED) and compile a list of all dosage forms | 
|---|
| 144 | ;"Input: Array -- PASS BY REFERENCE.  An OUT PARAMETER.  Prior entries will be killed | 
|---|
| 145 | ;"Results: Data passed back as follows: | 
|---|
| 146 | ;"              Array(DosageForm)="" | 
|---|
| 147 | ;"              Array(DosageForm)="" | 
|---|
| 148 | ;"Result: none. | 
|---|
| 149 |  | 
|---|
| 150 | new Itr,IEN | 
|---|
| 151 | set IEN=$$ItrInit^TMGITR(22706.9,.Itr) | 
|---|
| 152 | do PrepProgress^TMGITR(.Itr,20,0,"IEN") | 
|---|
| 153 | if IEN'="" for  do  quit:($$ItrNext^TMGITR(.Itr,.IEN)'>0) | 
|---|
| 154 | . if $piece($get(^TMG(22706.9,IEN,1)),"^",4)=1 quit  ;"1=SKIP | 
|---|
| 155 | . new DosageForm | 
|---|
| 156 | . set DosageForm=$piece($get(^TMG(22706.9,IEN,6)),"^",1) | 
|---|
| 157 | . if DosageForm="" quit | 
|---|
| 158 | . set Array(DosageForm)=IEN | 
|---|
| 159 |  | 
|---|
| 160 | quit | 
|---|
| 161 |  | 
|---|
| 162 |  | 
|---|
| 163 | TrimFoundForms(Array) | 
|---|
| 164 | ;"Purpose: To remove entries from Array, for which mapping to a VistA equivilent | 
|---|
| 165 | ;"         has already ben created | 
|---|
| 166 | ;"Input: Array -- PASS BY REFERENCE.  Array as created by GetFDARxForms | 
|---|
| 167 | new Form set Form="" | 
|---|
| 168 | for  set Form=$order(Array(Form)) quit:(Form="")  do | 
|---|
| 169 | . new shortForm set shortForm=$extract(Form,1,30) | 
|---|
| 170 | . if $order(^TMG(22706.8,"B",shortForm,""))'="" kill Array(Form) | 
|---|
| 171 | quit | 
|---|
| 172 |  | 
|---|
| 173 |  | 
|---|
| 174 | StubInNewRec(Array) | 
|---|
| 175 | ;"Purpose: To create new entries in 22706.8 for FDA forms not yet added. | 
|---|
| 176 | ;"Input: Array -- PASS BY REFERENCE.  An array of Forms to be added, as created | 
|---|
| 177 | ;"                by GetFDARxForms. | 
|---|
| 178 | ;"NOTE: ALL entries in Array will be added as new records.  Thus, screening for | 
|---|
| 179 | ;"      prior entries must be performed, such as through TrimFoundForms() | 
|---|
| 180 |  | 
|---|
| 181 | new TMGFDA,TMGMSG,TMGIEN | 
|---|
| 182 | new Form set Form="" | 
|---|
| 183 | for  set Form=$order(Array(Form)) quit:(Form="")  do | 
|---|
| 184 | . set TMGFDA(22706.8,"+1,",.01)=Form | 
|---|
| 185 | . kill TMGMSG,TMGIEN | 
|---|
| 186 | . do UPDATE^DIE("K","TMGFDA","TMGIEN","TMGMSG") | 
|---|
| 187 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 188 | quit | 
|---|
| 189 |  | 
|---|
| 190 |  | 
|---|
| 191 |  | 
|---|
| 192 | DisplayForms(Answers) | 
|---|
| 193 | ;"Purpose: to display the list of Dosage forms that don't have a corresponding VA DOSE FORM | 
|---|
| 194 | ;"Input: Answers -- PASS BY REFERENCE, and OUT PARAMETER. Old values killed. | 
|---|
| 195 | ;"Output: Answers filled in as follows: | 
|---|
| 196 | ;"      Answers(n)=DosageForm^IEN in 22706.8 | 
|---|
| 197 | ;"      Answers(n)=DosageForm^IEN in 22706.8 | 
|---|
| 198 | ;"Results: None | 
|---|
| 199 |  | 
|---|
| 200 | kill Answers | 
|---|
| 201 | new count set count=0 | 
|---|
| 202 | new Itr,IEN | 
|---|
| 203 | set IEN=$$ItrInit^TMGITR(22706.8,.Itr) | 
|---|
| 204 | ;"do PrepProgress^TMGITR(.Itr,20,0,"IEN") | 
|---|
| 205 | if IEN'="" for  do  quit:($$ItrNext^TMGITR(.Itr,.IEN)'>0) | 
|---|
| 206 | . new VADoseFormIEN set VADoseFormIEN=+$piece($get(^TMG(22706.8,IEN,0)),"^",2) | 
|---|
| 207 | . if VADoseFormIEN'=0 quit | 
|---|
| 208 | . new DoseForm set DoseForm=$piece($get(^TMG(22706.8,IEN,0)),"^",1) | 
|---|
| 209 | . set count=count+1 | 
|---|
| 210 | . write count,".    ",DoseForm," --> ??",! | 
|---|
| 211 | . set Answers(count)=DoseForm_"^"_IEN | 
|---|
| 212 | if count=0 do | 
|---|
| 213 | . write " -- List is Empty --",! | 
|---|
| 214 |  | 
|---|
| 215 | quit | 
|---|
| 216 |  | 
|---|
| 217 |  | 
|---|
| 218 | HandleLinks | 
|---|
| 219 | ;"Purpose: To interact with user and find a link between FDA dosage forms, and VA dosage forms | 
|---|
| 220 | ;"Input: none | 
|---|
| 221 | ;"Output: results are stored in 22706.8 | 
|---|
| 222 | ;"Results: none | 
|---|
| 223 |  | 
|---|
| 224 | new Answers | 
|---|
| 225 | new done set done=0 | 
|---|
| 226 | new input set input="R" | 
|---|
| 227 | do Unlock50dot606 | 
|---|
| 228 | new LastNum | 
|---|
| 229 | new VAPIndex | 
|---|
| 230 |  | 
|---|
| 231 | for  do  quit:(done=1) | 
|---|
| 232 | . if input="R" do | 
|---|
| 233 | . . write !! | 
|---|
| 234 | . . write "-------------------------------------------------------------------",! | 
|---|
| 235 | . . write "Specify which Dosage form to Look up",! | 
|---|
| 236 | . . write "-------------------------------------------------------------------",! | 
|---|
| 237 | . . do DisplayForms(.Answers) | 
|---|
| 238 | . . set LastNum=$order(Answers(""),-1) | 
|---|
| 239 | . . if LastNum="" set LastNum="^" | 
|---|
| 240 | . . write "-------------------------------------------------------------------",! | 
|---|
| 241 | . . write "Specify which Dosage form to Look up",! | 
|---|
| 242 | . . write "-------------------------------------------------------------------",! | 
|---|
| 243 | . write "  R to refresh, ? for instructions, E show Examples",! | 
|---|
| 244 | . write "  ^ to continue",! | 
|---|
| 245 | . write "Enter number to Lookup (or codes listed above): ",LastNum,"//" | 
|---|
| 246 | . read input | 
|---|
| 247 | . if input="" set input=LastNum write LastNum | 
|---|
| 248 | . write ! | 
|---|
| 249 | . ;"if input="" set input="^" | 
|---|
| 250 | . if input="" set input=LastNum write LastNum | 
|---|
| 251 | . set input=$$UP^XLFSTR(input) | 
|---|
| 252 | . if input="^" set done=1 | 
|---|
| 253 | . if (input="?") do | 
|---|
| 254 | . . do ShowHelp,ShowHlp2 | 
|---|
| 255 | . . set input="R" | 
|---|
| 256 | . if +input=input do | 
|---|
| 257 | . . do DoLink(input,.Answers) | 
|---|
| 258 | . . set input="R" | 
|---|
| 259 | . if input="E" do | 
|---|
| 260 | . . read "...Enter number to show examples for: ",input,! | 
|---|
| 261 | . . do ShowExamples(+input,.Answers,.VAPIndex) | 
|---|
| 262 | . . set input="R" | 
|---|
| 263 |  | 
|---|
| 264 | do Lock50dot606 | 
|---|
| 265 | quit | 
|---|
| 266 |  | 
|---|
| 267 |  | 
|---|
| 268 | ShowHelp | 
|---|
| 269 | ;"Purpose: to write out instructions | 
|---|
| 270 |  | 
|---|
| 271 | write #,! | 
|---|
| 272 | write "Drugs in the FDA database have drug 'forms', such as 'TABLET', 'CAPSULE' etc.",! | 
|---|
| 273 | write "In the VistA database, drugs also will have a drug form specified.  However",! | 
|---|
| 274 | write "the classification systems don't exctly match.  Sometimes the difference",! | 
|---|
| 275 | write "is just a matter of formatting, e.g. INJ,SUSP <--> INJECTION FOR SUSPENSION.",! | 
|---|
| 276 | write "But other times the exact concepts are different.  For example, when the FDA",! | 
|---|
| 277 | write "data specified: 'CAPSULE, DELAYED RELEASE PELLETS', I could not find an exact",! | 
|---|
| 278 | write "match, and chose: 'CAP,SPRINKLE,SA'.  A appropriately trained person should",! | 
|---|
| 279 | write "make such determinations.",! | 
|---|
| 280 | write ! | 
|---|
| 281 | write "This program does allow additions of NEW drug forms to the VistA database.",! | 
|---|
| 282 | write "However, this may be against VA policy and should be done only if no possible",! | 
|---|
| 283 | write "match can be found.  Also, if a new drug form is added, this new entry in file",! | 
|---|
| 284 | write "DOSAGE FORM (50.606) should be completed via a Fileman edit to fill in all",! | 
|---|
| 285 | write "other fields such as VERB, NOUN etc. for the new dosage form.",! | 
|---|
| 286 | write ! | 
|---|
| 287 | do PressToCont^TMGUSRIF | 
|---|
| 288 | quit | 
|---|
| 289 |  | 
|---|
| 290 | ShowHlp2 | 
|---|
| 291 | write #,! | 
|---|
| 292 | write "To link a FDA drug form to a VA drug form, enter its number, then type in a",! | 
|---|
| 293 | write "name to search for in the VistA database.  It is best to only type in PART of",! | 
|---|
| 294 | write "the name.  For example, 'CAP' instead of 'CAPSULE'.",! | 
|---|
| 295 | write ! | 
|---|
| 296 | write "To see examples of drugs that use a particular drug form, enter 'E'.",! | 
|---|
| 297 | write ! | 
|---|
| 298 | do PressToCont^TMGUSRIF | 
|---|
| 299 | quit | 
|---|
| 300 |  | 
|---|
| 301 | DoLink(InputNum,Answers) | 
|---|
| 302 | ;"Purpose: To try to establish a link between 1 FDA Dosage form and a VA DOSAGE form | 
|---|
| 303 | ;"Input:  InputNum -- the number that the user chose to fix. | 
|---|
| 304 | ;"         Answers -- PASS BY REFERENCE.  Array as put out by DisplayForms | 
|---|
| 305 | ;"Output:  if link is established then it will be store in 22706.8 | 
|---|
| 306 | ;"Results: none | 
|---|
| 307 |  | 
|---|
| 308 | new DosageForm,IEN | 
|---|
| 309 | set DosageForm=$piece($get(Answers(InputNum)),"^",1) | 
|---|
| 310 | set IEN=$piece($get(Answers(InputNum)),"^",2) | 
|---|
| 311 | if DosageForm="" goto DLDone | 
|---|
| 312 | new done set done=0 | 
|---|
| 313 |  | 
|---|
| 314 | new VistaIEN set VistaIEN=0 | 
|---|
| 315 | new DIC,X,Y | 
|---|
| 316 | set DIC=50.606 | 
|---|
| 317 | set X=DosageForm | 
|---|
| 318 | set DIC(0)="M" | 
|---|
| 319 | do ^DIC | 
|---|
| 320 | if +Y>0 do | 
|---|
| 321 | . write !,"Match automatically found...",! | 
|---|
| 322 | . write "Use '",$piece(Y,"^",2),"' for '",DosageForm,"'" | 
|---|
| 323 | . new % set %=1 do YN^DICN | 
|---|
| 324 | . if %'=1 quit | 
|---|
| 325 | . set VistaIEN=+Y | 
|---|
| 326 | if VistaIEN'=0 goto DL2 | 
|---|
| 327 |  | 
|---|
| 328 | set DIC(0)="AEQML" | 
|---|
| 329 | set DIC("A")="Enter VA DOSE FORM name: // " | 
|---|
| 330 | write !,"Enter name to match '"_DosageForm_"'" | 
|---|
| 331 | do ^DIC write ! | 
|---|
| 332 | if +Y>0 do | 
|---|
| 333 | . write "Use '",$piece(Y,"^",2),"' for '",DosageForm,"'" | 
|---|
| 334 | . new % set %=1 do YN^DICN | 
|---|
| 335 | . if %'=1 quit | 
|---|
| 336 | . set VistaIEN=+Y | 
|---|
| 337 |  | 
|---|
| 338 | DL2     if VistaIEN'=0 do | 
|---|
| 339 | . new TMGFDA,TMGMSG | 
|---|
| 340 | . set TMGFDA(22706.8,IEN_",",1)=VistaIEN | 
|---|
| 341 | . do FILE^DIE("K","TMGFDA","TMGMSG") | 
|---|
| 342 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 343 |  | 
|---|
| 344 | DLDone | 
|---|
| 345 | quit | 
|---|
| 346 |  | 
|---|
| 347 |  | 
|---|
| 348 | Unlock50dot606 | 
|---|
| 349 | ;"Purpose: to enable addition of dosage form to file DOSAGE FORM | 
|---|
| 350 | set $piece(^DD(50.606,.01,0),"^",5)="K:$L(X)>30!($L(X)<3) X" | 
|---|
| 351 | kill ^DD(50.606,.01,"LAYGO",.01,0) | 
|---|
| 352 |  | 
|---|
| 353 | quit | 
|---|
| 354 |  | 
|---|
| 355 | Lock50dot606 | 
|---|
| 356 | ;"NOTE: could just set XPDGREF=1 and not change this.... | 
|---|
| 357 |  | 
|---|
| 358 | ;"Purpose: to restore locks on file DOSAGE FORM | 
|---|
| 359 | set $piece(^DD(50.606,.01,0),"^",5)="K:$L(X)>30!($L(X)<3)!'(X'?1P.E)!(X'?.ANP) X" | 
|---|
| 360 | set ^DD(50.606,.01,"LAYGO",.01,0)="D:'$D(XPDGREF) EN^DDIOL(""ADDITIONS ARE NOT ALLOWED"") I $D(XPDGREF)" | 
|---|
| 361 | quit | 
|---|
| 362 |  | 
|---|
| 363 |  | 
|---|
| 364 | ShowExamples(InputNum,Answers,Index) | 
|---|
| 365 | ;"Purpose: To show all entries using dosage form specified | 
|---|
| 366 | ;"Input: InputNum -- the input number from user to show | 
|---|
| 367 | ;"       Answers -- PASS BY REFERENCE, array as put out by DisplayForms | 
|---|
| 368 | ;"       Index -- OPTIONAL.  An index of VAProduct | 
|---|
| 369 |  | 
|---|
| 370 | new DosageForm | 
|---|
| 371 | set DosageForm=$piece($get(Answers(InputNum)),"^",1) | 
|---|
| 372 | if DosageForm="" goto SEDone | 
|---|
| 373 |  | 
|---|
| 374 | if $data(Index)=0 do | 
|---|
| 375 | . do IndexVAProd^TMGNDF1C("Index") | 
|---|
| 376 |  | 
|---|
| 377 | new count set count=0 | 
|---|
| 378 | new IEN set IEN=0 | 
|---|
| 379 | for  do  quit:(+IEN'>0) | 
|---|
| 380 | . set IEN=$order(^TMG(22706.2,"C",DosageForm,IEN)) | 
|---|
| 381 | . if +IEN'>0 quit | 
|---|
| 382 | . new Array,result,ListingIEN,CompIEN | 
|---|
| 383 | . set ListingIEN=$piece($get(^TMG(22706.2,IEN,0)),"^",1) | 
|---|
| 384 | . set CompIEN=$piece($get(^TMG(22706.5,ListingIEN,0)),"^",9) | 
|---|
| 385 | . if +CompIEN>0,$piece($get(^TMG(22706.9,CompIEN,1)),"^",4)=1 quit  ;"check if skip field true | 
|---|
| 386 | . set result=$$GetDrugInfo^TMGNDF1C(ListingIEN,.Array,"Index") | 
|---|
| 387 | . if result do | 
|---|
| 388 | . . write "#",IEN,": " | 
|---|
| 389 | . . do FormatDrug(.Array) | 
|---|
| 390 | . . set count=count+1 | 
|---|
| 391 | . . if count>10 do | 
|---|
| 392 | . . . new input | 
|---|
| 393 | . . . read "Press ENTER to continue (^ to quit)",input:$get(DTIME,3600),! | 
|---|
| 394 | . . . if input="^" set IEN=0 | 
|---|
| 395 | . . . set count=0 | 
|---|
| 396 | . else  do | 
|---|
| 397 | . . ;"write !,"Couldn't find any examples (error occurred).",! | 
|---|
| 398 |  | 
|---|
| 399 | do PressToCont^TMGUSRIF | 
|---|
| 400 | SEDone | 
|---|
| 401 | quit | 
|---|
| 402 |  | 
|---|
| 403 |  | 
|---|
| 404 | FormatDrug(Array) | 
|---|
| 405 |  | 
|---|
| 406 | new s | 
|---|
| 407 | if '$data(Array) quit | 
|---|
| 408 | new i | 
|---|
| 409 |  | 
|---|
| 410 | set s=$get(Array("TRADENAME"))_" " | 
|---|
| 411 | set s=s_$get(Array("STRENGTH"))_" " | 
|---|
| 412 | set s=s_$get(Array("UNIT"))_" " | 
|---|
| 413 | set i=$order(Array("DOSE","")) | 
|---|
| 414 | if +i>0 for  do  quit:(+i'>0) | 
|---|
| 415 | . set s=s_$get(Array("DOSE",i,"DOSAGE NAME"))_" " | 
|---|
| 416 | . set i=$order(Array("DOSE",i)) | 
|---|
| 417 |  | 
|---|
| 418 | write $extract(s,1,60),! | 
|---|
| 419 |  | 
|---|
| 420 | quit | 
|---|
| 421 |  | 
|---|
| 422 |  | 
|---|
| 423 | ;"======================================== | 
|---|
| 424 | SelEditForms(SelArray,JustSelected) | 
|---|
| 425 | ;"Purpose: to use the Selector to browse and edit the TMG FDA IMPORT COMPILED, | 
|---|
| 426 | ;"         specifically fields 3.4 (FDA DOSAGE FORM) and 3.5 (DOSAGE FORM) | 
|---|
| 427 | ;"Input: SelArray: Optional.  PASS BY REFERENCE.  An array of preselected IEN's | 
|---|
| 428 | ;"               Format:  SelArray(IEN in 22706.9)="" <-- IEN preselected | 
|---|
| 429 | ;"       JustSelected: Optional.  if 1, then ONLY IENs from SelArray shown. | 
|---|
| 430 | ;"Output: User may alter the value of SKIP THIS RECORD field for all records | 
|---|
| 431 | ;"Results: none | 
|---|
| 432 |  | 
|---|
| 433 | new Options,IEN | 
|---|
| 434 | set Options("FIELDS",1)=".05^TRADENAME^30" | 
|---|
| 435 | set Options("FIELDS",1,"NO EDIT")=1  ;"i.e. show for browsing, but don't allow edit | 
|---|
| 436 | set Options("FIELDS",2)="2^UNIT^9" | 
|---|
| 437 | if +$get(editUnit)=0 set Options("FIELDS",2,"NO EDIT")=1  ;"i.e. show for browsing, but don't allow edit | 
|---|
| 438 | set Options("FIELDS",3)="3.4^FDA DOSAGE FORM^20" | 
|---|
| 439 | set Options("FIELDS",4)="3.5^DOSAGE FORM^21" | 
|---|
| 440 | set Options("FIELDS","MAX NUM")=4 | 
|---|
| 441 | set Options("FILE")="22706.9^TMG FDA IMPORT COMPILED" | 
|---|
| 442 |  | 
|---|
| 443 | if +$get(JustSelected)=0 do | 
|---|
| 444 | . ;"Get all records with SKIP THIS RECORD = 0 (KEEP) | 
|---|
| 445 | . do GetFldValue^TMGSELED(22706.9,6,0,$name(Options("IEN LIST"))) | 
|---|
| 446 | else  do | 
|---|
| 447 | . merge Options("IEN LIST")=SelArray | 
|---|
| 448 |  | 
|---|
| 449 | SE1     if $data(SelArray) do | 
|---|
| 450 | . set IEN="" | 
|---|
| 451 | . for  set IEN=$order(SelArray(IEN)) quit:(IEN="")  do | 
|---|
| 452 | . . if $data(Options("IEN LIST",IEN))>0 do | 
|---|
| 453 | . . . set Options("IEN LIST",IEN,"SEL")="" | 
|---|
| 454 |  | 
|---|
| 455 | if $$SELED^TMGSELED(.Options)'=2 goto SEKDone | 
|---|
| 456 | if $$GetIENs^TMGSELED(.Options)=0 goto SEKDone | 
|---|
| 457 | goto SE1 | 
|---|
| 458 |  | 
|---|
| 459 | SEKDone quit | 
|---|
| 460 |  | 
|---|
| 461 |  | 
|---|
| 462 | SelFormMap | 
|---|
| 463 | ;"Purpose: use Selector to browse and edit TMG FDA FORMS VISTA EQUIVALENTS | 
|---|
| 464 |  | 
|---|
| 465 | new Options,IEN | 
|---|
| 466 | set Options("FIELDS",1)=".01^FDA FORM^35" | 
|---|
| 467 | set Options("FIELDS",1,"NO EDIT")=1  ;"i.e. show for browsing, but don't allow edit | 
|---|
| 468 | set Options("FIELDS",2)="1^VISTA FORM^25" | 
|---|
| 469 | ;"set Options("FIELDS",3)="2^VISTA ROUTE^20" | 
|---|
| 470 | ;"set Options("FIELDS","MAX NUM")=3 | 
|---|
| 471 | set Options("FIELDS","MAX NUM")=2 | 
|---|
| 472 | set Options("FILE")="22706.8^TMG FDA FORMS VISTA EQUIVALENTS" | 
|---|
| 473 |  | 
|---|
| 474 | do GetFldValue^TMGSELED(22706.8,.01,"ALL",$name(Options("IEN LIST"))) | 
|---|
| 475 |  | 
|---|
| 476 | SFM1 | 
|---|
| 477 | if $$SELED^TMGSELED(.Options)'=2 goto SFMDone | 
|---|
| 478 | if $$GetIENs^TMGSELED(.Options)=0 goto SFMDone | 
|---|
| 479 | goto SFM1 | 
|---|
| 480 |  | 
|---|
| 481 | SFMDone quit | 
|---|
| 482 |  | 
|---|
| 483 |  | 
|---|
| 484 | SelMissing | 
|---|
| 485 | ;"Purpose: To preselect those entries with a missing VISTA FORMS | 
|---|
| 486 |  | 
|---|
| 487 | new PreSelArray | 
|---|
| 488 |  | 
|---|
| 489 | write "Scanning for entries with no VA FORM...",! | 
|---|
| 490 | do GetFldValue^TMGSELED(22706.9,3.5,"@","PreSelArray") | 
|---|
| 491 | write "Now scanning for the rest of the entries (ignoring skips)...",! | 
|---|
| 492 | do SelEditForms(.PreSelArray) | 
|---|
| 493 |  | 
|---|
| 494 | quit | 
|---|
| 495 |  | 
|---|
| 496 | EditForms | 
|---|
| 497 | ;"Purpose: To edit Vista drug forms in file 50.606 | 
|---|
| 498 |  | 
|---|
| 499 | new Options,IEN | 
|---|
| 500 | set Options("FIELDS",1)=".01^NAME^17" | 
|---|
| 501 | set Options("FIELDS",1,"NO EDIT")=1  ;"i.e. show for browsing, but don't allow edit | 
|---|
| 502 | set Options("FIELDS",2)="3^VERB^8" | 
|---|
| 503 | set Options("FIELDS",3)="5^PEPOSITION^12" | 
|---|
| 504 | set Options("FIELDS",4)="10^CONJUNCTION^12" | 
|---|
| 505 | set Options("FIELDS",5)="22706.8^DIVIDABLE^10" | 
|---|
| 506 | set Options("FIELDS","MAX NUM")=5 | 
|---|
| 507 | set Options("FILE")="50.606^DOSAGE FORM" | 
|---|
| 508 |  | 
|---|
| 509 | do GetFldValue^TMGSELED(50.606,.01,"ALL",$name(Options("IEN LIST"))) | 
|---|
| 510 |  | 
|---|
| 511 | EF1 | 
|---|
| 512 | if $$SELED^TMGSELED(.Options)'=2 goto EFDone | 
|---|
| 513 | if $$GetIENs^TMGSELED(.Options)=0 goto EFDone | 
|---|
| 514 | goto EF1 | 
|---|
| 515 |  | 
|---|
| 516 | EFDone quit | 
|---|
| 517 |  | 
|---|
| 518 | ;"========================================================== | 
|---|
| 519 | FixNoForm | 
|---|
| 520 | ;"Purpose: To scan through the TRADENAME fields (.05) and fix | 
|---|
| 521 | ;"         drugs that don't have a drug FORM in the name. | 
|---|
| 522 |  | 
|---|
| 523 | new IEN,Itr,abort,IgnoreList | 
|---|
| 524 | new quickMem | 
|---|
| 525 | new Suggestions | 
|---|
| 526 | set abort=0 | 
|---|
| 527 | set IEN=$$ItrInit^TMGITR(22706.9,.Itr) | 
|---|
| 528 | do PrepProgress^TMGITR(.Itr,20,0,"IEN") | 
|---|
| 529 | if IEN'="" for  do  quit:($$ItrNext^TMGITR(.Itr,.IEN)'>0)!abort | 
|---|
| 530 | . if $$UserAborted^TMGUSRIF() set abort=1 quit | 
|---|
| 531 | . if $piece($get(^TMG(22706.9,IEN,1)),"^",4)=1 quit  ;"1=SKIP | 
|---|
| 532 | . new tradeName,nameArray | 
|---|
| 533 | . set tradeName=$piece($get(^TMG(22706.9,IEN,0)),"^",4) | 
|---|
| 534 | . if tradeName="" write !,"No TRADENAME found for record#: ",IEN,! quit | 
|---|
| 535 | . new result set result=$$HandleNameArray(IEN,tradeName,.IgnoreList,1) | 
|---|
| 536 | . if result="^" set abort=1 | 
|---|
| 537 | . if +result=0 do | 
|---|
| 538 | . . set Suggestions(IEN)=$piece(result,"^",2) | 
|---|
| 539 |  | 
|---|
| 540 | if $data(Suggestions) do HndlSuggestions(.Suggestions,.IgnoreList) | 
|---|
| 541 | else  do | 
|---|
| 542 | . write "No changes needed.  Great!",! | 
|---|
| 543 | . do PressToCont^TMGUSRIF | 
|---|
| 544 |  | 
|---|
| 545 | quit | 
|---|
| 546 |  | 
|---|
| 547 |  | 
|---|
| 548 |  | 
|---|
| 549 | HandleNameArray(IEN,tradeName,IgnoreList,Quiet) | 
|---|
| 550 | ;"Purpose: To handle a name array, looking for a form. | 
|---|
| 551 | ;"Input: IEN -- IEN in 22706.9 of current drug | 
|---|
| 552 | ;"       tradeName -- current TRADENAME | 
|---|
| 553 | ;"       IgnoreList -- OPTIONAL -- a list of forms to be ignored (not perminant). | 
|---|
| 554 | ;"              Format: IgnoreList(FormName)="" | 
|---|
| 555 | ;"       Quiet -- OPTIONAL.  If =1 then will not ask, but prepair suggested answer. | 
|---|
| 556 | ;"NOTE: Makes use of variable with global scope quickMem.  Format: | 
|---|
| 557 | ;"          quickMem(FormNameFound)="" | 
|---|
| 558 | ;"          quickMem(FormNameFound)="" | 
|---|
| 559 | ;"Results: 1=drug FORM found, | 
|---|
| 560 | ;"         0 if not found, OR 0^SuggestedNewName | 
|---|
| 561 | ;"         ^=abort | 
|---|
| 562 |  | 
|---|
| 563 | new Array | 
|---|
| 564 | do CleaveToArray^TMGSTUTL(tradeName," ",.Array) | 
|---|
| 565 | ;"Returns Array in format: | 
|---|
| 566 | ;"        Array(1)="This" | 
|---|
| 567 | ;"        Array(2)="Is" | 
|---|
| 568 | ;"        Array(3)="A" | 
|---|
| 569 | ;"        Array(4)="Test" | 
|---|
| 570 | ;"        Array(MAXNODE)=4 | 
|---|
| 571 |  | 
|---|
| 572 | HNA0    new index,tempS | 
|---|
| 573 | new found set found=0 | 
|---|
| 574 | new result set result=0 | 
|---|
| 575 | set Quiet=+$get(Quiet,0) | 
|---|
| 576 | new suggestedName set suggestedName="" | 
|---|
| 577 | set tempS="" | 
|---|
| 578 | new DIC,X,Y | 
|---|
| 579 | new menu,menuIndex,UsrSlct | 
|---|
| 580 | new drugForm | 
|---|
| 581 | set menuIndex=1 | 
|---|
| 582 | new lastWord set lastWord="" | 
|---|
| 583 | for index=$get(Array("MAXNODE")):-1:1 do  quit:(found=1)!(result="^") | 
|---|
| 584 | . new thisWord set thisWord=$get(Array(index)) | 
|---|
| 585 | . if thisWord="" quit | 
|---|
| 586 | . new % set %=2 | 
|---|
| 587 | . if thisWord=lastWord do  quit:(result="^")!(%=1) | 
|---|
| 588 | . . if Quiet=1 quit | 
|---|
| 589 | . . write "Word '",thisWord,"' found more than once",! | 
|---|
| 590 | . . write " in '",tradeName,".'",! | 
|---|
| 591 | . . write " Delete one of these " | 
|---|
| 592 | . . set %=1 do YN^DICN write ! | 
|---|
| 593 | . . if %=-1 set result="^" quit | 
|---|
| 594 | . . if %=2 quit | 
|---|
| 595 | . . if %=1 kill Array(index) quit | 
|---|
| 596 | . set lastWord=thisWord | 
|---|
| 597 | . if tempS'="" set tempS=" "_tempS | 
|---|
| 598 | . set tempS=thisWord_tempS | 
|---|
| 599 | . set menuIndex=menuIndex+1 | 
|---|
| 600 | . set menu(menuIndex)=tempS | 
|---|
| 601 | . new TMGA,TMGMSG | 
|---|
| 602 | . if $data(quickMem(tempS)) set found=1 quit | 
|---|
| 603 | . do FIND^DIC(22706.8,"",".01","M",tempS,"1","B","","","TMGA","TMGMSG") | 
|---|
| 604 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 605 | . if +$get(TMGA("DILIST",0))>0 do  quit | 
|---|
| 606 | . . set found=1 | 
|---|
| 607 | . . set quickMem(tempS)="" | 
|---|
| 608 | . if $data(quickMem(thisWord)) set found=1 quit | 
|---|
| 609 | . do FIND^DIC(22706.8,"",".01","MC",thisWord,"1","","","","TMGA","TMGMSG") | 
|---|
| 610 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 611 | . if +$get(TMGA("DILIST",0))>0 do  quit | 
|---|
| 612 | . . set found=1 | 
|---|
| 613 | . . set quickMem(tempS)="" | 
|---|
| 614 | if found goto MCDone | 
|---|
| 615 |  | 
|---|
| 616 | set drugForm=$$GET1^DIQ(22706.9,IEN_",","3.5:.01") | 
|---|
| 617 | if $data(IgnoreList(drugForm)) goto MCDone  ;" marked to be ignored. | 
|---|
| 618 |  | 
|---|
| 619 | set menu(0)="Which option best shows the drug FORM? (Record #"_IEN_")" | 
|---|
| 620 | set menu(1)="None below.  Use linked FORM: "_drugForm_$char(9)_"NONE" | 
|---|
| 621 | set menuIndex=menuIndex+1 | 
|---|
| 622 | set menu(menuIndex)="Manually enter a NEW FULL TRADENAME + FORM for this drug"_$char(9)_"EDIT" | 
|---|
| 623 | set menuIndex=menuIndex+1 | 
|---|
| 624 | set menu(menuIndex)="Manually change LINKED drug FORM for this drug"_$char(9)_"ChangeForm" | 
|---|
| 625 | set menuIndex=menuIndex+1 | 
|---|
| 626 | set menu(menuIndex)="Ignore this drug and continue"_$char(9)_"Ignore" | 
|---|
| 627 |  | 
|---|
| 628 | if Quiet=1 set UsrSlct="QUIET" goto MC2 | 
|---|
| 629 |  | 
|---|
| 630 | ;"At this point, no drug form was found. | 
|---|
| 631 | MC1     write ! | 
|---|
| 632 | set UsrSlct=$$Menu^TMGUSRIF(.menu,menuIndex) | 
|---|
| 633 | write ! | 
|---|
| 634 | if UsrSlct="^" set result="^" goto MCDone | 
|---|
| 635 | if UsrSlct="Ignore" do  goto MCDone | 
|---|
| 636 | . write "Ignore all drugs with linked drug form of: ",drugForm," " | 
|---|
| 637 | . new % set %=2 do YN^DICN write ! | 
|---|
| 638 | . if %=-1 set result="^" quit | 
|---|
| 639 | . if %=2 quit | 
|---|
| 640 | . set IgnoreList(drugForm)="" | 
|---|
| 641 |  | 
|---|
| 642 | MC2     if UsrSlct=0 set UsrSlct="" | 
|---|
| 643 |  | 
|---|
| 644 | if UsrSlct>0 do  goto MCDone | 
|---|
| 645 | . new newForm set newForm=$get(menu(UsrSlct)) | 
|---|
| 646 | . new DIC,X,Y set DIC=22706.8 | 
|---|
| 647 | . set DIC(0)="MAEQL" | 
|---|
| 648 | . set DIC("A")="Select drug FORM to match with '"_newForm_"' ^//" | 
|---|
| 649 | . do ^DIC write ! | 
|---|
| 650 | . if +Y'>0 quit | 
|---|
| 651 | . new vistaForm,vistaRoute | 
|---|
| 652 | . set vistaForm=$piece($get(^TMG(22706.8,+Y,0)),"^",2) | 
|---|
| 653 | . set vistaRoute=$piece($get(^TMG(22706.8,+Y,0)),"^",3) | 
|---|
| 654 | . new TMGFDA,TMGMSG,TMGIEN | 
|---|
| 655 | . set TMGFDA(22706.8,"+1,",.01)=newForm | 
|---|
| 656 | . set TMGFDA(22706.8,"+1,",1)=vistaForm | 
|---|
| 657 | . set TMGFDA(22706.8,"+1,",2)=vistaRoute | 
|---|
| 658 | . do UPDATE^DIE("S","TMGFDA","TMGIEN","TMGMSG") | 
|---|
| 659 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 660 | . set found=1 | 
|---|
| 661 |  | 
|---|
| 662 | set Y=-1 | 
|---|
| 663 | if UsrSlct="ChangeForm" do  goto MCDone:(Y=-1),HNA0 | 
|---|
| 664 | . new DIC,X,Y | 
|---|
| 665 | . set DIC=50.606,DIC(0)="MAEQ" | 
|---|
| 666 | . set DIC("A")="Select drug FORM to use: ^// " | 
|---|
| 667 | . write "For '",tradeName,"',",! | 
|---|
| 668 | . do ^DIC | 
|---|
| 669 | . if Y=-1 quit | 
|---|
| 670 | . new newForm set newForm=$piece(Y,"^",2) | 
|---|
| 671 | . new origName set origName=$$GET1^DIQ(22706.9,IEN_",",.05) | 
|---|
| 672 | . set tradeName=origName_" "_newForm | 
|---|
| 673 | . if tradeName="" write "?? tradeName=''",! quit | 
|---|
| 674 | . new TMGFDA,TMGMSG,TMGA | 
|---|
| 675 | . set TMGFDA(22706.9,IEN_",",3.5)=+Y | 
|---|
| 676 | . set TMGFDA(22706.9,IEN_",",.05)=tradeName | 
|---|
| 677 | . do FILE^DIE("K","TMGFDA","TMGMSG") | 
|---|
| 678 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 679 | . do FIND^DIC(22706.8,"",".01","M",newForm,"1","B","","","TMGA","TMGMSG") | 
|---|
| 680 | . if +$get(TMGA("DILIST",0))'>0 do | 
|---|
| 681 | . . kill TMGFDA,TMGMSG new TMGIEN | 
|---|
| 682 | . . set TMGFDA(22706.8,"+1,",.01)=newForm | 
|---|
| 683 | . . do UPDATE^DIE("E","TMGFDA","TMGIDE","TMGMSG") | 
|---|
| 684 | . . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 685 | . set result="0^"_tradeName | 
|---|
| 686 |  | 
|---|
| 687 | if UsrSlct="QUIET" do  goto MCDone | 
|---|
| 688 | . set suggestedName=tradeName_" "_drugForm | 
|---|
| 689 | . set result="0^"_suggestedName | 
|---|
| 690 |  | 
|---|
| 691 | if UsrSlct="NONE" do  goto MCDone | 
|---|
| 692 | . new newName | 
|---|
| 693 | . if drugForm="" do  quit | 
|---|
| 694 | . . write "No drug FORM found in field 3.5 for record#: ",IEN,! quit | 
|---|
| 695 | . set newName=tradeName_" "_drugForm | 
|---|
| 696 | . write "Change TRADENAME to: ",newName," " | 
|---|
| 697 | . new % set %=1 do YN^DICN write ! | 
|---|
| 698 | . if %=-1 set result="^" quit | 
|---|
| 699 | . if %=2 quit | 
|---|
| 700 | . new TMGFDA,TMGMSG | 
|---|
| 701 | . set TMGFDA(22706.9,IEN_",",.05)=newName | 
|---|
| 702 | . do UPDATE^DIE("ES","TMGFDA","TMGMSG") | 
|---|
| 703 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 704 | . set found=1 | 
|---|
| 705 |  | 
|---|
| 706 | if UsrSlct="EDIT" do  goto MCDone | 
|---|
| 707 | . write "Enter NEW TRADENAME for drug (^ to abort): " | 
|---|
| 708 | . new newName read newName:$get(DTIME,3600),! | 
|---|
| 709 | . if newName="^" quit | 
|---|
| 710 | . write !,"Change TRADENAME from:",! | 
|---|
| 711 | . write tradeName," " | 
|---|
| 712 | . write "  ----->",! | 
|---|
| 713 | . write newName,! | 
|---|
| 714 | . new % set Y=1 | 
|---|
| 715 | . do YN^DICN write ! | 
|---|
| 716 | . if %=-1 set result="^" quit | 
|---|
| 717 | . if %='1 quit | 
|---|
| 718 | . new TMGFDA,TMGMSG | 
|---|
| 719 | . set TMGFDA(22706.9,IEN_",",.05)=newName | 
|---|
| 720 | . do UPDATE^DIE("ES","TMGFDA","TMGMSG") | 
|---|
| 721 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 722 | . set result="0^"_newName | 
|---|
| 723 |  | 
|---|
| 724 | MCDone | 
|---|
| 725 | if (found=1)&(result'="^") set result=1 | 
|---|
| 726 | quit result | 
|---|
| 727 |  | 
|---|
| 728 |  | 
|---|
| 729 | HndlSuggestions(Suggestions,IgnoreList) | 
|---|
| 730 | ;"Purpose: to interact with user about accepting or editing suggestions | 
|---|
| 731 | ;"Input:  Suggestions -- PASS BY REFERENCE.  Format: | 
|---|
| 732 | ;"              Suggestions(IEN)=SuggestedNameForTradeName | 
|---|
| 733 | ;"              Suggestions(IEN)=SuggestedNameForTradeName | 
|---|
| 734 | ;"        IgnoreList -- PASS BY REFERENCE.  A list of words/forms to be ignored | 
|---|
| 735 |  | 
|---|
| 736 | new Answers | 
|---|
| 737 | new done set done=0 | 
|---|
| 738 | new input set input="R" | 
|---|
| 739 | new CompactMode set CompactMode=0 | 
|---|
| 740 | new Cancelled set Cancelled=0 | 
|---|
| 741 | new LastNum set LastNum=0 | 
|---|
| 742 | new EntryList,EntryS | 
|---|
| 743 |  | 
|---|
| 744 | for  do  quit:(done=1) | 
|---|
| 745 | . if input="R" do | 
|---|
| 746 | . . write !! | 
|---|
| 747 | . . write "-------------------------------------------------------------------",! | 
|---|
| 748 | . . write "Specify which New TRADENAMES to accept",! | 
|---|
| 749 | . . write "-------------------------------------------------------------------",! | 
|---|
| 750 | . . do DispSuggestions(.Suggestions,.Answers,CompactMode) | 
|---|
| 751 | . . set LastNum=$order(Answers(""),-1) | 
|---|
| 752 | . . if LastNum="" set LastNum="^" | 
|---|
| 753 | . . write "-------------------------------------------------------------------",! | 
|---|
| 754 | . . write "Specify which New TRADENAMES to accept",! | 
|---|
| 755 | . . write "-------------------------------------------------------------------",! | 
|---|
| 756 | . write " R to refresh, I to Ignore some; M to manually edit",! | 
|---|
| 757 | . write " C=set Compact ",$select((CompactMode=1):"OFF",1:"ON"),", " | 
|---|
| 758 | . write " S to Screen names for a given form to Ignore.",! | 
|---|
| 759 | . write " A to show ALTERNATE drugs similar to shown",! | 
|---|
| 760 | . write " O to show sOurce (from FDA) for drug; K to mark drug sKipped.",! | 
|---|
| 761 | . write " # or #-# or #,#-#,# etc.,  ^ done, ",! | 
|---|
| 762 | . ;"write "Enter number(s) to Accept (or codes listed above): ",LastNum,"//" | 
|---|
| 763 | . write "Enter number(s) to Accept (or codes listed above): ^//" | 
|---|
| 764 | . read input:$get(DTIME,3600),! | 
|---|
| 765 | . ;"if input="" set input=LastNum write LastNum | 
|---|
| 766 | . if input="" set input="^" write "^" | 
|---|
| 767 | . set input=$$UP^XLFSTR(input) | 
|---|
| 768 | . if input="^" set done=1 quit | 
|---|
| 769 | . if input="A" do  ;"--- show alternatives | 
|---|
| 770 | . . new valid set valid=1 | 
|---|
| 771 | . . if $get(EntryS)="" do  quit:(valid=0) | 
|---|
| 772 | . . . read "...Enter number(s) to show ALTERNATIVES for from list: ^// ",input,! | 
|---|
| 773 | . . . set valid=$$MkMultList^TMGMISC(input,.EntryList) | 
|---|
| 774 | . . . if valid set EntryS=input | 
|---|
| 775 | . . set Cancelled=0 | 
|---|
| 776 | . . do ShowAlts(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 777 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 778 | . . set input="R" | 
|---|
| 779 | . if input="I" do  ;"--- ignore entries. | 
|---|
| 780 | . . new valid set valid=1 | 
|---|
| 781 | . . if $get(EntryS)="" do  quit:(valid=0) | 
|---|
| 782 | . . . read "...Enter number(s) to IGNORE from list: ^// ",input,! | 
|---|
| 783 | . . . set valid=$$MkMultList^TMGMISC(input,.EntryList) | 
|---|
| 784 | . . . if valid set EntryS=input | 
|---|
| 785 | . . set Cancelled=0 | 
|---|
| 786 | . . do KillSugg(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 787 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 788 | . . set input="R" | 
|---|
| 789 | . else  if input="K" do  ;"--- Set to SKIP | 
|---|
| 790 | . . new valid set valid=1 | 
|---|
| 791 | . . if $get(EntryS)="" do  quit:(valid=0) | 
|---|
| 792 | . . . read "...Enter number(s) to PERMINANTLY SKIP from list: ^// ",input,! | 
|---|
| 793 | . . . set valid=$$MkMultList^TMGMISC(input,.EntryList) | 
|---|
| 794 | . . . if valid set EntryS=input | 
|---|
| 795 | . . set Cancelled=0 | 
|---|
| 796 | . . do SetSkip(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 797 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 798 | . . set input="R" | 
|---|
| 799 | . else  if input="C" do  ;"--- toggle compact mode | 
|---|
| 800 | . . set CompactMode='CompactMode | 
|---|
| 801 | . . set input="R" | 
|---|
| 802 | . else  if input="M" do  ;"--- manually handle entry | 
|---|
| 803 | . . new valid set valid=1 | 
|---|
| 804 | . . if $get(EntryS)="" do  quit:(valid=0) | 
|---|
| 805 | . . . read "...Enter number(s) to MANUALLY EDIT from list: ^// ",input,! | 
|---|
| 806 | . . . set valid=$$MkMultList^TMGMISC(input,.EntryList) | 
|---|
| 807 | . . . if valid set EntryS=input | 
|---|
| 808 | . . set Cancelled=0 | 
|---|
| 809 | . . do ManualEdit(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 810 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 811 | . . set input="R" | 
|---|
| 812 | . else  if input="O" do  ;"--- show FDA source | 
|---|
| 813 | . . new valid set valid=1 | 
|---|
| 814 | . . if $get(EntryS)="" do  quit:(valid=0) | 
|---|
| 815 | . . . read "...Enter number(s) to show FDA SOURCE for from list: ^// ",input,! | 
|---|
| 816 | . . . set valid=$$MkMultList^TMGMISC(input,.EntryList) | 
|---|
| 817 | . . . if valid set EntryS=input | 
|---|
| 818 | . . set Cancelled=0 | 
|---|
| 819 | . . do ShowSrc(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 820 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 821 | . . set input="R" | 
|---|
| 822 | . else  if input="S" do  ;"--- screen for those to ignore | 
|---|
| 823 | . . new scrnForm | 
|---|
| 824 | . . read "Enter Form to screen for.  All entries with this form will be ignored: ",scrnForm,! | 
|---|
| 825 | . . if scrnForm="^" quit | 
|---|
| 826 | . . kill EntryList,EntryS | 
|---|
| 827 | . . new num set num="" | 
|---|
| 828 | . . for  set num=$order(Answers(num)) quit:(num="")  do | 
|---|
| 829 | . . . new newName set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 830 | . . . if newName[scrnForm set EntryList(num)="" | 
|---|
| 831 | . . do KillSugg(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 832 | . . set input="R" | 
|---|
| 833 | . else  if input'="R" do | 
|---|
| 834 | . . if $$MkMultList^TMGMISC(input,.EntryList)=0 quit | 
|---|
| 835 | . . set EntryS=input | 
|---|
| 836 | . . set Cancelled=0 | 
|---|
| 837 | . . do AcceptSugg(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 838 | . . if Cancelled=0 kill EntryList,EntryS | 
|---|
| 839 | . . set input="R" | 
|---|
| 840 |  | 
|---|
| 841 | quit | 
|---|
| 842 |  | 
|---|
| 843 |  | 
|---|
| 844 | AcceptSugg(Array,Answers,EntryList,Cancelled) | 
|---|
| 845 | ;"Purpose: To accept new suggested name from Array | 
|---|
| 846 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 847 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 848 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 849 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 850 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 851 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 852 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 853 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 854 | ;"              Format as follows. | 
|---|
| 855 | ;"                      List(Entry number)="" | 
|---|
| 856 | ;"                      List(Entry number)="" | 
|---|
| 857 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 858 | ;"Results: none | 
|---|
| 859 |  | 
|---|
| 860 | new num set num="" | 
|---|
| 861 | for  set num=$order(EntryList(num)) quit:(num="")  do | 
|---|
| 862 | . new IEN,newName | 
|---|
| 863 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 864 | . if IEN="" quit | 
|---|
| 865 | . set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 866 | . if $length(newName)>64 do  quit:(newName="^") | 
|---|
| 867 | . . set newName=$$ShortName^TMGSHORT(newName,64,1," ") | 
|---|
| 868 | . new TMGFDA,TMGMSG | 
|---|
| 869 | . set TMGFDA(22706.9,IEN_",",.05)=newName | 
|---|
| 870 | . do UPDATE^DIE("ES","TMGFDA","TMGMSG") | 
|---|
| 871 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 872 |  | 
|---|
| 873 | do KillSugg(.Array,.Answers,.EntryList,.Cancelled) | 
|---|
| 874 |  | 
|---|
| 875 | quit | 
|---|
| 876 |  | 
|---|
| 877 | ManualEdit(Suggestions,Answers,EntryList,Cancelled,IgnoreList) | 
|---|
| 878 | ;"Purpose: To accept manually edit suggestions from Array | 
|---|
| 879 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 880 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 881 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 882 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 883 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 884 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 885 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 886 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 887 | ;"              Format as follows. | 
|---|
| 888 | ;"                      List(Entry number)="" | 
|---|
| 889 | ;"                      List(Entry number)="" | 
|---|
| 890 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 891 | ;"       IgnoreList -- PASS BY REFERENCE.  A list of words/forms to ignore. | 
|---|
| 892 | ;"NOTE: function HandleNameArray (called here) uses variable with global | 
|---|
| 893 | ;"      scope: quickMem | 
|---|
| 894 | ;"Results: none | 
|---|
| 895 |  | 
|---|
| 896 | new num set num="" | 
|---|
| 897 | set Cancelled=$get(Cancelled,0) | 
|---|
| 898 | for  set num=$order(EntryList(num)) quit:(num="")!(Cancelled=1)  do | 
|---|
| 899 | . new IEN,newName | 
|---|
| 900 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 901 | . if IEN="" quit | 
|---|
| 902 | . ;"set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 903 | . set newName=$$GET1^DIQ(22706.9,IEN_",",.05) | 
|---|
| 904 | . new result set result=$$HandleNameArray(IEN,newName,.IgnoreList,0) | 
|---|
| 905 | . if +result=0 do | 
|---|
| 906 | . . set $piece(Answers(num),"^",2)=$piece(result,"^",2) | 
|---|
| 907 | . . set Suggestions(IEN)=$piece(result,"^",2) | 
|---|
| 908 | . if result="^" set Cancelled=1 | 
|---|
| 909 | . if result=1 do  quit | 
|---|
| 910 | . . write "Entry handled and removed from list.",! | 
|---|
| 911 | . . do PressToContinue^TMGUSRIF | 
|---|
| 912 | . . kill Answers(num),Suggestions(IEN),EntryList(num) | 
|---|
| 913 |  | 
|---|
| 914 | quit | 
|---|
| 915 |  | 
|---|
| 916 |  | 
|---|
| 917 | ShowSrc(Suggestions,Answers,EntryList,Cancelled) | 
|---|
| 918 | ;"Purpose: To show FDA source for drugs in Array | 
|---|
| 919 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 920 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 921 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 922 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 923 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 924 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 925 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 926 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 927 | ;"              Format as follows. | 
|---|
| 928 | ;"                      List(Entry number)="" | 
|---|
| 929 | ;"                      List(Entry number)="" | 
|---|
| 930 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 931 | ;"Results: none | 
|---|
| 932 |  | 
|---|
| 933 | new num set num="" | 
|---|
| 934 | set Cancelled=$get(Cancelled,0) | 
|---|
| 935 | for  set num=$order(EntryList(num)) quit:(num="")!(Cancelled=1)  do | 
|---|
| 936 | . new IEN,newName | 
|---|
| 937 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 938 | . if IEN="" quit | 
|---|
| 939 | . set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 940 | . do Show1Source^TMGNDF1A(IEN) | 
|---|
| 941 | . do PressToCont^TMGUSRIF | 
|---|
| 942 |  | 
|---|
| 943 | quit | 
|---|
| 944 |  | 
|---|
| 945 |  | 
|---|
| 946 | SetSkip(Suggestions,Answers,EntryList,Cancelled,Quiet) | 
|---|
| 947 | ;"Purpose: To set the drugs in the Array as perminantly skipped. | 
|---|
| 948 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 949 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 950 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 951 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 952 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 953 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 954 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 955 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 956 | ;"              Format as follows. | 
|---|
| 957 | ;"                      List(Entry number)="" | 
|---|
| 958 | ;"                      List(Entry number)="" | 
|---|
| 959 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 960 | ;"       Quiet -- OPTIONAL.  if 1, then user is not asked.  Default=0 | 
|---|
| 961 | ;"Results: none | 
|---|
| 962 |  | 
|---|
| 963 | new num set num="" | 
|---|
| 964 | set Cancelled=$get(Cancelled,0) | 
|---|
| 965 | if $get(Quiet)=1 goto SK1 | 
|---|
| 966 | write "For this list of drug TRADENAME:",! | 
|---|
| 967 | write "--------------------------------",! | 
|---|
| 968 | for  set num=$order(EntryList(num)) quit:(num="")!(Cancelled=1)  do | 
|---|
| 969 | . new IEN,newName | 
|---|
| 970 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 971 | . if IEN="" quit | 
|---|
| 972 | . set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 973 | . write " ",newName," (#",IEN,")",! | 
|---|
| 974 | write "--------------------------------",! | 
|---|
| 975 | write "Set these drugs to be PERMINANTLY SKIPPED" | 
|---|
| 976 | new % set %=2 do YN^DICN write ! | 
|---|
| 977 | if %=-1 set Cancelled=1 goto SSDone | 
|---|
| 978 | if %=2 goto SSDone | 
|---|
| 979 | if %=1 do | 
|---|
| 980 | SK1     for  set num=$order(EntryList(num)) quit:(num="")!(Cancelled=1)  do | 
|---|
| 981 | . new IEN,newName | 
|---|
| 982 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 983 | . if IEN="" quit | 
|---|
| 984 | . set $piece(^TMG(22706.9,IEN,1),"^",4)=1  ;"1=SKIP | 
|---|
| 985 | do KillSugg(.Suggestions,.Answers,.EntryList,.Cancelled) | 
|---|
| 986 |  | 
|---|
| 987 | SSDone | 
|---|
| 988 | quit | 
|---|
| 989 |  | 
|---|
| 990 |  | 
|---|
| 991 | ShowAlts(Suggestions,Answers,EntryList,Cancelled) | 
|---|
| 992 | ;"Purpose: To show alternate drugs from drugs in Array | 
|---|
| 993 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 994 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 995 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 996 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 997 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 998 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 999 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 1000 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 1001 | ;"              Format as follows. | 
|---|
| 1002 | ;"                      List(Entry number)="" | 
|---|
| 1003 | ;"                      List(Entry number)="" | 
|---|
| 1004 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 1005 | ;"Results: none | 
|---|
| 1006 |  | 
|---|
| 1007 | new num set num="" | 
|---|
| 1008 | set Cancelled=$get(Cancelled,0) | 
|---|
| 1009 | new skipList | 
|---|
| 1010 | for  set num=$order(EntryList(num)) quit:(num="")!(Cancelled=1)  do | 
|---|
| 1011 | . new IEN,newName,foundList | 
|---|
| 1012 | . set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 1013 | . if IEN="" quit | 
|---|
| 1014 | . set newName=$piece($get(Answers(num)),"^",2) | 
|---|
| 1015 | . do GETS^DIQ(22706.9,IEN_",",".04;.05;.07;1;3.5","","TMGA","TMGMSG") | 
|---|
| 1016 | . new origName set origName=$get(TMGA(22706.9,IEN_",",.05)) | 
|---|
| 1017 | . if origName="" quit | 
|---|
| 1018 | . new NameDose set NameDose=origName_" ("_$get(TMGA(22706.9,IEN_",",.07))_") "_$get(TMGA(22706.9,IEN_",",1)) | 
|---|
| 1019 | . write !,!,"For drug '",NameDose,"', below are alternatives...",! | 
|---|
| 1020 | . do FIND^DIC(22706.9,"",".05","M",origName,"30","B","","","TMGA","TMGMSG") | 
|---|
| 1021 | . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 1022 | . if +$get(TMGA("DILIST",0))=1 do | 
|---|
| 1023 | . . do FIND^DIC(22706.9,"",".05","M",$piece(origName," ",1),"30","B","","","TMGA","TMGMSG") | 
|---|
| 1024 | . . do ShowIfDIERR^TMGDEBUG(.TMGMSG) | 
|---|
| 1025 | . merge foundList=TMGA("DILIST",2)  ;"format foundList(seq#)=IEN22706d9 | 
|---|
| 1026 | SAL1    . new numShown set numShown=0 | 
|---|
| 1027 | . write "--------------------------",! | 
|---|
| 1028 | . if $data(foundList) do | 
|---|
| 1029 | . . new seqNum set seqNum="" | 
|---|
| 1030 | . . for  set seqNum=$order(foundList(seqNum)) quit:(seqNum="")  do | 
|---|
| 1031 | . . . new TMGA,TMGMSG,IEN2 | 
|---|
| 1032 | . . . set IEN2=$get(foundList(seqNum)) | 
|---|
| 1033 | . . . if (+IEN2'>0)!(IEN2=IEN) quit | 
|---|
| 1034 | . . . if $piece($get(^TMG(22706.9,IEN2,1)),"^",4)=1 quit  ;"1=SKIP | 
|---|
| 1035 | . . . do GETS^DIQ(22706.9,IEN2_",",".04;.07;1;3.5","","TMGA","TMGMSG") | 
|---|
| 1036 | . . . write " ",$get(TMGA(22706.9,IEN2_",",.07)) | 
|---|
| 1037 | . . . write " ",$get(TMGA(22706.9,IEN2_",",1)) | 
|---|
| 1038 | . . . write " ",$get(TMGA(22706.9,IEN2_",",3.5))," ; " | 
|---|
| 1039 | . . . write " ",$get(TMGA(22706.9,IEN2_",",.04)),! | 
|---|
| 1040 | . . . set numShown=numShown+1 | 
|---|
| 1041 | . if numShown=0 do | 
|---|
| 1042 | . . write " -- List is empty --",! | 
|---|
| 1043 | . write "--------------------------",! | 
|---|
| 1044 | . write "For drug '",NameDose,"', above alternatives were found:",! | 
|---|
| 1045 | . write !,"If a similar drug is seen in list above, then SKIP is OK",! | 
|---|
| 1046 | . write "Set '",NameDose,"'",! | 
|---|
| 1047 | . write "  to be PERMINANTLY SKIPPED" | 
|---|
| 1048 | . new % set %=2 do YN^DICN write ! | 
|---|
| 1049 | . if %=-1 set Cancelled=1 quit | 
|---|
| 1050 | . if %=1 set skipList(num)="" quit | 
|---|
| 1051 | . set %=2 | 
|---|
| 1052 | . write "Lookup a comparison manually" do YN^DICN write ! | 
|---|
| 1053 | . if %=-1 set Cancelled=1 quit | 
|---|
| 1054 | . if %=2 quit | 
|---|
| 1055 | . if %=1 do  goto SAL1 | 
|---|
| 1056 | . . new DIC,X,Y | 
|---|
| 1057 | . . set DIC=22706.9,DIC(0)="MAEQ" | 
|---|
| 1058 | . . do ^DIC write ! | 
|---|
| 1059 | . . if Y=-1 write !,"NO MATCH.",!,! | 
|---|
| 1060 |  | 
|---|
| 1061 |  | 
|---|
| 1062 | if $data(skipList) do | 
|---|
| 1063 | . do SetSkip(.Suggestions,.Answers,.skipList,.Cancelled,1) | 
|---|
| 1064 |  | 
|---|
| 1065 | do PressToCont^TMGUSRIF | 
|---|
| 1066 |  | 
|---|
| 1067 | quit | 
|---|
| 1068 |  | 
|---|
| 1069 |  | 
|---|
| 1070 | KillSugg(Array,Answers,EntryList,Cancelled) | 
|---|
| 1071 | ;"Purpose: To accept new suggested name from Array | 
|---|
| 1072 | ;"Input: Array -- PASS BY REFERENCE, array holding data, | 
|---|
| 1073 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 1074 | ;"              Array(IEN)=SuggestedNewTradeName | 
|---|
| 1075 | ;"       Answers -- PASS BY REFERENCE, an array linking display number to IENS. | 
|---|
| 1076 | ;"              Array should be the one created by DispSuggestions() | 
|---|
| 1077 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 1078 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 1079 | ;"       List -- PASS BY REFERENCE -- an array of entries (user input values) to process. | 
|---|
| 1080 | ;"              Format as follows. | 
|---|
| 1081 | ;"                      List(Entry number)="" | 
|---|
| 1082 | ;"                      List(Entry number)="" | 
|---|
| 1083 | ;"       Cancelled -- OPTIONAL, PASS BY REFERENCE, will be set to 1 if user cancelled. | 
|---|
| 1084 | ;"Results: none | 
|---|
| 1085 |  | 
|---|
| 1086 | new num set num="" | 
|---|
| 1087 | for  set num=$order(EntryList(num)) quit:(num="")  do | 
|---|
| 1088 | . new IEN set IEN=$piece($get(Answers(num)),"^",1) | 
|---|
| 1089 | . kill Answers(num) | 
|---|
| 1090 | . kill Array(IEN) | 
|---|
| 1091 |  | 
|---|
| 1092 | quit | 
|---|
| 1093 |  | 
|---|
| 1094 |  | 
|---|
| 1095 | DispSuggestions(Suggestions,Answers,Compact) | 
|---|
| 1096 | ;"Purpose: to display list of Suggested name changes | 
|---|
| 1097 | ;"Input:  Suggestions -- PASS BY REFERENCE.  Format: | 
|---|
| 1098 | ;"              Suggestions(IEN)=SuggestedNameForTradeName | 
|---|
| 1099 | ;"              Suggestions(IEN)=SuggestedNameForTradeName | 
|---|
| 1100 | ;"        Answers -- PASS BY REFERENCE.  Format: | 
|---|
| 1101 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 1102 | ;"              Answers(DispNum)=IEN^SuggestedNameForTradeName | 
|---|
| 1103 | ;"        Compact -- OPTIONAL, Default=0.  If 1, only first part of list shown. | 
|---|
| 1104 | ;"Results: None | 
|---|
| 1105 |  | 
|---|
| 1106 | kill Answers | 
|---|
| 1107 | new count set count=0 | 
|---|
| 1108 | set Compact=+$get(Compact) | 
|---|
| 1109 | new IEN set IEN="" | 
|---|
| 1110 | for  set IEN=$order(Suggestions(IEN)) quit:(IEN="")!((Compact=1)&(count>10))  do | 
|---|
| 1111 | . new newName set newName=$get(Suggestions(IEN)) | 
|---|
| 1112 | . set count=count+1 | 
|---|
| 1113 | . write count,".    ",newName,! | 
|---|
| 1114 | . set Answers(count)=IEN_"^"_newName | 
|---|
| 1115 | if count=0 do | 
|---|
| 1116 | . write " -- List is Empty --",! | 
|---|
| 1117 |  | 
|---|
| 1118 | quit | 
|---|
| 1119 |  | 
|---|