From aeb34ab5f87daf96a96e6cc10e23c6ad8970f58b Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 31 Oct 2023 17:12:15 +0530 Subject: [PATCH] #1142 - (note this is not in 5.1 release) removed unused code related to health modules and program config. --- packages/openchs-android/package-lock.json | 14 ++--- packages/openchs-android/package.json | 2 +- .../familyFolder/FamilyFolderActions.js | 5 +- .../src/service/FilterService.js | 30 ----------- .../src/service/IndividualService.js | 54 ------------------- .../src/service/ProgramConfigService.js | 9 +--- .../src/state/ProgramEncounterState.js | 7 +-- .../src/state/ProgramEnrolmentState.js | 10 ++-- .../openchs-android/src/views/MenuView.js | 7 --- 9 files changed, 15 insertions(+), 123 deletions(-) delete mode 100644 packages/openchs-android/src/service/FilterService.js diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index 968de237f..a450c5ee5 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -33,7 +33,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.30.81", + "openchs-models": "1.30.84", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", @@ -16431,9 +16431,9 @@ } }, "node_modules/openchs-models": { - "version": "1.30.81", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.81.tgz", - "integrity": "sha512-SIMncoc+5IGYMem864CeiZdvO08RYo+2sMp2RSxwT8divsplwxAk8HlTJsyhmAWHBdGTU0LE8UeeGgJx/EZ66A==", + "version": "1.30.84", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.84.tgz", + "integrity": "sha512-0cekDEsM03D48RIz3cUfJnubvs0MU5GG84gV46MaYnVvCflHC0N8DIOV8n7Dirbu68GS2R8b12lPU9Au9oJ3mw==", "peerDependencies": { "lodash": "*", "moment": "*" @@ -35131,9 +35131,9 @@ } }, "openchs-models": { - "version": "1.30.81", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.81.tgz", - "integrity": "sha512-SIMncoc+5IGYMem864CeiZdvO08RYo+2sMp2RSxwT8divsplwxAk8HlTJsyhmAWHBdGTU0LE8UeeGgJx/EZ66A==" + "version": "1.30.84", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.84.tgz", + "integrity": "sha512-0cekDEsM03D48RIz3cUfJnubvs0MU5GG84gV46MaYnVvCflHC0N8DIOV8n7Dirbu68GS2R8b12lPU9Au9oJ3mw==" }, "opencollective-postinstall": { "version": "2.0.3", diff --git a/packages/openchs-android/package.json b/packages/openchs-android/package.json index a96e01475..ad6ff5a99 100644 --- a/packages/openchs-android/package.json +++ b/packages/openchs-android/package.json @@ -57,7 +57,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.30.81", + "openchs-models": "1.30.84", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", diff --git a/packages/openchs-android/src/action/familyFolder/FamilyFolderActions.js b/packages/openchs-android/src/action/familyFolder/FamilyFolderActions.js index 8a3d97ba0..0070e79b8 100644 --- a/packages/openchs-android/src/action/familyFolder/FamilyFolderActions.js +++ b/packages/openchs-android/src/action/familyFolder/FamilyFolderActions.js @@ -42,10 +42,7 @@ class FamilyFolderActions { static onListLoad(state, action, context) { const familyService = context.get(FamilyService); const methodMap = new Map([ - ["all", familyService.allFamiliesIn], - // ["withHighRiskMember", familyService.allOverdueVisitsIn], - // ["mother", familyService.allCompletedVisitsIn], - // ["child", familyService.allHighRiskPatients] + ["all", familyService.allFamiliesIn] ]); const allFamilies = methodMap.get(action.listType)(action.address, new Date(), new Date()) .map(({uuid}) => familyService.findByUUID(uuid)); diff --git a/packages/openchs-android/src/service/FilterService.js b/packages/openchs-android/src/service/FilterService.js deleted file mode 100644 index 644bc4bd2..000000000 --- a/packages/openchs-android/src/service/FilterService.js +++ /dev/null @@ -1,30 +0,0 @@ -import BaseService from "./BaseService"; -import Service from "../framework/bean/Service"; -import ProgramConfigService from "./ProgramConfigService"; -import IndividualService from "./IndividualService"; -import SingleSelectFilterModel from "../model/SingleSelectFilterModel"; - -@Service("FilterService") -class FilterService extends BaseService { - constructor(db, beanStore) { - super(db, beanStore); - this.filters = []; - } - - atRisk() { - const programConfigService = this.getService(ProgramConfigService); - const individualService = this.getService(IndividualService); - const atRiskConcepts = programConfigService.atRiskConcepts(); - return new SingleSelectFilterModel("At Risk?", - new Map([ - ['Yes', individualService.atRiskFilter(atRiskConcepts)], - ['No', individualService.notAtRiskFilter(atRiskConcepts)]]), new Map()); - } - - getAllFilters() { - //hiding at risk filter for now. - return [/*this.atRisk()*/]; - } -} - -export default FilterService; diff --git a/packages/openchs-android/src/service/IndividualService.js b/packages/openchs-android/src/service/IndividualService.js index f57b8fe81..dc01a4083 100644 --- a/packages/openchs-android/src/service/IndividualService.js +++ b/packages/openchs-android/src/service/IndividualService.js @@ -28,7 +28,6 @@ import {getUnderlyingRealmCollection} from "openchs-models"; class IndividualService extends BaseService { constructor(db, context) { super(db, context); - this.allHighRiskPatients = this.allHighRiskPatients.bind(this); this.allCompletedVisitsIn = this.allCompletedVisitsIn.bind(this); this.allScheduledVisitsIn = this.allScheduledVisitsIn.bind(this); this.allOverdueVisitsIn = this.allOverdueVisitsIn.bind(this); @@ -365,10 +364,6 @@ class IndividualService extends BaseService { return this._uniqIndividualsFrom(encounters); } - totalOverdueVisits(program, addressLevel, encounterType) { - return this.overdueVisits(program, addressLevel, encounterType).length; - } - allCompletedVisitsIn(date, queryAdditions) { let fromDate = moment(date).startOf('day').toDate(); let tillDate = moment(date).endOf('day').toDate(); @@ -571,55 +566,6 @@ class IndividualService extends BaseService { return this.completedVisits(program, addressLevel, encounterType, tillDate).length; } - allHighRiskPatients(addressLevel) { - const HIGH_RISK_CONCEPTS = ["High Risk Conditions", "Adolescent Vulnerabilities"]; - let allEnrolments = this.db.objects(ProgramEnrolment.schema.name); - if (!_.isNil(addressLevel)) - allEnrolments = allEnrolments.filtered('individual.lowestAddressLevel.uuid = $0', addressLevel.uuid); - return allEnrolments.filter((enrolment) => HIGH_RISK_CONCEPTS - .some((concept) => !_.isEmpty(enrolment.findObservation(concept)))) - .map((enrolment) => { - return _.assignIn({}, enrolment.individual, {addressUUID: enrolment.individual.lowestAddressLevel.uuid}); - }); - } - - allHighRiskPatientCount() { - return this.allHighRiskPatients().length; - } - - highRiskPatients(program, addressLevel) { - const HIGH_RISK_CONCEPTS = ["High Risk Conditions", "Adolescent Vulnerabilities"]; - let allEnrolments = this.db.objects(ProgramEnrolment.schema.name) - .filtered("program.uuid = $0 " + - "AND individual.lowestAddressLevel.uuid = $1 ", - program.uuid, - addressLevel.uuid); - return allEnrolments.filter((enrolment) => HIGH_RISK_CONCEPTS - .some((concept) => !_.isEmpty(enrolment.findObservationInEntireEnrolment(concept)))) - .map((enrolment) => enrolment.individual); - } - - atRiskFilter(atRiskConcepts) { - return (individuals) => individuals.filter((individual) => { - const ind = _.isNil(individual.visitInfo) ? individual : individual.individual; - return ind.nonVoidedEnrolments().some((enrolment) => atRiskConcepts.length === 0 || atRiskConcepts - .some(concept => enrolment.observationExistsInEntireEnrolment(concept.name))) - }); - } - - notAtRiskFilter(atRiskConcepts) { - return (individuals) => individuals.filter((individual) => { - const ind = _.isNil(individual.visitInfo) ? individual : individual.individual; - return !ind.nonVoidedEnrolments().some((enrolment) => atRiskConcepts.length === 0 || atRiskConcepts - .some(concept => enrolment.observationExistsInEntireEnrolment(concept.name))) - }); - } - - totalHighRisk(program, addressLevel) { - return this.highRiskPatients(program, addressLevel).length; - } - - voidUnVoidIndividual(individualUUID, setVoided, groupAffiliation) { const individual = this.findByUUID(individualUUID); let individualClone = individual.cloneForEdit(); diff --git a/packages/openchs-android/src/service/ProgramConfigService.js b/packages/openchs-android/src/service/ProgramConfigService.js index 5e1488ad5..313d0e7ee 100644 --- a/packages/openchs-android/src/service/ProgramConfigService.js +++ b/packages/openchs-android/src/service/ProgramConfigService.js @@ -1,7 +1,6 @@ import BaseService from './BaseService.js' import Service from '../framework/bean/Service'; import _ from "lodash"; -import {ProgramConfig} from 'avni-models'; import {programConfig} from 'avni-health-modules'; @Service("programConfigService") @@ -20,12 +19,6 @@ class ProgramConfigService extends BaseService { findDashboardButtons(program) { return _.get(this.configForProgram(program), ['programDashboardButtons']); } - - atRiskConcepts() { - const programConfigs = _.defaultTo(this.findAll(ProgramConfig.schema.name), []); - return programConfigs - .reduce((acc, pc) => acc.concat(pc.atRiskConcepts.map(_.identity)), []); - } } -export default ProgramConfigService; \ No newline at end of file +export default ProgramConfigService; diff --git a/packages/openchs-android/src/state/ProgramEncounterState.js b/packages/openchs-android/src/state/ProgramEncounterState.js index ba8daab70..83f145cdc 100644 --- a/packages/openchs-android/src/state/ProgramEncounterState.js +++ b/packages/openchs-android/src/state/ProgramEncounterState.js @@ -3,7 +3,6 @@ import Wizard from "./Wizard"; import { AbstractEncounter, ObservationsHolder, - ProgramConfig, ProgramEncounter, StaticFormElementGroup } from "avni-models"; @@ -109,10 +108,8 @@ class ProgramEncounterState extends AbstractDataEntryState { } getNextScheduledVisits(ruleService, context) { - const programConfig = ruleService - .findByKey("program.uuid", this.programEncounter.programEnrolment.program.uuid, ProgramConfig.schema.name); - const nextScheduledVisits = ruleService.getNextScheduledVisits(this.programEncounter, ProgramEncounter.schema.name, [..._.get(programConfig, "visitSchedule", [])] - .map(k => _.assignIn({}, k))); + const nextScheduledVisits = ruleService.getNextScheduledVisits(this.programEncounter, ProgramEncounter.schema.name, []) + .map(k => _.assignIn({}, k)); return context.get(IndividualService).validateAndInjectOtherSubjectForScheduledVisit(this.programEncounter.individual, nextScheduledVisits); } diff --git a/packages/openchs-android/src/state/ProgramEnrolmentState.js b/packages/openchs-android/src/state/ProgramEnrolmentState.js index 9656139dc..382404d56 100644 --- a/packages/openchs-android/src/state/ProgramEnrolmentState.js +++ b/packages/openchs-android/src/state/ProgramEnrolmentState.js @@ -1,5 +1,5 @@ import AbstractDataEntryState from "./AbstractDataEntryState"; -import {ProgramConfig, ProgramEnrolment, ObservationsHolder, Concept} from 'avni-models'; +import {ProgramEnrolment, ObservationsHolder, Concept} from 'avni-models'; import _ from 'lodash'; import ConceptService from "../service/ConceptService"; import IndividualService from "../service/IndividualService"; @@ -60,7 +60,7 @@ class ProgramEnrolmentState extends AbstractDataEntryState { getAffiliatedGroups() { return this.groupAffiliation ? - _.map(this.groupAffiliation.groupSubjectObservations, ({groupSubject}) => groupSubject) : []; + _.map(this.groupAffiliation.groupSubjectObservations, ({groupSubject}) => groupSubject) : []; } get staticFormElementIds() { @@ -138,12 +138,8 @@ class ProgramEnrolmentState extends AbstractDataEntryState { } getNextScheduledVisits(ruleService, context) { - const programConfig = ruleService - .findByKey("program.uuid", this.enrolment.program.uuid, ProgramConfig.schema.name); if (this.usage === ProgramEnrolmentState.UsageKeys.Enrol) { - const nextScheduledVisits = ruleService.getNextScheduledVisits(this.enrolment, ProgramEnrolment.schema.name, - [..._.get(programConfig, "visitSchedule", [])] - .map(k => _.assignIn({}, k))); + const nextScheduledVisits = ruleService.getNextScheduledVisits(this.enrolment, ProgramEnrolment.schema.name, []); return context.get(IndividualService).validateAndInjectOtherSubjectForScheduledVisit(this.enrolment.individual, nextScheduledVisits); } else { return null; diff --git a/packages/openchs-android/src/views/MenuView.js b/packages/openchs-android/src/views/MenuView.js index 04aeed243..ada1908af 100644 --- a/packages/openchs-android/src/views/MenuView.js +++ b/packages/openchs-android/src/views/MenuView.js @@ -10,17 +10,10 @@ import General from "../utility/General"; import CHSContent from "./common/CHSContent"; import Colors from "./primitives/Colors"; import AuthService from "../service/AuthService"; -import RuleService from "../service/RuleService"; -import ProgramConfigService from "../service/ProgramConfigService"; -import MessageService from "../service/MessageService"; -import {IndividualSearchActionNames as IndividualSearchActions} from "../action/individual/IndividualSearchActions"; -import {LandingViewActionsNames as LandingViewActions} from "../action/LandingViewActions"; -import {MyDashboardActionNames} from "../action/mydashboard/MyDashboardActions"; import RuleEvaluationService from "../service/RuleEvaluationService"; import Distances from "./primitives/Distances"; import Fonts from "./primitives/Fonts"; import CHSContainer from "./common/CHSContainer"; -import {Icon} from 'native-base'; import Separator from "./primitives/Separator"; import SettingsView from "./settings/SettingsView"; import Styles from "./primitives/Styles";