Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/28/08 05:16:52 (8 months ago)
Author:
bmckown
Message:

complex_obs branch: Merging trunk to complex-obs [3891] [4378] TODO: sqldiff.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/complex-obs/src/api/org/openmrs/api/ObsService.java

    • Property svn:eol-style set to CRLF
    r4265 r4417  
    1919import java.util.Set; 
    2020 
     21import org.openmrs.Cohort; 
    2122import org.openmrs.Concept; 
    2223import org.openmrs.Encounter; 
     
    2728import org.openmrs.annotation.Authorized; 
    2829import org.openmrs.api.db.ObsDAO; 
    29 import org.openmrs.logic.Aggregation; 
    30 import org.openmrs.logic.Constraint; 
    3130import org.openmrs.obs.ComplexData; 
    3231import org.openmrs.obs.ComplexObsHandler; 
    33 import org.openmrs.reporting.PatientSet; 
    3432import org.openmrs.util.OpenmrsConstants; 
     33import org.openmrs.util.OpenmrsConstants.PERSON_TYPE; 
    3534import org.springframework.transaction.annotation.Transactional; 
    3635 
     36 
    3737/** 
    38  * The ObsService provides methods for acting on Obs, ObsGroup, and ComplexObs 
    39  * objects. 
     38 * The ObsService deals with saving and getting Obs to/from the 
     39 * database 
    4040 *  
    41  * Use: <code> 
    42  *      Context.getObsService().getObs(123); 
    43  * </code> 
     41 * Usage: 
     42 * <pre> 
     43 *  ObsService obsService = Context.getObsService(); 
     44 *  // get the obs for patient with internal identifier of 1235 
     45 *  List<Obs> someObsList = obsService.getObservationsByPerson(new Patient(1235)); 
     46 * </pre> 
    4447 *  
    45  * There are also a number of convenience methods for extracting obs pertaining 
    46  * to certain Concepts, people, or encounters 
    47  *  
     48 * There are also a number of convenience methods for extracting obs 
     49 * pertaining to certain Concepts, people, or encounters 
     50 * 
     51 * @see org.openmrs.Obs 
     52 * @see org.openmrs.ComplexObs 
     53 * @see org.openmrs.MimeType 
     54 * @see org.openmrs.api.context.Context 
    4855 */ 
    4956@Transactional 
    50 public interface ObsService { 
    51  
     57public interface ObsService extends OpenmrsService { 
     58 
     59        /** 
     60         * @see org.openmrs.util.OpenmrsConstants 
     61         * @deprecated Use org.openmrs.util.OpenmrsConstants#PERSON_TYPE.PATIENT 
     62         */ 
    5263        public static final Integer PERSON = 1; 
     64         
     65        /** 
     66         * @see org.openmrs.util.OpenmrsConstants 
     67         * @deprecated Use OpenmrsConstants#PERSON_TYPE.PATIENT 
     68         */ 
    5369        public static final Integer PATIENT = 2; 
     70         
     71        /** 
     72         * @see org.openmrs.util.OpenmrsConstants 
     73         * @deprecated Use OpenmrsConstants.PERSON_TYPE.USER 
     74         */ 
    5475        public static final Integer USER = 4; 
    5576 
     77        /** 
     78         * Set the given <code>dao</code> on this obs service.  
     79         * The dao will act as the conduit through with all obs 
     80         * calls get to the database 
     81         *  
     82         * @param dao specific ObsDAO to use for this service 
     83         */ 
    5684        public void setObsDAO(ObsDAO dao); 
    5785 
     
    6189         * @param Obs 
    6290         * @throws APIException 
    63          */ 
    64         @Authorized( { OpenmrsConstants.PRIV_ADD_OBS }) 
     91         * @deprecated use {@link #saveObs(Obs, String)} 
     92         */ 
     93        @Authorized(OpenmrsConstants.PRIV_ADD_OBS) 
    6594        public void createObs(Obs obs) throws APIException; 
    6695 
     
    7099         *  
    71100         * The proper use is: 
    72          *  
    73101         * <pre> 
    74102         * Obs obsGroup = new Obs(); 
     
    79107         * </pre> 
    80108         *  
    81          * @param obs array of observations to be grouped 
    82          * @throws APIException 
    83          * @deprecated This method should no longer need to be called on the api. 
    84          *             This was meant as temporary until we created a true ObsGroup 
    85          *             pojo. Replaced by {@link #createObsGroup(Obs, List)} 
     109         * @param obs - array of observations to be grouped 
     110         * @throws APIException 
     111         * @deprecated This method should no longer need to be called on the api. This 
     112         *                       was meant as temporary until we created a true ObsGroup pojo. 
     113         *                       Replaced by {@link #createObsGroup(Obs, List)} 
    86114         *  
    87115         * @see #createObsGroup(Obs, List) 
    88116         */ 
    89         @Authorized( { OpenmrsConstants.PRIV_ADD_OBS }
     117        @Authorized(OpenmrsConstants.PRIV_ADD_OBS
    90118        public void createObsGroup(Obs[] obs) throws APIException; 
    91119 
     
    98126         */ 
    99127        @Transactional(readOnly = true) 
    100         @Authorized( { OpenmrsConstants.PRIV_VIEW_OBS }
     128        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS
    101129        public Obs getObs(Integer obsId) throws APIException; 
     130 
     131        /** 
     132         * Save changes to observation 
     133         *  
     134         * @param Obs 
     135         * @throws APIException 
     136         * @deprecated use {@link #saveObs(Obs, String)} 
     137         */ 
     138        @Authorized(OpenmrsConstants.PRIV_EDIT_OBS) 
     139        public void updateObs(Obs obs) throws APIException; 
     140 
     141        /** 
     142         * Save the given obs to the database. This will move the 
     143         * contents of the given <code>obs</code> to the database. This 
     144         * acts as both the initial save and an update kind of save. 
     145         * The returned obs will be the same as the obs passed in. It is 
     146         * included for chaining. 
     147         *  
     148         * If this is an initial save, the obsId on the given 
     149         * <code>obs</code> object will be updated to reflect the auto 
     150         * numbering from the database.  The obsId on the returned obs 
     151         * will also have this number. 
     152         *  
     153         * If there is already an obsId on the given <code>obs</code> object, 
     154         * the given obs will be voided and a new row in the database will be 
     155         * created that has a new obs id. 
     156         *  
     157         * @param obs the Obs to save to the database 
     158         * @param changeMessage String explaining why <code>obs</code> is being changed. If  
     159         *              <code>obs</code> is a new obs, changeMessage is nullable, or if  
     160         *              it is being updated, it would be required 
     161         * @return Obs that was saved to the database 
     162         * @throws APIException 
     163         */ 
     164        @Authorized({OpenmrsConstants.PRIV_ADD_OBS, OpenmrsConstants.PRIV_EDIT_OBS}) 
     165        public Obs saveObs(Obs obs, String changeMessage) throws APIException; 
     166 
     167        /** 
     168         * Equivalent to deleting an observation 
     169         *  
     170         * @param Obs obs to void 
     171         * @param String reason 
     172         * @throws APIException 
     173         */ 
     174        @Authorized(OpenmrsConstants.PRIV_EDIT_OBS) 
     175        public Obs voidObs(Obs obs, String reason) throws APIException; 
     176 
     177        /** 
     178         * Revive an observation (pull a Lazarus) 
     179         *  
     180         * @param Obs 
     181         * @throws APIException 
     182         */ 
     183        @Authorized(OpenmrsConstants.PRIV_EDIT_OBS) 
     184        public Obs unvoidObs(Obs obs) throws APIException; 
     185 
     186        /** 
     187         * This method shouldn't be used.  Use either {@link #purgeObs(Obs)} or 
     188         * {@link #voidObs(Obs)} 
     189         *  
     190         * @param Obs 
     191         * @throws APIException 
     192         * @deprecated use #purgeObs(Obs) 
     193         */ 
     194        @Authorized(OpenmrsConstants.PRIV_DELETE_OBS) 
     195        public void deleteObs(Obs obs) throws APIException; 
     196 
     197        /** 
     198         * Completely remove an observation from the database. This should typically 
     199         * not be called because we don't want to ever lose data.  The data really 
     200         * <i>should</i> be voided and then it is not seen in interface any longer  
     201         * (see #voidObs(Obs) for that one) 
     202         *  
     203         * If other things link to this obs, an error will be thrown. 
     204         *  
     205         * @param Obs 
     206         * @throws APIException 
     207         */ 
     208        @Authorized(OpenmrsConstants.PRIV_DELETE_OBS) 
     209        public void purgeObs(Obs obs) throws APIException; 
     210         
     211        /** 
     212         * Completely remove an observation from the database. This should typically 
     213         * not be called because we don't want to ever lose data.  The data really 
     214         * <i>should</i> be voided and then it is not seen in interface any longer  
     215         * (see #voidObs(Obs) for that one) 
     216         *  
     217         * @param Obs the observation to remove from the database 
     218         * @param cascade true/false whether or not to cascade down to other things 
     219         *                      that link to this observation (like Orders and ObsGroups) 
     220         * @throws APIException 
     221         * @see #purgeObs(Obs, boolean) 
     222         */ 
     223        @Authorized(OpenmrsConstants.PRIV_DELETE_OBS) 
     224        public void purgeObs(Obs obs, boolean cascade) throws APIException; 
     225         
     226        /** 
     227         * @deprecated use {@link #getAllMimeTypes()} 
     228         */ 
     229        @Transactional(readOnly = true) 
     230        @Authorized(OpenmrsConstants.PRIV_VIEW_MIME_TYPES) 
     231        public List<MimeType> getMimeTypes() throws APIException; 
     232 
     233        /** 
     234         * Gets all mime types (including retired ones) 
     235         *  
     236         * @return list of MimeTypes in the system 
     237         * @see #getAllMimeTypes(boolean) 
     238         * @throws APIException 
     239         */ 
     240        @Authorized(OpenmrsConstants.PRIV_VIEW_MIME_TYPES) 
     241        public List<MimeType> getAllMimeTypes() throws APIException; 
     242         
     243        /** 
     244         * Gets all mime types and disregards the retired ones 
     245         * if <code>includeRetired</code> is true 
     246         *  
     247         * @param includeRetired true/false of whether to also return the retired ones 
     248         * @return list of MimeTypes lll 
     249         * @throws APIException 
     250         */ 
     251        @Authorized(OpenmrsConstants.PRIV_VIEW_MIME_TYPES) 
     252        public List<MimeType> getAllMimeTypes(boolean includeRetired) throws APIException; 
     253 
     254        /** 
     255         * Get mimeType by internal identifier 
     256         *  
     257         * @param mimeType id 
     258         * @return mimeType with given internal identifier 
     259         * @throws APIException 
     260         */ 
     261        @Transactional(readOnly = true) 
     262        @Authorized(OpenmrsConstants.PRIV_VIEW_MIME_TYPES) 
     263        public MimeType getMimeType(Integer mimeTypeId) throws APIException; 
     264 
     265        /** 
     266         * Save the given <code>mimeType</code> to the database. 
     267         * If mimeType is not null, the mimeType is updated in the database. 
     268         * If mimeType is null, a new mimeType is added to the database 
     269         *  
     270         * @param mimeType mimeType 
     271         * @return mimeType that was saved/updated in the database 
     272         * @throws APIException 
     273         */ 
     274        @Authorized(OpenmrsConstants.PRIV_MANAGE_MIME_TYPES) 
     275        public MimeType saveMimeType(MimeType mimeType) throws APIException; 
     276         
     277        /** 
     278         * This effectively removes the given mimeType from the system.  Voided 
     279         * mimeTypes are still linked to from complexObs, they just aren't shown  
     280         * in the list of available mimeTypes  
     281         *  
     282         * @param mimeType the MimeType to remove 
     283         * @param reason the reason this mimeType is being voided 
     284         * @return 
     285         * @throws APIException 
     286         * @see {@link #createObs(Obs)} 
     287         */ 
     288        @Authorized(OpenmrsConstants.PRIV_MANAGE_MIME_TYPES) 
     289        public MimeType voidMimeType(MimeType mimeType, String reason) throws APIException; 
     290         
     291        /** 
     292         * This completely removes the given <code>MimeType</code> from the database. 
     293         * If data has been stored already that points at this mimeType an 
     294         * exception is thrown 
     295         *  
     296         * @param mimeType the MimeType to remove 
     297         * @throws APIException 
     298         * @see {@link #purgeMimeType(MimeType) 
     299         */ 
     300        @Authorized(OpenmrsConstants.PRIV_PURGE_MIME_TYPES) 
     301        public void purgeMimeType(MimeType mimeType) throws APIException; 
     302         
     303        /** 
     304         * @see {@link org.openmrs.Person#getObservations()} 
     305         * @deprecated use the method on the org.openmrs.Person for getObservations 
     306         */ 
     307        @Transactional(readOnly = true) 
     308        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     309        public Set<Obs> getObservations(Person who, boolean includeVoided); 
     310 
     311        /** 
     312         * Get all Observations for the given personperson 
     313         *  
     314         * @param who the user to match on 
     315         * @return 
     316         * @see {@link #getObservations(List, List, List, List, List, List, String, Integer, Integer, Date, Date, boolean)} 
     317         */ 
     318        @Transactional(readOnly = true) 
     319        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     320        public List<Obs> getObservationsByPerson(Person who); 
     321         
     322        /** 
     323         * This method fetches observations according to the criteria in 
     324         * the given arguments.  All arguments are optional and nullable.  If 
     325         * more than one argument is non-null, the result is equivalent to an 
     326         * "and"ing of the arguments. (e.g. if both a <code>location</code> and  
     327         * a <code>fromDate</code> are given, only Obs that are <u>both</u> at  
     328         * that Location and after the fromDate are returned). 
     329         *  
     330         * Note: If <code>whom</code> has elements, <code>personType</code> is ignored  
     331         *  
     332         * @param whom List<Person> to restrict obs to (optional) 
     333         * @param encounters List<Encounter> to restrict obs to (optional) 
     334         * @param questions List<Concept> to restrict the obs to (optional) 
     335         * @param answers List<Concept> to restrict the valueCoded to (optional) 
     336         * @param personType PERSON_TYPE objects to restrict this to. Only used if <code>whom</code> not an 
     337         *                              empty list (optional) 
     338         * @param locations The org.openmrs.Location objects to restrict to (optional) 
     339         * @param sort list of column names to sort on (obsId, obsDatetime, etc) if null, defaults to obsDatetime (optional) 
     340         * @param mostRecentN restrict the number of obs returned to this size (optional) 
     341         * @param obsGroupId the Obs.getObsGroupId() to this integer (optional) 
     342         * @param fromDate the earliest Obs date to get (optional) 
     343         * @param toDate the latest Obs date to get (optional) 
     344         * @param includeVoidedObs true/false whether to also include the voided obs (required) 
     345         * @return list of Observations that match all of the criteria given in the arguments 
     346         * @throws APIException 
     347         */ 
     348        @Transactional(readOnly = true) 
     349        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     350        public List<Obs> getObservations(List<Person> whom, List<Encounter> encounters,  
     351                                         List<Concept> questions, List<Concept> answers,  
     352                                         List<PERSON_TYPE> personTypes, List<Location> locations,  
     353                                         List<String> sort, Integer mostRecentN, Integer obsGroupId,  
     354                                         Date fromDate, Date toDate, boolean includeVoidedObs)  
     355                                         throws APIException; 
     356         
     357        /** 
     358         * This method searches the obs table based on the given 
     359         * <code>searchString</code>. 
     360         *  
     361         * @param searchString The string to search on 
     362         * @return observations matching the given string  
     363         * @throws APIException 
     364         */ 
     365        @Transactional(readOnly = true) 
     366        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     367        public List<Obs> getObservations(String searchString) throws APIException; 
     368         
     369        /** 
     370         * @deprecated use {@link #getObservations(List, Encounter, List, List, List, List, String, Integer, Integer, Date, Date, boolean)} 
     371         */ 
     372        @Transactional(readOnly = true) 
     373        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     374        public List<Obs> getObservations(Concept c, Location loc, String sort, Integer personType, boolean includeVoided); 
     375         
     376        /** 
     377         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     378         */ 
     379        @Transactional(readOnly = true) 
     380        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     381        public Set<Obs> getObservations(Person who, Concept question, boolean includeVoided); 
     382         
     383        /** 
     384         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     385         */ 
     386        @Transactional(readOnly = true) 
     387        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     388        public List<Obs> getLastNObservations(Integer n, Person who, 
     389                Concept question, boolean includeVoided); 
     390 
     391        /** 
     392         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     393         */ 
     394        @Transactional(readOnly = true) 
     395        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     396        public List<Obs> getObservations(Concept question, String sort, Integer personType, boolean includeVoided); 
     397 
     398        /** 
     399         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     400         */ 
     401        @Transactional(readOnly = true) 
     402        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     403        public List<Obs> getObservationsAnsweredByConcept(Concept answer, Integer personType, boolean includeVoided); 
     404 
     405        /** 
     406         * Return all numeric answer values for the given concept ordered by value 
     407         * numeric low to high 
     408         *  
     409         * personType should be one of PATIENT, PERSON, or USER; 
     410         *  
     411         * @param concept 
     412         * @param sortByValue true/false if sorting by valueNumeric. If false, will 
     413         *        sort by obsDatetime 
     414         * @param personType 
     415         * @deprecated use {@link #getObservations(List, Encounter, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     416         *  
     417         * @return List<Object[]> [0]=<code>obsId</code>, [1]=<code>obsDatetime</code>, [2]=<code>valueNumeric</code>s 
     418         **/ 
     419        @Transactional(readOnly = true) 
     420        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     421        public List<Object[]> getNumericAnswersForConcept(Concept answer, Boolean sortByValue, Integer personType, boolean includeVoided); 
     422 
     423        /** 
     424         * @deprecated use org.openmrs.Encounter.getObservations() 
     425         * @see {@link org.openmrs.Encounter.getObservations()} 
     426         */ 
     427        @Transactional(readOnly = true) 
     428        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     429        public Set<Obs> getObservations(Encounter whichEncounter); 
     430 
     431        /** 
     432         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     433         */ 
     434        @Transactional(readOnly = true) 
     435        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     436        public List<Obs> getVoidedObservations(); 
     437 
     438        /** 
     439         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     440         */ 
     441        @Transactional(readOnly = true) 
     442        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     443        public List<Obs> findObservations(String search, boolean includeVoided, Integer personType); 
     444 
     445        /** 
     446         * @deprecated should use Obs.getGroupMembers() or {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     447         */ 
     448        @Transactional(readOnly = true) 
     449        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     450        public List<Obs> findObsByGroupId(Integer obsGroupId); 
     451         
     452        /** 
     453         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     454         */ 
     455        @Transactional(readOnly = true) 
     456        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     457        public List<Obs> getObservations(List<Concept> concepts, Date fromDate, Date toDate, boolean includeVoided); 
     458 
     459        /** 
     460         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     461         */ 
     462        @Transactional(readOnly = true) 
     463        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     464        public List<Obs> getObservations(List<Concept> concepts, Date fromDate, Date toDate); 
     465 
     466         
     467        /** 
     468         * @deprecated use {@link #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)} 
     469         */ 
     470        @Transactional(readOnly=true) 
     471        @Authorized(OpenmrsConstants.PRIV_VIEW_OBS) 
     472        public List<Obs> getObservations(Cohort patients, List<Concept> concepts, Date fromDate, Date toDate); 
    102473 
    103474        /** 
     
    161532        @Authorized( {OpenmrsConstants.PRIV_DELETE_OBS}) 
    162533        public boolean purgeComplexData(Obs obs) throws APIException; 
    163          
    164         /** 
    165          * Save changes to observation 
    166          *  
    167          * @param Obs 
    168          * @throws APIException 
    169          */ 
    170         @Authorized( { OpenmrsConstants.PRIV_EDIT_OBS }) 
    171         public void updateObs(Obs obs) throws APIException; 
    172  
    173         /** 
    174          * Equivalent to deleting an observation 
    175          *  
    176          * @param Obs obs to void 
    177          * @param String reason 
    178          * @throws APIException 
    179          */ 
    180         @Authorized( { OpenmrsConstants.PRIV_EDIT_OBS }) 
    181         public void voidObs(Obs obs, String reason) throws APIException; 
    182  
    183         /** 
    184          * Revive an observation (pull a Lazarus) 
    185          *  
    186          * @param Obs 
    187          * @throws APIException 
    188          */ 
    189         @Authorized( { OpenmrsConstants.PRIV_EDIT_OBS }) 
    190         public void unvoidObs(Obs obs) throws APIException; 
    191  
    192         /** 
    193          * Delete an observation. SHOULD NOT BE CALLED unless caller is lower-level. 
    194          *  
    195          * @param Obs 
    196          * @throws APIException 
    197          * @see voidObs(Obs) 
    198          */ 
    199         @Authorized( { OpenmrsConstants.PRIV_DELETE_OBS }) 
    200         public void deleteObs(Obs obs) throws APIException; 
    201  
    202         /** 
    203          * Get all mime types 
    204          *  
    205          * @return mime types list 
    206          * @throws APIException 
    207          */ 
    208         @Transactional(readOnly = true) 
    209         public List<MimeType> getMimeTypes() throws APIException; 
    210  
    211         /** 
    212          * Get mimeType by internal identifier 
    213          *  
    214          * @param mimeType id 
    215          * @return mimeType with given internal identifier 
    216          * @throws APIException 
    217          */ 
    218         @Transactional(readOnly = true) 
    219         public MimeType getMimeType(Integer mimeTypeId) throws APIException; 
    220  
    221         /** 
    222          * Get all Observations for a person 
    223          *  
    224          * @param who 
    225          * @param includeVoided 
    226          * @return 
    227          */ 
    228         @Transactional(readOnly = true) 
    229         public Set<Obs> getObservations(Person who, boolean includeVoided); 
    230  
    231         /** 
    232          * Get all Observations for this concept/location Sort is optional 
    233          *  
    234          * @param concept 
    235          * @param location 
    236          * @param sort 
    237          * @param personType 
    238          * @param includeVoided 
    239          * @return list of obs for a location 
    240          */ 
    241         @Transactional(readOnly = true) 
    242         public List<Obs> getObservations(Concept c, Location loc, String sort, 
    243                 Integer personType, boolean includeVoided); 
    244  
    245         /** 
    246          * e.g. get all CD4 counts for a person 
    247          *  
    248          * @param who 
    249          * @param question 
    250          * @param includeVoided 
    251          * @return 
    252          */ 
    253         @Transactional(readOnly = true) 
    254         public Set<Obs> getObservations(Person who, Concept question, 
    255                 boolean includeVoided); 
    256  
    257         /** 
    258          * e.g. get last 'n' number of observations for a person for given concept 
    259          *  
    260          * @param n number of concepts to retrieve 
    261          * @param who 
    262          * @param question 
    263          * @return 
    264          */ 
    265         @Transactional(readOnly = true) 
    266         public List<Obs> getLastNObservations(Integer n, Person who, 
    267                 Concept question, boolean includeVoided); 
    268  
    269         /** 
    270          * e.g. get all observations referring to RETURN VISIT DATE 
    271          *  
    272          * @param question (Concept: RETURN VISIT DATE) 
    273          * @param sort (obsId, obsDatetime, etc) if null, defaults to obsId 
    274          * @param personType 
    275          *  
    276          * @return 
    277          */ 
    278         @Transactional(readOnly = true) 
    279         public List<Obs> getObservations(Concept question, String sort, 
    280                 Integer personType, boolean includeVoided); 
    281  
    282         /** 
    283          * Return all observations that have the given concept as an answer (<code>answer.getConceptId()</code> == 
    284          * value_coded) 
    285          *  
    286          * @param concept 
    287          * @param personType 
    288          * @return list of obs 
    289          */ 
    290         @Transactional(readOnly = true) 
    291         public List<Obs> getObservationsAnsweredByConcept(Concept answer, 
    292                 Integer personType, boolean includeVoided); 
    293  
    294         /** 
    295          * Return all numeric answer values for the given concept ordered by value 
    296          * numeric low to high 
    297          *  
    298          * personType should be one of PATIENT, PERSON, or USER; 
    299          *  
    300          * @param concept 
    301          * @param sortByValue true/false if sorting by valueNumeric. If false, will 
    302          *        sort by obsDatetime 
    303          * @param personType 
    304          *  
    305          * @return List<Object[]> [0]=<code>obsId</code>, [1]=<code>obsDatetime</code>, 
    306          *         [2]=<code>valueNumeric</code>s 
    307          */ 
    308         @Transactional(readOnly = true) 
    309         public List<Object[]> getNumericAnswersForConcept(Concept answer, 
    310                 Boolean sortByValue, Integer personType, boolean includeVoided); 
    311  
    312         /** 
    313          * Get all observations from a specific encounter 
    314          *  
    315          * @param whichEncounter 
    316          * @return Set of Obs 
    317          */ 
    318         @Transactional(readOnly = true) 
    319         public Set<Obs> getObservations(Encounter whichEncounter); 
    320  
    321         /** 
    322          * Get all observations that have been voided Observations are ordered by 
    323          * descending voidedDate 
    324          *  
    325          * @return List of Obs 
    326          */ 
    327         @Transactional(readOnly = true) 
    328         public List<Obs> getVoidedObservations(); 
    329  
    330         /** 
    331          * Find observations matching the search string "matching" is defined as 
    332          * either the obsId or the person identifier 
    333          *  
    334          * @param search 
    335          * @param includeVoided 
    336          * @param personType 
    337          * @return list of matched observations 
    338          */ 
    339         @Transactional(readOnly = true) 
    340         public List<Obs> findObservations(String search, boolean includeVoided, 
    341                 Integer personType); 
    342  
    343         /** 
    344          *  
    345          * @param question 
    346          * @param personType 
    347          * @return 
    348          */ 
    349         @Transactional(readOnly = true) 
    350         public List<String> getDistinctObservationValues(Concept question, 
    351                 Integer personType); 
    352  
    353         /** 
    354          * @param obsGroupId 
    355          * @return All obs that share obsGroupId 
    356          */ 
    357         @Transactional(readOnly = true) 
    358         public List<Obs> findObsByGroupId(Integer obsGroupId); 
    359  
    360         @Transactional(readOnly = true) 
    361         @Authorized( { "View Person" }) 
    362         public List<Obs> getObservations(Person who, Aggregation aggregation, 
    363                 Concept question, Constraint constraint); 
    364  
    365         /** 
    366          * Get all Observations for these concepts between these dates. Ideal for 
    367          * getting things like recent lab results regardless of what patient 
    368          *  
    369          * @param concepts get observations for these concepts (leave as null to get 
    370          *        all) 
    371          * @param fromDate 
    372          * @param toDate 
    373          * @param includeVoided 
    374          * @return list of obs for a location 
    375          */ 
    376         @Transactional(readOnly = true) 
    377         public List<Obs> getObservations(List<Concept> concepts, Date fromDate, 
    378                 Date toDate, boolean includeVoided); 
    379  
    380         /** 
    381          * Get all Observations for these concepts between these dates. Ideal for 
    382          * getting things like recent lab results regardless of what patient 
    383          *  
    384          * @param concepts get observations for these concepts (leave as null to get 
    385          *        all) 
    386          * @param fromDate 
    387          * @param toDate 
    388          * @return list of obs for a location 
    389          */ 
    390         @Transactional(readOnly = true) 
    391         public List<Obs> getObservations(List<Concept> concepts, Date fromDate, 
    392                 Date toDate); 
    393  
    394         /** 
    395          * Get all Observations for this patient set, for these concepts, between 
    396          * these dates. Ideal for getting things like recent lab results for a set 
    397          * of patients 
    398          *  
    399          * @param ps the patientset for which to retrieve data for - null means all 
    400          *        patients 
    401          * @param concepts list of the concepts for which to retrieve obs - null 
    402          *        means all obs 
    403          * @param fromDate lower bound for date - null means no lower bound 
    404          * @param toDate upper bound for date - null means no upper bound 
    405          * @return observations, for this patient set, with concepts in list of 
    406          *         concepts passed, between the two dates passed in 
    407          */ 
    408         @Transactional(readOnly = true) 
    409         public List<Obs> getObservations(PatientSet patients, 
    410                 List<Concept> concepts, Date fromDate, Date toDate); 
    411  
     534                 
    412535        /** 
    413536         * @return All registered ComplexObsHandler 
     
    478601         */ 
    479602        public void removeHandler(String handlerClass) throws APIException; 
    480  
     603         
    481604}