| 75 | | public Cohort(Set<Integer> memberIds) { |
|---|
| 76 | | this.memberIds = memberIds; |
|---|
| 77 | | } |
|---|
| 78 | | |
|---|
| 79 | | public Cohort(Collection<Integer> memberIds) { |
|---|
| 80 | | this.memberIds = new HashSet<Integer>(); |
|---|
| 81 | | this.memberIds.addAll(memberIds); |
|---|
| 82 | | } |
|---|
| 83 | | |
|---|
| | 78 | /** |
|---|
| | 79 | * This constructor does not check whether the database contains patients with the given ids, but @see CohortService.saveCohort(Cohort) will. |
|---|
| | 80 | * @param name |
|---|
| | 81 | * @param description optional description |
|---|
| | 82 | * @param ids option array of Integer ids |
|---|
| | 83 | */ |
|---|
| | 84 | public Cohort(String name, String description, Integer[] ids) { |
|---|
| | 85 | this.name = name; |
|---|
| | 86 | this.description = description; |
|---|
| | 87 | memberIds = new HashSet<Integer>(); |
|---|
| | 88 | if (ids != null) |
|---|
| | 89 | memberIds.addAll(Arrays.asList(ids)); |
|---|
| | 90 | } |
|---|
| | 91 | |
|---|
| | 92 | /** |
|---|
| | 93 | * This constructor does not check whether the database contains patients with the given ids, but @see CohortService.saveCohort(Cohort) will. |
|---|
| | 94 | * @param name |
|---|
| | 95 | * @param description optional description |
|---|
| | 96 | * @param patients optional array of patients |
|---|
| | 97 | */ |
|---|
| | 98 | public Cohort(String name, String description, Patient[] patients) { |
|---|
| | 99 | this.name = name; |
|---|
| | 100 | this.description = description; |
|---|
| | 101 | memberIds = new HashSet<Integer>(); |
|---|
| | 102 | if (patients != null) |
|---|
| | 103 | for (Patient p : patients) |
|---|
| | 104 | memberIds.add(p.getPatientId()); |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| | 107 | /** |
|---|
| | 108 | * This constructor does not check whether the database contains patients with the given ids, but @see CohortService.saveCohort(Cohort) will. |
|---|
| | 109 | * @param patientsOrIds optional collection which may contain Patients, or patientIds which may be Integers, Strings, or anything whose toString() can be parsed to an Integer. |
|---|
| | 110 | */ |
|---|
| | 111 | public Cohort(Collection patientsOrIds) { |
|---|
| | 112 | this(null, null, patientsOrIds); |
|---|
| | 113 | } |
|---|
| | 114 | |
|---|
| | 115 | /** |
|---|
| | 116 | * This constructor does not check whether the database contains patients with the given ids, but @see CohortService.saveCohort(Cohort) will. |
|---|
| | 117 | * @param name |
|---|
| | 118 | * @param description optional description |
|---|
| | 119 | * @param patientsOrIds optional collection which may contain Patients, or patientIds which may be Integers, Strings, or anything whose toString() can be parsed to an Integer. |
|---|
| | 120 | */ |
|---|
| | 121 | public Cohort(String name, String description, Collection patientsOrIds) { |
|---|
| | 122 | this.name = name; |
|---|
| | 123 | this.description = description; |
|---|
| | 124 | memberIds = new HashSet<Integer>(); |
|---|
| | 125 | if (patientsOrIds != null) { |
|---|
| | 126 | for (Object o : patientsOrIds) { |
|---|
| | 127 | if (o instanceof Patient) |
|---|
| | 128 | memberIds.add(((Patient) o).getPatientId()); |
|---|
| | 129 | else if (o instanceof Integer) |
|---|
| | 130 | memberIds.add((Integer) o); |
|---|
| | 131 | else |
|---|
| | 132 | memberIds.add(Integer.valueOf(o.toString())); |
|---|
| | 133 | } |
|---|
| | 134 | } |
|---|
| | 135 | } |
|---|
| | 136 | |
|---|
| | 137 | /** |
|---|
| | 138 | * Convenience contructor taking in a string that is a list of comma separated patient ids |
|---|
| | 139 | * This constructor does not check whether the database contains patients with the given ids, but @see CohortService.saveCohort(Cohort) will. |
|---|
| | 140 | * |
|---|
| | 141 | * @param commaSeparatedIds |
|---|
| | 142 | */ |
|---|