Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Patient Names, Demographics & Address to dynamic reports #35

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ export const reportIndicators: Array<Indicator> = [
type: "PatientIdentifier",
attributes: [],
},
{
id: "PEN",
label: "Person Names",
type: "PersonName",
attributes: [],
},
{
id: "DEM",
label: "Demographics",
type: "Demographics",
attributes: [],
},
{
id: "ADD",
label: "Address",
type: "Address",
attributes: [],
},
{
id: "PAT",
label: "Person Attributes",
Expand Down Expand Up @@ -483,3 +501,156 @@ export const modifiers = [
label: "Provider",
},
];

export const personNames = [
{
id: "givenName",
label: "Given Name",
type: "PersonName",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "middleName",
label: "Middle Name",
type: "PersonName",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "familyName",
label: "Family Name",
type: "PersonName",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "familyName2",
label: "Family Name 2",
type: "PersonName",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
];

export const Demographics = [
{
id: "gender",
label: "Gender",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "birthdate",
label: "Birthdate",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "Age",
label: "Age",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "birthdateEstimated",
label: "Birth Date estimated",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "dead",
label: "Deceased",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "deathDate",
label: "Date of death",
type: "Demographics",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
];

export const Address = [
{
id: "country",
label: "Country",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "countyDistrict",
label: "District",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "stateProvince",
label: "County",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "address3",
label: "Sub County",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "address4",
label: "Parish",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
{
id: "address5",
label: "Village",
type: "Address",
modifier: 1,
showModifierPanel: false,
extras: [],
attributes: [],
},
];
89 changes: 63 additions & 26 deletions src/data-visualizer/data-visualizer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ import {
reportTypes,
reportPeriod,
dynamicReportOptions,
personNames,
Address,
Demographics,
} from "../constants";
import DataList from "../components/data-table/data-table.component";
import CQIDataList from "../components/cqi-components/cqi-data-table.component";
Expand Down Expand Up @@ -217,6 +220,14 @@ const DataVisualizer: React.FC = () => {
description: `Report ${selectedReport.label} sent Successfully`,
});
}
{
showNotification({
title: "Error sending report to DHIS2",
kind: "error",
critical: true,
description: `Failed with error code ${response.status}, Contact System Administrator`,
});
}
setIsSendingReport(false);
},
(error) => {
Expand Down Expand Up @@ -352,30 +363,52 @@ const DataVisualizer: React.FC = () => {
setAvailableParameters([]);
};

const handleIndicatorChange = useCallback(({ selectedItem }) => {
const indicator = selectedItem;
getCategoryIndicator(selectedItem.id).then(
(response) => {
let results;
if (selectedItem.type === "") {
results = mapDataElements(response, null, "concepts");
} else {
results = mapDataElements(response?.results, selectedItem.type);
const handleIndicatorChange = useCallback(
({ selectedItem }) => {
const indicator = selectedItem;
getCategoryIndicator(selectedItem.id).then(
(response) => {
let results;
switch (selectedItem.type) {
case "PersonName":
results = personNames;
break;
case "Demographics":
results = Demographics;
break;
case "Address":
results = Address;
break;
case "":
results = mapDataElements(response, null, "concepts");
break;
default:
results = mapDataElements(response?.results, selectedItem.type);
break;
}

setSelectedIndicators(indicator);
const filteredArray = results?.filter(
(resultParameter) =>
!selectedParameters?.some(
(parameter) => parameter.id === resultParameter.id
)
);
indicator.attributes = filteredArray;
setAvailableParameters(indicator.attributes ?? []);
},
(error) => {
showNotification({
title: "Error fetching Indicators",
kind: "error",
critical: true,
description: error?.message,
});
}
indicator.attributes = results;
setSelectedIndicators(indicator);
setAvailableParameters(indicator.attributes ?? []);
},
(error) => {
showNotification({
title: "Error fetching Indicators",
kind: "error",
critical: true,
description: error?.message,
});
}
);
}, []);
);
},
[selectedParameters]
);

const handleSelectedReportDefinition = ({ selectedItem }) => {
setSelectedReport(selectedItem);
Expand Down Expand Up @@ -875,9 +908,13 @@ const DataVisualizer: React.FC = () => {
/>
</div>
{parameter.label}
{parameter?.type !==
"PatientIdentifier" &&
parameter?.type !== "PersonAttribute" ? (
{![
"PatientIdentifier",
"PersonAttribute",
"PersonName",
"Demographics",
"Address",
].includes(parameter?.type) ? (
<div
className={styles.modifierContainer}
>
Expand Down
Loading