@Transactional public class VisitServiceImpl extends BaseOpenmrsService implements VisitService
VisitService
. This class should not be used on its own. The
current OpenMRS implementation should be fetched from the Context.Constructor and Description |
---|
VisitServiceImpl() |
Modifier and Type | Method and Description |
---|---|
Visit |
endVisit(Visit visit,
Date stopDate)
Sets the stopDate of a given visit.
|
List<Visit> |
getActiveVisitsByPatient(Patient patient)
Convenience method that delegates to getVisitsByPatient(patient, false, false)
|
List<VisitAttributeType> |
getAllVisitAttributeTypes() |
List<Visit> |
getAllVisits()
Gets all unvoided visits in the database.
|
List<VisitType> |
getAllVisitTypes()
Gets all visit types.
|
List<VisitType> |
getAllVisitTypes(boolean includeRetired)
Get all visit types based on includeRetired flag
|
Visit |
getVisit(Integer visitId)
Gets a visit by its visit id.
|
VisitAttribute |
getVisitAttributeByUuid(String uuid) |
VisitAttributeType |
getVisitAttributeType(Integer id) |
VisitAttributeType |
getVisitAttributeTypeByUuid(String uuid) |
Visit |
getVisitByUuid(String uuid)
Gets a visit by its UUID.
|
VisitDAO |
getVisitDAO() |
List<Visit> |
getVisits(Collection<VisitType> visitTypes,
Collection<Patient> patients,
Collection<Location> locations,
Collection<Concept> indications,
Date minStartDatetime,
Date maxStartDatetime,
Date minEndDatetime,
Date maxEndDatetime,
Map<VisitAttributeType,Object> attributeValues,
boolean includeInactive,
boolean includeVoided)
Gets the visits matching the specified arguments
|
List<Visit> |
getVisits(VisitSearchCriteria visitSearchCriteria)
Gets the visits matching the specified search criteria
|
List<Visit> |
getVisitsByPatient(Patient patient)
Gets all unvoided visits for the specified patient
|
List<Visit> |
getVisitsByPatient(Patient patient,
boolean includeInactive,
boolean includeVoided)
Gets all visits for the specified patient
|
VisitType |
getVisitType(Integer visitTypeId)
Gets a visit type by its visit type id.
|
VisitType |
getVisitTypeByUuid(String uuid)
Gets a visit type by its UUID.
|
List<VisitType> |
getVisitTypes(String fuzzySearchPhrase)
Gets all visit types whose names are similar to or contain the given search phrase.
|
void |
purgeVisit(Visit visit)
Completely erases a visit from the database.
|
void |
purgeVisitAttributeType(VisitAttributeType visitAttributeType)
Completely removes a visit attribute type from the database
|
void |
purgeVisitType(VisitType visitType)
Completely removes a visit type from the database.
|
VisitAttributeType |
retireVisitAttributeType(VisitAttributeType visitAttributeType,
String reason)
Retires the given visit attribute type in the database
|
VisitType |
retireVisitType(VisitType visitType,
String reason)
Retires a given visit type.
|
Visit |
saveVisit(Visit visit)
Creates or updates the given visit in the database.
|
VisitAttributeType |
saveVisitAttributeType(VisitAttributeType visitAttributeType)
Creates or updates the given visit attribute type in the database
|
VisitType |
saveVisitType(VisitType visitType)
Creates or updates the given visit type in the database.
|
void |
setVisitDAO(VisitDAO dao)
Method used to inject the visit data access object.
|
void |
stopVisits(Date maximumStartDate)
Stops all active visits started before or on the specified date which match any of the visit
types specified by the
OpenmrsConstants.GP_VISIT_TYPES_TO_AUTO_CLOSE global property. |
VisitAttributeType |
unretireVisitAttributeType(VisitAttributeType visitAttributeType)
Restores a visit attribute type that was previous retired in the database
|
VisitType |
unretireVisitType(VisitType visitType)
Unretires a visit type.
|
Visit |
unvoidVisit(Visit visit)
Unvoids the given visit.
|
Visit |
voidVisit(Visit visit,
String reason)
Voids the given visit.
|
onShutdown, onStartup
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
public void setVisitDAO(VisitDAO dao)
dao
- the visit data access object.public VisitDAO getVisitDAO()
@Transactional(readOnly=true) public List<VisitType> getAllVisitTypes()
VisitService
getAllVisitTypes
in interface VisitService
VisitService.getAllVisitTypes()
@Transactional(readOnly=true) public List<VisitType> getAllVisitTypes(boolean includeRetired)
VisitService
getAllVisitTypes
in interface VisitService
VisitService.getAllVisitTypes(boolean)
@Transactional(readOnly=true) public VisitType getVisitType(Integer visitTypeId)
VisitService
getVisitType
in interface VisitService
visitTypeId
- the visit type id.VisitService.getVisitType(java.lang.Integer)
@Transactional(readOnly=true) public VisitType getVisitTypeByUuid(String uuid)
VisitService
getVisitTypeByUuid
in interface VisitService
uuid
- the visit type UUID.VisitService.getVisitTypeByUuid(java.lang.String)
@Transactional(readOnly=true) public List<VisitType> getVisitTypes(String fuzzySearchPhrase)
VisitService
getVisitTypes
in interface VisitService
fuzzySearchPhrase
- the search phrase to use.VisitService.getVisitTypes(java.lang.String)
public VisitType saveVisitType(VisitType visitType) throws APIException
VisitService
saveVisitType
in interface VisitService
visitType
- the visit type to create or update.APIException
VisitService.saveVisitType(org.openmrs.VisitType)
public VisitType retireVisitType(VisitType visitType, String reason)
VisitService
retireVisitType
in interface VisitService
visitType
- the visit type to retire.reason
- the reason why the visit type is retired.VisitService.retireVisitType(org.openmrs.VisitType, java.lang.String)
public VisitType unretireVisitType(VisitType visitType)
VisitService
unretireVisitType
in interface VisitService
visitType
- the visit type to unretire.VisitService.unretireVisitType(org.openmrs.VisitType)
public void purgeVisitType(VisitType visitType)
VisitService
purgeVisitType
in interface VisitService
visitType
- the visit type to delete from the database.
Should delete given visit typeVisitService.purgeVisitType(org.openmrs.VisitType)
@Transactional(readOnly=true) public List<Visit> getAllVisits() throws APIException
VisitService
getAllVisits
in interface VisitService
APIException
- Should return all unvoided visitsVisitService.getAllVisits()
@Transactional(readOnly=true) public Visit getVisit(Integer visitId) throws APIException
VisitService
getVisit
in interface VisitService
visitId
- the visit id.APIException
VisitService.getVisit(java.lang.Integer)
@Transactional(readOnly=true) public Visit getVisitByUuid(String uuid) throws APIException
VisitService
getVisitByUuid
in interface VisitService
uuid
- the visit UUID.APIException
- Should return a visit matching the specified uuidVisitService.getVisitByUuid(java.lang.String)
public Visit saveVisit(Visit visit) throws APIException
VisitService
saveVisit
in interface VisitService
visit
- the visit to create or update.APIException
- Should add a new visit to the database
Should update an existing visit in the database
Should fail if validation errors are found
Should pass if no validation errors are found
Should be able to add an attribute to a visit
Should void an attribute if max occurs is 1 and same attribute type already exists
Should save a visit though changedBy and dateCreated are not set for VisitAttribute
explicitly
Should should save new visit with encounters successfullyVisitService.saveVisit(org.openmrs.Visit)
public Visit endVisit(Visit visit, Date stopDate)
VisitService
endVisit
in interface VisitService
visit
- the visit whose stopDate is to be setstopDate
- the date and time the visit is ending. if null, current date is usedVisitService.endVisit(org.openmrs.Visit, java.util.Date)
public Visit voidVisit(Visit visit, String reason) throws APIException
VisitService
voidVisit
in interface VisitService
visit
- the visit to void.reason
- the reason why the visit is voidedAPIException
- Should void the visit and set the voidReason
Should void encounters with visitVisitService.voidVisit(org.openmrs.Visit, java.lang.String)
public Visit unvoidVisit(Visit visit) throws APIException
VisitService
unvoidVisit
in interface VisitService
visit
- the visit to unvoidAPIException
- Should unvoid the visit and unset all the void related fields
Should unvoid encounters voided with visitVisitService.unvoidVisit(org.openmrs.Visit)
public void purgeVisit(Visit visit) throws APIException
VisitService
purgeVisit
in interface VisitService
visit
- the visit to delete from the database.APIException
- Should erase the visit from the database
Should fail if the visit has encounters associated to itVisitService.purgeVisit(org.openmrs.Visit)
@Transactional(readOnly=true) public List<Visit> getVisits(Collection<VisitType> visitTypes, Collection<Patient> patients, Collection<Location> locations, Collection<Concept> indications, Date minStartDatetime, Date maxStartDatetime, Date minEndDatetime, Date maxEndDatetime, Map<VisitAttributeType,Object> attributeValues, boolean includeInactive, boolean includeVoided) throws APIException
VisitService
getVisits
in interface VisitService
visitTypes
- a list of visit types to match againstlocations
- a list of locations to match againstindications
- a list of indication concepts to match againstminStartDatetime
- the minimum visit start date to match againstmaxStartDatetime
- the maximum visit start date to match againstminEndDatetime
- the minimum visit end date to match againstmaxEndDatetime
- the maximum visit end date to match againstincludeInactive
- if false, the min/maxEndDatetime parameters are ignored and only open
visits are returnedincludeVoided
- specifies if voided visits should also be returnedAPIException
- Should get visits by visit type
Should get visits by patients
Should get visits by locations
Should get visits by indications
Should get visits started between the given start dates
Should get visits ended between the given end dates
Should get visits that are still open even if minStartDatetime is specified
Should return all visits if includeVoided is set to true
Should get all visits with given attribute values
Should not find any visits if none have given attribute valuesVisitService.getVisits(Collection, Collection, Collection, Collection, Date, Date, Date, Date, Map, boolean, boolean)
public List<Visit> getVisits(VisitSearchCriteria visitSearchCriteria) throws APIException
VisitService
getVisits
in interface VisitService
APIException
VisitService.getVisits(VisitSearchCriteria)
@Transactional(readOnly=true) public List<Visit> getVisitsByPatient(Patient patient) throws APIException
VisitService
getVisitsByPatient
in interface VisitService
patient
- the patient whose visits to getAPIException
- Should return all unvoided visits for the specified patientVisitService.getVisitsByPatient(org.openmrs.Patient)
@Transactional(readOnly=true) public List<Visit> getActiveVisitsByPatient(Patient patient) throws APIException
VisitService
getActiveVisitsByPatient
in interface VisitService
patient
- the patient whose visits to getAPIException
VisitService.getActiveVisitsByPatient(org.openmrs.Patient)
@Transactional(readOnly=true) public List<Visit> getVisitsByPatient(Patient patient, boolean includeInactive, boolean includeVoided) throws APIException
VisitService
getVisitsByPatient
in interface VisitService
patient
- the patient whose visits to getAPIException
- Should return all active unvoided visits for the specified patient
Should return all unvoided visits for the specified patient
Should return all active visits for the specified patientVisitService.getVisitsByPatient(org.openmrs.Patient, boolean, boolean)
@Transactional(readOnly=true) public List<VisitAttributeType> getAllVisitAttributeTypes()
getAllVisitAttributeTypes
in interface VisitService
VisitAttributeType
s
Should return all visit attribute types including retired onesVisitService.getAllVisitAttributeTypes()
@Transactional(readOnly=true) public VisitAttributeType getVisitAttributeType(Integer id)
getVisitAttributeType
in interface VisitService
VisitAttributeType
with the given internal id
Should return the visit attribute type with the given id
Should return null if no visit attribute type exists with the given idVisitService.getVisitAttributeType(java.lang.Integer)
@Transactional(readOnly=true) public VisitAttributeType getVisitAttributeTypeByUuid(String uuid)
getVisitAttributeTypeByUuid
in interface VisitService
VisitAttributeType
with the given uuid
Should return the visit attribute type with the given uuid
Should return null if no visit attribute type exists with the given uuidVisitService.getVisitAttributeTypeByUuid(java.lang.String)
public VisitAttributeType saveVisitAttributeType(VisitAttributeType visitAttributeType)
VisitService
saveVisitAttributeType
in interface VisitService
VisitService.saveVisitAttributeType(org.openmrs.VisitAttributeType)
public VisitAttributeType retireVisitAttributeType(VisitAttributeType visitAttributeType, String reason)
VisitService
retireVisitAttributeType
in interface VisitService
VisitService.retireVisitAttributeType(org.openmrs.VisitAttributeType,
java.lang.String)
public VisitAttributeType unretireVisitAttributeType(VisitAttributeType visitAttributeType)
VisitService
unretireVisitAttributeType
in interface VisitService
VisitService.unretireVisitAttributeType(org.openmrs.VisitAttributeType)
public void purgeVisitAttributeType(VisitAttributeType visitAttributeType)
VisitService
purgeVisitAttributeType
in interface VisitService
visitAttributeType
- Should completely remove a visit attribute typeVisitService.purgeVisitAttributeType(org.openmrs.VisitAttributeType)
@Transactional(readOnly=true) public VisitAttribute getVisitAttributeByUuid(String uuid)
getVisitAttributeByUuid
in interface VisitService
VisitAttribute
with the given uuid
Should get the visit attribute with the given uuid
Should return null if no visit attribute has the given uuidVisitService.getVisitAttributeByUuid(java.lang.String)
public void stopVisits(Date maximumStartDate)
VisitService
OpenmrsConstants.GP_VISIT_TYPES_TO_AUTO_CLOSE
global property.
If startDatetime is null, the default will be end of the current day.stopVisits
in interface VisitService
maximumStartDate
- Visits started on or before this date time value will get stopped
Should close all unvoided active visit matching the specified visit typesVisitService.stopVisits(Date)
Copyright © 2024 OpenMRS Inc.. All rights reserved.