Skip to content

Commit

Permalink
refactor: remove unused areas affected api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Oct 27, 2024
1 parent 9b884af commit 1774738
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 56 deletions.
3 changes: 0 additions & 3 deletions src/data/repositories/OrgUnitD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ export class OrgUnitD2Repository implements OrgUnitRepository {
},
})
).map(response => {
// const d2OrgUnitsProvinceOrDistrict = response.organisationUnits.filter(
// ou => ou.level === 2 || ou.level === 3
// );
return this.mapD2OrgUnitsToOrgUnits(response.organisationUnits);
});
}
Expand Down
8 changes: 2 additions & 6 deletions src/data/repositories/consts/DiseaseOutbreakConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ export function getValueFromDiseaseOutbreak(
RTSL_ZEB_TEA_MAIN_SYNDROME: diseaseOutbreak.mainSyndromeCode ?? "",
RTSL_ZEB_TEA_SUSPECTED_DISEASE: diseaseOutbreak.suspectedDiseaseCode ?? "",
RTSL_ZEB_TEA_NOTIFICATION_SOURCE: diseaseOutbreak.notificationSourceCode,
RTSL_ZEB_TEA_AREAS_AFFECTED_PROVINCES: getOUTextFromList(
diseaseOutbreak.areasAffectedProvinceIds
),
RTSL_ZEB_TEA_AREAS_AFFECTED_DISTRICTS: getOUTextFromList(
diseaseOutbreak.areasAffectedDistrictIds
),
RTSL_ZEB_TEA_AREAS_AFFECTED_PROVINCES: "",
RTSL_ZEB_TEA_AREAS_AFFECTED_DISTRICTS: "",
RTSL_ZEB_TEA_INCIDENT_STATUS: diseaseOutbreak.incidentStatus,
RTSL_ZEB_TEA_DATE_EMERGED: getDateAsIsoString(diseaseOutbreak.emerged.date),
RTSL_ZEB_TEA_DATE_EMERGED_NARRATIVE: diseaseOutbreak.emerged.narrative,
Expand Down
2 changes: 0 additions & 2 deletions src/data/repositories/utils/DiseaseOutbreakMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export function mapTrackedEntityAttributesToDiseaseOutbreak(
mainSyndromeCode: fromMap("mainSyndrome"),
suspectedDiseaseCode: fromMap("suspectedDisease"),
notificationSourceCode: fromMap("notificationSource"),
areasAffectedProvinceIds: getMultipleOUFromText(fromMap("areasAffectedProvinces")),
areasAffectedDistrictIds: getMultipleOUFromText(fromMap("areasAffectedDistricts")),
incidentStatus: incidentStatus,
emerged: {
date: new Date(fromMap("emergedDate")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export type DiseaseOutbreakEventBaseAttrs = NamedRef & {
mainSyndromeCode: Maybe<Code>;
suspectedDiseaseCode: Maybe<Code>;
notificationSourceCode: Code;
areasAffectedProvinceIds: Id[];
areasAffectedDistrictIds: Id[];
incidentStatus: NationalIncidentStatus;
emerged: DateWithNarrative;
detected: DateWithNarrative;
Expand All @@ -79,8 +77,6 @@ export type DiseaseOutbreakEventAttrs = DiseaseOutbreakEventBaseAttrs & {
mainSyndrome: Maybe<NamedRef>;
suspectedDisease: Maybe<NamedRef>;
notificationSource: NamedRef;
areasAffectedProvinces: OrgUnit[];
areasAffectedDistricts: OrgUnit[];
incidentManager: Maybe<TeamMember>; //TO DO : make mandatory once form rules applied.
riskAssessment: Maybe<RiskAssessment>;
incidentActionPlan: Maybe<IncidentActionPlan>;
Expand Down
55 changes: 19 additions & 36 deletions src/domain/usecases/GetDiseaseOutbreakByIdUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export class GetDiseaseOutbreakByIdUseCase {
suspectedDiseaseCode,
notificationSourceCode,
incidentManagerName,
areasAffectedDistrictIds,
areasAffectedProvinceIds,
} = diseaseOutbreakEventBase;

const { selectableOptions } = configurations;
Expand All @@ -59,10 +57,6 @@ export class GetDiseaseOutbreakByIdUseCase {
return Future.error(new Error("Notification source not found"));

return Future.joinObj({
areasAffectedProvinces:
this.options.orgUnitRepository.get(areasAffectedProvinceIds),
areasAffectedDistricts:
this.options.orgUnitRepository.get(areasAffectedDistrictIds),
riskAssessment: getAll(
id,
this.options.riskAssessmentRepository,
Expand All @@ -79,36 +73,25 @@ export class GetDiseaseOutbreakByIdUseCase {
configurations
),
roles: this.options.roleRepository.getAll(),
}).flatMap(
({
areasAffectedProvinces,
areasAffectedDistricts,
riskAssessment,
incidentAction,
incidentManagementTeam,
roles,
}) => {
return this.options.incidentManagementTeamRepository
.getIncidentManagementTeamMember(incidentManagerName, id, roles)
.flatMap(incidentManager => {
const diseaseOutbreakEvent: DiseaseOutbreakEvent =
new DiseaseOutbreakEvent({
...diseaseOutbreakEventBase,
createdBy: undefined, //TO DO : FIXME populate once metadata change is done.
mainSyndrome: mainSyndrome,
suspectedDisease: suspectedDisease,
notificationSource: notificationSource,
areasAffectedProvinces: areasAffectedProvinces,
areasAffectedDistricts: areasAffectedDistricts,
incidentManager: incidentManager,
riskAssessment: riskAssessment,
incidentActionPlan: incidentAction,
incidentManagementTeam: incidentManagementTeam,
});
return Future.success(diseaseOutbreakEvent);
});
}
);
}).flatMap(({ riskAssessment, incidentAction, incidentManagementTeam, roles }) => {
return this.options.incidentManagementTeamRepository
.getIncidentManagementTeamMember(incidentManagerName, id, roles)
.flatMap(incidentManager => {
const diseaseOutbreakEvent: DiseaseOutbreakEvent =
new DiseaseOutbreakEvent({
...diseaseOutbreakEventBase,
createdBy: undefined, //TO DO : FIXME populate once metadata change is done.
mainSyndrome: mainSyndrome,
suspectedDisease: suspectedDisease,
notificationSource: notificationSource,
incidentManager: incidentManager,
riskAssessment: riskAssessment,
incidentActionPlan: incidentAction,
incidentManagementTeam: incidentManagementTeam,
});
return Future.success(diseaseOutbreakEvent);
});
});
});
}
}
6 changes: 3 additions & 3 deletions src/webapp/pages/event-tracker/useDiseaseOutbreakEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export type FormSummaryData = {
notes: string;
};
export function useDiseaseOutbreakEvent(id: Id) {
const { compositionRoot, configurations: appConfiguration } = useAppContext();
const { compositionRoot, configurations } = useAppContext();
const [formSummary, setFormSummary] = useState<FormSummaryData>();
const [summaryError, setSummaryError] = useState<string>();
const [riskAssessmentRows, setRiskAssessmentRows] = useState<TableRowType[]>([]);
const [eventTrackerDetails, setEventTrackerDetails] = useState<DiseaseOutbreakEvent>();

useEffect(() => {
compositionRoot.diseaseOutbreakEvent.get.execute(id, appConfiguration).run(
compositionRoot.diseaseOutbreakEvent.get.execute(id, configurations).run(
diseaseOutbreakEvent => {
setFormSummary(mapDiseaseOutbreakEventToFormSummary(diseaseOutbreakEvent));
setRiskAssessmentRows(
Expand All @@ -51,7 +51,7 @@ export function useDiseaseOutbreakEvent(id: Id) {
setSummaryError(`Event tracker with id: ${id} does not exist`);
}
);
}, [compositionRoot.diseaseOutbreakEvent.get, appConfiguration, id]);
}, [compositionRoot.diseaseOutbreakEvent.get, configurations, id]);

const mapDiseaseOutbreakEventToFormSummary = (
diseaseOutbreakEvent: DiseaseOutbreakEvent
Expand Down
3 changes: 1 addition & 2 deletions src/webapp/pages/form-page/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ export function useForm(formType: FormType, id?: Id): State {
formState,
configurableForm,
currentUser.username,
compositionRoot.save,
compositionRoot.diseaseOutbreakEvent.mapDiseaseOutbreakEventToAlerts,
compositionRoot,
currentEventTracker?.id,
goTo,
]);
Expand Down

0 comments on commit 1774738

Please sign in to comment.