Skip to content

Commit

Permalink
#1142 - (note this is not in 5.1 release) removed unused code related…
Browse files Browse the repository at this point in the history
… to health modules and program config.
  • Loading branch information
petmongrels committed Oct 31, 2023
1 parent 681ffd9 commit aeb34ab
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 123 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 @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
30 changes: 0 additions & 30 deletions packages/openchs-android/src/service/FilterService.js

This file was deleted.

54 changes: 0 additions & 54 deletions packages/openchs-android/src/service/IndividualService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 1 addition & 8 deletions packages/openchs-android/src/service/ProgramConfigService.js
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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;
export default ProgramConfigService;
7 changes: 2 additions & 5 deletions packages/openchs-android/src/state/ProgramEncounterState.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Wizard from "./Wizard";
import {
AbstractEncounter,
ObservationsHolder,
ProgramConfig,
ProgramEncounter,
StaticFormElementGroup
} from "avni-models";
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 3 additions & 7 deletions packages/openchs-android/src/state/ProgramEnrolmentState.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions packages/openchs-android/src/views/MenuView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit aeb34ab

Please sign in to comment.