org.openmrs.api
Interface ObsService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
ObsServiceImpl

@Transactional
public interface ObsService
extends OpenmrsService

The ObsService deals with saving and getting Obs to/from the database Usage:

  ObsService obsService = Context.getObsService();
  // get the obs for patient with internal identifier of 1235
  List someObsList = obsService.getObservationsByPerson(new Patient(1235));
 
There are also a number of convenience methods for extracting obs pertaining to certain Concepts, people, or encounters

See Also:
Obs, ComplexObs, MimeType, Context

Field Summary
static java.lang.Integer PATIENT
          Deprecated. Use OpenmrsConstants#PERSON_TYPE.PATIENT
static java.lang.Integer PERSON
          Deprecated. Use org.openmrs.util.OpenmrsConstants#PERSON_TYPE.PATIENT
static java.lang.Integer USER
          Deprecated. Use OpenmrsConstants.PERSON_TYPE.USER
 
Method Summary
 void createObs(Obs obs)
          Deprecated. use saveObs(Obs, String)
 void createObsGroup(Obs[] obs)
          Deprecated. This method should no longer need to be called on the api. This was meant as temporary until we created a true ObsGroup pojo. Replaced by #createObsGroup(Obs, List)
 void deleteObs(Obs obs)
          Deprecated. use #purgeObs(Obs)
 java.util.List<Obs> findObsByGroupId(java.lang.Integer obsGroupId)
          Deprecated. should use Obs.getGroupMembers() or #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> findObservations(java.lang.String search, boolean includeVoided, java.lang.Integer personType)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<MimeType> getAllMimeTypes()
          Gets all mime types (including retired ones)
 java.util.List<MimeType> getAllMimeTypes(boolean includeRetired)
          Gets all mime types and disregards the retired ones if includeRetired is true
 java.util.List<Obs> getLastNObservations(java.lang.Integer n, Person who, Concept question, boolean includeVoided)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 MimeType getMimeType(java.lang.Integer mimeTypeId)
          Get mimeType by internal identifier
 java.util.List<MimeType> getMimeTypes()
          Deprecated. use getAllMimeTypes()
 java.util.List<java.lang.Object[]> getNumericAnswersForConcept(Concept answer, java.lang.Boolean sortByValue, java.lang.Integer personType, boolean includeVoided)
          Deprecated. use #getObservations(List, Encounter, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 Obs getObs(java.lang.Integer obsId)
          Get an observation
 java.util.List<Obs> getObservations(Cohort patients, java.util.List<Concept> concepts, java.util.Date fromDate, java.util.Date toDate)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservations(Concept c, Location loc, java.lang.String sort, java.lang.Integer personType, boolean includeVoided)
          Deprecated. use #getObservations(List, Encounter, List, List, List, List, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservations(Concept question, java.lang.String sort, java.lang.Integer personType, boolean includeVoided)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.Set<Obs> getObservations(Encounter whichEncounter)
          Deprecated. use org.openmrs.Encounter.getObservations()
 java.util.List<Obs> getObservations(java.util.List<Concept> concepts, java.util.Date fromDate, java.util.Date toDate)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservations(java.util.List<Concept> concepts, java.util.Date fromDate, java.util.Date toDate, boolean includeVoided)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservations(java.util.List<Person> whom, java.util.List<Encounter> encounters, java.util.List<Concept> questions, java.util.List<Concept> answers, java.util.List<OpenmrsConstants.PERSON_TYPE> personTypes, java.util.List<Location> locations, java.util.List<java.lang.String> sort, java.lang.Integer mostRecentN, java.lang.Integer obsGroupId, java.util.Date fromDate, java.util.Date toDate, boolean includeVoidedObs)
          This method fetches observations according to the criteria in the given arguments.
 java.util.Set<Obs> getObservations(Person who, boolean includeVoided)
          Deprecated. use getObservationsByPerson(Person)
 java.util.Set<Obs> getObservations(Person who, Concept question, boolean includeVoided)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservations(java.lang.String searchString)
          This method searches the obs table based on the given searchString.
 java.util.List<Obs> getObservationsAnsweredByConcept(Concept answer, java.lang.Integer personType, boolean includeVoided)
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 java.util.List<Obs> getObservationsByPerson(Person who)
          Get all Observations for the given person.
 java.util.List<Obs> getObservationsByPersonAndConcept(Person who, Concept question)
          Get all nonvoided observations for the given patient with the given concept as the question concept (conceptId)
 java.util.List<Obs> getVoidedObservations()
          Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)
 void purgeMimeType(MimeType mimeType)
          This completely removes the given MimeType from the database.
 void purgeObs(Obs obs)
          Completely remove an observation from the database.
 void purgeObs(Obs obs, boolean cascade)
          Completely remove an observation from the database.
 MimeType saveMimeType(MimeType mimeType)
          Save the given mimeType to the database.
 Obs saveObs(Obs obs, java.lang.String changeMessage)
          Save the given obs to the database.
 void setObsDAO(ObsDAO dao)
          Set the given dao on this obs service.
 Obs unvoidObs(Obs obs)
          Revive an observation (pull a Lazarus)
 void updateObs(Obs obs)
          Deprecated. use saveObs(Obs, String)
 MimeType voidMimeType(MimeType mimeType, java.lang.String reason)
          This effectively removes the given mimeType from the system.
 Obs voidObs(Obs obs, java.lang.String reason)
          Equivalent to deleting an observation
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Field Detail

PERSON

static final java.lang.Integer PERSON
Deprecated. Use org.openmrs.util.OpenmrsConstants#PERSON_TYPE.PATIENT
See Also:
OpenmrsConstants

PATIENT

static final java.lang.Integer PATIENT
Deprecated. Use OpenmrsConstants#PERSON_TYPE.PATIENT
See Also:
OpenmrsConstants

USER

static final java.lang.Integer USER
Deprecated. Use OpenmrsConstants.PERSON_TYPE.USER
See Also:
OpenmrsConstants
Method Detail

setObsDAO

void setObsDAO(ObsDAO dao)
Set the given dao on this obs service. The dao will act as the conduit through with all obs calls get to the database

Parameters:
dao - specific ObsDAO to use for this service

createObs

@Authorized(value="Add Observations")
void createObs(Obs obs)
               throws APIException
Deprecated. use saveObs(Obs, String)

Create an observation

Parameters:
Obs -
Throws:
APIException

createObsGroup

@Authorized(value="Add Observations")
void createObsGroup(Obs[] obs)
                    throws APIException
Deprecated. This method should no longer need to be called on the api. This was meant as temporary until we created a true ObsGroup pojo. Replaced by #createObsGroup(Obs, List)

Create a grouping of observations (observations linked by Obs.getObsGroupId() The proper use is:
 Obs obsGroup = new Obs();
 for (Obs member : obs) {
   obsGroup.addGroupMember(obs);
 }
 pass obsGroup to createObs(Obs)
 

Parameters:
obs - - array of observations to be grouped
Throws:
APIException
See Also:
#createObsGroup(Obs, List)

getObs

@Transactional(readOnly=true)
@Authorized(value="View Observations")
Obs getObs(java.lang.Integer obsId)
           throws APIException
Get an observation

Parameters:
integer - obsId of observation desired
Returns:
matching Obs
Throws:
APIException

updateObs

@Authorized(value="Edit Observations")
void updateObs(Obs obs)
               throws APIException
Deprecated. use saveObs(Obs, String)

Save changes to observation

Parameters:
Obs -
Throws:
APIException

saveObs

@Authorized(value={"Add Observations","Edit Observations"})
Obs saveObs(Obs obs,
                            java.lang.String changeMessage)
            throws APIException
Save the given obs to the database. This will move the contents of the given obs to the database. This acts as both the initial save and an update kind of save. The returned obs will be the same as the obs passed in. It is included for chaining. If this is an initial save, the obsId on the given obs object will be updated to reflect the auto numbering from the database. The obsId on the returned obs will also have this number. If there is already an obsId on the given obs object, the given obs will be voided and a new row in the database will be created that has a new obs id.

Parameters:
obs - the Obs to save to the database
changeMessage - String explaining why obs is being changed. If obs is a new obs, changeMessage is nullable, or if it is being updated, it would be required
Returns:
Obs that was saved to the database
Throws:
APIException

voidObs

@Authorized(value="Edit Observations")
Obs voidObs(Obs obs,
                            java.lang.String reason)
            throws APIException
Equivalent to deleting an observation

Parameters:
Obs - obs to void
String - reason
Throws:
APIException

unvoidObs

@Authorized(value="Edit Observations")
Obs unvoidObs(Obs obs)
              throws APIException
Revive an observation (pull a Lazarus)

Parameters:
Obs -
Throws:
APIException

deleteObs

@Authorized(value="Delete Observations")
void deleteObs(Obs obs)
               throws APIException
Deprecated. use #purgeObs(Obs)

This method shouldn't be used. Use either purgeObs(Obs) or #voidObs(Obs)

Parameters:
Obs -
Throws:
APIException

purgeObs

@Authorized(value="Delete Observations")
void purgeObs(Obs obs)
              throws APIException
Completely remove an observation from the database. This should typically not be called because we don't want to ever lose data. The data really should be voided and then it is not seen in interface any longer (see #voidObs(Obs) for that one) If other things link to this obs, an error will be thrown.

Parameters:
Obs -
Throws:
APIException

purgeObs

@Authorized(value="Delete Observations")
void purgeObs(Obs obs,
                              boolean cascade)
              throws APIException
Completely remove an observation from the database. This should typically not be called because we don't want to ever lose data. The data really should be voided and then it is not seen in interface any longer (see #voidObs(Obs) for that one)

Parameters:
Obs - the observation to remove from the database
cascade - true/false whether or not to cascade down to other things that link to this observation (like Orders and ObsGroups)
Throws:
APIException
See Also:
purgeObs(Obs, boolean)

getMimeTypes

@Transactional(readOnly=true)
@Authorized(value="View Mime Types")
java.util.List<MimeType> getMimeTypes()
                                      throws APIException
Deprecated. use getAllMimeTypes()

Throws:
APIException

getAllMimeTypes

@Authorized(value="View Mime Types")
java.util.List<MimeType> getAllMimeTypes()
                                         throws APIException
Gets all mime types (including retired ones)

Returns:
list of MimeTypes in the system
Throws:
APIException
See Also:
getAllMimeTypes(boolean)

getAllMimeTypes

@Authorized(value="View Mime Types")
java.util.List<MimeType> getAllMimeTypes(boolean includeRetired)
                                         throws APIException
Gets all mime types and disregards the retired ones if includeRetired is true

Parameters:
includeRetired - true/false of whether to also return the retired ones
Returns:
list of MimeTypes lll
Throws:
APIException

getMimeType

@Transactional(readOnly=true)
@Authorized(value="View Mime Types")
MimeType getMimeType(java.lang.Integer mimeTypeId)
                     throws APIException
Get mimeType by internal identifier

Parameters:
mimeType - id
Returns:
mimeType with given internal identifier
Throws:
APIException

saveMimeType

@Authorized(value="Manage Mime Types")
MimeType saveMimeType(MimeType mimeType)
                      throws APIException
Save the given mimeType to the database. If mimeType is not null, the mimeType is updated in the database. If mimeType is null, a new mimeType is added to the database

Parameters:
mimeType - mimeType
Returns:
mimeType that was saved/updated in the database
Throws:
APIException

voidMimeType

@Authorized(value="Manage Mime Types")
MimeType voidMimeType(MimeType mimeType,
                                      java.lang.String reason)
                      throws APIException
This effectively removes the given mimeType from the system. Voided mimeTypes are still linked to from complexObs, they just aren't shown in the list of available mimeTypes

Parameters:
mimeType - the MimeType to remove
reason - the reason this mimeType is being voided
Returns:
Throws:
APIException
See Also:
#createObs(Obs)}

purgeMimeType

@Authorized(value="Purge Mime Types")
void purgeMimeType(MimeType mimeType)
                   throws APIException
This completely removes the given MimeType from the database. If data has been stored already that points at this mimeType an exception is thrown

Parameters:
mimeType - the MimeType to remove
Throws:
APIException
See Also:
#purgeMimeType(MimeType)

getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.Set<Obs> getObservations(Person who,
                                                                 boolean includeVoided)
Deprecated. use getObservationsByPerson(Person)

See Also:
org.openmrs.Person#getObservations()}

getObservationsByPerson

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservationsByPerson(Person who)
Get all Observations for the given person. Does not return voided observations

Parameters:
who - the user to match on
Returns:
See Also:
#getObservations(List, List, List, List, List, List, String, Integer, Integer, Date, Date, boolean)}

getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(java.util.List<Person> whom,
                                                                  java.util.List<Encounter> encounters,
                                                                  java.util.List<Concept> questions,
                                                                  java.util.List<Concept> answers,
                                                                  java.util.List<OpenmrsConstants.PERSON_TYPE> personTypes,
                                                                  java.util.List<Location> locations,
                                                                  java.util.List<java.lang.String> sort,
                                                                  java.lang.Integer mostRecentN,
                                                                  java.lang.Integer obsGroupId,
                                                                  java.util.Date fromDate,
                                                                  java.util.Date toDate,
                                                                  boolean includeVoidedObs)
                                    throws APIException
This method fetches observations according to the criteria in the given arguments. All arguments are optional and nullable. If more than one argument is non-null, the result is equivalent to an "and"ing of the arguments. (e.g. if both a location and a fromDate are given, only Obs that are both at that Location and after the fromDate are returned). Note: If whom has elements, personType is ignored

Parameters:
whom - List to restrict obs to (optional)
encounters - List to restrict obs to (optional)
questions - List to restrict the obs to (optional)
answers - List to restrict the valueCoded to (optional)
personType - PERSON_TYPE objects to restrict this to. Only used if whom not an empty list (optional)
locations - The org.openmrs.Location objects to restrict to (optional)
sort - list of column names to sort on (obsId, obsDatetime, etc) if null, defaults to obsDatetime (optional)
mostRecentN - restrict the number of obs returned to this size (optional)
obsGroupId - the Obs.getObsGroupId() to this integer (optional)
fromDate - the earliest Obs date to get (optional)
toDate - the latest Obs date to get (optional)
includeVoidedObs - true/false whether to also include the voided obs (required)
Returns:
list of Observations that match all of the criteria given in the arguments
Throws:
APIException

getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(java.lang.String searchString)
                                    throws APIException
This method searches the obs table based on the given searchString.

Parameters:
searchString - The string to search on
Returns:
observations matching the given string
Throws:
APIException

getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(Concept c,
                                                                  Location loc,
                                                                  java.lang.String sort,
                                                                  java.lang.Integer personType,
                                                                  boolean includeVoided)
Deprecated. use #getObservations(List, Encounter, List, List, List, List, String, Integer, Integer, Date, Date, boolean)


getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.Set<Obs> getObservations(Person who,
                                                                 Concept question,
                                                                 boolean includeVoided)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservationsByPersonAndConcept

java.util.List<Obs> getObservationsByPersonAndConcept(Person who,
                                                      Concept question)
                                                      throws APIException
Get all nonvoided observations for the given patient with the given concept as the question concept (conceptId)

Parameters:
who - person to match on
question - conceptId to match on
Returns:
list of all nonvoided observations matching these criteria
Throws:
APIException
See Also:
#getObservations(List, List, List, List, List, List, List, Integer, Integer, Date, Date, boolean)}

getLastNObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getLastNObservations(java.lang.Integer n,
                                                                       Person who,
                                                                       Concept question,
                                                                       boolean includeVoided)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(Concept question,
                                                                  java.lang.String sort,
                                                                  java.lang.Integer personType,
                                                                  boolean includeVoided)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservationsAnsweredByConcept

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservationsAnsweredByConcept(Concept answer,
                                                                                   java.lang.Integer personType,
                                                                                   boolean includeVoided)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getNumericAnswersForConcept

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<java.lang.Object[]> getNumericAnswersForConcept(Concept answer,
                                                                                             java.lang.Boolean sortByValue,
                                                                                             java.lang.Integer personType,
                                                                                             boolean includeVoided)
Deprecated. use #getObservations(List, Encounter, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)

Return all numeric answer values for the given concept ordered by value numeric low to high personType should be one of PATIENT, PERSON, or USER;

Parameters:
concept -
sortByValue - true/false if sorting by valueNumeric. If false, will sort by obsDatetime
personType -
Returns:
List [0]=obsId, [1]=obsDatetime, [2]=valueNumerics

getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.Set<Obs> getObservations(Encounter whichEncounter)
Deprecated. use org.openmrs.Encounter.getObservations()

See Also:
org.openmrs.Encounter.getObservations()}

getVoidedObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getVoidedObservations()
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


findObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> findObservations(java.lang.String search,
                                                                   boolean includeVoided,
                                                                   java.lang.Integer personType)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


findObsByGroupId

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> findObsByGroupId(java.lang.Integer obsGroupId)
Deprecated. should use Obs.getGroupMembers() or #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(java.util.List<Concept> concepts,
                                                                  java.util.Date fromDate,
                                                                  java.util.Date toDate,
                                                                  boolean includeVoided)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(java.util.List<Concept> concepts,
                                                                  java.util.Date fromDate,
                                                                  java.util.Date toDate)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


getObservations

@Transactional(readOnly=true)
@Authorized(value="View Observations")
java.util.List<Obs> getObservations(Cohort patients,
                                                                  java.util.List<Concept> concepts,
                                                                  java.util.Date fromDate,
                                                                  java.util.Date toDate)
Deprecated. use #getObservations(List, List, List, org.openmrs.api.ObsService.PERSON_TYPE, Location, String, Integer, Integer, Date, Date, boolean)


OpenMRS-trunk

Generated May 29 2008 02:01 AM. NOTE - these libraries are in active development and subject to change