public interface EncounterService extends OpenmrsService
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 subject)
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 subject)
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
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 encounterType)
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
void setEncounterDAO(EncounterDAO dao)
dao
on this encounter service. The dao will act as the conduit
through with all encounter calls get to the databasedao
- @Authorized(value={"Add Encounters","Edit Encounters"}) Encounter saveEncounter(Encounter encounter) throws APIException
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 allergies@Authorized(value="Get Encounters") Encounter getEncounter(Integer encounterId) throws APIException
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 it@Authorized(value="Get Encounters") Encounter getEncounterByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get Encounters") List<Encounter> getEncountersByPatient(Patient patient)
patient
- @Authorized(value="Get Encounters") List<Encounter> getEncountersByPatientId(Integer patientId) throws APIException
patientId
- APIException
- Should not get voided encounters
Should throw error if given a null parameter@Authorized(value="Get Encounters") List<Encounter> getEncountersByPatientIdentifier(String identifier) throws APIException
identifier
- APIException
- Should not get voided encounters
Should throw error if given null parameter@Deprecated @Authorized(value="Get Encounters") 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)
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 not@Authorized(value="Get Encounters") List<Encounter> getEncounters(EncounterSearchCriteria encounterSearchCriteria)
encounterSearchCriteria
- the object containing search parameters@Authorized(value="Edit Encounters") Encounter voidEncounter(Encounter encounter, String reason)
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 encounter@Authorized(value="Edit Encounters") Encounter unvoidEncounter(Encounter encounter) throws APIException
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
@Authorized(value="Purge Encounters") void purgeEncounter(Encounter encounter) throws APIException
voidEncounter(org.openmrs.Encounter)
encounter
- encounter object to be purged
Should purgeEncounter
Should fail if user is not supposed to edit encounters of type of given encounterAPIException
@Authorized(value="Purge Encounters") void purgeEncounter(Encounter encounter, boolean cascade) throws APIException
voidEncounter(org.openmrs.Encounter)
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
@Authorized(value="Manage Encounter Types") EncounterType saveEncounterType(EncounterType encounterType) throws APIException
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 lockedAPIException
@Authorized(value="Get Encounter Types") EncounterType getEncounterType(Integer encounterTypeId) throws APIException
encounterTypeId
- IntegerAPIException
- Should throw error if given null parameter@Authorized(value="Get Encounter Types") EncounterType getEncounterTypeByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get Encounter Types") EncounterType getEncounterType(String name) throws APIException
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 parameter@Authorized(value="Get Encounter Types") List<EncounterType> getAllEncounterTypes() throws APIException
APIException
- Should not return retired types@Authorized(value="Get Encounter Types") List<EncounterType> getAllEncounterTypes(boolean includeRetired) throws APIException
includeRetired
- APIException
- Should not return retired types
Should include retired types with true includeRetired parameter@Authorized(value="Get Encounter Types") List<EncounterType> findEncounterTypes(String name) throws APIException
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 first@Authorized(value="Manage Encounter Types") EncounterType retireEncounterType(EncounterType encounterType, String reason) throws APIException
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
locked@Authorized(value="Manage Encounter Types") EncounterType unretireEncounterType(EncounterType encounterType) throws APIException
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
locked@Authorized(value="Purge Encounter Types") void purgeEncounterType(EncounterType encounterType) throws APIException
encounterType
- APIException
- Should purge type
Should should throw error when trying to delete encounter type when encounter types are
locked@Authorized(value="Get Encounters") List<Encounter> getEncountersByPatient(String query) throws APIException
query
- patient name or identifierAPIException
getEncountersByPatient(String, boolean)
@Authorized(value="Get Encounters") List<Encounter> getEncountersByPatient(String query, boolean includeVoided) throws APIException
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 true@Authorized(value="Get Encounters") List<Encounter> getEncounters(String query, Integer start, Integer length, boolean includeVoided) throws APIException
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
@Authorized(value="Get Encounters") List<Encounter> getEncounters(String query, Integer patientId, Integer start, Integer length, boolean includeVoided) throws APIException
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
Map<Integer,List<Encounter>> getAllEncounters(Cohort patients)
patients
- Cohort of patients to search@Authorized(value="Get Encounters") Integer getCountOfEncounters(String query, boolean includeVoided)
query
- patient name or identifierincludeVoided
- Specifies whether voided encounters should be included@Authorized(value="Get Encounters") List<Encounter> getEncountersByVisit(Visit visit, boolean includeVoided)
visit
- the visit.includeVoided
- whether voided encounters should be returnedList<EncounterVisitHandler> getEncounterVisitHandlers()
EncounterVisitHandler
EncounterVisitHandler getActiveEncounterVisitHandler() throws APIException
APIException
- thrown if something goes wrong during the retrieval of the handler.EncounterVisitHandler
@Authorized(value="Manage Encounter Roles") EncounterRole saveEncounterRole(EncounterRole encounterRole) throws APIException
encounterRole
- to be savedAPIException
@Authorized(value="Get Encounter Roles") EncounterRole getEncounterRole(Integer encounterRoleId) throws APIException
encounterRoleId
- to be retrievedAPIException
@Authorized(value="Purge Encounter Roles") void purgeEncounterRole(EncounterRole encounterRole) throws APIException
retireEncounterRole(org.openmrs.Encounter, java.lang.String)
encounterRole
- encounter role object to be purgedAPIException
@Authorized(value="Get Encounter Roles") List<EncounterRole> getAllEncounterRoles(boolean includeRetired)
includeRetired
- @Authorized(value="Get Encounter Roles") EncounterRole getEncounterRoleByUuid(String uuid) throws APIException
uuid
- APIException
@Authorized(value="Get Encounter Roles") EncounterRole getEncounterRoleByName(String name)
name
- @Authorized(value="Manage Encounter Roles") EncounterRole retireEncounterRole(EncounterRole encounterRole, String reason) throws APIException
encounterRole
- the encounter role to retirereason
- required non-null purpose for retiring this encounter roleAPIException
@Authorized(value="Manage Encounter Roles") EncounterRole unretireEncounterRole(EncounterRole encounterType) throws APIException
encounterType
- the encounter role to unretireAPIException
@Authorized(value="Get Encounters") List<Encounter> getEncountersNotAssignedToAnyVisit(Patient patient) throws APIException
patient
- the patient to match againstEncounter
sAPIException
- Should return the unvoided encounters not assigned to any visit@Authorized(value="Get Visits") List<Encounter> getEncountersByVisitsAndPatient(Patient patient, boolean includeVoided, String query, Integer start, Integer length) throws APIException
The empty encounters have only visit set.
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
@Authorized(value="Get Visits") Integer getEncountersByVisitsAndPatientCount(Patient patient, boolean includeVoided, String query) throws APIException
getEncountersByVisitsAndPatient(Patient, boolean, String, Integer, Integer)
.patient
- includeVoided
- query
- APIException
@Authorized(value="Get Encounters") List<Encounter> filterEncountersByViewPermissions(List<Encounter> encounters, User user)
encounters
- the list of encounters to be filtereduser
- the user instance to filter "visible" encounters forboolean canViewAllEncounterTypes(User subject)
subject
- the user whose permission to view all encounter types will be checkedboolean canEditAllEncounterTypes(User subject)
subject
- the user whose permission to edit all encounter types will be checkedboolean canEditEncounter(Encounter encounter, User subject)
encounter
- the encounter instance to be checkedsubject
- the user, who requests edit accessboolean canViewEncounter(Encounter encounter, User subject)
encounter
- the encounter instance to be checkedsubject
- the user, who requests view accessvoid checkIfEncounterTypesAreLocked() throws EncounterTypeLockedException
EncounterTypeLockedException
@Authorized(value="Get Encounter Roles") List<EncounterRole> getEncounterRolesByName(String name)
name
- @Authorized(value="Edit Encounters") Encounter transferEncounter(Encounter encounter, Patient patient)
encounter
- patient
- Copyright © 2024 OpenMRS Inc.. All rights reserved.