Skip to content

Commit

Permalink
avniproject/avni-product#1453 | Display planned encounters / registra…
Browse files Browse the repository at this point in the history
…tion details based on subject type settings
  • Loading branch information
1t5j0y committed Mar 11, 2024
1 parent a8af46e commit 986d545
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 43 deletions.
14 changes: 7 additions & 7 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
"openchs-models": "1.31.44",
"openchs-models": "1.31.46",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ActionSelector from "../common/ActionSelector";
import PrivilegeService from "../../service/PrivilegeService";
import NewFormButton from "../common/NewFormButton";
import AvniToast from "../common/AvniToast";
import {SubjectType} from "openchs-models";

class SubjectDashboardGeneralTab extends AbstractComponent {
static propTypes = {
Expand Down Expand Up @@ -64,23 +65,25 @@ class SubjectDashboardGeneralTab extends AbstractComponent {
}

renderPlannedVisits() {
const scheduledEncounters = _.filter(_.map(this.state.encounters, 'encounter'), (encounter) => !encounter.encounterDateTime && !encounter.cancelDateTime);
const cancelVisitCriteria = `privilege.name = '${Privilege.privilegeName.cancelVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND programUuid = null AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const allowedEncounterTypeUuidsForCancelVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(cancelVisitCriteria, 'encounterTypeUuid');
const performVisitCriteria = `privilege.name = '${Privilege.privilegeName.performVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND programUuid = null AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const allowedEncounterTypeUuidsForPerformVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(performVisitCriteria, 'encounterTypeUuid');
return (<PreviousEncounters encounters={scheduledEncounters}
allowedEncounterTypeUuidsForCancelVisit={allowedEncounterTypeUuidsForCancelVisit}
allowedEncounterTypeUuidsForPerformVisit={allowedEncounterTypeUuidsForPerformVisit}
formType={Form.formTypes.Encounter}
style={{marginBottom: 21}}
showPartial={false}
showCount={this.state.showCount}
title={this.I18n.t('visitsPlanned')}
emptyTitle={this.I18n.t('noPlannedEncounters')}
expandCollapseView={false}
subjectInfo={this.state.individual.name}
/>);
if (this.state.individual.subjectType.getSetting(SubjectType.settingKeys.displayPlannedEncounters) !== false) {
const scheduledEncounters = _.filter(_.map(this.state.encounters, 'encounter'), (encounter) => !encounter.encounterDateTime && !encounter.cancelDateTime);
const cancelVisitCriteria = `privilege.name = '${Privilege.privilegeName.cancelVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND programUuid = null AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const allowedEncounterTypeUuidsForCancelVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(cancelVisitCriteria, 'encounterTypeUuid');
const performVisitCriteria = `privilege.name = '${Privilege.privilegeName.performVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND programUuid = null AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const allowedEncounterTypeUuidsForPerformVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(performVisitCriteria, 'encounterTypeUuid');
return (<PreviousEncounters encounters={scheduledEncounters}
allowedEncounterTypeUuidsForCancelVisit={allowedEncounterTypeUuidsForCancelVisit}
allowedEncounterTypeUuidsForPerformVisit={allowedEncounterTypeUuidsForPerformVisit}
formType={Form.formTypes.Encounter}
style={{ marginBottom: 21 }}
showPartial={false}
showCount={this.state.showCount}
title={this.I18n.t('visitsPlanned')}
emptyTitle={this.I18n.t('noPlannedEncounters')}
expandCollapseView={false}
subjectInfo={this.state.individual.name}
/>);
}
}

renderCompletedVisits() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import CustomActivityIndicator from "../CustomActivityIndicator";
import GroupSubjectService from "../../service/GroupSubjectService";
import UserInfoService from "../../service/UserInfoService";
import AvniToast from "../common/AvniToast";
import {SubjectType} from "openchs-models";

class SubjectDashboardProfileTab extends AbstractComponent {
static propTypes = {
Expand Down Expand Up @@ -334,6 +335,14 @@ class SubjectDashboardProfileTab extends AbstractComponent {
</View>
}

renderProfileOrVoided(individual) {
if (individual.subjectType.getSetting(SubjectType.settingKeys.displayRegistrationDetails) !== false) {
return <View style={styles.container}>
{individual.voided ? this.renderVoided() : this.renderProfile()}
</View>
}
}

renderSummary() {
return <View style={{
padding: Distances.ScaledContentDistanceFromEdge,
Expand Down Expand Up @@ -369,9 +378,7 @@ class SubjectDashboardProfileTab extends AbstractComponent {
onDisplayIndicatorToggle={(display) => this.dispatchAction(Actions.ON_DISPLAY_INDICATOR_TOGGLE, {display})}
/>
{!_.isEmpty(this.state.subjectSummary) && this.renderSummary()}
<View style={styles.container}>
{individual.voided ? this.renderVoided() : this.renderProfile()}
</View>
{this.renderProfileOrVoided(individual)}
{relativesFeatureToggle ? this.renderRelatives() : <View/>}
{groupSubjectToggle ? this.renderMembers() : <View/>}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Icon from 'react-native-vector-icons/SimpleLineIcons'
import Separator from "../primitives/Separator";
import UserInfoService from "../../service/UserInfoService";
import AvniToast from "../common/AvniToast";
import {SubjectType} from "openchs-models";

class SubjectDashboardProgramsTab extends AbstractComponent {
static propTypes = {
Expand Down Expand Up @@ -147,21 +148,23 @@ class SubjectDashboardProgramsTab extends AbstractComponent {
}

renderPlannedVisits(allowedEncounterTypeUuids) {
const cancelEncounterCriteria = `privilege.name = '${Privilege.privilegeName.cancelVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND subjectTypeUuid = '${this.state.enrolment.individual.subjectType.uuid}' AND programUuid = '${this.state.enrolment.program.uuid}'`;
const allowedEncounterTypeUuidsForCancelVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(cancelEncounterCriteria, 'programEncounterTypeUuid');
const programEnrolment = this.state.enrolment;
const scheduledEncounters = _.filter(programEnrolment.nonVoidedEncounters(), (encounter) => !encounter.encounterDateTime && !encounter.cancelDateTime);
return (<PreviousEncounters encounters={scheduledEncounters}
allowedEncounterTypeUuidsForCancelVisit={allowedEncounterTypeUuidsForCancelVisit}
allowedEncounterTypeUuidsForPerformVisit={allowedEncounterTypeUuids}
formType={Form.formTypes.ProgramEncounter}
showCount={this.state.showCount}
showPartial={false}
title={this.I18n.t('visitsPlanned')}
emptyTitle={this.I18n.t('noPlannedEncounters')}
subjectInfo={`${programEnrolment.individual.name}, ${programEnrolment.program.displayName}`}
expandCollapseView={false}
/>);
if (this.state.enrolment.individual.subjectType.getSetting(SubjectType.settingKeys.displayPlannedEncounters) !== false) {
const cancelEncounterCriteria = `privilege.name = '${Privilege.privilegeName.cancelVisit}' AND privilege.entityType = '${Privilege.privilegeEntityType.encounter}' AND subjectTypeUuid = '${this.state.enrolment.individual.subjectType.uuid}' AND programUuid = '${this.state.enrolment.program.uuid}'`;
const allowedEncounterTypeUuidsForCancelVisit = this.privilegeService.allowedEntityTypeUUIDListForCriteria(cancelEncounterCriteria, 'programEncounterTypeUuid');
const programEnrolment = this.state.enrolment;
const scheduledEncounters = _.filter(programEnrolment.nonVoidedEncounters(), (encounter) => !encounter.encounterDateTime && !encounter.cancelDateTime);
return (<PreviousEncounters encounters={scheduledEncounters}
allowedEncounterTypeUuidsForCancelVisit={allowedEncounterTypeUuidsForCancelVisit}
allowedEncounterTypeUuidsForPerformVisit={allowedEncounterTypeUuids}
formType={Form.formTypes.ProgramEncounter}
showCount={this.state.showCount}
showPartial={false}
title={this.I18n.t('visitsPlanned')}
emptyTitle={this.I18n.t('noPlannedEncounters')}
subjectInfo={`${programEnrolment.individual.name}, ${programEnrolment.program.displayName}`}
expandCollapseView={false}
/>);
}
}

renderCompletedVisits() {
Expand Down

0 comments on commit 986d545

Please sign in to comment.