Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/16/08 13:28:28 (4 months ago)
Author:
bwolfe
Message:

api-refactoring: Re-refactoring some of the api services

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/api_refactoring/src/api/org/openmrs/api/impl/ConceptServiceImpl.java

    r4231 r4240  
    5050 
    5151/** 
    52  * Implementations of ConceptService service layer classes 
     52 * Default Implementation of ConceptService service layer classes 
     53 *  
    5354 * @see org.openmrs.ConceptService to access these methods 
    54  * @version 1.0 
    5555 */ 
    5656public class ConceptServiceImpl extends BaseOpenmrsService implements ConceptService { 
     
    6060        private ConceptDAO dao; 
    6161         
    62         public ConceptServiceImpl() { } 
    63  
    64         /** 
    65          *  
    66          * Getter for ConceptDAO 
    67          *  
    68          * @return ConceptDAO 
    69          */ 
    70         private ConceptDAO getConceptDAO() { 
    71                 return dao; 
    72         } 
    73          
    7462        /** 
    7563         * @see org.openmrs.api.ConceptService#setConceptDAO(org.openmrs.api.db.ConceptDAO) 
     
    8068         
    8169        /** 
    82          * @see org.openmrs.api.ConceptService#createConcept(org.openmrs.Concept) 
    83          * @deprecated Use saveConcept(Concept); 
     70         * @deprecated use {@link #saveConcept(Concept)} 
    8471         */ 
    8572        public void createConcept(Concept concept) { 
    86                 checkIfLocked();         
    87                 this.modifyCollections(concept); 
    88                 this.updateConceptWord(concept); 
    89                 getConceptDAO().saveConcept(concept); 
    90         } 
    91  
    92         /** 
    93          * @param numeric 
    94          *            concept to be created 
    95          * @deprecated use saveConcept(Concept) 
     73                saveConcept(concept); 
     74        } 
     75 
     76        /** 
     77         * @deprecated use {@link #saveConcept(Concept)} 
    9678         */ 
    9779        public void createConcept(ConceptNumeric concept) { 
     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 { 
    98129                checkIfLocked(); 
    99130                this.modifyCollections(concept); 
    100131                this.updateConceptWord(concept); 
    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);     
    226133    } 
    227134         
     
    230137     */ 
    231138    public Drug saveDrug(Drug drug) throws APIException { 
    232             return getConceptDAO().saveDrug(drug); 
     139        checkIfLocked(); 
     140         
     141        if (drug.getCreator() == null) 
     142                drug.setCreator(Context.getAuthenticatedUser()); 
     143        if (drug.getDateCreated() == null) 
     144                        drug.setDateCreated(new Date()); 
     145         
     146                return dao.saveDrug(drug); 
    233147    } 
    234148     
     
    236150     * @see org.openmrs.api.ConceptService#purgeConcept(java.lang.Object) 
    237151     */ 
    238     public void purgeConcept(Concept concept) 
    239             throws APIException { 
     152    public void purgeConcept(Concept concept) throws APIException { 
    240153        checkIfLocked(); 
    241         getConceptDAO().purgeConcept(concept); 
     154        dao.purgeConcept(concept); 
    242155    } 
    243156     
     
    247160    public Concept retireConcept(Concept concept, String reason) 
    248161            throws APIException { 
    249         checkIfLocked(); 
    250         concept.setRetired(true); 
    251             return getConceptDAO().saveConcept(concept); 
    252     } 
    253      
     162         
     163        // only do this if the concept isn't retired already 
     164        if (concept.isRetired() == false) { 
     165                checkIfLocked(); 
     166         
     167                concept.setRetired(true); 
     168                concept.setRetireReason(reason); 
     169                concept.setRetiredBy(Context.getAuthenticatedUser()); 
     170                concept.setDateRetired(new Date()); 
     171                    return dao.saveConcept(concept); 
     172        } 
     173         
     174        return concept; 
     175    } 
    254176     
    255177        /** 
     
    257179     * @throws APIException 
    258180     */ 
    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    } 
    267193     
    268194        /** 
     
    272198         */ 
    273199    public void purgeDrug(Drug drug) throws APIException { 
    274         getConceptDAO().purgeDrug(drug); 
    275     } 
    276      
    277         /** 
    278          *  
     200        dao.purgeDrug(drug); 
     201    } 
     202     
     203        /** 
    279204         * @see org.openmrs.api.ConceptService#getConcept(java.lang.Integer) 
    280          * @throws APIException 
    281205         */ 
    282206        public Concept getConcept(Integer conceptId) throws APIException { 
    283                 return getConceptDAO().getConcept(conceptId); 
    284         } 
    285          
    286         /** 
    287          *  
     207                return dao.getConcept(conceptId); 
     208        } 
     209         
     210        /** 
    288211         * @see org.openmrs.api.ConceptService#getConceptAnswer(java.lang.Integer) 
    289212         */ 
    290213        public ConceptAnswer getConceptAnswer(Integer conceptAnswerId) throws APIException { 
    291                 return getConceptDAO().getConceptAnswer(conceptAnswerId); 
    292         } 
    293          
    294         /** 
    295          *  
     214                return dao.getConceptAnswer(conceptAnswerId); 
     215        } 
     216         
     217        /** 
    296218         * @see org.openmrs.api.ConceptService#getDrug(java.lang.Integer) 
    297219         */ 
    298220        public Drug getDrug(Integer drugId) throws APIException { 
    299                 return getConceptDAO().getDrug(drugId); 
    300         } 
    301          
    302         /** 
    303          *  
     221                return dao.getDrug(drugId); 
     222        } 
     223         
     224        /** 
    304225         * @see org.openmrs.api.ConceptService#getConceptNumeric(java.lang.Integer) 
    305226         */ 
    306227        public ConceptNumeric getConceptNumeric(Integer conceptId) throws APIException { 
    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)} 
    324248         */ 
    325249        public List<Concept> getConcepts(String sortBy, String dir) throws APIException{ 
    326250                boolean asc = true ? dir.equals("asc") : !dir.equals("asc"); 
    327                 return getConceptDAO().getConcepts(sortBy, asc, true); 
    328         } 
    329  
    330         /** 
    331          * Return a list of concepts matching "name" anywhere in the name 
    332          *  
    333          * @param name 
    334          * @return List of concepts 
    335          * @deprecated use ConceptService.getConcepts(String, Locale (null), ConceptClass (null), boolean (false)) 
     251                return getAllConcepts(sortBy, asc, true); 
     252        } 
     253 
     254        /** 
     255         * @see org.openmrs.api.ConceptService#getConceptsByName(java.lang.String) 
    336256         */ 
    337257        public List<Concept> getConceptsByName(String name) throws APIException { 
    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) 
    347263         */ 
    348264        public Concept getConceptByName(String name) { 
    349                 List<Concept> concepts =  getConceptDAO().getConcepts(name, Context.getLocale(), false, false); 
     265                List<Concept> concepts =  getConcepts(name, Context.getLocale(), false, null, null); 
    350266                int size = concepts.size();  
    351267                if (size > 0){ 
     
    358274         
    359275        /** 
    360          *  
    361276         * @see org.openmrs.api.ConceptService#getConceptByIdOrName(java.lang.String) 
    362          * @deprecated 
     277         * @deprecated use {@link #getConcept(String))} 
    363278         */ 
    364279        public Concept getConceptByIdOrName(String idOrName) { 
    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        } 
    397282     
    398283    /** 
     
    412297                        c = getConcept(conceptId); 
    413298                } else { 
    414                         c = getConcept(conceptIdOrName, Context.getLocale(), false); 
     299                        c = getConceptByName(conceptIdOrName); 
    415300                } 
    416301                return c; 
     
    418303     
    419304        /** 
    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,  
    424308                                                List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 
    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){ 
    499311                 
    500312                if (requireClasses == null) 
     
    507319                        excludeDatatypes = new Vector<ConceptDatatype>(); 
    508320                 
     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) { 
    509343                List<Locale> locales = new Vector<Locale>(); 
    510344                locales.add(locale); 
    511345                 
    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 
    519382         *  
    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) { 
    574401        Integer drugId = null;   
    575402                try { 
     
    582409                } else { 
    583410                        List<Drug> drugs = new ArrayList<Drug>(); 
    584                         drugs = getConceptDAO().getDrugs(drugNameOrId, null, false); 
     411                        drugs = dao.getDrugs(drugNameOrId, null, false); 
    585412                        if (drugs.size() > 1) 
    586413                                log.warn("more than one drug name returned with name:" + drugNameOrId); 
     
    589416                        return (Drug) drugs.get(0); 
    590417                } 
    591     } 
    592  
    593         /** 
    594          * Return a list of drugs currently in the database 
    595          *  
    596          * @return List of Drugs 
     418        } 
     419         
     420        /** 
     421         * @see org.openmrs.api.ConceptService#getDrugByNameOrId(java.lang.String) 
     422         * @deprecated use {@link #getDrug(String)} 
     423         */ 
     424        public Drug getDrugByNameOrId(String drugNameOrId) { 
     425                return getDrug(drugNameOrId); 
     426        } 
     427 
     428        /** 
     429         * @deprecated use {@link #getAllDrugs()} 
    597430         */ 
    598431        public List<Drug> getDrugs() { 
    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)} 
    607452         */ 
    608453        public List<Drug> getDrugs(Concept concept) { 
    609                 return getConceptDAO().getDrugs(null, concept, false); 
     454                return getDrugsByConcept(concept); 
     455        } 
     456         
     457        /** 
     458         * @see org.openmrs.api.ConceptService#getDrugsByConcept(org.openmrs.Concept) 
     459         */ 
     460        public List<Drug> getDrugsByConcept(Concept concept) { 
     461                return dao.getDrugs(null, concept, false); 
    610462        } 
    611463         
    612464        /** 
    613465     * @see org.openmrs.api.ConceptService#getDrugs(org.openmrs.Concept, boolean) 
    614      */ 
    615     public List<Drug> getDrugs(Concept concept, boolean includeVoided) { 
    616         return getConceptDAO().getDrugs(null, concept, includeVoided); 
     466     * @deprecated Use {@link #getDrugsByConcept(Concept)} 
     467     */ 
     468    public List<Drug> getDrugs(Concept concept, boolean includeRetired) { 
     469        if (includeRetired == true) 
     470                throw new APIException("Getting retired drugs is no longer an options.  Use the getAllDrugs() method for that"); 
     471         
     472        return getDrugsByConcept(concept); 
    617473    } 
    618474     
    619475        /** 
    620476     * @see org.openmrs.api.ConceptService#getDrugs(boolean) 
     477     * @deprecated Use {@link #getAllDrugs(boolean)} 
    621478     */ 
    622479    public List<Drug> getDrugs(boolean includeVoided) { 
    623            return getConceptDAO().getDrugs(null, null, includeVoided); 
    624     } 
    625      
    626         /** 
    627          *  
     480        return getAllDrugs(includeVoided); 
     481    } 
     482     
     483        /** 
    628484         * @see org.openmrs.api.ConceptService#findDrugs(java.lang.String, boolean) 
     485         * @deprecated Use {@link #getDrugs(String)} 
    629486         */ 
    630487        public List<Drug> findDrugs(String phrase, boolean includeRetired) { 
    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); 
    640499        } 
    641500         
    642501        /** 
    643502         * @see org.openmrs.api.ConceptService#getConceptsByClass(org.openmrs.ConceptClass) 
    644          * @deprecated 
    645503         */ 
    646504        public List<Concept> getConceptsByClass(ConceptClass cc) { 
    647                 return getConceptDAO().getConcepts(cc, false); 
    648         } 
    649          
    650          
    651         /** 
    652          * Return a list of concept classes currently in the database 
    653          *  
    654          * @return List of Concept class objects 
    655          * @deprecated 
     505                List<ConceptClass> classes = new Vector<ConceptClass>(); 
     506                classes.add(cc); 
     507                 
     508                return getConcepts(null, null, false, classes, null); 
     509        } 
     510         
     511        /** 
     512         * @see org.openmrs.api.ConceptService#getConceptClasses() 
    656513         */ 
    657514        public List<ConceptClass> getConceptClasses() { 
    658                 return getConceptDAO().getConceptClasses(null); 
    659         } 
    660          
    661         /** 
    662          * Return a Concept class matching the given identifier 
    663          *  
    664          * @param i Integer 
    665          * @return ConceptClass 
     515                return getAllConceptClasses(true); 
     516        } 
     517         
     518        /** 
     519         * @see org.openmrs.api.ConceptService#getAllConceptClasses(boolean) 
     520         */ 
     521        public List<ConceptClass> getAllConceptClasses(boolean includeRetired) { 
     522                return dao.getAllConceptClasses(includeRetired); 
     523        } 
     524         
     525        /** 
     526         * @see org.openmrs.api.ConceptService#getConceptClass(java.lang.Integer) 
    666527         */ 
    667528        public ConceptClass getConceptClass(Integer i) { 
    668                 return getConceptDAO().getConceptClass(i); 
    669         } 
    670          
    671         /** 
    672          * Return a Concept class matching the given name 
    673          *  
    674          * @param name String 
    675