Skip to content

Commit

Permalink
Merge pull request #61 from EyeSeeTea/feature/changes-nursing-midwifery
Browse files Browse the repository at this point in the history
only check totals dataElements
  • Loading branch information
Ramon-Jimenez authored Jun 5, 2024
2 parents 301500a + f45fde2 commit fb36ca1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
4 changes: 4 additions & 0 deletions src/data/common/D2DataElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class D2DataElement {
.get({
fields: {
id: true,
formName: true,
code: true,
displayFormName: true,
displayName: true,
displayShortName: true,
Expand All @@ -29,6 +31,8 @@ export class D2DataElement {
return d2Response.data.objects.map((d2DataElement): DataElement => {
return {
id: d2DataElement.id,
code: d2DataElement.code,
originalName: d2DataElement.formName,
name:
d2DataElement.displayFormName ||
d2DataElement.displayShortName ||
Expand Down
5 changes: 5 additions & 0 deletions src/data/repositories/ModuleD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export class ModuleD2Repository implements ModuleRepository {
dataSetElements: {
dataElement: {
id: true,
code: true,
formName: true,
displayFormName: true,
valueType: true,
categoryCombo: {
id: true,
code: true,
name: true,
displayName: true,
categories: {
id: true,
Expand Down Expand Up @@ -79,6 +82,8 @@ export class ModuleD2Repository implements ModuleRepository {
d2DataSetElement.dataElement.categoryCombo;
return {
id: d2DataSetElement.dataElement.id,
code: d2DataSetElement.dataElement.code,
originalName: d2DataSetElement.dataElement.formName,
name: d2DataSetElement.dataElement.displayFormName,
isNumber:
d2DataSetElement.dataElement.valueType === "NUMBER" ||
Expand Down
5 changes: 3 additions & 2 deletions src/domain/entities/DataElement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Maybe } from "$/utils/ts-utils";
import { NamedRef } from "./Ref";
import { NamedCodeRef, NamedRef } from "./Ref";

export type DataElement = NamedRef & {
export type DataElement = NamedCodeRef & {
originalName: string;
isNumber: boolean;
disaggregation: Maybe<NamedRef & { options: NamedRef[] }>;
};
10 changes: 5 additions & 5 deletions src/domain/usecases/GetMissingDisaggregatesUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ export class GetMissingDisaggregatesUseCase {
dataElements: DataElement[]
) {
if (disaggregationSetting.type === "combos") {
return dataElements.filter(de => {
return dataElements.filter(dataElement => {
return (
de.name.split(separator)[0] === disaggregationSetting.id &&
de.disaggregation?.id === disaggregationSetting.disaggregationId
dataElement.name.split(separator)[0] === disaggregationSetting.id &&
dataElement.disaggregation?.id === disaggregationSetting.disaggregationId
);
});
} else {
return dataElements.filter(de => {
return de.disaggregation?.id === disaggregationSetting.id;
return dataElements.filter(dataElement => {
return dataElement.disaggregation?.id === disaggregationSetting.id;
});
}
}
Expand Down
14 changes: 3 additions & 11 deletions src/domain/usecases/ValidateMidwiferyAndPersonnelUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class ValidateMidwiferyAndPersonnelUseCase {
.flatMap(dataElementToCheck => {
const [nursing, midwifery] = dataElementToCheck;
if (!nursing || !midwifery) return [];
const personnelDe = dataElements.find(de => de.name.includes(nursing));
const midwiferyDe = dataElements.find(de => de.name.includes(midwifery));
const personnelDe = dataElements.find(de => de.originalName.includes(nursing));
const midwiferyDe = dataElements.find(de => de.originalName.includes(midwifery));

if (!personnelDe || !midwiferyDe) return [];

Expand Down Expand Up @@ -296,15 +296,7 @@ export class ValidateMidwiferyAndPersonnelUseCase {
} else if (sectionDisaggregation.type === "key_occupations") {
return [["2. Nursing Personnel", "3. Midwifery Personnel"]];
} else {
return [
["2 - Nursing Personnel", "3 - Midwifery personnel"],
["2.1 - Nursing Professionals", "3.1 - Midwifery Professionals"],
[
"2.2 - Nursing Associate Professionals",
"3.2 - Midwifery Associate Professionals",
],
["2.3 - Nurses not further defined", "3.3 - Midwives not further defined"],
];
return [["2 - Nursing Personnel", "3 - Midwifery personnel"]];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { QualityAnalysis } from "$/domain/entities/QualityAnalysis";
import { QualityAnalysisSection } from "$/domain/entities/QualityAnalysisSection";
import { UpdateAnalysisState } from "$/webapp/pages/analysis/AnalysisPage";
import { Maybe } from "$/utils/ts-utils";
import _ from "$/domain/entities/generic/Collection";

export function useNursingMidwiferyStep(props: UseNursingMidwiferyStepProps) {
const { analysis, section, updateAnalysis } = props;
Expand All @@ -23,7 +24,12 @@ export function useNursingMidwiferyStep(props: UseNursingMidwiferyStepProps) {
text: item.name,
}));
setDisaggregations(selectedDisaggregations);
setSelectedDissagregations(selectedDisaggregations.map(item => item.value));
setSelectedDissagregations(
_(selectedDisaggregations)
.map(item => (item.text === "Total" ? item.value : undefined))
.compact()
.value()
);
},
error => {
setError(error.message);
Expand Down

0 comments on commit fb36ca1

Please sign in to comment.