org.openmrs.api.db.hibernate
Class HibernatePatientSetDAO

java.lang.Object
  extended by org.openmrs.api.db.hibernate.HibernatePatientSetDAO
All Implemented Interfaces:
PatientSetDAO

public class HibernatePatientSetDAO
extends java.lang.Object
implements PatientSetDAO

Hibernate specific implementation of the PatientSetDAO.

This class should not be instantiated. Rather, it is injected into the PatientSetService by Spring.

See Also:
Context, PatientSetService, PatientSetDAO

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
HibernatePatientSetDAO()
           
 
Method Summary
 Cohort convertPatientIdentifier(java.util.List<java.lang.String> identifiers)
           
 java.lang.String exportXml(Cohort ps)
          Deprecated.  
 java.lang.String exportXml(java.lang.Integer patientId)
          Deprecated.  
static java.util.List<java.lang.String> findObsValueColumnName(Concept c)
           
 java.util.Map<java.lang.Integer,java.util.Collection<java.lang.Integer>> getActiveDrugIds(java.util.Collection<java.lang.Integer> patientIds, java.util.Date fromDate, java.util.Date toDate)
          Returns a Map from patientId to a Collection of drugIds for drugs active for the patients on that date If patientIds is null then do this for all patients
 Cohort getAllPatients()
           
 java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Object>> getCharacteristics(Cohort patients)
           
 java.util.Map<java.lang.Integer,java.util.List<DrugOrder>> getCurrentDrugOrders(Cohort patients, java.util.List<Concept> drugConcepts)
           
 java.util.Map<java.lang.Integer,PatientState> getCurrentStates(Cohort ps, ProgramWorkflow wf)
           
 java.util.Map<java.lang.Integer,java.util.List<DrugOrder>> getDrugOrders(Cohort patients, java.util.List<Concept> drugConcepts)
           
 java.util.Map<java.lang.Integer,java.lang.Object> getEncounterAttrsByType(Cohort patients, java.util.List<EncounterType> encTypes, java.lang.String attr, java.lang.Boolean earliestFirst)
           
 java.util.Map<java.lang.Integer,Encounter> getEncounters(Cohort patients)
           
 java.util.List<Encounter> getEncountersByForm(Cohort patients, java.util.List<Form> forms)
          Gets a list of encounters associated with the given form, filtered by the given patient set.
 java.util.Map<java.lang.Integer,Encounter> getEncountersByType(Cohort patients, java.util.List<EncounterType> encTypes)
           
 java.util.Map<java.lang.Integer,Encounter> getFirstEncountersByType(Cohort patients, java.util.List<EncounterType> types)
           
 java.util.Map<java.lang.Integer,java.util.List<Obs>> getObservations(Cohort patients, Concept concept, java.util.Date fromDate, java.util.Date toDate)
           
 java.util.Map<java.lang.Integer,java.util.List<java.util.List<java.lang.Object>>> getObservationsValues(Cohort patients, Concept c, java.util.List<java.lang.String> attributes)
           
 java.util.Map<java.lang.Integer,java.lang.Object> getPatientAttributes(Cohort patients, java.lang.String className, java.lang.String property, boolean returnAll)
           
 java.util.Map<java.lang.Integer,PatientIdentifier> getPatientIdentifierByType(Cohort patients, java.util.List<PatientIdentifierType> types)
           
 java.util.Map<java.lang.Integer,PatientProgram> getPatientPrograms(Cohort ps, Program program, boolean includeVoided, boolean includePast)
          This method assumes the patient is not simultaneously enrolled in the program more than once.
 java.util.List<Patient> getPatients(java.util.Collection<java.lang.Integer> patientIds)
           
 Cohort getPatientsByCharacteristics(java.lang.String gender, java.util.Date minBirthdate, java.util.Date maxBirthdate, java.lang.Integer minAge, java.lang.Integer maxAge, java.lang.Boolean aliveOnly, java.lang.Boolean deadOnly)
           
 Cohort getPatientsByCharacteristics(java.lang.String gender, java.util.Date minBirthdate, java.util.Date maxBirthdate, java.lang.Integer minAge, java.lang.Integer maxAge, java.lang.Boolean aliveOnly, java.lang.Boolean deadOnly, java.util.Date effectiveDate)
           
 Cohort getPatientsByProgramAndState(Program program, java.util.List<ProgramWorkflowState> stateList, java.util.Date fromDate, java.util.Date toDate)
          TODO: Fails to leave out patients who are voided Returns the set of patients that were in a given program, workflow, and state, within a given date range
 Cohort getPatientsByRelationship(RelationshipType relType, boolean includeAtoB, boolean includeBtoA, Person target)
          Returns the cohort of patients matching a particular relationship search.
 Cohort getPatientsHavingDateObs(java.lang.Integer conceptId, java.util.Date startTime, java.util.Date endTime)
          TODO: don't return voided patients Gets all patients with an obs's value_date column value within startTime and endTime
 Cohort getPatientsHavingDrugOrder(java.util.List<Drug> drugList, java.util.List<Concept> drugConceptList, java.util.Date startDateFrom, java.util.Date startDateTo, java.util.Date stopDateFrom, java.util.Date stopDateTo, java.lang.Boolean discontinued, java.util.List<Concept> discontinuedReason)
           
 Cohort getPatientsHavingEncounters(java.util.List<EncounterType> encounterTypeList, Location location, Form form, java.util.Date fromDate, java.util.Date toDate, java.lang.Integer minCount, java.lang.Integer maxCount)
          TODO: don't return voided patients Returns the set of patients that have encounters, with several optional parameters: * of type encounterType * at a given location * from filling out a specific form * on or after fromDate * on or before toDate * patients with at least minCount of the given encounters * patients with up to maxCount of the given encounters
 Cohort getPatientsHavingLocation(java.lang.Integer locationId, PatientSetService.PatientLocationMethod method)
           
 Cohort getPatientsHavingNumericObs(java.lang.Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, java.lang.Number value, java.util.Date fromDate, java.util.Date toDate)
           
 Cohort getPatientsHavingObs(java.lang.Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, java.lang.Object value, java.util.Date fromDate, java.util.Date toDate)
           
 Cohort getPatientsHavingPersonAttribute(PersonAttributeType attribute, java.lang.String value)
           
 Cohort getPatientsHavingTextObs(java.lang.Integer conceptId, java.lang.String value, PatientSetService.TimeModifier timeModifier)
           
 Cohort getPatientsInProgram(java.lang.Integer programId, java.util.Date fromDate, java.util.Date toDate)
          TODO: Don't return voided patients Returns the set of patients that were ever in enrolled in a given program.
 java.util.Map<java.lang.Integer,java.lang.Object> getPersonAttributes(Cohort patients, java.lang.String attributeTypeName, java.lang.String joinClass, java.lang.String joinProperty, java.lang.String outputColumn, boolean returnAll)
           
 java.util.Map<java.lang.Integer,java.util.List<Relationship>> getRelationships(Cohort patients, RelationshipType relType)
           
 java.util.Map<java.lang.Integer,java.util.List<Person>> getRelatives(Cohort patients, RelationshipType relType, boolean forwards)
           
 java.util.Map<java.lang.Integer,java.lang.String> getShortPatientDescriptions(java.util.Collection<java.lang.Integer> patientIds)
           
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Set sessionFactory.getCurrentSession() factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

HibernatePatientSetDAO

public HibernatePatientSetDAO()
Method Detail

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Set sessionFactory.getCurrentSession() factory

Parameters:
sessionFactory - SessionFactory to set

exportXml

public java.lang.String exportXml(Cohort ps)
                           throws DAOException
Deprecated. 

Specified by:
exportXml in interface PatientSetDAO
Throws:
DAOException
See Also:
PatientSetDAO.exportXml(org.openmrs.Cohort)

exportXml

public java.lang.String exportXml(java.lang.Integer patientId)
                           throws DAOException
Deprecated. 

Note that the formatting may depend on locale

Specified by:
exportXml in interface PatientSetDAO
Throws:
DAOException

getAllPatients

public Cohort getAllPatients()
Specified by:
getAllPatients in interface PatientSetDAO

getPatientsByProgramAndState

public Cohort getPatientsByProgramAndState(Program program,
                                           java.util.List<ProgramWorkflowState> stateList,
                                           java.util.Date fromDate,
                                           java.util.Date toDate)
TODO: Fails to leave out patients who are voided Returns the set of patients that were in a given program, workflow, and state, within a given date range

Specified by:
getPatientsByProgramAndState in interface PatientSetDAO
Parameters:
program - The program the patient must have been in
stateList - List of states the patient must have been in (implies a workflow) (can be null)
fromDate - If not null, then only patients in the given program/workflow/state on or after this date
toDate - If not null, then only patients in the given program/workflow/state on or before this date
Returns:
Cohort of Patients matching criteria

getPatientsInProgram

public Cohort getPatientsInProgram(java.lang.Integer programId,
                                   java.util.Date fromDate,
                                   java.util.Date toDate)
TODO: Don't return voided patients Returns the set of patients that were ever in enrolled in a given program. If fromDate != null, then only those patients who were in the program at any time after that date if toDate != null, then only those patients who were in the program at any time before that date

Specified by:
getPatientsInProgram in interface PatientSetDAO

getPatientsHavingObs

public Cohort getPatientsHavingObs(java.lang.Integer conceptId,
                                   PatientSetService.TimeModifier timeModifier,
                                   PatientSetService.Modifier modifier,
                                   java.lang.Object value,
                                   java.util.Date fromDate,
                                   java.util.Date toDate)
Specified by:
getPatientsHavingObs in interface PatientSetDAO

getPatientsHavingEncounters

public Cohort getPatientsHavingEncounters(java.util.List<EncounterType> encounterTypeList,
                                          Location location,
                                          Form form,
                                          java.util.Date fromDate,
                                          java.util.Date toDate,
                                          java.lang.Integer minCount,
                                          java.lang.Integer maxCount)
TODO: don't return voided patients Returns the set of patients that have encounters, with several optional parameters: * of type encounterType * at a given location * from filling out a specific form * on or after fromDate * on or before toDate * patients with at least minCount of the given encounters * patients with up to maxCount of the given encounters

Specified by:
getPatientsHavingEncounters in interface PatientSetDAO

getPatientsHavingDateObs

public Cohort getPatientsHavingDateObs(java.lang.Integer conceptId,
                                       java.util.Date startTime,
                                       java.util.Date endTime)
TODO: don't return voided patients Gets all patients with an obs's value_date column value within startTime and endTime

Specified by:
getPatientsHavingDateObs in interface PatientSetDAO
Parameters:
conceptId -
startTime -
endTime -
Returns:
PatientSet

getPatientsHavingNumericObs

public Cohort getPatientsHavingNumericObs(java.lang.Integer conceptId,
                                          PatientSetService.TimeModifier timeModifier,
                                          PatientSetService.Modifier modifier,
                                          java.lang.Number value,
                                          java.util.Date fromDate,
                                          java.util.Date toDate)
Specified by:
getPatientsHavingNumericObs in interface PatientSetDAO

getPatientsByCharacteristics

public Cohort getPatientsByCharacteristics(java.lang.String gender,
                                           java.util.Date minBirthdate,
                                           java.util.Date maxBirthdate,
                                           java.lang.Integer minAge,
                                           java.lang.Integer maxAge,
                                           java.lang.Boolean aliveOnly,
                                           java.lang.Boolean deadOnly)
                                    throws DAOException
Specified by:
getPatientsByCharacteristics in interface PatientSetDAO
Throws:
DAOException

getPatientsByCharacteristics

public Cohort getPatientsByCharacteristics(java.lang.String gender,
                                           java.util.Date minBirthdate,
                                           java.util.Date maxBirthdate,
                                           java.lang.Integer minAge,
                                           java.lang.Integer maxAge,
                                           java.lang.Boolean aliveOnly,
                                           java.lang.Boolean deadOnly,
                                           java.util.Date effectiveDate)
                                    throws DAOException
Specified by:
getPatientsByCharacteristics in interface PatientSetDAO
Throws:
DAOException

getShortPatientDescriptions

public java.util.Map<java.lang.Integer,java.lang.String> getShortPatientDescriptions(java.util.Collection<java.lang.Integer> patientIds)
                                                                              throws DAOException
Specified by:
getShortPatientDescriptions in interface PatientSetDAO
Throws:
DAOException

getCharacteristics

public java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Object>> getCharacteristics(Cohort patients)
                                                                                                     throws DAOException
Specified by:
getCharacteristics in interface PatientSetDAO
Throws:
DAOException

getObservations

public java.util.Map<java.lang.Integer,java.util.List<Obs>> getObservations(Cohort patients,
                                                                            Concept concept,
                                                                            java.util.Date fromDate,
                                                                            java.util.Date toDate)
                                                                     throws DAOException
Specified by:
getObservations in interface PatientSetDAO
Throws:
DAOException

getObservationsValues

public java.util.Map<java.lang.Integer,java.util.List<java.util.List<java.lang.Object>>> getObservationsValues(Cohort patients,
                                                                                                               Concept c,
                                                                                                               java.util.List<java.lang.String> attributes)
Specified by:
getObservationsValues in interface PatientSetDAO

findObsValueColumnName

public static java.util.List<java.lang.String> findObsValueColumnName(Concept c)

getEncountersByType

public java.util.Map<java.lang.Integer,Encounter> getEncountersByType(Cohort patients,
                                                                      java.util.List<EncounterType> encTypes)
Specified by:
getEncountersByType in interface PatientSetDAO

getEncountersByForm

public java.util.List<Encounter> getEncountersByForm(Cohort patients,
                                                     java.util.List<Form> forms)
Gets a list of encounters associated with the given form, filtered by the given patient set.

Specified by:
getEncountersByForm in interface PatientSetDAO
Parameters:
patients - the patients to filter by (null will return all encounters for all patients)
forms - the forms to filter by

getEncounterAttrsByType

public java.util.Map<java.lang.Integer,java.lang.Object> getEncounterAttrsByType(Cohort patients,
                                                                                 java.util.List<EncounterType> encTypes,
                                                                                 java.lang.String attr,
                                                                                 java.lang.Boolean earliestFirst)
Specified by:
getEncounterAttrsByType in interface PatientSetDAO

getEncounters

public java.util.Map<java.lang.Integer,Encounter> getEncounters(Cohort patients)
Specified by:
getEncounters in interface PatientSetDAO

getFirstEncountersByType

public java.util.Map<java.lang.Integer,Encounter> getFirstEncountersByType(Cohort patients,
                                                                           java.util.List<EncounterType> types)
Specified by:
getFirstEncountersByType in interface PatientSetDAO

getPatientAttributes

public java.util.Map<java.lang.Integer,java.lang.Object> getPatientAttributes(Cohort patients,
                                                                              java.lang.String className,
                                                                              java.lang.String property,
                                                                              boolean returnAll)
                                                                       throws DAOException
Specified by:
getPatientAttributes in interface PatientSetDAO
Throws:
DAOException

getPersonAttributes

public java.util.Map<java.lang.Integer,java.lang.Object> getPersonAttributes(Cohort patients,
                                                                             java.lang.String attributeTypeName,
                                                                             java.lang.String joinClass,
                                                                             java.lang.String joinProperty,
                                                                             java.lang.String outputColumn,
                                                                             boolean returnAll)
Specified by:
getPersonAttributes in interface PatientSetDAO
See Also:
PatientSetDAO.getPersonAttributes(org.openmrs.Cohort, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)

getPatientsHavingTextObs

public Cohort getPatientsHavingTextObs(java.lang.Integer conceptId,
                                       java.lang.String value,
                                       PatientSetService.TimeModifier timeModifier)
                                throws DAOException
Specified by:
getPatientsHavingTextObs in interface PatientSetDAO
Throws:
DAOException

getPatientsHavingLocation

public Cohort getPatientsHavingLocation(java.lang.Integer locationId,
                                        PatientSetService.PatientLocationMethod method)
                                 throws DAOException
Specified by:
getPatientsHavingLocation in interface PatientSetDAO
Throws:
DAOException

convertPatientIdentifier

public Cohort convertPatientIdentifier(java.util.List<java.lang.String> identifiers)
                                throws DAOException
Specified by:
convertPatientIdentifier in interface PatientSetDAO
Throws:
DAOException

getPatients

public java.util.List<Patient> getPatients(java.util.Collection<java.lang.Integer> patientIds)
                                    throws DAOException
Specified by:
getPatients in interface PatientSetDAO
Throws:
DAOException

getActiveDrugIds

public java.util.Map<java.lang.Integer,java.util.Collection<java.lang.Integer>> getActiveDrugIds(java.util.Collection<java.lang.Integer> patientIds,
                                                                                                 java.util.Date fromDate,
                                                                                                 java.util.Date toDate)
                                                                                          throws DAOException
Returns a Map from patientId to a Collection of drugIds for drugs active for the patients on that date If patientIds is null then do this for all patients

Specified by:
getActiveDrugIds in interface PatientSetDAO
Throws:
DAOException

getCurrentStates

public java.util.Map<java.lang.Integer,PatientState> getCurrentStates(Cohort ps,
                                                                      ProgramWorkflow wf)
                                                               throws DAOException
Specified by:
getCurrentStates in interface PatientSetDAO
Throws:
DAOException

getPatientPrograms

public java.util.Map<java.lang.Integer,PatientProgram> getPatientPrograms(Cohort ps,
                                                                          Program program,
                                                                          boolean includeVoided,
                                                                          boolean includePast)
                                                                   throws DAOException
This method assumes the patient is not simultaneously enrolled in the program more than once. if (includeVoided == true) then include voided programs if (includePast == true) then include program which are already complete In all cases this only returns the latest program enrollment for each patient.

Specified by:
getPatientPrograms in interface PatientSetDAO
Throws:
DAOException

getCurrentDrugOrders

public java.util.Map<java.lang.Integer,java.util.List<DrugOrder>> getCurrentDrugOrders(Cohort patients,
                                                                                       java.util.List<Concept> drugConcepts)
                                                                                throws DAOException
Specified by:
getCurrentDrugOrders in interface PatientSetDAO
Throws:
DAOException

getDrugOrders

public java.util.Map<java.lang.Integer,java.util.List<DrugOrder>> getDrugOrders(Cohort patients,
                                                                                java.util.List<Concept> drugConcepts)
                                                                         throws DAOException
Specified by:
getDrugOrders in interface PatientSetDAO
Throws:
DAOException

getRelatives

public java.util.Map<java.lang.Integer,java.util.List<Person>> getRelatives(Cohort patients,
                                                                            RelationshipType relType,
                                                                            boolean forwards)
Specified by:
getRelatives in interface PatientSetDAO

getRelationships

public java.util.Map<java.lang.Integer,java.util.List<Relationship>> getRelationships(Cohort patients,
                                                                                      RelationshipType relType)
Specified by:
getRelationships in interface PatientSetDAO

getPatientsHavingPersonAttribute

public Cohort getPatientsHavingPersonAttribute(PersonAttributeType attribute,
                                               java.lang.String value)
Specified by:
getPatientsHavingPersonAttribute in interface PatientSetDAO

getPatientsHavingDrugOrder

public Cohort getPatientsHavingDrugOrder(java.util.List<Drug> drugList,
                                         java.util.List<Concept> drugConceptList,
                                         java.util.Date startDateFrom,
                                         java.util.Date startDateTo,
                                         java.util.Date stopDateFrom,
                                         java.util.Date stopDateTo,
                                         java.lang.Boolean discontinued,
                                         java.util.List<Concept> discontinuedReason)
Specified by:
getPatientsHavingDrugOrder in interface PatientSetDAO

getPatientIdentifierByType

public java.util.Map<java.lang.Integer,PatientIdentifier> getPatientIdentifierByType(Cohort patients,
                                                                                     java.util.List<PatientIdentifierType> types)
Specified by:
getPatientIdentifierByType in interface PatientSetDAO
Parameters:
patients -
types - List of types to get
Returns:
Map of PatientIdentifiers

getPatientsByRelationship

public Cohort getPatientsByRelationship(RelationshipType relType,
                                        boolean includeAtoB,
                                        boolean includeBtoA,
                                        Person target)
Description copied from interface: PatientSetDAO
Returns the cohort of patients matching a particular relationship search. If relType is specified, then search for patients at one or either end of that relationship type. (Which end is controlled by includeAtoB and includeBtoA.) If target is specified, then that person must be at the other end of the relationship.

Specified by:
getPatientsByRelationship in interface PatientSetDAO
Returns:
patients matching the specified relationship search
See Also:
PatientSetDAO.getPatientsByRelationship(org.openmrs.RelationshipType, boolean, boolean, org.openmrs.Person)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change