| | 80 | saveConcept(concept); |
|---|
| | 81 | } |
|---|
| | 82 | |
|---|
| | 83 | /** |
|---|
| | 84 | * @deprecated use {@link #saveConcept(Concept)} |
|---|
| | 85 | */ |
|---|
| | 86 | public void updateConcept(Concept concept) { |
|---|
| | 87 | saveConcept(concept); |
|---|
| | 88 | } |
|---|
| | 89 | |
|---|
| | 90 | /** |
|---|
| | 91 | * @deprecated use {@link #saveConcept(Concept)} |
|---|
| | 92 | */ |
|---|
| | 93 | public void updateConcept(ConceptNumeric concept) { |
|---|
| | 94 | saveConcept(concept); |
|---|
| | 95 | } |
|---|
| | 96 | |
|---|
| | 97 | /** |
|---|
| | 98 | * @deprecated use #saveDrug(Drug) |
|---|
| | 99 | */ |
|---|
| | 100 | public void createDrug(Drug drug) { |
|---|
| | 101 | saveDrug(drug); |
|---|
| | 102 | } |
|---|
| | 103 | |
|---|
| | 104 | /** |
|---|
| | 105 | * @deprecated Use #saveDrug(Drug) |
|---|
| | 106 | */ |
|---|
| | 107 | public void updateDrug(Drug drug) { |
|---|
| | 108 | saveDrug(drug); |
|---|
| | 109 | } |
|---|
| | 110 | |
|---|
| | 111 | /** |
|---|
| | 112 | * @deprecated use #purgeConcept(Concept concept) |
|---|
| | 113 | */ |
|---|
| | 114 | public void deleteConcept(Concept concept) { |
|---|
| | 115 | purgeConcept(concept); |
|---|
| | 116 | } |
|---|
| | 117 | |
|---|
| | 118 | /** |
|---|
| | 119 | * @deprecated use {@link #retireConcept(Concept, String)}etireConcept |
|---|
| | 120 | */ |
|---|
| | 121 | public void voidConcept(Concept concept, String reason) { |
|---|
| | 122 | retireConcept(concept, reason); |
|---|
| | 123 | } |
|---|
| | 124 | |
|---|
| | 125 | /** |
|---|
| | 126 | * @see org.openmrs.api.ConceptService#saveConcept(org.openmrs.Concept) |
|---|
| | 127 | */ |
|---|
| | 128 | public Concept saveConcept(Concept concept) throws APIException { |
|---|
| 101 | | getConceptDAO().saveConcept(concept); |
|---|
| 102 | | } |
|---|
| 103 | | |
|---|
| 104 | | /** |
|---|
| 105 | | * Update the given concept |
|---|
| 106 | | * |
|---|
| 107 | | * @param concept |
|---|
| 108 | | * to be updated |
|---|
| 109 | | * @deprecated use saveConcept |
|---|
| 110 | | */ |
|---|
| 111 | | public void updateConcept(Concept concept) { |
|---|
| 112 | | checkIfLocked(); |
|---|
| 113 | | |
|---|
| 114 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 115 | | .toString(); |
|---|
| 116 | | |
|---|
| 117 | | log.info(authUserId + "|" + concept.getConceptId().toString()); |
|---|
| 118 | | this.modifyCollections(concept); |
|---|
| 119 | | this.updateConceptWord(concept); |
|---|
| 120 | | getConceptDAO().saveConcept(concept); |
|---|
| 121 | | } |
|---|
| 122 | | |
|---|
| 123 | | /** |
|---|
| 124 | | * Update the given numeric concept |
|---|
| 125 | | * |
|---|
| 126 | | * @param numeric |
|---|
| 127 | | * concept to be updated |
|---|
| 128 | | * @deprecated Use saveConcept(Concept) |
|---|
| 129 | | */ |
|---|
| 130 | | public void updateConcept(ConceptNumeric concept) { |
|---|
| 131 | | checkIfLocked(); |
|---|
| 132 | | |
|---|
| 133 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 134 | | .toString(); |
|---|
| 135 | | |
|---|
| 136 | | log.info(authUserId + "|" + concept.getConceptId().toString()); |
|---|
| 137 | | |
|---|
| 138 | | getConceptDAO().saveConcept(concept); |
|---|
| 139 | | } |
|---|
| 140 | | |
|---|
| 141 | | /** |
|---|
| 142 | | * @param drug |
|---|
| 143 | | * to be created |
|---|
| 144 | | * @deprecated use saveDrug(Drug) |
|---|
| 145 | | */ |
|---|
| 146 | | public void createDrug(Drug drug) { |
|---|
| 147 | | checkIfLocked(); |
|---|
| 148 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 149 | | .toString(); |
|---|
| 150 | | log.info("creating drug - " + authUserId + "|" |
|---|
| 151 | | + drug.getConcept().toString()); |
|---|
| 152 | | getConceptDAO().saveDrug(drug); |
|---|
| 153 | | } |
|---|
| 154 | | |
|---|
| 155 | | /** |
|---|
| 156 | | * Update the given drug |
|---|
| 157 | | * |
|---|
| 158 | | * @param drug |
|---|
| 159 | | * to be updated |
|---|
| 160 | | * @deprecated Use saveDrug(Drug) |
|---|
| 161 | | */ |
|---|
| 162 | | public void updateDrug(Drug drug) { |
|---|
| 163 | | checkIfLocked(); |
|---|
| 164 | | |
|---|
| 165 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 166 | | .toString(); |
|---|
| 167 | | |
|---|
| 168 | | if (drug.getConcept() != null) |
|---|
| 169 | | log.info("updating drug - " + authUserId + "|" |
|---|
| 170 | | + drug.getConcept().toString()); |
|---|
| 171 | | |
|---|
| 172 | | getConceptDAO().saveDrug(drug); |
|---|
| 173 | | } |
|---|
| 174 | | |
|---|
| 175 | | |
|---|
| 176 | | /** |
|---|
| 177 | | * Delete the given concept |
|---|
| 178 | | * |
|---|
| 179 | | * For super users only. If dereferencing concepts, use |
|---|
| 180 | | * <code>voidConcept(org.openmrs.Concept)</code> |
|---|
| 181 | | * |
|---|
| 182 | | * @param Concept |
|---|
| 183 | | * to be deleted |
|---|
| 184 | | * @deprecated use purgeConcept(Concept concept) |
|---|
| 185 | | */ |
|---|
| 186 | | public void deleteConcept(Concept concept) { |
|---|
| 187 | | checkIfLocked(); |
|---|
| 188 | | |
|---|
| 189 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 190 | | .toString(); |
|---|
| 191 | | |
|---|
| 192 | | log.info(authUserId + "|" + concept.getConceptId().toString()); |
|---|
| 193 | | |
|---|
| 194 | | getConceptDAO().purgeConcept(concept); |
|---|
| 195 | | } |
|---|
| 196 | | |
|---|
| 197 | | /** |
|---|
| 198 | | * Voiding a concept essentially removes it from circulation |
|---|
| 199 | | * |
|---|
| 200 | | * @param Concept |
|---|
| 201 | | * concept |
|---|
| 202 | | * @param String |
|---|
| 203 | | * reason |
|---|
| 204 | | * @deprecated use retireConcept |
|---|
| 205 | | */ |
|---|
| 206 | | public void voidConcept(Concept concept, String reason) { |
|---|
| 207 | | checkIfLocked(); |
|---|
| 208 | | |
|---|
| 209 | | String authUserId = Context.getAuthenticatedUser().getUserId() |
|---|
| 210 | | .toString(); |
|---|
| 211 | | |
|---|
| 212 | | log.info(authUserId + "|" + concept.getConceptId().toString()); |
|---|
| 213 | | |
|---|
| 214 | | this.retireConcept(concept, reason); |
|---|
| 215 | | } |
|---|
| 216 | | |
|---|
| 217 | | /** |
|---|
| 218 | | * @see org.openmrs.api.ConceptService#saveConcept(org.openmrs.Concept) |
|---|
| 219 | | */ |
|---|
| 220 | | public Concept saveConcept(Concept concept) |
|---|
| 221 | | throws APIException { |
|---|
| 222 | | checkIfLocked(); |
|---|
| 223 | | this.modifyCollections(concept); |
|---|
| 224 | | this.updateConceptWord(concept); |
|---|
| 225 | | return getConceptDAO().saveConcept(concept); |
|---|
| | 132 | return dao.saveConcept(concept); |
|---|
| 259 | | public Drug voidDrug(Drug drug, String reason) throws APIException { |
|---|
| 260 | | drug.setVoided(true); |
|---|
| 261 | | drug.setVoidedBy(Context.getAuthenticatedUser()); |
|---|
| 262 | | drug.setVoidReason(reason); |
|---|
| 263 | | drug.setDateVoided(new Date()); |
|---|
| 264 | | return getConceptDAO().saveDrug(drug); |
|---|
| 265 | | } |
|---|
| 266 | | |
|---|
| | 181 | public Drug retireDrug(Drug drug, String reason) throws APIException { |
|---|
| | 182 | |
|---|
| | 183 | if (drug.isRetired() == false) { |
|---|
| | 184 | drug.setRetired(true); |
|---|
| | 185 | drug.setRetiredBy(Context.getAuthenticatedUser()); |
|---|
| | 186 | drug.setRetireReason(reason); |
|---|
| | 187 | drug.setDateRetired(new Date()); |
|---|
| | 188 | return dao.saveDrug(drug); |
|---|
| | 189 | } |
|---|
| | 190 | |
|---|
| | 191 | return drug; |
|---|
| | 192 | } |
|---|
| 307 | | return getConceptDAO().getConceptNumeric(conceptId); |
|---|
| 308 | | } |
|---|
| 309 | | |
|---|
| 310 | | /** |
|---|
| 311 | | * @see org.openmrs.api.ConceptService#getConcepts(java.lang.String, boolean, boolean) |
|---|
| 312 | | */ |
|---|
| 313 | | public List<Concept> getConcepts(String sortBy, boolean asc, boolean includeRetired) throws APIException{ |
|---|
| 314 | | return getConceptDAO().getConcepts(sortBy, asc, includeRetired); |
|---|
| 315 | | } |
|---|
| 316 | | |
|---|
| 317 | | /** |
|---|
| 318 | | * Return a list of concepts sorted on sortBy in dir direction (asc/desc) |
|---|
| 319 | | * |
|---|
| 320 | | * @param sortBy |
|---|
| 321 | | * @param dir |
|---|
| 322 | | * @return List of concepts |
|---|
| 323 | | * @deprecated use getConcepts(String sortBy, boolean asc, boolean includeRetired) |
|---|
| | 228 | return dao.getConceptNumeric(conceptId); |
|---|
| | 229 | } |
|---|
| | 230 | |
|---|
| | 231 | /** |
|---|
| | 232 | * @see org.openmrs.api.ConceptService#getAllConcepts() |
|---|
| | 233 | */ |
|---|
| | 234 | public List<Concept> getAllConcepts() throws APIException { |
|---|
| | 235 | return getAllConcepts(null, true, true); |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| | 238 | /** |
|---|
| | 239 | * @see org.openmrs.api.ConceptService#getAllConcepts(java.lang.String, boolean, boolean) |
|---|
| | 240 | */ |
|---|
| | 241 | public List<Concept> getAllConcepts(String sortBy, boolean asc, |
|---|
| | 242 | boolean includeRetired) throws APIException { |
|---|
| | 243 | return dao.getAllConcepts(sortBy, asc, includeRetired); |
|---|
| | 244 | } |
|---|
| | 245 | |
|---|
| | 246 | /** |
|---|
| | 247 | * @deprecated use {@link #getAllConcepts(String, boolean, boolean)} |
|---|
| 338 | | return getConceptDAO().getConcepts(name, Context.getLocale(), false, true); |
|---|
| 339 | | } |
|---|
| 340 | | |
|---|
| 341 | | /** |
|---|
| 342 | | * Return a Concept that matches the name exactly |
|---|
| 343 | | * |
|---|
| 344 | | * @param name |
|---|
| 345 | | * @return Concept with matching name |
|---|
| 346 | | * @deprecated use ConceptService.getConcepts(String, Locale (null), ConceptClass (null), boolean (false)) |
|---|
| | 258 | return dao.getConcepts(name, Context.getLocale(), true, null, null); |
|---|
| | 259 | } |
|---|
| | 260 | |
|---|
| | 261 | /** |
|---|
| | 262 | * @see org.openmrs.api.ConceptService#getConceptByName(java.lang.String) |
|---|
| 365 | | Concept c = null; |
|---|
| 366 | | Integer conceptId = null; |
|---|
| 367 | | |
|---|
| 368 | | try { |
|---|
| 369 | | conceptId = new Integer(idOrName); |
|---|
| 370 | | } catch (NumberFormatException nfe) { |
|---|
| 371 | | conceptId = null; |
|---|
| 372 | | } |
|---|
| 373 | | |
|---|
| 374 | | if ( conceptId != null ) { |
|---|
| 375 | | c = getConcept(conceptId); |
|---|
| 376 | | } else { |
|---|
| 377 | | c = getConcept(idOrName, Context.getLocale(), false); |
|---|
| 378 | | } |
|---|
| 379 | | |
|---|
| 380 | | return c; |
|---|
| 381 | | } |
|---|
| 382 | | |
|---|
| 383 | | /** |
|---|
| 384 | | * @see org.openmrs.api.ConceptService#getConcept(java.lang.String, java.util.Locale, boolean) |
|---|
| 385 | | */ |
|---|
| 386 | | public Concept getConcept(String name, Locale locale, boolean includeRetired) { |
|---|
| 387 | | List<Concept> concepts = new ArrayList<Concept>(); |
|---|
| 388 | | if (locale == null) |
|---|
| 389 | | locale = Context.getLocale(); |
|---|
| 390 | | concepts = getConceptDAO().getConcepts(name, locale, includeRetired, false); |
|---|
| 391 | | if (concepts.size() > 1) |
|---|
| 392 | | log.warn("multiple concepts found for concept:" + name); |
|---|
| 393 | | if (concepts.size() == 0) |
|---|
| 394 | | return null; |
|---|
| 395 | | return concepts.get(0); |
|---|
| 396 | | } |
|---|
| | 280 | return getConcept(idOrName); |
|---|
| | 281 | } |
|---|
| 420 | | * |
|---|
| 421 | | * @see org.openmrs.api.ConceptService#getConcepts(java.lang.String, java.util.Locale, boolean, java.util.List, java.util.List, java.util.List, java.util.List, int, int) |
|---|
| 422 | | */ |
|---|
| 423 | | public List<ConceptWord> getConcepts(String phrase, List<Locale> locales, boolean includeRetired, |
|---|
| | 305 | * @see org.openmrs.api.ConceptService#getConceptWords(java.lang.String, java.util.Locale, boolean, java.util.List, java.util.List, java.util.List, java.util.List, Concept, int, int) |
|---|
| | 306 | */ |
|---|
| | 307 | public List<ConceptWord> getConceptWords(String phrase, List<Locale> locales, boolean includeRetired, |
|---|
| 425 | | List<ConceptDatatype> requireDatatypes,List<ConceptDatatype> excludeDatatypes, |
|---|
| 426 | | Integer start, Integer size){ |
|---|
| 427 | | |
|---|
| 428 | | return getConceptDAO().getConcepts(phrase, locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, start, size); |
|---|
| 429 | | } |
|---|
| 430 | | |
|---|
| 431 | | /** |
|---|
| 432 | | * |
|---|
| 433 | | * Finds concepts but only returns the given range |
|---|
| 434 | | * |
|---|
| 435 | | * @param phrase |
|---|
| 436 | | * @param locale |
|---|
| 437 | | * @param includeRetired |
|---|
| 438 | | * @param start |
|---|
| 439 | | * @param size |
|---|
| 440 | | * @return ConceptWord list |
|---|
| 441 | | * @deprecated |
|---|
| 442 | | */ |
|---|
| 443 | | public List<ConceptWord> findConcepts(String phrase, Locale locale, |
|---|
| 444 | | boolean includeRetired, int start, int size) { |
|---|
| 445 | | List<Locale> locales = new Vector<Locale>(); |
|---|
| 446 | | locales.add(locale); |
|---|
| 447 | | |
|---|
| 448 | | List<ConceptWord> conceptWords = getConcepts(phrase, locales, |
|---|
| 449 | | includeRetired, null, null, null, null, start, size); |
|---|
| 450 | | List<ConceptWord> subList = conceptWords.subList(start, start + size); |
|---|
| 451 | | |
|---|
| 452 | | return subList; |
|---|
| 453 | | } |
|---|
| 454 | | |
|---|
| 455 | | /** |
|---|
| 456 | | * Searches on given phrase via the concept word table |
|---|
| 457 | | * |
|---|
| 458 | | * @param phrase/search/words |
|---|
| 459 | | * String |
|---|
| 460 | | * @param locale |
|---|
| 461 | | * Locale |
|---|
| 462 | | * @param includeRetired |
|---|
| 463 | | * boolean |
|---|
| 464 | | * @return |
|---|
| 465 | | * @deprecated |
|---|
| 466 | | */ |
|---|
| 467 | | public List<ConceptWord> findConcepts(String phrase, Locale locale, |
|---|
| 468 | | boolean includeRetired) { |
|---|
| 469 | | List<Locale> locales = new Vector<Locale>(); |
|---|
| 470 | | locales.add(locale); |
|---|
| 471 | | |
|---|
| 472 | | return getConcepts(phrase, locales, includeRetired, null, null, null, null, null, null); |
|---|
| 473 | | } |
|---|
| 474 | | |
|---|
| 475 | | /** |
|---|
| 476 | | * Searches on given phrase via the concept word table |
|---|
| 477 | | * |
|---|
| 478 | | * @param phrase/search/words |
|---|
| 479 | | * String |
|---|
| 480 | | * @param locale |
|---|
| 481 | | * Locale |
|---|
| 482 | | * @param includeRetired |
|---|
| 483 | | * boolean |
|---|
| 484 | | * @param requireClasses |
|---|
| 485 | | * List<ConceptClass> |
|---|
| 486 | | * @param excludeClasses |
|---|
| 487 | | * List<ConceptClass> |
|---|
| 488 | | * @param requireDatatypes |
|---|
| 489 | | * List<ConceptDatatype> |
|---|
| 490 | | * @param excludeDatatypes |
|---|
| 491 | | * List<ConceptDatatype> |
|---|
| 492 | | * @return |
|---|
| 493 | | * @deprecated |
|---|
| 494 | | * @see {@link ConceptService#getConcepts(String, Locale, boolean, List, List, List, List, Integer, Integer)} |
|---|
| 495 | | */ |
|---|
| 496 | | public List<ConceptWord> findConcepts(String phrase, Locale locale, boolean includeRetired, |
|---|
| 497 | | List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, |
|---|
| 498 | | List<ConceptDatatype> requireDatatypes, List<ConceptDatatype> excludeDatatypes) { |
|---|
| | 309 | List<ConceptDatatype> requireDatatypes, List<ConceptDatatype> excludeDatatypes, |
|---|
| | 310 | Concept answerToConcept, Integer start, Integer size){ |
|---|
| | 321 | List<ConceptWord> conceptWords = dao.getConceptWords(phrase, |
|---|
| | 322 | locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, answerToConcept, start, size); |
|---|
| | 323 | |
|---|
| | 324 | return weightWords(phrase, locales, conceptWords); |
|---|
| | 325 | } |
|---|
| | 326 | |
|---|
| | 327 | /** |
|---|
| | 328 | * @see org.openmrs.api.ConceptService#getConceptWords(java.lang.String, java.util.Locale) |
|---|
| | 329 | */ |
|---|
| | 330 | public List<ConceptWord> getConceptWords(String phrase, Locale locale) |
|---|
| | 331 | throws APIException { |
|---|
| | 332 | List<Locale> locales = new Vector<Locale>(); |
|---|
| | 333 | locales.add(locale); |
|---|
| | 334 | |
|---|
| | 335 | return getConceptWords(phrase, locales, false, null, null, null, null, null, null, null); |
|---|
| | 336 | } |
|---|
| | 337 | |
|---|
| | 338 | /** |
|---|
| | 339 | * @deprecated use {@link #getConceptWords(String, List, boolean, List, List, List, List, Integer, Integer)} |
|---|
| | 340 | */ |
|---|
| | 341 | public List<ConceptWord> findConcepts(String phrase, Locale locale, |
|---|
| | 342 | boolean includeRetired, int start, int size) { |
|---|
| 512 | | List<ConceptWord> conceptWords = getConceptDAO().getConcepts(phrase, |
|---|
| 513 | | locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, null, null); |
|---|
| 514 | | |
|---|
| 515 | | return weightWords(phrase, locales, conceptWords); |
|---|
| 516 | | } |
|---|
| 517 | | |
|---|
| 518 | | /** |
|---|
| | 346 | // delegate to the non-deprecated method |
|---|
| | 347 | List<ConceptWord> conceptWords = getConceptWords(phrase, locales, |
|---|
| | 348 | includeRetired, null, null, null, null, null, start, size); |
|---|
| | 349 | |
|---|
| | 350 | List<ConceptWord> subList = conceptWords.subList(start, start + size); |
|---|
| | 351 | |
|---|
| | 352 | return subList; |
|---|
| | 353 | } |
|---|
| | 354 | |
|---|
| | 355 | /** |
|---|
| | 356 | * @deprecated use {@link #getConceptWords(String, List, boolean, List, List, List, List, Integer, Integer)} |
|---|
| | 357 | */ |
|---|
| | 358 | public List<ConceptWord> findConcepts(String phrase, Locale locale, |
|---|
| | 359 | boolean includeRetired) { |
|---|
| | 360 | |
|---|
| | 361 | List<Locale> locales = new Vector<Locale>(); |
|---|
| | 362 | locales.add(locale); |
|---|
| | 363 | |
|---|
| | 364 | return getConceptWords(phrase, locales, includeRetired, null, null, null, null, null, null, null); |
|---|
| | 365 | } |
|---|
| | 366 | |
|---|
| | 367 | /** |
|---|
| | 368 | * @deprecated use {@link #getConceptWords(String, List, boolean, List, List, List, List, Integer, Integer)} |
|---|
| | 369 | */ |
|---|
| | 370 | public List<ConceptWord> findConcepts(String phrase, Locale locale, boolean includeRetired, |
|---|
| | 371 | List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, |
|---|
| | 372 | List<ConceptDatatype> requireDatatypes, List<ConceptDatatype> excludeDatatypes) { |
|---|
| | 373 | |
|---|
| | 374 | List<Locale> locales = new Vector<Locale>(); |
|---|
| | 375 | locales.add(locale); |
|---|
| | 376 | |
|---|
| | 377 | return getConceptWords(phrase, locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, null, null, null); |
|---|
| | 378 | } |
|---|
| | 379 | |
|---|
| | 380 | /** |
|---|
| | 381 | * Auto generated method comment |
|---|
| 520 | | * @see org.openmrs.api.ConceptService#getConcepts(org.openmrs.ConceptClass, boolean) |
|---|
| 521 | | */ |
|---|
| 522 | | public List<Concept> getConcepts(ConceptClass cc, boolean includeRetired){ |
|---|
| 523 | | return getConceptDAO().getConcepts(cc, includeRetired); |
|---|
| 524 | | } |
|---|
| 525 | | |
|---|
| 526 | | /** |
|---|
| 527 | | * |
|---|
| 528 | | * @see org.openmrs.api.ConceptService#getConcepts(java.lang.String, java.util.Locale, boolean, boolean) |
|---|
| 529 | | */ |
|---|
| 530 | | public List<Concept> getConcepts(String name, Locale loc, boolean includeRetired, boolean searchOnPhrase){ |
|---|
| 531 | | return getConceptDAO().getConcepts(name, loc, includeRetired, searchOnPhrase); |
|---|
| 532 | | } |
|---|
| 533 | | |
|---|
| 534 | | /** |
|---|
| 535 | | * Return the drug object corresponding to the given name |
|---|
| 536 | | * |
|---|
| 537 | | * @return Drug |
|---|
| 538 | | * @deprecated |
|---|
| 539 | | */ |
|---|
| 540 | | public Drug getDrug(String drugName) { |
|---|
| 541 | | List<Drug> drugs = new ArrayList<Drug>(); |
|---|
| 542 | | drugs = getConceptDAO().getDrugs(drugName, null, false); |
|---|
| 543 | | if (drugs.size() > 1) |
|---|
| 544 | | log.warn("more than one drug name returned with name:" + drugName); |
|---|
| 545 | | if (drugs.size() == 0) |
|---|
| 546 | | return null; |
|---|
| 547 | | return (Drug) drugs.get(0); |
|---|
| 548 | | } |
|---|
| 549 | | |
|---|
| 550 | | |
|---|
| 551 | | /** |
|---|
| 552 | | * |
|---|
| 553 | | * @see org.openmrs.api.ConceptService#getDrugByNameOrId(java.lang.String) |
|---|
| 554 | | * @deprecated |
|---|
| 555 | | */ |
|---|
| 556 | | public Drug getDrugByNameOrId(String drug) { |
|---|
| 557 | | Integer drugId = null; |
|---|
| 558 | | try { |
|---|
| 559 | | drugId = new Integer(drug); |
|---|
| 560 | | } catch ( NumberFormatException nfe ) { |
|---|
| 561 | | drugId = null; |
|---|
| 562 | | } |
|---|
| 563 | | if ( drugId != null ) { |
|---|
| 564 | | return getDrug(drugId); |
|---|
| 565 | | } else { |
|---|
| 566 | | return getDrug(drug, false); |
|---|
| 567 | | } |
|---|
| 568 | | } |
|---|
| 569 | | |
|---|
| 570 | | /** |
|---|
| 571 | | * @see org.openmrs.api.ConceptService#getDrug(java.lang.String, java.util.Locale, boolean) |
|---|
| 572 | | */ |
|---|
| 573 | | public Drug getDrug(String drugNameOrId, boolean includeVoided) throws APIException { |
|---|
| | 383 | * @param name |
|---|
| | 384 | * @param loc |
|---|
| | 385 | * @param searchOnPhrase |
|---|
| | 386 | * @return |
|---|
| | 387 | */ |
|---|
| | 388 | private List<Concept> getConcepts(String name, Locale loc, boolean searchOnPhrase, List<ConceptClass> classes, List<ConceptDatatype> datatypes){ |
|---|
| | 389 | if (classes == null) |
|---|
| | 390 | classes = new Vector<ConceptClass>(); |
|---|
| | 391 | if (datatypes == null) |
|---|
| | 392 | datatypes = new Vector<ConceptDatatype>(); |
|---|
| | 393 | |
|---|
| | 394 | return dao.getConcepts(name, loc, searchOnPhrase, classes, datatypes); |
|---|
| | 395 | } |
|---|
| | 396 | |
|---|
| | 397 | /** |
|---|
| | 398 | * @see org.openmrs.api.ConceptService#getDrug(java.lang.String) |
|---|
| | 399 | */ |
|---|
| | 400 | public Drug getDrug(String drugNameOrId) { |
|---|
| 599 | | return getConceptDAO().getDrugs(null, null, true); |
|---|
| 600 | | } |
|---|
| 601 | | |
|---|
| 602 | | /** |
|---|
| 603 | | * Return a list of drugs associated with the given concept |
|---|
| 604 | | * |
|---|
| 605 | | * @param Concept |
|---|
| 606 | | * @return List of Drugs |
|---|
| | 432 | return getAllDrugs(); |
|---|
| | 433 | } |
|---|
| | 434 | |
|---|
| | 435 | /** |
|---|
| | 436 | * @see org.openmrs.api.ConceptService#getAllDrugs() |
|---|
| | 437 | */ |
|---|
| | 438 | public List<Drug> getAllDrugs() { |
|---|
| | 439 | return getAllDrugs(true); |
|---|
| | 440 | } |
|---|
| | 441 | |
|---|
| | 442 | /** |
|---|
| | 443 | * @see org.openmrs.api.ConceptService#getAllDrugs(boolean) |
|---|
| | 444 | */ |
|---|
| | 445 | public List<Drug> getAllDrugs(boolean includeRetired) { |
|---|
| | 446 | return dao.getDrugs(null, null, includeRetired); |
|---|
| | 447 | } |
|---|
| | 448 | |
|---|
| | 449 | /** |
|---|
| | 450 | * @see org.openmrs.api.ConceptService#getDrugs(org.openmrs.Concept) |
|---|
| | 451 | * @deprecated use {@link #getDrugsByConcept(Concept)} |
|---|
| 631 | | return getConceptDAO().getDrugs(phrase, includeRetired); |
|---|
| 632 | | } |
|---|
| 633 | | |
|---|
| 634 | | /** |
|---|
| 635 | | * |
|---|
| 636 | | * @see org.openmrs.api.ConceptService#getDrugs(java.lang.String, boolean) |
|---|
| 637 | | */ |
|---|
| 638 | | public List<Drug> getDrugs(String phrase, boolean includeRetired) { |
|---|
| 639 | | return getConceptDAO().getDrugs(phrase, includeRetired); |
|---|
| | 488 | if (includeRetired == true) |
|---|
| | 489 | throw new APIException("Getting retired drugs is no longer an options. Use the getAllDrugs() method for that"); |
|---|
| | 490 | |
|---|
| | 491 | return getDrugs(phrase); |
|---|
| | 492 | } |
|---|
| | 493 | |
|---|
| | 494 | /** |
|---|
| | 495 | * @see org.openmrs.api.ConceptService#getDrugs(java.lang.String) |
|---|
| | 496 | */ |
|---|
| | 497 | public List<Drug> getDrugs(String phrase) { |
|---|
| | 498 | return dao.getDrugs(phrase); |
|---|