@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_CLOSEglobal 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, onStartupclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonShutdown, onStartuppublic void setVisitDAO(VisitDAO dao)
dao - the visit data access object.public VisitDAO getVisitDAO()
@Transactional(readOnly=true) public List<VisitType> getAllVisitTypes()
VisitServicegetAllVisitTypes in interface VisitServiceVisitService.getAllVisitTypes()@Transactional(readOnly=true) public List<VisitType> getAllVisitTypes(boolean includeRetired)
VisitServicegetAllVisitTypes in interface VisitServiceVisitService.getAllVisitTypes(boolean)@Transactional(readOnly=true) public VisitType getVisitType(Integer visitTypeId)
VisitServicegetVisitType in interface VisitServicevisitTypeId - the visit type id.VisitService.getVisitType(java.lang.Integer)@Transactional(readOnly=true) public VisitType getVisitTypeByUuid(String uuid)
VisitServicegetVisitTypeByUuid in interface VisitServiceuuid - the visit type UUID.VisitService.getVisitTypeByUuid(java.lang.String)@Transactional(readOnly=true) public List<VisitType> getVisitTypes(String fuzzySearchPhrase)
VisitServicegetVisitTypes in interface VisitServicefuzzySearchPhrase - the search phrase to use.VisitService.getVisitTypes(java.lang.String)public VisitType saveVisitType(VisitType visitType) throws APIException
VisitServicesaveVisitType in interface VisitServicevisitType - the visit type to create or update.APIExceptionVisitService.saveVisitType(org.openmrs.VisitType)public VisitType retireVisitType(VisitType visitType, String reason)
VisitServiceretireVisitType in interface VisitServicevisitType - 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)
VisitServiceunretireVisitType in interface VisitServicevisitType - the visit type to unretire.VisitService.unretireVisitType(org.openmrs.VisitType)public void purgeVisitType(VisitType visitType)
VisitServicepurgeVisitType in interface VisitServicevisitType - 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
VisitServicegetAllVisits in interface VisitServiceAPIException - Should return all unvoided visitsVisitService.getAllVisits()@Transactional(readOnly=true) public Visit getVisit(Integer visitId) throws APIException
VisitServicegetVisit in interface VisitServicevisitId - the visit id.APIExceptionVisitService.getVisit(java.lang.Integer)@Transactional(readOnly=true) public Visit getVisitByUuid(String uuid) throws APIException
VisitServicegetVisitByUuid in interface VisitServiceuuid - the visit UUID.APIException - Should return a visit matching the specified uuidVisitService.getVisitByUuid(java.lang.String)public Visit saveVisit(Visit visit) throws APIException
VisitServicesaveVisit in interface VisitServicevisit - 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)
VisitServiceendVisit in interface VisitServicevisit - 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
VisitServicevoidVisit in interface VisitServicevisit - 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
VisitServiceunvoidVisit in interface VisitServicevisit - 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
VisitServicepurgeVisit in interface VisitServicevisit - 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
VisitServicegetVisits in interface VisitServicevisitTypes - 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
VisitServicegetVisits in interface VisitServiceAPIExceptionVisitService.getVisits(VisitSearchCriteria)@Transactional(readOnly=true) public List<Visit> getVisitsByPatient(Patient patient) throws APIException
VisitServicegetVisitsByPatient in interface VisitServicepatient - 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
VisitServicegetActiveVisitsByPatient in interface VisitServicepatient - the patient whose visits to getAPIExceptionVisitService.getActiveVisitsByPatient(org.openmrs.Patient)@Transactional(readOnly=true) public List<Visit> getVisitsByPatient(Patient patient, boolean includeInactive, boolean includeVoided) throws APIException
VisitServicegetVisitsByPatient in interface VisitServicepatient - 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 VisitServiceVisitAttributeTypes
 Should return all visit attribute types including retired onesVisitService.getAllVisitAttributeTypes()@Transactional(readOnly=true) public VisitAttributeType getVisitAttributeType(Integer id)
getVisitAttributeType in interface VisitServiceVisitAttributeType 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 VisitServiceVisitAttributeType 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)
VisitServicesaveVisitAttributeType in interface VisitServiceVisitService.saveVisitAttributeType(org.openmrs.VisitAttributeType)public VisitAttributeType retireVisitAttributeType(VisitAttributeType visitAttributeType, String reason)
VisitServiceretireVisitAttributeType in interface VisitServiceVisitService.retireVisitAttributeType(org.openmrs.VisitAttributeType,
      java.lang.String)public VisitAttributeType unretireVisitAttributeType(VisitAttributeType visitAttributeType)
VisitServiceunretireVisitAttributeType in interface VisitServiceVisitService.unretireVisitAttributeType(org.openmrs.VisitAttributeType)public void purgeVisitAttributeType(VisitAttributeType visitAttributeType)
VisitServicepurgeVisitAttributeType in interface VisitServicevisitAttributeType - Should completely remove a visit attribute typeVisitService.purgeVisitAttributeType(org.openmrs.VisitAttributeType)@Transactional(readOnly=true) public VisitAttribute getVisitAttributeByUuid(String uuid)
getVisitAttributeByUuid in interface VisitServiceVisitAttribute 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)
VisitServiceOpenmrsConstants.GP_VISIT_TYPES_TO_AUTO_CLOSE global property.
 If startDatetime is null, the default will be end of the current day.stopVisits in interface VisitServicemaximumStartDate - 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.