@Transactional public class ObsServiceImpl extends BaseOpenmrsService implements ObsService
ObsService
Modifier and Type | Field and Description |
---|---|
protected ObsDAO |
dao
The data access object for the obs service
|
Constructor and Description |
---|
ObsServiceImpl()
Default empty constructor for this obs service
|
Modifier and Type | Method and Description |
---|---|
Obs |
getComplexObs(Integer obsId,
String view)
Get a complex observation.
|
ComplexObsHandler |
getHandler(Obs obs)
Get the ComplexObsHandler associated with a complex observation
Returns the ComplexObsHandler.
|
ComplexObsHandler |
getHandler(String key)
Get the ComplexObsHandler that has been registered with the given key
|
Map<String,ComplexObsHandler> |
getHandlers()
Gets the handlers map registered
|
Obs |
getObs(Integer obsId)
Get an observation
|
Obs |
getObsByUuid(String uuid)
Get Obs by its UUID
|
Integer |
getObservationCount(List<ConceptName> conceptNames,
boolean includeVoided)
Gets the number of observations(including voided ones) that are using the specified
conceptNames as valueCodedName answers
|
Integer |
getObservationCount(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs)
This method fetches the count of observations according to the criteria in the given
arguments.
|
Integer |
getObservationCount(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs,
String accessionNumber) |
Integer |
getObservationCount(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
List<Visit> visits,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs,
String accessionNumber) |
List<Obs> |
getObservations(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
List<String> sort,
Integer mostRecentN,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs)
This method fetches observations according to the criteria in the given arguments.
|
List<Obs> |
getObservations(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
List<String> sort,
Integer mostRecentN,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs,
String accessionNumber) |
List<Obs> |
getObservations(List<Person> whom,
List<Encounter> encounters,
List<Concept> questions,
List<Concept> answers,
List<OpenmrsConstants.PERSON_TYPE> personTypes,
List<Location> locations,
List<String> sort,
List<Visit> visits,
Integer mostRecentN,
Integer obsGroupId,
Date fromDate,
Date toDate,
boolean includeVoidedObs,
String accessionNumber) |
List<Obs> |
getObservations(String searchString)
This implementation queries the obs table comparing the given
searchString with
the patient's identifier, encounterId, and obsId |
List<Obs> |
getObservationsByPerson(Person who)
Get all Observations for the given person, sorted by obsDatetime ascending.
|
List<Obs> |
getObservationsByPersonAndConcept(Person who,
Concept question)
Get all nonvoided observations for the given patient with the given concept as the question
concept (conceptId)
|
Obs |
getRevisionObs(Obs initialObs)
Get Revision Obs for initial Obs
|
void |
onShutdown()
Clean up after this class.
|
protected boolean |
purgeComplexData(Obs obs)
Internal method to remove ComplexData when an Obs is purged.
|
void |
purgeObs(Obs obs)
Completely remove an observation from the database.
|
void |
purgeObs(Obs obs,
boolean cascade)
Completely remove an observation from the database.
|
void |
registerHandler(String key,
ComplexObsHandler handler)
Registers the given handler with the given key If the given String key exists, that handler
is overwritten with the given handler
|
void |
registerHandler(String key,
String handlerClass)
Convenience method for
ObsService.registerHandler(String, ComplexObsHandler) |
void |
removeHandler(String key)
Remove the handler associated with the key from list of available handlers
|
Obs |
saveObs(Obs obs,
String changeMessage)
Save the given obs to the database.
|
void |
setHandlers(Map<String,ComplexObsHandler> newHandlers)
Add the given map to this service's handlers.
|
void |
setObsDAO(ObsDAO dao)
Set the given
dao on this obs service. |
Obs |
unvoidObs(Obs obs)
Unvoids an Obs
If the Obs argument is an obsGroup, all group members with the same dateVoided will also be
unvoided.
|
Obs |
voidObs(Obs obs,
String reason)
Voids an Obs If the Obs argument is an obsGroup, all group members will be voided.
|
onStartup
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onStartup
protected ObsDAO dao
public ObsServiceImpl()
public void setObsDAO(ObsDAO dao)
ObsService
dao
on this obs service. The dao will act as the conduit through
with all obs calls get to the databasesetObsDAO
in interface ObsService
dao
- specific ObsDAO to use for this serviceObsService.setObsDAO(org.openmrs.api.db.ObsDAO)
public void onShutdown()
onShutdown
in interface OpenmrsService
onShutdown
in class BaseOpenmrsService
BaseOpenmrsService.onShutdown()
public Obs saveObs(Obs obs, String changeMessage) throws APIException
ObsService
Save the given obs to the database. The behavior differs for first-time save, and edit.
When you save a new observation to the database:
When you edit an existing observation:
saveObs
in interface ObsService
obs
- the Obs to save to the databasechangeMessage
- 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 requiredAPIException
- Should create new file from complex data for new obs
Should not overwrite file when updating a complex obs
Should void the given obs in the database
Should create very basic obs and add new obsId
Should allow setting properties on obs
Should return a different object when updating an obs
Should set creator and dateCreated on new obs
Should cascade save to child obs groups
Should cascade update to new child obs groups
Should link original and updated obs
Should set void reason message to changeMessage
Should not void an Obs with no changesObsService.saveObs(org.openmrs.Obs, String)
@Transactional(readOnly=true) public Obs getObs(Integer obsId) throws APIException
ObsService
getObs
in interface ObsService
obsId
- integer obsId of observation desiredAPIException
- Should get obs matching given obsIdObsService.getObs(java.lang.Integer)
public Obs voidObs(Obs obs, String reason) throws APIException
voidObs
in interface ObsService
obs
- the Obs to voidreason
- the void reasonAPIException
ObsService.voidObs(org.openmrs.Obs, java.lang.String)
public Obs unvoidObs(Obs obs) throws APIException
If the Obs argument is an obsGroup, all group members with the same dateVoided will also be unvoided.
unvoidObs
in interface ObsService
obs
- the Obs to unvoidAPIException
ObsService.unvoidObs(org.openmrs.Obs)
public void purgeObs(Obs obs, boolean cascade) throws APIException
ObsService
purgeObs
in interface ObsService
obs
- the observation to remove from the databasecascade
- true/false whether or not to cascade down to other things that link to this
observation (like Orders and ObsGroups)APIException
ObsService.purgeObs(org.openmrs.Obs, boolean)
public void purgeObs(Obs obs) throws APIException
ObsService
purgeObs
in interface ObsService
APIException
ObsService.purgeObs(org.openmrs.Obs)
@Transactional(readOnly=true) public List<Obs> getObservations(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, List<String> sort, Integer mostRecentN, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs) throws APIException
ObsService
location
and a
fromDate
are given, only Obs that are both at that Location and after the
fromDate are returned). whom
has elements, personType
is ignored getObservations
in interface ObsService
whom
- List<Person> to restrict obs to (optional)encounters
- List<Encounter> to restrict obs to (optional)questions
- List<Concept> to restrict the obs to (optional)answers
- List<Concept> to restrict the valueCoded to (optional)personTypes
- List<PERSON_TYPE> objects to restrict this to. Only used if
whom
is 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)APIException
ObsService.getObservations(java.util.List, java.util.List,
java.util.List, java.util.List, List, List, java.util.List, java.lang.Integer,
java.lang.Integer, java.util.Date, java.util.Date, boolean)
@Transactional(readOnly=true) public List<Obs> getObservations(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, List<String> sort, Integer mostRecentN, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs, String accessionNumber) throws APIException
getObservations
in interface ObsService
whom
- List<Person> to restrict obs to (optional)encounters
- List<Encounter> to restrict obs to (optional)questions
- List<Concept> to restrict the obs to (optional)answers
- List<Concept> to restrict the valueCoded to (optional)personTypes
- List<PERSON_TYPE> objects to restrict this to. Only used if
whom
is 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)accessionNumber
- accession number (optional)APIException
- Should compare dates using lte and gte
Should get all obs assigned to given encounters
Should get all obs with question concept in given questions parameter
Should get all obs with answer concept in given answers parameter
Should return all obs whose person is a person only
Should return obs whose person is a patient only
Should return obs whose person is a user only
Should return obs with location in given locations parameter
Should sort returned obs by obsDatetime if sort is empty
Should sort returned obs by conceptId if sort is concept
Should limit number of obs returned to mostReturnN parameter
Should return obs whose groupId is given obsGroupId
Should not include voided obs
Should include voided obs if includeVoidedObs is true
Should only return observations with matching accession numberObsService.getObservations(java.util.List, java.util.List,
java.util.List, java.util.List, List, List, java.util.List, java.lang.Integer,
java.lang.Integer, java.util.Date, java.util.Date, boolean, java.lang.String)
@Transactional(readOnly=true) public List<Obs> getObservations(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, List<String> sort, List<Visit> visits, Integer mostRecentN, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs, String accessionNumber) throws APIException
getObservations
in interface ObsService
visits
- List<Visit> to restrict obs to (optional)APIException
ObsService.getObservations(java.util.List, java.util.List,
java.util.List, java.util.List, List, List, java.util.List, java.util.List, java.lang.Integer,
java.lang.Integer, java.util.Date, java.util.Date, boolean, java.lang.String)
@Transactional(readOnly=true) public Integer getObservationCount(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs) throws APIException
ObsService
location
and a fromDate
are given, only Obs that are both at
that Location and after the fromDate are returned). whom
has elements, personType
is ignored getObservationCount
in interface ObsService
whom
- List<Person> to restrict obs to (optional)encounters
- List<Encounter> to restrict obs to (optional)questions
- List<Concept> to restrict the obs to (optional)answers
- List<Concept> to restrict the valueCoded to (optional)personTypes
- List<PERSON_TYPE> objects to restrict this to. Only used if
whom
is an empty list (optional)locations
- The org.openmrs.Location objects to restrict to (optional) obsDatetime
(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)APIException
ObsService.getObservationCount(java.util.List, java.util.List,
java.util.List, java.util.List, java.util.List, java.util.List, java.lang.Integer,
java.util.Date, java.util.Date, boolean)
@Transactional(readOnly=true) public Integer getObservationCount(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs, String accessionNumber) throws APIException
getObservationCount
in interface ObsService
whom
- List<Person> to restrict obs to (optional)encounters
- List<Encounter> to restrict obs to (optional)questions
- List<Concept> to restrict the obs to (optional)answers
- List<Concept> to restrict the valueCoded to (optional)personTypes
- List<PERSON_TYPE> objects to restrict this to. Only used if
whom
is an empty list (optional)locations
- The org.openmrs.Location objects to restrict to (optional) obsDatetime
(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)accessionNumber
- accession number (optional)APIException
- Should compare dates using lte and gte
Should get the count of all obs assigned to given encounters
Should get the count of all obs with question concept in given questions parameter
Should get the count of all obs with answer concept in given answers parameter
Should return the count of all obs whose person is a person only
Should return the count of all obs whose person is a patient only
Should return the count of obs whose person is a user only
Should return the count of obs with location in given locations parameter
Should return the count of obs whose groupId is given obsGroupId
Should not include count of voided obs
Should include count of voided obs if includeVoidedObs is true
Should return count of obs with matching accession numberObsService.getObservationCount(java.util.List, java.util.List,
java.util.List, java.util.List, java.util.List, java.util.List, java.lang.Integer,
java.util.Date, java.util.Date, boolean, java.lang.String)
@Transactional(readOnly=true) public Integer getObservationCount(List<Person> whom, List<Encounter> encounters, List<Concept> questions, List<Concept> answers, List<OpenmrsConstants.PERSON_TYPE> personTypes, List<Location> locations, List<Visit> visits, Integer obsGroupId, Date fromDate, Date toDate, boolean includeVoidedObs, String accessionNumber) throws APIException
getObservationCount
in interface ObsService
visits
- List<Visit> to restrict obs to (optional)APIException
ObsService.getObservationCount(java.util.List, java.util.List,
java.util.List, java.util.List, java.util.List, java.util.List, java.util.List, java.lang.Integer,
java.util.Date, java.util.Date, boolean, java.lang.String)
@Transactional(readOnly=true) public List<Obs> getObservations(String searchString)
searchString
with
the patient's identifier, encounterId, and obsIdgetObservations
in interface ObsService
searchString
- The string to search onObsService.getObservations(java.lang.String)
@Transactional(readOnly=true) public List<Obs> getObservationsByPerson(Person who)
ObsService
getObservationsByPerson
in interface ObsService
who
- the user to match onObsService.getObservationsByPerson(org.openmrs.Person)
@Transactional(readOnly=true) public List<Obs> getObservationsByPersonAndConcept(Person who, Concept question) throws APIException
ObsService
getObservationsByPersonAndConcept
in interface ObsService
who
- person to match onquestion
- conceptId to match onAPIException
ObsService.getObservationsByPersonAndConcept(org.openmrs.Person,
org.openmrs.Concept)
@Transactional(readOnly=true) public Obs getObsByUuid(String uuid) throws APIException
ObsService
getObsByUuid
in interface ObsService
APIException
ObsService.getObsByUuid(java.lang.String)
@Transactional(readOnly=true) public Obs getRevisionObs(Obs initialObs)
ObsService
getRevisionObs
in interface ObsService
ObsService.getRevisionObs(org.openmrs.Obs)
@Transactional(readOnly=true) public Obs getComplexObs(Integer obsId, String view) throws APIException
ObsService
getComplexObs
in interface ObsService
APIException
ObsService.getComplexObs(Integer, String)
protected boolean purgeComplexData(Obs obs) throws APIException
APIException
@Transactional(readOnly=true) public ComplexObsHandler getHandler(Obs obs) throws APIException
ObsService
getHandler
in interface ObsService
obs
- A complex Obs.APIException
ObsService.getHandler(org.openmrs.Obs)
public ComplexObsHandler getHandler(String key)
ObsService
getHandler
in interface ObsService
key
- that has been registered with a handler classObsService.getHandler(java.lang.String)
public void setHandlers(Map<String,ComplexObsHandler> newHandlers) throws APIException
ObsService
setHandlers
in interface ObsService
newHandlers
- Map of class to handler objectAPIException
ObsService.setHandlers(Map)
,
registerHandler(String, ComplexObsHandler)
@Transactional(readOnly=true) public Map<String,ComplexObsHandler> getHandlers() throws APIException
ObsService
getHandlers
in interface ObsService
APIException
- Should never return nullObsService.getHandlers()
public void registerHandler(String key, ComplexObsHandler handler) throws APIException
ObsService
registerHandler
in interface ObsService
key
- the key name to use for this handlerhandler
- the class to register with this keyAPIException
ObsService.registerHandler(String, ComplexObsHandler)
public void registerHandler(String key, String handlerClass) throws APIException
ObsService
ObsService.registerHandler(String, ComplexObsHandler)
registerHandler
in interface ObsService
key
- the key name to use for this handlerhandlerClass
- the class to register with this keyAPIException
ObsService.registerHandler(String, String)
@Transactional(readOnly=true) public Integer getObservationCount(List<ConceptName> conceptNames, boolean includeVoided)
ObsService
getObservationCount
in interface ObsService
conceptNames
- the conceptNames to be searched againstincludeVoided
- whether voided observation should be includedObsService.getObservationCount(java.util.List, boolean)
public void removeHandler(String key)
ObsService
removeHandler
in interface ObsService
key
- the key of the handler to unregisterObsService.removeHandler(java.lang.String)
Copyright © 2024 OpenMRS Inc.. All rights reserved.