diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json
index 32403e757..4980bf23c 100644
--- a/packages/openchs-android/package-lock.json
+++ b/packages/openchs-android/package-lock.json
@@ -34,7 +34,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
- "openchs-models": "1.31.26",
+ "openchs-models": "1.31.33",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
@@ -72,7 +72,7 @@
"realm": "11.8.0",
"redux": "4.2.0",
"rn-fetch-blob": "0.13.0-beta-1",
- "rules-config": "github:openchs/rules-config#fe552da405368bfd138e2f38e605c1d307e3ebe4",
+ "rules-config": "github:openchs/rules-config#982bb007c4f759639063159196edee386b48cac3",
"stacktrace-js": "2.0.2",
"transducers-js": "0.4.174",
"uuid": "^9.0.1"
@@ -16439,9 +16439,9 @@
}
},
"node_modules/openchs-models": {
- "version": "1.31.26",
- "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.26.tgz",
- "integrity": "sha512-/kEq646aut4gqxCEs3hw3e6ZNIS6gVVCEfmFgl2cHQPCFzwr+ySY2n1MABALbDVBuxl66C3iRBZY76UXDAMLGg==",
+ "version": "1.31.33",
+ "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.33.tgz",
+ "integrity": "sha512-5lBx6strH9Y3c3SXeG4FremioAED5eWYsyQ5SNeB+2z5xnsC07yuIMYKdUZv/VGpjN+lnNImmAJ6IF/Zkagnyw==",
"dependencies": {
"uuid": "^9.0.1"
},
@@ -19269,8 +19269,8 @@
},
"node_modules/rules-config": {
"version": "0.0.1",
- "resolved": "git+ssh://git@github.com/openchs/rules-config.git#fe552da405368bfd138e2f38e605c1d307e3ebe4",
- "integrity": "sha512-SM3+9ZMkwOmwdUIUxyqmJCQGK13MHZv191JM+Ws4RDynXXTV1QqKUKxscoJV/HnMtT4hWqnL8o3uI37xEtN/1Q==",
+ "resolved": "git+ssh://git@github.com/openchs/rules-config.git#982bb007c4f759639063159196edee386b48cac3",
+ "integrity": "sha512-xjAk3BmIQRDxEsrYWAtlpt+LDC1o7dBGMIFYU3dNRK8bqUkBUQ5bJaszro8Fdoa7ObpcXoqDHEUwRguL7zhexQ==",
"license": "AGPL-3.0",
"peerDependencies": {
"lodash": "*",
@@ -35170,9 +35170,9 @@
}
},
"openchs-models": {
- "version": "1.31.26",
- "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.26.tgz",
- "integrity": "sha512-/kEq646aut4gqxCEs3hw3e6ZNIS6gVVCEfmFgl2cHQPCFzwr+ySY2n1MABALbDVBuxl66C3iRBZY76UXDAMLGg==",
+ "version": "1.31.33",
+ "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.33.tgz",
+ "integrity": "sha512-5lBx6strH9Y3c3SXeG4FremioAED5eWYsyQ5SNeB+2z5xnsC07yuIMYKdUZv/VGpjN+lnNImmAJ6IF/Zkagnyw==",
"requires": {
"uuid": "^9.0.1"
}
@@ -37401,9 +37401,9 @@
}
},
"rules-config": {
- "version": "git+ssh://git@github.com/openchs/rules-config.git#fe552da405368bfd138e2f38e605c1d307e3ebe4",
- "integrity": "sha512-SM3+9ZMkwOmwdUIUxyqmJCQGK13MHZv191JM+Ws4RDynXXTV1QqKUKxscoJV/HnMtT4hWqnL8o3uI37xEtN/1Q==",
- "from": "rules-config@github:openchs/rules-config#fe552da405368bfd138e2f38e605c1d307e3ebe4"
+ "version": "git+ssh://git@github.com/openchs/rules-config.git#982bb007c4f759639063159196edee386b48cac3",
+ "integrity": "sha512-xjAk3BmIQRDxEsrYWAtlpt+LDC1o7dBGMIFYU3dNRK8bqUkBUQ5bJaszro8Fdoa7ObpcXoqDHEUwRguL7zhexQ==",
+ "from": "rules-config@github:openchs/rules-config#982bb007c4f759639063159196edee386b48cac3"
},
"run-parallel-limit": {
"version": "1.1.0",
diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json
index 1b9807335..5d0a310dc 100644
--- a/packages/openchs-android/package.json
+++ b/packages/openchs-android/package.json
@@ -58,7 +58,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
- "openchs-models": "1.31.29",
+ "openchs-models": "1.31.33",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
@@ -96,7 +96,7 @@
"realm": "11.8.0",
"redux": "4.2.0",
"rn-fetch-blob": "0.13.0-beta-1",
- "rules-config": "github:openchs/rules-config#fe552da405368bfd138e2f38e605c1d307e3ebe4",
+ "rules-config": "github:openchs/rules-config#982bb007c4f759639063159196edee386b48cac3",
"stacktrace-js": "2.0.2",
"transducers-js": "0.4.174",
"uuid": "^9.0.1"
diff --git a/packages/openchs-android/src/action/individual/IndividualRegistrationDetailsActions.js b/packages/openchs-android/src/action/individual/IndividualRegistrationDetailsActions.js
index edb2c1bf1..30819b4e6 100644
--- a/packages/openchs-android/src/action/individual/IndividualRegistrationDetailsActions.js
+++ b/packages/openchs-android/src/action/individual/IndividualRegistrationDetailsActions.js
@@ -10,6 +10,7 @@ import SubjectProgramEligibilityService from "../../service/program/SubjectProgr
import EntityService from "../../service/EntityService";
import FormMappingService from "../../service/FormMappingService";
import GroupAffiliationState from '../../state/GroupAffiliationState';
+import {EditFormRuleResponse} from "rules-config";
class IndividualRegistrationDetailsActions {
static getInitialState() {
@@ -17,7 +18,8 @@ class IndividualRegistrationDetailsActions {
expand: false,
subjectProgramEligibilityStatuses: [],
displayIndicator: false,
- groupAffiliationState: new GroupAffiliationState()
+ groupAffiliationState: new GroupAffiliationState(),
+ editFormRuleResponse: EditFormRuleResponse.createEditAllowedResponse()
};
}
@@ -42,10 +44,22 @@ class IndividualRegistrationDetailsActions {
subjectSummary,
isRelationshipTypePresent: individualRelationGenderMappings.length > 0,
subjectProgramEligibilityStatuses,
- groupAffiliation: groupAffiliationState
+ groupAffiliation: groupAffiliationState,
+ editFormRuleResponse: EditFormRuleResponse.createEditAllowedResponse()
};
}
+ static onEditStart(state, action, context) {
+ const registrationForm = context.get(FormMappingService).findRegistrationForm(state.individual.subjectType);
+ const editFormRuleResponse = context.get(RuleEvaluationService).runEditFormRule(registrationForm, state.individual, 'Individual');
+ const newState = {...state};
+ if (editFormRuleResponse.isEditAllowed())
+ action.formEditAllowed();
+ else
+ newState.editFormRuleResponse = editFormRuleResponse;
+ return newState;
+ }
+
static onDeleteRelative(state, action, context) {
context.get(IndividualRelationshipService).deleteRelative(action.individualRelative);
const relatives = context.get(IndividualRelationshipService).getRelatives(state.individual);
@@ -130,7 +144,6 @@ class IndividualRegistrationDetailsActions {
}
});
}
-
}
const IndividualRegistrationDetailsActionsNames = {
@@ -140,6 +153,7 @@ const IndividualRegistrationDetailsActionsNames = {
ON_TOGGLE: "IRDA.ON_TOGGLE",
ON_SUBJECT_PROGRAM_ELIGIBILITY_CHECK: "IRDA.ON_SUBJECT_PROGRAM_ELIGIBILITY_CHECK",
ON_DISPLAY_INDICATOR_TOGGLE: "IRDA.ON_DISPLAY_INDICATOR_TOGGLE",
+ ON_EDIT_START: "IRDA.ON_EDIT_START"
};
const IndividualRegistrationDetailsActionsMap = new Map([
@@ -149,6 +163,7 @@ const IndividualRegistrationDetailsActionsMap = new Map([
[IndividualRegistrationDetailsActionsNames.ON_TOGGLE, IndividualRegistrationDetailsActions.onToggle],
[IndividualRegistrationDetailsActionsNames.ON_SUBJECT_PROGRAM_ELIGIBILITY_CHECK, IndividualRegistrationDetailsActions.onSubjectProgramEligibilityCheck],
[IndividualRegistrationDetailsActionsNames.ON_DISPLAY_INDICATOR_TOGGLE, IndividualRegistrationDetailsActions.onDisplayIndicatorToggle],
+ [IndividualRegistrationDetailsActionsNames.ON_EDIT_START, IndividualRegistrationDetailsActions.onEditStart],
]);
export {
diff --git a/packages/openchs-android/src/model/Rules.js b/packages/openchs-android/src/model/Rules.js
deleted file mode 100644
index 372425415..000000000
--- a/packages/openchs-android/src/model/Rules.js
+++ /dev/null
@@ -1,9 +0,0 @@
-class Rules {
- constructor() {
-
- }
-
- registrationDecisions() {
-
- }
-}
\ No newline at end of file
diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js
index 1c2cc3fc0..48215f2ab 100644
--- a/packages/openchs-android/src/service/RuleEvaluationService.js
+++ b/packages/openchs-android/src/service/RuleEvaluationService.js
@@ -42,7 +42,10 @@ import ProgramService from "./program/ProgramService";
import individualServiceFacade from "./facade/IndividualServiceFacade";
import addressLevelServiceFacade from "./facade/AddressLevelServiceFacade";
import MessageService from './MessageService';
-import {JSONStringify} from '../utility/JsonStringify';
+import {Groups} from "openchs-models";
+import {JSONStringify} from "../utility/JsonStringify";
+import UserInfoService from "./UserInfoService";
+import {EditFormRuleResponse} from "rules-config";
function getImports() {
return {rulesConfig, common, lodash, moment, motherCalculations, log: console.log};
@@ -88,7 +91,7 @@ class RuleEvaluationService extends BaseService {
}
}
- getIndividualUUID = (entity, entityName) => {
+ getIndividualUUID(entity, entityName) {
switch (entityName) {
case 'Individual':
return entity.uuid;
@@ -136,9 +139,9 @@ class RuleEvaluationService extends BaseService {
General.logDebug("RuleEvaluationService", trimmedDecisions);
return trimmedDecisions;
} catch (e) {
- General.logDebug("RuleEvaluationService",`form.uuid: ${form.uuid} entityName: ${entityName}`);
+ General.logDebug("RuleEvaluationService", `form.uuid: ${form.uuid} entityName: ${entityName}`);
this.saveFailedRules(e, form.uuid, individualUUID,
- 'Decision', form.uuid, entityName, entity.uuid);
+ 'Decision', form.uuid, entityName, entity.uuid);
}
} else {
const decisionsMap = rulesFromTheBundle.reduce((decisions, rule) => {
@@ -185,7 +188,7 @@ class RuleEvaluationService extends BaseService {
return true;
} catch (error) {
this.saveFailedRules(error, ruleUUID, individualUUID,
- 'Validation', ruleUUID, 'Individual', individualUUID);
+ 'Validation', ruleUUID, 'Individual', individualUUID);
return false;
}
}
@@ -210,7 +213,7 @@ class RuleEvaluationService extends BaseService {
} catch (e) {
General.logDebug("Rule-Failure", `New worklist updation rule failed ${orgConfig.uuid} `);
this.saveFailedRules(e, orgConfig.uuid, this.getIndividualUUID(workLists, "WorkList"),
- 'WorkListUpdation', orgConfig.uuid, entityName, context.entity.uuid);
+ 'WorkListUpdation', orgConfig.uuid, entityName, context.entity.uuid);
}
} else {
const additionalRules = this.getService(RuleService).getRulesByType('WorkListUpdation');
@@ -220,6 +223,27 @@ class RuleEvaluationService extends BaseService {
return workLists;
}
+ runEditFormRule(form, entity, entityName) {
+ const user = this.getService(UserInfoService).getUserInfo();
+ const userGroups = this.getService(EntityService).loadAll(Groups.schema.name);
+ if (_.isEmpty(form.editFormRule)) {
+ return EditFormRuleResponse.createEditAllowedResponse();
+ } else {
+ try {
+ const ruleFunc = eval(form.editFormRule);
+ const ruleResponse = ruleFunc({
+ params: {entity, form, services: this.services, user, myUserGroups: userGroups},
+ imports: getImports()
+ });
+ return EditFormRuleResponse.createEditRuleResponse(ruleResponse);
+ } catch (e) {
+ General.logDebug("Rule-Failure", `EditFormRule failed: ${JSONStringify(e)}`);
+ this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName), 'EditForm', form.uuid, entityName, entity.uuid);
+ return EditFormRuleResponse.createEditAllowedResponse();
+ }
+ }
+ }
+
runRuleAndSaveFailure(rule, entityName, entity, ruleTypeValue, config, context, entityContext) {
try {
if (entityName === 'WorkList') {
@@ -233,7 +257,7 @@ class RuleEvaluationService extends BaseService {
} catch (error) {
General.logDebug("Rule-Failure", `Rule failed: ${rule.name}, uuid: ${rule.uuid}`);
this.saveFailedRules(error, rule.uuid, this.getIndividualUUID(entity, entityName),
- 'Decision', rule.uuid, entityName, entity.uuid);
+ 'Decision', rule.uuid, entityName, entity.uuid);
return ruleTypeValue;
}
}
@@ -277,7 +301,7 @@ class RuleEvaluationService extends BaseService {
return this.entityRulesMap.get(entityName).getEnrolmentSummary(enrolment, context);
} catch (error) {
this.saveFailedRules(error, '', this.getIndividualUUID(enrolment, entityName),
- 'EnrolmentSummary', enrolment.program.uuid, entityName, enrolment.uuid);
+ 'EnrolmentSummary', enrolment.program.uuid, entityName, enrolment.uuid);
return [];
}
}
@@ -312,7 +336,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Failure",
`Subject Summary Rule failed for: ${subjectType.name} Subject type`);
this.saveFailedRules(e, subjectType.uuid, this.getIndividualUUID(individual, entityName),
- 'SubjectSummary', subjectType.uuid, entityName, individual.uuid);
+ 'SubjectSummary', subjectType.uuid, entityName, individual.uuid);
return [];
}
}
@@ -344,7 +368,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Failure",
`Subject Program Eligibility Rule failed for: ${subjectType.name} Subject type ${e.message} ${e.stack}`);
this.saveFailedRules(e, subjectType.uuid, this.getIndividualUUID(individual, 'Individual'),
- 'EnrolmentEligibilityCheck', subjectType.uuid, 'Individual', individual.uuid);
+ 'EnrolmentEligibilityCheck', subjectType.uuid, 'Individual', individual.uuid);
throw Error(e.message);
}
}
@@ -383,7 +407,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Failure",
`New Enrolment Summary Rule failed for: ${enrolment.program.name} program`);
this.saveFailedRules(e, program.uuid, this.getIndividualUUID(enrolment, entityName),
- 'EnrolmentSummary', program.uuid, entityName, enrolment.uuid);
+ 'EnrolmentSummary', program.uuid, entityName, enrolment.uuid);
return [];
}
}
@@ -404,7 +428,7 @@ class RuleEvaluationService extends BaseService {
console.log(e);
General.logDebug("Rule-Failure", `Validation failed for: ${form.name} form name`);
this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName),
- 'Validation', form.uuid, entityName, entity.uuid);
+ 'Validation', form.uuid, entityName, entity.uuid);
}
} else if (!_.isEmpty(rulesFromTheBundle)) {
const validationErrors = rulesFromTheBundle.reduce(
@@ -463,7 +487,7 @@ class RuleEvaluationService extends BaseService {
} catch (e) {
General.logDebug("Rule-Failure", `New checklist rule failed for form: ${form.uuid}`);
this.saveFailedRules(e, form.uuid, this.getIndividualUUID(entity, entityName),
- 'Checklist', form.uuid, entityName, entity.uuid);
+ 'Checklist', form.uuid, entityName, entity.uuid);
}
} else {
const allChecklists = this.getAllRuleItemsFor(form, "Checklists", "Form")
@@ -500,7 +524,7 @@ class RuleEvaluationService extends BaseService {
} catch (e) {
General.logDebug("Rule-Failure", `New form element group rule failed for: ${formElementGroup.uuid}`);
this.saveFailedRules(e, formElementGroup.uuid, this.getIndividualUUID(entity, entityName),
- 'FormElementGroup', formElementGroup.uuid, entityName, entity.uuid);
+ 'FormElementGroup', formElementGroup.uuid, entityName, entity.uuid);
}
}
@@ -588,7 +612,7 @@ class RuleEvaluationService extends BaseService {
} catch (e) {
General.logDebug("Rule-Failure", `New Rule failed for: ${formElement.name}`);
this.saveFailedRules(e, formElement.uuid, this.getIndividualUUID(entity, entityName),
- 'FormElement', formElement.uuid, entityName, entity.uuid);
+ 'FormElement', formElement.uuid, entityName, entity.uuid);
return null;
}
}
@@ -630,7 +654,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Faiure", e);
General.logDebug("Rule-Failure", `New encounter eligibility failed for: ${encounterType.name} encounter name`);
this.saveFailedRules(e, encounterType.uuid, individual.uuid,
- 'EncounterEligibilityCheck', encounterType.uuid, 'Individual', individual.uuid);
+ 'EncounterEligibilityCheck', encounterType.uuid, 'Individual', individual.uuid);
}
} else if (!_.isEmpty(rulesFromTheBundle)) {
return this.runRuleAndSaveFailure(_.last(rulesFromTheBundle), 'Encounter', {individual}, true);
@@ -653,7 +677,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Failure", e);
General.logDebug("Rule-Failure", `New enrolment eligibility failed for: ${program.name} program name`);
this.saveFailedRules(e, program.uuid, individual.uuid,
- 'EnrolmentEligibilityCheck', program.uuid, 'Individual', individual.uuid);
+ 'EnrolmentEligibilityCheck', program.uuid, 'Individual', individual.uuid);
}
} else if (!_.isEmpty(rulesFromTheBundle)) {
return this.runRuleAndSaveFailure(_.last(rulesFromTheBundle), 'Encounter', {individual}, true);
@@ -674,7 +698,7 @@ class RuleEvaluationService extends BaseService {
General.logDebug("Rule-Failure", e);
General.logDebug("Rule-Failure", `Manual enrolment eligibility failed for: ${program.name} program name`);
this.saveFailedRules(e, program.uuid, subject.uuid,
- 'ManualEnrolmentEligibilityCheckRule', program.uuid, 'Individual', subject.uuid);
+ 'ManualEnrolmentEligibilityCheckRule', program.uuid, 'Individual', subject.uuid);
}
}
@@ -693,7 +717,7 @@ class RuleEvaluationService extends BaseService {
General.logError("Rule-Failure", `DashboardCard report card rule failed for uuid: ${reportCard.uuid}, name: ${reportCard.name}`);
General.logError("Rule-Failure", error);
this.saveFailedRules(error, reportCard.uuid, '',
- 'ReportCard', reportCard.uuid, null, null);
+ 'ReportCard', reportCard.uuid, null, null);
return {
hasErrorMsg: true,
primaryValue: this.I18n.t("Error"),
@@ -710,7 +734,7 @@ class RuleEvaluationService extends BaseService {
getDashboardCardCount(reportCard, ruleInput) {
const queryResult = this.executeDashboardCardRule(reportCard, ruleInput);
- if(queryResult.hasErrorMsg) {
+ if (queryResult.hasErrorMsg) {
return this.createErrorResponse(reportCard, queryResult);
}
if (this.isOldStyleQueryResult(queryResult)) {
@@ -761,7 +785,7 @@ class RuleEvaluationService extends BaseService {
return queryResult;
} else if (reportCard.nested) {
return _.flatMap(queryResult.reportCards, (reportCardResultsItr, index) => (
- reportCard.itemKey === reportCard.getCardId(index) && _.isFunction(reportCardResultsItr.lineListFunction) ? reportCardResultsItr.lineListFunction() : []
+ reportCard.itemKey === reportCard.getCardId(index) && _.isFunction(reportCardResultsItr.lineListFunction) ? reportCardResultsItr.lineListFunction() : []
));
} else {
return _.isFunction(queryResult.lineListFunction) ? queryResult.lineListFunction() : null;
diff --git a/packages/openchs-android/src/views/common/IndividualProfile.js b/packages/openchs-android/src/views/common/IndividualProfile.js
index 38f632b59..cbf517ab2 100644
--- a/packages/openchs-android/src/views/common/IndividualProfile.js
+++ b/packages/openchs-android/src/views/common/IndividualProfile.js
@@ -235,7 +235,7 @@ class IndividualProfile extends AbstractComponent {
const textColor = this.props.textColor ? this.props.textColor : Styles.blackColor;
let isPerson = this.props.individual.subjectType.isPerson();
let headingSuffixesList = [this.props.individual.fullAddress(this.I18n)]
- if(isPerson) {
+ if (isPerson) {
headingSuffixesList.unshift(this.props.individual.userProfileSubtext2(this.I18n)); //localized Age
headingSuffixesList.unshift(this.props.individual.userProfileSubtext1(this.I18n)); //localized Gender
}
@@ -306,7 +306,7 @@ class IndividualProfile extends AbstractComponent {
{this.props.individual.nameString}
- {headingSuffix}
+ {headingSuffix}
)}
;
@@ -315,8 +315,6 @@ class IndividualProfile extends AbstractComponent {
launchChooseProgram() {
this.dispatchAction(Actions.LAUNCH_ACTION_SELECTOR);
}
-
-
}
export default IndividualProfile;
diff --git a/packages/openchs-android/src/views/individual/SubjectDashboardProfileTab.js b/packages/openchs-android/src/views/individual/SubjectDashboardProfileTab.js
index caf13ae16..4c746d756 100644
--- a/packages/openchs-android/src/views/individual/SubjectDashboardProfileTab.js
+++ b/packages/openchs-android/src/views/individual/SubjectDashboardProfileTab.js
@@ -1,4 +1,4 @@
-import {Alert, StyleSheet, Text, TouchableOpacity, View} from "react-native";
+import {Alert, StyleSheet, Text, ToastAndroid, TouchableOpacity, View} from "react-native";
import PropTypes from 'prop-types';
import React from "react";
import AbstractComponent from "../../framework/view/AbstractComponent";
@@ -39,7 +39,6 @@ import SubjectProgramEligibilityWidget from "./SubjectProgramEligibilityWidget";
import CustomActivityIndicator from "../CustomActivityIndicator";
import GroupSubjectService from "../../service/GroupSubjectService";
import UserInfoService from "../../service/UserInfoService";
-import I18n from "i18n-js";
class SubjectDashboardProfileTab extends AbstractComponent {
static propTypes = {
@@ -128,14 +127,18 @@ class SubjectDashboardProfileTab extends AbstractComponent {
editProfile() {
logEvent(firebaseEvents.EDIT_SUBJECT);
- CHSNavigator.navigateToRegisterView(this, {
- workLists: new WorkLists(
- new WorkList(`${this.state.individual.subjectType.name} `,
- [new WorkItem(General.randomUUID(), WorkItem.type.REGISTRATION,
- {
- uuid: this.state.individual.uuid,
- subjectTypeName: this.state.individual.subjectType.name
- })]))
+ this.dispatchAction(Actions.ON_EDIT_START, {
+ formEditAllowed: () => {
+ CHSNavigator.navigateToRegisterView(this, {
+ workLists: new WorkLists(
+ new WorkList(`${this.state.individual.subjectType.name} `,
+ [new WorkItem(General.randomUUID(), WorkItem.type.REGISTRATION,
+ {
+ uuid: this.state.individual.uuid,
+ subjectTypeName: this.state.individual.subjectType.name
+ })]))
+ });
+ }
});
}
@@ -345,29 +348,31 @@ class SubjectDashboardProfileTab extends AbstractComponent {
render() {
General.logDebug(this.viewName(), 'render');
const displayGeneralEncounterInfo = this.props.params.displayGeneralInfoInProfileTab;
- const relativesFeatureToggle = this.state.individual.isPerson() && this.state.isRelationshipTypePresent;
- const groupSubjectToggle = this.state.individual.subjectType.isGroup();
+ const {individual, editFormRuleResponse, isRelationshipTypePresent, displayIndicator, subjectProgramEligibilityStatuses} = this.state;
+ const relativesFeatureToggle = individual.isPerson() && isRelationshipTypePresent;
+ const groupSubjectToggle = individual.subjectType.isGroup();
return (
-
+
this.dispatchAsyncAction(Actions.ON_SUBJECT_PROGRAM_ELIGIBILITY_CHECK, {subjectProgramEligibilityStatuses})}
onManualProgramEligibilityPress={_.noop}
onDisplayIndicatorToggle={(display) => this.dispatchAction(Actions.ON_DISPLAY_INDICATOR_TOGGLE, {display})}
/>
{!_.isEmpty(this.state.subjectSummary) && this.renderSummary()}
- {this.state.individual.voided ? this.renderVoided() : this.renderProfile()}
+ {individual.voided ? this.renderVoided() : this.renderProfile()}
{relativesFeatureToggle ? this.renderRelatives() : }
{groupSubjectToggle ? this.renderMembers() : }
{displayGeneralEncounterInfo && }
+ {editFormRuleResponse.isEditDisallowed() && ToastAndroid.show(editFormRuleResponse.getMessageKey(), ToastAndroid.SHORT)}
);
}