@Transactional public class EncounterServiceImpl extends BaseOpenmrsService implements EncounterService
EncounterService
This class should not be instantiated alone, get a service class from the Context: Context.getEncounterService();
Context
,
EncounterService
Constructor and Description |
---|
EncounterServiceImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
canEditAllEncounterTypes(User subject)
Determines whether given user is granted to edit all encounter types or not
|
boolean |
canEditEncounter(Encounter encounter,
User user)
Checks if passed in user can edit given encounter.
|
boolean |
canViewAllEncounterTypes(User subject)
Determines whether given user is granted to view all encounter types or not
|
boolean |
canViewEncounter(Encounter encounter,
User user)
Checks if passed in user can view given encounter.
|
void |
checkIfEncounterTypesAreLocked()
Check if the encounter types are locked, and if so, throw exception during manipulation of
encounter type
|
List<Encounter> |
filterEncountersByViewPermissions(List<Encounter> encounters,
User user)
Filters out all encounters to which given user does not have access.
|
List<EncounterType> |
findEncounterTypes(String name)
Find Encounter Types with name matching the beginning of the search string.
|
EncounterVisitHandler |
getActiveEncounterVisitHandler()
Gets the active handler for assigning visits to encounters.
|
List<EncounterRole> |
getAllEncounterRoles(boolean includeRetired)
Get all encounter roles based on includeRetired flag
|
Map<Integer,List<Encounter>> |
getAllEncounters(Cohort patients)
Get all encounters for a cohort of patients
|
List<EncounterType> |
getAllEncounterTypes()
Get all encounter types (including retired)
|
List<EncounterType> |
getAllEncounterTypes(boolean includeRetired)
Get all encounter types.
|
Integer |
getCountOfEncounters(String query,
boolean includeVoided)
Return the number of encounters matching a patient name or patient identifier
|
Encounter |
getEncounter(Integer encounterId)
Get encounter by internal identifier
|
Encounter |
getEncounterByUuid(String uuid)
Get Encounter by its UUID
|
EncounterRole |
getEncounterRole(Integer encounterRoleId)
Gets an encounter role when and internal encounter role id is provided.
|
EncounterRole |
getEncounterRoleByName(String name)
Get EncounterRole by name
|
EncounterRole |
getEncounterRoleByUuid(String uuid)
Get EncounterRole by its UUID
|
List<EncounterRole> |
getEncounterRolesByName(String name)
Get EncounterRoles by name
|
List<Encounter> |
getEncounters(EncounterSearchCriteria encounterSearchCriteria)
Get all encounters that match a variety of (nullable) criteria contained in the parameter object.
|
List<Encounter> |
getEncounters(Patient who,
Location loc,
Date fromDate,
Date toDate,
Collection<Form> enteredViaForms,
Collection<EncounterType> encounterTypes,
Collection<Provider> providers,
Collection<VisitType> visitTypes,
Collection<Visit> visits,
boolean includeVoided)
Deprecated.
As of 2.0, replaced by
getEncounters(EncounterSearchCriteria) |
List<Encounter> |
getEncounters(String query,
Integer start,
Integer length,
boolean includeVoided)
Search for encounters by patient name or patient identifier and returns a specific number of
them from the specified starting position.
|
List<Encounter> |
getEncounters(String query,
Integer patientId,
Integer start,
Integer length,
boolean includeVoided)
Searches for encounters by patient id, provider identifier, location, encounter type,
provider, form or provider name.
|
List<Encounter> |
getEncountersByPatient(Patient patient)
Get all encounters (not voided) for a patient, sorted by encounterDatetime ascending.
|
List<Encounter> |
getEncountersByPatient(String query)
Search for encounters by patient name or patient identifier.
|
List<Encounter> |
getEncountersByPatient(String query,
boolean includeVoided)
Search for encounters by patient name or patient identifier.
|
List<Encounter> |
getEncountersByPatientId(Integer patientId)
Get encounters for a patientId
|
List<Encounter> |
getEncountersByPatientIdentifier(String identifier)
Get encounters (not voided) for a patient identifier
|
List<Encounter> |
getEncountersByVisit(Visit visit,
boolean includeVoided)
Gets all encounters grouped within a given visit.
|
List<Encounter> |
getEncountersByVisitsAndPatient(Patient patient,
boolean includeVoided,
String query,
Integer start,
Integer length)
Gets encounters for the given patient.
|
Integer |
getEncountersByVisitsAndPatientCount(Patient patient,
boolean includeVoided,
String query)
Returns result count for
EncounterService.getEncountersByVisitsAndPatient(Patient, boolean, String, Integer, Integer) . |
List<Encounter> |
getEncountersNotAssignedToAnyVisit(Patient patient)
Gets the unvoided encounters for the specified patient that are not assigned to any visit.
|
EncounterType |
getEncounterType(Integer encounterTypeId)
Get encounterType by internal identifier
|
EncounterType |
getEncounterType(String name)
Get encounterType by exact name
|
EncounterType |
getEncounterTypeByUuid(String uuid)
Get EncounterType by its UUID
|
List<EncounterVisitHandler> |
getEncounterVisitHandlers() |
void |
purgeEncounter(Encounter encounter)
Completely remove an encounter from database.
|
void |
purgeEncounter(Encounter encounter,
boolean cascade)
Completely remove an encounter from database.
|
void |
purgeEncounterRole(EncounterRole encounterRole)
Completely remove an encounter role from database.
|
void |
purgeEncounterType(EncounterType encounterType)
Completely remove an encounter type from database.
|
EncounterRole |
retireEncounterRole(EncounterRole encounterRole,
String reason)
Retire an EncounterRole.
|
EncounterType |
retireEncounterType(EncounterType encounterType,
String reason)
Retire an EncounterType.
|
Encounter |
saveEncounter(Encounter encounter)
Saves a new encounter or updates an existing encounter.
|
EncounterRole |
saveEncounterRole(EncounterRole encounterRole)
Saves a new encounter role or updates an existing encounter role.
|
EncounterType |
saveEncounterType(EncounterType encounterType)
Save a new Encounter Type or update an existing Encounter Type.
|
void |
setEncounterDAO(EncounterDAO dao)
Set the given
dao on this encounter service. |
Encounter |
transferEncounter(Encounter encounter,
Patient patient)
Transfer encounter to another patient
|
EncounterRole |
unretireEncounterRole(EncounterRole encounterRole)
Unretire an EncounterRole.
|
EncounterType |
unretireEncounterType(EncounterType encounterType)
Unretire an EncounterType.
|
Encounter |
unvoidEncounter(Encounter encounter)
Unvoid encounter record
|
Encounter |
voidEncounter(Encounter encounter,
String reason)
Voiding a encounter essentially removes it from circulation
|
onShutdown, onStartup
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
public void setEncounterDAO(EncounterDAO dao)
EncounterService
dao
on this encounter service. The dao will act as the conduit
through with all encounter calls get to the databasesetEncounterDAO
in interface EncounterService
EncounterService.setEncounterDAO(org.openmrs.api.db.EncounterDAO)
@Transactional(readOnly=true) public List<Encounter> getEncountersByPatient(String query, boolean includeVoided) throws APIException
EncounterService
getEncountersByPatient
in interface EncounterService
query
- patient name or identifierincludeVoided
- Specifies whether voided encounters should be includedAPIException
- Should get all unvoided encounters for the given patient name
Should get all unvoided encounters for the given patient identifier
Should throw error if given null parameter
Should include voided encounters in the returned list if includedVoided is trueEncounterService.getEncountersByPatient(java.lang.String, boolean)
public Encounter saveEncounter(Encounter encounter) throws APIException
EncounterService
saveEncounter
in interface EncounterService
encounter
- to be savedAPIException
- Should save encounter with basic details
Should update encounter successfully
Should cascade save to contained obs
Should cascade patient to orders in the encounter
Should cascade save to contained obs when encounter already exists
Should cascade encounter datetime to obs
Should only cascade the obsdatetimes to obs with different initial obsdatetimes
Should not overwrite creator if non null
Should not overwrite dateCreated if non null
Should not overwrite obs and orders creator or dateCreated
Should not assign encounter to visit if no handler is registered
Should not assign encounter to visit if the no assign handler is registered
Should assign encounter to visit if the assign to existing handler is registered
Should assign encounter to visit if the assign to existing or new handler is registered
Should cascade save encounter providers
Should cascade delete encounter providers
Should cascade save encounter conditions
Should void and create new obs when saving encounter
Should fail if user is not supposed to edit encounters of type of given encounter
Should cascade save encounter allergiesEncounterService.saveEncounter(org.openmrs.Encounter)
@Transactional(readOnly=true) public Encounter getEncounter(Integer encounterId) throws APIException
EncounterService
getEncounter
in interface EncounterService
encounterId
- encounter idAPIException
- Should throw error if given null parameter
Should fail if user is not allowed to view encounter by given id
Should return encounter if user is allowed to view itEncounterService.getEncounter(java.lang.Integer)
@Transactional(readOnly=true) public List<Encounter> getEncountersByPatient(Patient patient) throws APIException
EncounterService
getEncountersByPatient
in interface EncounterService
APIException
EncounterService.getEncountersByPatient(org.openmrs.Patient)
@Transactional(readOnly=true) public List<Encounter> getEncountersByPatient(String query) throws APIException
EncounterService
getEncountersByPatient
in interface EncounterService
query
- patient name or identifierAPIException
EncounterService.getEncountersByPatient(String)
@Transactional(readOnly=true) public List<Encounter> getEncountersByPatientId(Integer patientId) throws APIException
EncounterService
getEncountersByPatientId
in interface EncounterService
APIException
- Should not get voided encounters
Should throw error if given a null parameterEncounterService.getEncountersByPatientId(java.lang.Integer)
@Transactional(readOnly=true) public List<Encounter> getEncountersByPatientIdentifier(String identifier) throws APIException
EncounterService
getEncountersByPatientIdentifier
in interface EncounterService
APIException
- Should not get voided encounters
Should throw error if given null parameterEncounterService.getEncountersByPatientIdentifier(java.lang.String)
@Deprecated @Transactional(readOnly=true) public List<Encounter> getEncounters(Patient who, Location loc, Date fromDate, Date toDate, Collection<Form> enteredViaForms, Collection<EncounterType> encounterTypes, Collection<Provider> providers, Collection<VisitType> visitTypes, Collection<Visit> visits, boolean includeVoided)
getEncounters(EncounterSearchCriteria)
EncounterService
getEncounters
in interface EncounterService
who
- the patient the encounter is forloc
- the location this encounter took placefromDate
- the minimum date (inclusive) this encounter took placetoDate
- the maximum date (exclusive) this encounter took placeenteredViaForms
- the form that entered this encounter must be in this listencounterTypes
- the type of encounter must be in this listproviders
- the provider of this encounter must be in this listvisitTypes
- the visit types of this encounter must be in this listvisits
- the visits of this encounter must be in this listincludeVoided
- true/false to include the voided encounters or notEncounterService.getEncounters(org.openmrs.Patient,
org.openmrs.Location, java.util.Date, java.util.Date, java.util.Collection,
java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection,
boolean)
public List<Encounter> getEncounters(EncounterSearchCriteria encounterSearchCriteria)
EncounterService
getEncounters
in interface EncounterService
encounterSearchCriteria
- the object containing search parametersEncounterService.getEncounters(org.openmrs.parameter.EncounterSearchCriteria)
public Encounter voidEncounter(Encounter encounter, String reason)
EncounterService
voidEncounter
in interface EncounterService
encounter
- Encounter object to voidreason
- String reason that it's being voided
Should void encounter and set attributes
Should cascade to obs
Should cascade to orders
Should throw error with null reason parameter
Should not void providers
Should fail if user is not supposed to edit encounters of type of given encounterEncounterService.voidEncounter(org.openmrs.Encounter, java.lang.String)
public Encounter unvoidEncounter(Encounter encounter) throws APIException
EncounterService
unvoidEncounter
in interface EncounterService
encounter
- Encounter to be revived
Should cascade unvoid to obs
Should cascade unvoid to orders
Should unvoid and unmark all attributes
Should fail if user is not supposed to edit encounters of type of given encounterAPIException
EncounterService.unvoidEncounter(org.openmrs.Encounter)
public void purgeEncounter(Encounter encounter) throws APIException
EncounterService
voidEncounter(org.openmrs.Encounter)
purgeEncounter
in interface EncounterService
encounter
- encounter object to be purged
Should purgeEncounter
Should fail if user is not supposed to edit encounters of type of given encounterAPIException
EncounterService.purgeEncounter(org.openmrs.Encounter)
public void purgeEncounter(Encounter encounter, boolean cascade) throws APIException
EncounterService
voidEncounter(org.openmrs.Encounter)
purgeEncounter
in interface EncounterService
encounter
- encounter object to be purgedcascade
- Purge any related observations as well?
Should cascade purge to obs and orders
Should fail if user is not supposed to edit encounters of type of given encounterAPIException
EncounterService.purgeEncounter(Encounter, boolean)
public EncounterType saveEncounterType(EncounterType encounterType)
EncounterService
saveEncounterType
in interface EncounterService
encounterType
- Should save encounter type
Should not overwrite creator
Should not overwrite creator or date created
Should not overwrite date created
Should update an existing encounter type name
Should throw error when trying to save encounter type when encounter types are lockedEncounterService.saveEncounterType(org.openmrs.EncounterType)
@Transactional(readOnly=true) public EncounterType getEncounterType(Integer encounterTypeId) throws APIException
EncounterService
getEncounterType
in interface EncounterService
encounterTypeId
- IntegerAPIException
- Should throw error if given null parameterEncounterService.getEncounterType(java.lang.Integer)
@Transactional(readOnly=true) public EncounterType getEncounterType(String name) throws APIException
EncounterService
getEncounterType
in interface EncounterService
name
- string to match to an Encounter.nameAPIException
- Should not get retired types
Should return null if only retired type found
Should not get by inexact name
Should return null with null name parameterEncounterService.getEncounterType(java.lang.String)
@Transactional(readOnly=true) public List<EncounterType> getAllEncounterTypes() throws APIException
EncounterService
getAllEncounterTypes
in interface EncounterService
APIException
- Should not return retired typesEncounterService.getAllEncounterTypes()
@Transactional(readOnly=true) public List<EncounterType> getAllEncounterTypes(boolean includeRetired) throws APIException
EncounterService
getAllEncounterTypes
in interface EncounterService
APIException
- Should not return retired types
Should include retired types with true includeRetired parameterEncounterService.getAllEncounterTypes(boolean)
@Transactional(readOnly=true) public List<EncounterType> findEncounterTypes(String name) throws APIException
EncounterService
findEncounterTypes
in interface EncounterService
name
- of the encounter type to findAPIException
- Should return types by partial name match
Should return types by partial case insensitive match
Should include retired types in the results
Should not partial match name on internal substrings
Should return types ordered on name and nonretired firstEncounterService.findEncounterTypes(java.lang.String)
public EncounterType retireEncounterType(EncounterType encounterType, String reason) throws APIException
EncounterService
retireEncounterType
in interface EncounterService
encounterType
- the encounter type to retirereason
- required non-null purpose for retiring this encounter typeAPIException
- Should retire type and set attributes
Should throw error if given null reason parameter
Should should throw error when trying to retire encounter type when encounter types are
lockedEncounterService.retireEncounterType(EncounterType, String)
public EncounterType unretireEncounterType(EncounterType encounterType) throws APIException
EncounterService
unretireEncounterType
in interface EncounterService
encounterType
- the encounter type to unretireAPIException
- Should unretire type and unmark attributes
Should should throw error when trying to unretire encounter type when encounter types are
lockedEncounterService.unretireEncounterType(org.openmrs.EncounterType)
public void purgeEncounterType(EncounterType encounterType) throws APIException
EncounterService
purgeEncounterType
in interface EncounterService
APIException
- Should purge type
Should should throw error when trying to delete encounter type when encounter types are
lockedEncounterService.purgeEncounterType(org.openmrs.EncounterType)
@Transactional(readOnly=true) public Encounter getEncounterByUuid(String uuid) throws APIException
EncounterService
getEncounterByUuid
in interface EncounterService
APIException
EncounterService.getEncounterByUuid(java.lang.String)
@Transactional(readOnly=true) public EncounterType getEncounterTypeByUuid(String uuid) throws APIException
EncounterService
getEncounterTypeByUuid
in interface EncounterService
APIException
EncounterService.getEncounterTypeByUuid(java.lang.String)
@Transactional(readOnly=true) public Map<Integer,List<Encounter>> getAllEncounters(Cohort patients)
EncounterService
getAllEncounters
in interface EncounterService
patients
- Cohort of patients to searchEncounterService.getAllEncounters(org.openmrs.Cohort)
@Transactional(readOnly=true) public List<Encounter> getEncounters(String query, Integer start, Integer length, boolean includeVoided) throws APIException
EncounterService
getEncounters
in interface EncounterService
query
- patient name or identifierstart
- beginning index for the batchlength
- number of encounters to return in the batchincludeVoided
- Specifies whether voided encounters should be includedAPIException
EncounterService.getEncounters(java.lang.String, java.lang.Integer,
java.lang.Integer, boolean)
@Transactional(readOnly=true) public List<Encounter> getEncounters(String query, Integer patientId, Integer start, Integer length, boolean includeVoided) throws APIException
EncounterService
getEncounters
in interface EncounterService
query
- provider identifier, location, encounter type, provider, form or provider namepatientId
- the patient idstart
- beginning index for the batchlength
- number of encounters to return in the batchincludeVoided
- Specifies whether voided encounters should be includedAPIException
EncounterService.getEncounters(java.lang.String, java.lang.Integer,
java.lang.Integer, java.lang.Integer, boolean)
@Transactional(readOnly=true) public Integer getCountOfEncounters(String query, boolean includeVoided)
EncounterService
getCountOfEncounters
in interface EncounterService
query
- patient name or identifierincludeVoided
- Specifies whether voided encounters should be includedEncounterService.getCountOfEncounters(java.lang.String, boolean)
@Transactional(readOnly=true) public List<Encounter> getEncountersByVisit(Visit visit, boolean includeVoided)
EncounterService
getEncountersByVisit
in interface EncounterService
visit
- the visit.includeVoided
- whether voided encounters should be returnedEncounterService.getEncountersByVisit(Visit, boolean)
@Transactional(readOnly=true) public List<EncounterVisitHandler> getEncounterVisitHandlers()
getEncounterVisitHandlers
in interface EncounterService
EncounterVisitHandler
@Transactional(readOnly=true) public EncounterVisitHandler getActiveEncounterVisitHandler() throws APIException
EncounterService
getActiveEncounterVisitHandler
in interface EncounterService
APIException
- thrown if something goes wrong during the retrieval of the handler.EncounterService.getActiveEncounterVisitHandler()
public EncounterRole saveEncounterRole(EncounterRole encounterRole) throws APIException
EncounterService
saveEncounterRole
in interface EncounterService
encounterRole
- to be savedAPIException
EncounterService.saveEncounterRole(org.openmrs.EncounterRole)
@Transactional(readOnly=true) public EncounterRole getEncounterRole(Integer encounterRoleId) throws APIException
EncounterService
getEncounterRole
in interface EncounterService
encounterRoleId
- to be retrievedAPIException
EncounterService.getEncounterRole(Integer)
public void purgeEncounterRole(EncounterRole encounterRole) throws APIException
EncounterService
retireEncounterRole(org.openmrs.Encounter, java.lang.String)
purgeEncounterRole
in interface EncounterService
encounterRole
- encounter role object to be purgedAPIException
EncounterService.purgeEncounterRole(org.openmrs.EncounterRole)
@Transactional(readOnly=true) public List<EncounterRole> getAllEncounterRoles(boolean includeRetired)
EncounterService
getAllEncounterRoles
in interface EncounterService
EncounterService.getAllEncounterRoles(boolean)
@Transactional(readOnly=true) public EncounterRole getEncounterRoleByUuid(String uuid) throws APIException
EncounterService
getEncounterRoleByUuid
in interface EncounterService
APIException
EncounterService.getEncounterRoleByUuid(String)
public EncounterRole getEncounterRoleByName(String name)
EncounterService
getEncounterRoleByName
in interface EncounterService
EncounterService.getEncounterRoleByName(String)
public EncounterRole retireEncounterRole(EncounterRole encounterRole, String reason) throws APIException
EncounterService
retireEncounterRole
in interface EncounterService
encounterRole
- the encounter role to retirereason
- required non-null purpose for retiring this encounter roleAPIException
EncounterService.retireEncounterRole(org.openmrs.EncounterRole, String)
public EncounterRole unretireEncounterRole(EncounterRole encounterRole) throws APIException
EncounterService
unretireEncounterRole
in interface EncounterService
encounterRole
- the encounter role to unretireAPIException
EncounterService.unretireEncounterRole(org.openmrs.EncounterRole)
@Transactional(readOnly=true) public List<Encounter> getEncountersNotAssignedToAnyVisit(Patient patient) throws APIException
EncounterService
getEncountersNotAssignedToAnyVisit
in interface EncounterService
patient
- the patient to match againstEncounter
sAPIException
- Should return the unvoided encounters not assigned to any visitEncounterService.getEncountersNotAssignedToAnyVisit(org.openmrs.Patient)
@Transactional(readOnly=true) public List<Encounter> getEncountersByVisitsAndPatient(Patient patient, boolean includeVoided, String query, Integer start, Integer length) throws APIException
EncounterService
The empty encounters have only visit set.
getEncountersByVisitsAndPatient
in interface EncounterService
patient
- the patient to matchincludeVoided
- if voided encounters or visits should be includedquery
- filters results (defaults to return all results if null
)start
- index to start with (defaults to 0 if null
)length
- number of results to return (default to return all results if null
)APIException
EncounterService.getEncountersByVisitsAndPatient(org.openmrs.Patient,
boolean, java.lang.String, java.lang.Integer, java.lang.Integer)
@Transactional(readOnly=true) public Integer getEncountersByVisitsAndPatientCount(Patient patient, boolean includeVoided, String query) throws APIException
EncounterService
EncounterService.getEncountersByVisitsAndPatient(Patient, boolean, String, Integer, Integer)
.getEncountersByVisitsAndPatientCount
in interface EncounterService
APIException
EncounterService.getEncountersByVisitsAndPatientCount(org.openmrs.Patient,
boolean, java.lang.String)
@Transactional(readOnly=true) public List<Encounter> filterEncountersByViewPermissions(List<Encounter> encounters, User user)
EncounterService
filterEncountersByViewPermissions
in interface EncounterService
encounters
- the list of encounters to be filtereduser
- the user instance to filter "visible" encounters forEncounterService.filterEncountersByViewPermissions(java.util.List,
org.openmrs.User)
@Transactional(readOnly=true) public boolean canViewAllEncounterTypes(User subject)
EncounterService
canViewAllEncounterTypes
in interface EncounterService
subject
- the user whose permission to view all encounter types will be checkedEncounterService.canViewAllEncounterTypes(org.openmrs.User)
@Transactional(readOnly=true) public boolean canEditAllEncounterTypes(User subject)
EncounterService
canEditAllEncounterTypes
in interface EncounterService
subject
- the user whose permission to edit all encounter types will be checkedEncounterService.canEditAllEncounterTypes(org.openmrs.User)
public boolean canEditEncounter(Encounter encounter, User user)
EncounterService
canEditEncounter
in interface EncounterService
encounter
- the encounter instance to be checkeduser
- the user, who requests edit accessEncounterService.canEditEncounter(org.openmrs.Encounter,
org.openmrs.User)
public boolean canViewEncounter(Encounter encounter, User user)
EncounterService
canViewEncounter
in interface EncounterService
encounter
- the encounter instance to be checkeduser
- the user, who requests view accessEncounterService.canViewEncounter(org.openmrs.Encounter,
org.openmrs.User)
@Transactional(readOnly=true) public void checkIfEncounterTypesAreLocked()
EncounterService
checkIfEncounterTypesAreLocked
in interface EncounterService
EncounterService.checkIfEncounterTypesAreLocked()
public List<EncounterRole> getEncounterRolesByName(String name)
EncounterService
getEncounterRolesByName
in interface EncounterService
EncounterService.getEncounterRolesByName(String)
public Encounter transferEncounter(Encounter encounter, Patient patient)
EncounterService
transferEncounter
in interface EncounterService
Copyright © 2024 OpenMRS Inc.. All rights reserved.