- Timestamp:
- 05/09/08 10:53:35 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/trunk/src/api/org/openmrs/api/db/hibernate/HibernatePatientSetDAO.java
r4095 r4158 53 53 import org.hibernate.criterion.Restrictions; 54 54 import org.hibernate.type.StringType; 55 import org.openmrs.Cohort; 55 56 import org.openmrs.Concept; 56 57 import org.openmrs.Drug; … … 86 87 import org.openmrs.api.db.DAOException; 87 88 import org.openmrs.api.db.PatientSetDAO; 88 import org.openmrs.reporting.PatientSet;89 89 import org.w3c.dom.Document; 90 90 import org.w3c.dom.Element; … … 110 110 } 111 111 112 public String exportXml( PatientSet ps) throws DAOException {112 public String exportXml(Cohort ps) throws DAOException { 113 113 // TODO: This is inefficient for large patient sets. 114 114 StringBuffer ret = new StringBuffer("<patientset>"); 115 for (Integer patientId : ps.get PatientIds()) {115 for (Integer patientId : ps.getMemberIds()) { 116 116 ret.append(exportXml(patientId)); 117 117 } … … 450 450 451 451 @SuppressWarnings("unchecked") 452 public PatientSet getAllPatients() {453 454 Query query = sessionFactory.getCurrentSession().createQuery("select distinct patientId from Patient p where p.voided = 0 order by patientId");455 456 List<Integer> ids = new ArrayList<Integer>();452 public Cohort getAllPatients() { 453 454 Query query = sessionFactory.getCurrentSession().createQuery("select distinct patientId from Patient p where p.voided = 0"); 455 456 Set<Integer> ids = new HashSet<Integer>(); 457 457 ids.addAll(query.list()); 458 458 459 PatientSet patientSet = new PatientSet(); 460 patientSet.setPatientIds(ids); 461 462 return patientSet; 459 return new Cohort(ids); 463 460 } 464 461 … … 472 469 * @return 473 470 */ 474 public PatientSet getPatientsByProgramAndState(Program program, List<ProgramWorkflowState> stateList, Date fromDate, Date toDate) {471 public Cohort getPatientsByProgramAndState(Program program, List<ProgramWorkflowState> stateList, Date fromDate, Date toDate) { 475 472 Integer programId = program == null ? null : program.getProgramId(); 476 473 List<Integer> stateIds = null; … … 522 519 query.setDate("toDate", toDate); 523 520 524 PatientSet ret = new PatientSet(); 525 ret.copyPatientIds(query.list()); 526 return ret; 521 return new Cohort(query.list()); 527 522 } 528 523 … … 533 528 * if toDate != null, then only those patients who were in the program at any time before that date 534 529 */ 535 public PatientSet getPatientsInProgram(Integer programId, Date fromDate, Date toDate) {530 public Cohort getPatientsInProgram(Integer programId, Date fromDate, Date toDate) { 536 531 String sql = "select patient_id from patient_program pp where pp.voided = false and pp.program_id = :programId "; 537 532 if (fromDate != null) … … 550 545 query.setDate("toDate", toDate); 551 546 552 Set<Integer> ptIds = new HashSet<Integer>(); 553 ptIds.addAll(query.list()); 554 PatientSet ret = new PatientSet(); 555 ret.copyPatientIds(ptIds); 556 return ret; 557 } 558 559 public PatientSet getPatientsHavingObs(Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, Object value, Date fromDate, Date toDate) { 547 return new Cohort(query.list()); 548 } 549 550 public Cohort getPatientsHavingObs(Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, Object value, Date fromDate, Date toDate) { 560 551 if (conceptId == null && value == null) 561 552 throw new IllegalArgumentException("Can't have conceptId == null and value == null"); … … 690 681 query.setDate("toDate", toDate); 691 682 692 PatientSet ret;683 Cohort ret; 693 684 if (doInvert) { 694 685 ret = getAllPatients(); 695 ret. removeAllIds(query.list());686 ret.getMemberIds().removeAll(query.list()); 696 687 } else { 697 ret = new PatientSet(); 698 List patientIds = query.list(); 699 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 688 ret = new Cohort(query.list()); 700 689 } 701 690 … … 714 703 * * patients with up to maxCount of the given encounters 715 704 */ 716 public PatientSet getPatientsHavingEncounters(List<EncounterType> encounterTypeList, Location location, Form form, Date fromDate, Date toDate, Integer minCount, Integer maxCount) {705 public Cohort getPatientsHavingEncounters(List<EncounterType> encounterTypeList, Location location, Form form, Date fromDate, Date toDate, Integer minCount, Integer maxCount) { 717 706 List<Integer> encTypeIds = null; 718 707 if (encounterTypeList != null) { … … 769 758 query.setInteger("maxCount", maxCount); 770 759 771 PatientSet ret = new PatientSet(); 772 ret.copyPatientIds(query.list()); 773 return ret; 760 return new Cohort(query.list()); 774 761 } 775 762 … … 785 772 */ 786 773 @SuppressWarnings("unchecked") 787 public PatientSet getPatientsHavingDateObs(Integer conceptId, Date startTime, Date endTime) {774 public Cohort getPatientsHavingDateObs(Integer conceptId, Date startTime, Date endTime) { 788 775 StringBuffer sb = new StringBuffer(); 789 776 sb.append("select o.person_id from obs o " + … … 799 786 query.setDate("endValue", endTime); 800 787 801 PatientSet ret = new PatientSet(); 802 List patientIds = query.list(); 803 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 804 805 return ret; 806 } 807 808 @SuppressWarnings("unchecked") 809 public PatientSet getPatientsHavingNumericObs(Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, Number value, Date fromDate, Date toDate) { 788 return new Cohort(query.list()); 789 } 790 791 @SuppressWarnings("unchecked") 792 public Cohort getPatientsHavingNumericObs(Integer conceptId, PatientSetService.TimeModifier timeModifier, PatientSetService.Modifier modifier, Number value, Date fromDate, Date toDate) { 810 793 811 794 Concept concept = Context.getConceptService().getConcept(conceptId); … … 875 858 query.setDate("toDate", fromDate); 876 859 877 PatientSet ret;860 Cohort ret; 878 861 if (doInvert) { 879 862 ret = getAllPatients(); 880 ret. removeAllIds(query.list());863 ret.getMemberIds().removeAll(query.list()); 881 864 } else { 882 ret = new PatientSet(); 883 List patientIds = query.list(); 884 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 865 ret = new Cohort(query.list()); 885 866 } 886 867 … … 889 870 890 871 @SuppressWarnings("unchecked") 891 public PatientSet getPatientsByCharacteristics(String gender, Date minBirthdate, Date maxBirthdate,872 public Cohort getPatientsByCharacteristics(String gender, Date minBirthdate, Date maxBirthdate, 892 873 Integer minAge, Integer maxAge, Boolean aliveOnly, Boolean deadOnly) throws DAOException { 874 return getPatientsByCharacteristics(gender, minBirthdate, maxBirthdate, minAge, maxAge, aliveOnly, deadOnly, null); 875 } 876 877 @SuppressWarnings("unchecked") 878 public Cohort getPatientsByCharacteristics(String gender, Date minBirthdate, Date maxBirthdate, 879 Integer minAge, Integer maxAge, Boolean aliveOnly, Boolean deadOnly, Date effectiveDate) throws DAOException { 880 881 if (effectiveDate == null) { 882 effectiveDate = new Date(); 883 } 893 884 894 885 StringBuffer queryString = new StringBuffer("select patientId from Patient patient"); … … 908 899 } 909 900 if (aliveOnly != null && aliveOnly) { 910 clauses.add("patient.dead = false"); 901 clauses.add("patient.dead = false"); // TODO: Should this use effectiveDate? What if deathDate is null? 911 902 } 912 903 if (deadOnly != null && deadOnly) { 913 clauses.add("patient.dead = true"); 904 clauses.add("patient.dead = true"); // TODO: Should this use effectiveDate? What if deathDate is null? 914 905 } 915 906 … … 917 908 if (minAge != null) { 918 909 Calendar cal = new GregorianCalendar(); 910 cal.setTime(effectiveDate); 919 911 cal.add(Calendar.YEAR, -minAge); 920 912 maxBirthFromAge = cal.getTime(); … … 924 916 if (maxAge != null) { 925 917 Calendar cal = new GregorianCalendar(); 918 cal.setTime(effectiveDate); 926 919 cal.add(Calendar.YEAR, -(maxAge + 1)); 927 920 minBirthFromAge = cal.getTime(); … … 956 949 } 957 950 958 List<Integer> patientIds = query.list(); 959 960 PatientSet ret = new PatientSet(); 961 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 962 963 return ret; 951 return new Cohort(query.list()); 964 952 } 965 953 … … 998 986 999 987 @SuppressWarnings("unchecked") 1000 public Map<Integer, Map<String, Object>> getCharacteristics( PatientSet patients) throws DAOException {988 public Map<Integer, Map<String, Object>> getCharacteristics(Cohort patients) throws DAOException { 1001 989 Map<Integer, Map<String, Object>> ret = new HashMap<Integer, Map<String, Object>>(); 1002 Collection<Integer> ids = patients.get PatientIds();990 Collection<Integer> ids = patients.getMemberIds(); 1003 991 Query query = sessionFactory.getCurrentSession().createQuery("select patient.personId, patient.gender, patient.birthdate from Patient patient where patient.voided = false"); 1004 992 query.setCacheMode(CacheMode.IGNORE); … … 1030 1018 * TODO: finish this. 1031 1019 */ 1032 public Map<Integer, List<Obs>> getObservations( PatientSet patients, Concept concept, Date fromDate, Date toDate) throws DAOException {1020 public Map<Integer, List<Obs>> getObservations(Cohort patients, Concept concept, Date fromDate, Date toDate) throws DAOException { 1033 1021 Map<Integer, List<Obs>> ret = new HashMap<Integer, List<Obs>>(); 1034 1022 … … 1060 1048 // only add this where clause if patients were passed in 1061 1049 if (patients != null) 1062 criteria.add(Restrictions.in("person.personId", patients.get PatientIds()));1050 criteria.add(Restrictions.in("person.personId", patients.getMemberIds())); 1063 1051 1064 1052 criteria.add(Restrictions.eq("voided", false)); … … 1079 1067 } 1080 1068 1081 public Map<Integer, List<List<Object>>> getObservationsValues( PatientSet patients, Concept c, List<String> attributes) {1069 public Map<Integer, List<List<Object>>> getObservationsValues(Cohort patients, Concept c, List<String> attributes) { 1082 1070 Map<Integer, List<List<Object>>> ret = new HashMap<Integer, List<List<Object>>>(); 1083 1071 … … 1151 1139 // only restrict on patient ids if some were passed in 1152 1140 if (patients != null) 1153 criteria.add(Restrictions.in("obs.personId", patients.get PatientIds()));1141 criteria.add(Restrictions.in("obs.personId", patients.getMemberIds())); 1154 1142 1155 1143 criteria.add(Expression.eq("obs.concept", c)); … … 1227 1215 1228 1216 @SuppressWarnings("unchecked") 1229 public Map<Integer, Encounter> getEncountersByType( PatientSet patients, List<EncounterType> encTypes) {1217 public Map<Integer, Encounter> getEncountersByType(Cohort patients, List<EncounterType> encTypes) { 1230 1218 Map<Integer, Encounter> ret = new HashMap<Integer, Encounter>(); 1231 1219 … … 1236 1224 // this "where clause" is only necessary if patients were passed in 1237 1225 if (patients != null && patients.size() > 0) 1238 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));1226 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1239 1227 1240 1228 criteria.add(Restrictions.eq("voided", false)); … … 1265 1253 */ 1266 1254 @SuppressWarnings("unchecked") 1267 public List<Encounter> getEncountersByForm( PatientSet patients, List<Form> forms) {1255 public List<Encounter> getEncountersByForm(Cohort patients, List<Form> forms) { 1268 1256 1269 1257 // default query … … 1273 1261 // this "where clause" is only necessary if patients were passed in 1274 1262 if (patients != null && patients.size() > 0) 1275 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));1263 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1276 1264 1277 1265 criteria.add(Restrictions.eq("voided", false)); … … 1288 1276 1289 1277 1290 public Map<Integer, Object> getEncounterAttrsByType( PatientSet patients, List<EncounterType> encTypes, String attr, Boolean earliestFirst) {1278 public Map<Integer, Object> getEncounterAttrsByType(Cohort patients, List<EncounterType> encTypes, String attr, Boolean earliestFirst) { 1291 1279 Map<Integer, Object> ret = new HashMap<Integer, Object>(); 1292 1280 … … 1297 1285 // this "where clause" is only necessary if patients were specified 1298 1286 if (patients != null) 1299 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));1287 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1300 1288 1301 1289 criteria.add(Restrictions.eq("voided", false)); … … 1328 1316 1329 1317 @SuppressWarnings("unchecked") 1330 public Map<Integer, Encounter> getEncounters( PatientSet patients) {1318 public Map<Integer, Encounter> getEncounters(Cohort patients) { 1331 1319 Map<Integer, Encounter> ret = new HashMap<Integer, Encounter>(); 1332 1320 … … 1337 1325 // only include this where clause if patients were passed in 1338 1326 if (patients != null) 1339 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));1327 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1340 1328 1341 1329 criteria.add(Restrictions.eq("voided", false)); … … 1357 1345 1358 1346 @SuppressWarnings("unchecked") 1359 public Map<Integer, Encounter> getFirstEncountersByType( PatientSet patients, List<EncounterType> types) {1347 public Map<Integer, Encounter> getFirstEncountersByType(Cohort patients, List<EncounterType> types) { 1360 1348 Map<Integer, Encounter> ret = new HashMap<Integer, Encounter>(); 1361 1349 … … 1366 1354 // this "where clause" is only needed if patients were specified 1367 1355 if (patients != null) 1368 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));1356 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1369 1357 1370 1358 criteria.add(Restrictions.eq("voided", false)); … … 1390 1378 @SuppressWarnings("unchecked") 1391 1379 // TODO: this method seems to be missing a check for voided==false. 1392 public Map<Integer, Object> getPatientAttributes( PatientSet patients, String className, String property, boolean returnAll) throws DAOException {1380 public Map<Integer, Object> getPatientAttributes(Cohort patients, String className, String property, boolean returnAll) throws DAOException { 1393 1381 Map<Integer, Object> ret = new HashMap<Integer, Object>(); 1394 1382 … … 1416 1404 1417 1405 if (patients != null) 1418 criteria.add(Restrictions.in("person.personId", patients.getPatientIds())); 1406 criteria.add(Restrictions.in("person.personId", patients.getMemberIds())); 1407 1408 // do not include voided person rows 1409 criteria.add(Expression.eq("personVoided", false)); 1419 1410 } 1420 1411 else { … … 1423 1414 1424 1415 if (patients != null) 1425 criteria.add(Restrictions.in("patient.personId", patients.getPatientIds())); 1416 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1417 1418 // do not include voided patients 1419 criteria.add(Expression.eq("voided", false)); 1426 1420 } 1427 1421 criteria.setProjection(projectionList); 1428 1429 //criteria.addOrder(org.hibernate.criterion.Order.desc("voided"));1430 criteria.add(Expression.eq("voided", false));1431 1422 1432 1423 // add 'preferred' sort order if necessary … … 1478 1469 1479 1470 /** 1480 * @see org.openmrs.api.db.PatientSetDAO#getPersonAttributes(org.openmrs. reporting.PatientSet, java.lang.String, java.lang.String, java.lang.String, boolean)1471 * @see org.openmrs.api.db.PatientSetDAO#getPersonAttributes(org.openmrs.Cohort, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) 1481 1472 */ 1482 public Map<Integer, Object> getPersonAttributes( PatientSet patients, String attributeTypeName, String joinClass, String joinProperty, String outputColumn, boolean returnAll) {1473 public Map<Integer, Object> getPersonAttributes(Cohort patients, String attributeTypeName, String joinClass, String joinProperty, String outputColumn, boolean returnAll) { 1483 1474 Map<Integer, Object> ret = new HashMap<Integer, Object>(); 1484 1475 … … 1511 1502 // this where clause is only necessary if patients were passed in 1512 1503 if (patients != null) 1513 query.setParameterList("ids", patients.get PatientIds());1504 query.setParameterList("ids", patients.getMemberIds()); 1514 1505 1515 1506 query.setString("typeName", attributeTypeName); … … 1551 1542 // TODO: don't return voided patients. Also, remove this method 1552 1543 @SuppressWarnings("unchecked") 1553 public PatientSet getPatientsHavingTextObs(Integer conceptId, String value, TimeModifier timeModifier) throws DAOException {1544 public Cohort getPatientsHavingTextObs(Integer conceptId, String value, TimeModifier timeModifier) throws DAOException { 1554 1545 Query query; 1555 1546 StringBuffer sb = new StringBuffer(); … … 1585 1576 } 1586 1577 1587 PatientSet ret = new PatientSet(); 1588 List patientIds = query.list(); 1589 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 1590 1591 return ret; 1578 return new Cohort(query.list()); 1592 1579 } 1593 1580 1594 1581 //TODO: the encounter variants may return voided patients 1595 1582 @SuppressWarnings("unchecked") 1596 public PatientSet getPatientsHavingLocation(Integer locationId, PatientSetService.PatientLocationMethod method) throws DAOException {1583 public Cohort getPatientsHavingLocation(Integer locationId, PatientSetService.PatientLocationMethod method) throws DAOException { 1597 1584 1598 1585 // TODO this needs to be retired after the cohort builder is in place … … 1639 1626 query.setInteger("location_id", locationId); 1640 1627 1641 PatientSet ret = new PatientSet(); 1642 List<Integer> patientIds = query.list(); 1643 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 1644 1645 return ret; 1646 } 1647 1648 public PatientSet convertPatientIdentifier(List<String> identifiers) throws DAOException { 1628 return new Cohort(query.list()); 1629 } 1630 1631 public Cohort convertPatientIdentifier(List<String> identifiers) throws DAOException { 1649 1632 1650 1633 StringBuffer sb = new StringBuffer(); … … 1654 1637 query.setCacheMode(CacheMode.IGNORE); 1655 1638 query.setParameterList("identifiers", identifiers, new StringType()); 1656 PatientSet ret = new PatientSet(); 1657 List<Integer> patientIds = query.list(); 1658 ret.setPatientIds(new ArrayList<Integer>(patientIds)); 1659 1660 return ret; 1639 return new Cohort(query.list()); 1661 1640 } 1662 1641 … … 1736 1715 1737 1716 @SuppressWarnings("unchecked") 1738 public Map<Integer, PatientState> getCurrentStates( PatientSet ps, ProgramWorkflow wf) throws DAOException {1717 public Map<Integer, PatientState> getCurrentStates(Cohort ps, ProgramWorkflow wf) throws DAOException { 1739 1718 Map<Integer, PatientState> ret = new HashMap<Integer, PatientState>(); 1740 1719 … … 1747 1726 // only include this where clause if patients were passed in 1748 1727 if (ps != null) 1749 criteria.createCriteria("patientProgram").add(Restrictions.in("patient.personId", ps.get PatientIds()));1728 criteria.createCriteria("patientProgram").add(Restrictions.in("patient.personId", ps.getMemberIds())); 1750 1729 1751 1730 //criteria.add(Restrictions.eq("state.programWorkflow", wf)); … … 1771 1750 */ 1772 1751 @SuppressWarnings("unchecked") 1773 public Map<Integer, PatientProgram> getPatientPrograms( PatientSet ps, Program program,1752 public Map<Integer, PatientProgram> getPatientPrograms(Cohort ps, Program program, 1774 1753 boolean includeVoided, boolean includePast) throws DAOException { 1775 1754 Map<Integer, PatientProgram> ret = new HashMap<Integer, PatientProgram>(); … … 1782 1761 // this "where clause" is only necessary if patients were passed in 1783 1762 if (ps != null) 1784 criteria.add(Restrictions.in("patient.personId", ps.get PatientIds()));1763 criteria.add(Restrictions.in("patient.personId", ps.getMemberIds())); 1785 1764 1786 1765 criteria.add(Restrictions.eq("program", program)); … … 1801 1780 1802 1781 @SuppressWarnings("unchecked") 1803 public Map<Integer, List<DrugOrder>> getCurrentDrugOrders( PatientSet ps, List<Concept> drugConcepts) throws DAOException {1782 public Map<Integer, List<DrugOrder>> getCurrentDrugOrders(Cohort patients, List<Concept> drugConcepts) throws DAOException { 1804 1783 Map<Integer, List<DrugOrder>> ret = new HashMap<Integer, List<DrugOrder>>(); 1805 1784 … … 1810 1789 1811 1790 // this "where clause" is only necessary if patients were passed in 1812 if (p s != null)1813 criteria.add(Restrictions.in("patient.personId", p s.getPatientIds()));1791 if (patients != null) 1792 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1814 1793 1815 1794 //criteria.add(Restrictions.in("encounter.patient.personId", ids)); … … 1839 1818 1840 1819 @SuppressWarnings("unchecked") 1841 public Map<Integer, List<DrugOrder>> getDrugOrders( PatientSet ps, List<Concept> drugConcepts) throws DAOException {1820 public Map<Integer, List<DrugOrder>> getDrugOrders(Cohort patients, List<Concept> drugConcepts) throws DAOException { 1842 1821 Map<Integer, List<DrugOrder>> ret = new HashMap<Integer, List<DrugOrder>>(); 1843 1822 … … 1846 1825 1847 1826 // only include this where clause if patients were passed in 1848 if (p s != null)1849 criteria.add(Restrictions.in("patient.personId", p s.getPatientIds()));1827 if (patients != null) 1828 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 1850 1829 1851 1830 if (drugConcepts != null) … … 1873 1852 */ 1874 1853 @SuppressWarnings("unchecked") 1875 public Map<Integer, List<Person>> getRelatives( PatientSet ps, RelationshipType relType, boolean forwards) {1854 public Map<Integer, List<Person>> getRelatives(Cohort patients, RelationshipType relType, boolean forwards) { 1876 1855 if (relType == null) 1877 1856 throw new IllegalArgumentException("Must give a relationship type"); 1878 1857 Map<Integer, List<Person>> ret = new HashMap<Integer, List<Person>>(); 1879 if (p s != null)1880 if (p s.size() == 0)1858 if (patients != null) 1859 if (patients.size() == 0) 1881 1860 return ret; 1882 1861 1883 1862 Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Relationship.class); 1884 1863 criteria.add(Restrictions.eq("voided", false)); 1885 if (p s != null) {1864 if (patients != null) { 1886 1865 if (forwards) { 1887 criteria.add(Restrictions.in("personA.personId", p s.getPatientIds()));1866 criteria.add(Restrictions.in("personA.personId", patients.getMemberIds())); 1888 1867 } else { 1889 criteria.add(Restrictions.in("personB.personId", p s.getPatientIds()));1868 criteria.add(Restrictions.in("personB.personId", patients.getMemberIds())); 1890 1869 } 1891 1870 } … … 1909 1888 // TODO: Refactor this completely to make it useful now that relationships are bidirectional. (Or delete it.) 1910 1889 @SuppressWarnings("unchecked") 1911 public Map<Integer, List<Relationship>> getRelationships( PatientSet ps, RelationshipType relType) {1890 public Map<Integer, List<Relationship>> getRelationships(Cohort patients, RelationshipType relType) { 1912 1891 Map<Integer, List<Relationship>> ret = new HashMap<Integer, List<Relationship>>(); 1913 1892 … … 1918 1897 1919 1898 // this "where clause" is only useful if patients were passed in 1920 if (p s != null)1921 criteria.createCriteria("personB").add(Restrictions.in("personId", p s.getPatientIds()));1899 if (patients != null) 1900 criteria.createCriteria("personB").add(Restrictions.in("personId", patients.getMemberIds())); 1922 1901 1923 1902 criteria.add(Restrictions.eq("voided", false)); … … 1936 1915 } 1937 1916 1938 public PatientSet getPatientsHavingPersonAttribute(PersonAttributeType attribute, String value) {1917 public Cohort getPatientsHavingPersonAttribute(PersonAttributeType attribute, String value) { 1939 1918 StringBuilder sb = new StringBuilder(); 1940 1919 sb.append(" select pat.patient_id from person p inner join patient pat on pat.patient_id = p.person_id inner join person_attribute a on p.person_id = a.person_id "); … … 1953 1932 query.setString("value", value); 1954 1933 1955 PatientSet ps = new PatientSet(); 1956 ps.copyPatientIds(query.list()); 1957 return ps; 1934 return new Cohort(query.list()); 1958 1935 } 1959 1936 1960 1937 // TODO: don't return voided patients 1961 public PatientSet getPatientsHavingDrugOrder(1938 public Cohort getPatientsHavingDrugOrder( 1962 1939 List<Drug> drugList, List<Concept> drugConceptList, 1963 1940 Date startDateFrom, Date startDateTo, … … 2047 2024 } 2048 2025 2049 PatientSet ps = new PatientSet(); 2050 ps.copyPatientIds(query.list()); 2051 return ps; 2026 return new Cohort(query.list()); 2052 2027 } 2053 2028 … … 2061 2036 */ 2062 2037 @SuppressWarnings("unchecked") 2063 public Map<Integer, PatientIdentifier> getPatientIdentifierByType( PatientSet patients, List<PatientIdentifierType> types) {2038 public Map<Integer, PatientIdentifier> getPatientIdentifierByType(Cohort patients, List<PatientIdentifierType> types) { 2064 2039 Map<Integer, PatientIdentifier> patientIdentifiers = new HashMap<Integer, PatientIdentifier>(); 2065 2040 … … 2070 2045 // Add patient restriction if necessary 2071 2046 if (patients != null) 2072 criteria.add(Restrictions.in("patient.personId", patients.get PatientIds()));2047 criteria.add(Restrictions.in("patient.personId", patients.getMemberIds())); 2073 2048 2074 2049 // all identifiers must be non-voided