Skip to content

Commit 8eb1668

Browse files
committed
#806 allow multiple enrolments. do not show same program twice in search results view even when active
1 parent fc697c7 commit 8eb1668

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/openchs-android/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lodash": "4.17.21",
5151
"moment": "2.29.4",
5252
"native-base": "3.4.9",
53-
"openchs-models": "1.27.14",
53+
"openchs-models": "1.27.17",
5454
"prop-types": "15.8.1",
5555
"react": "18.2.0",
5656
"react-native": "0.69.7",

packages/openchs-android/src/service/IndividualService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class IndividualService extends BaseService {
9696
eligiblePrograms(individualUUID) {
9797
const individual = this.findByUUID(individualUUID);
9898
const programs = this.getService(FormMappingService).findActiveProgramsForSubjectType(individual.subjectType);
99-
const nonEnrolledPrograms = individual.eligiblePrograms(programs);
99+
const nonEnrolledPrograms = individual.staticallyEligiblePrograms(programs);
100100
const ruleEvaluationService = this.getService(RuleEvaluationService);
101101
const enrolProgramCriteria = `privilege.name = '${Privilege.privilegeName.enrolSubject}' AND privilege.entityType = '${Privilege.privilegeEntityType.enrolment}'`;
102102
const privilegeService = this.getService(PrivilegeService);

packages/openchs-android/src/views/common/SubjectInfoCard.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import SubjectProfilePicture from "./SubjectProfilePicture";
88
import OrganisationConfigService from "../../service/OrganisationConfigService";
99
import _ from 'lodash';
1010
import ConceptService from "../../service/ConceptService";
11-
import {Observation} from 'avni-models';
11+
import {Observation, ProgramEnrolment} from 'openchs-models';
1212
import EncounterService from "../../service/EncounterService";
1313
import IndividualService from "../../service/IndividualService";
1414
import AddressLevelService from "../../service/AddressLevelService";
@@ -71,6 +71,9 @@ class SubjectInfoCard extends AbstractComponent {
7171
const i18n = this.I18n;
7272
const conceptService = this.getService(ConceptService);
7373
const iconContainerStyle = {minHeight: 72, alignItems: 'center', justifyContent: 'center'};
74+
const enrolledPrograms = _.filter(this.props.individual.nonVoidedEnrolments(), (enrolment) => enrolment.isActive)
75+
.map((x: ProgramEnrolment) => x.program);
76+
7477
return (
7578
<View style={{
7679
flexDirection: 'row',
@@ -127,7 +130,7 @@ class SubjectInfoCard extends AbstractComponent {
127130
justifyContent: 'flex-end',
128131
flexWrap: 'wrap',
129132
}}>
130-
{_.filter(this.props.individual.nonVoidedEnrolments(), (enrolment) => enrolment.isActive).map((enrolment, index) => this.renderProgram(enrolment.program, index))}
133+
{_.uniqBy(enrolledPrograms, (x) => x.name).map((program, index) => this.renderProgram(program, index))}
131134
</View>}
132135
</View>
133136
</View>

0 commit comments

Comments
 (0)