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 support for adding concepts to DEATH table #900

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7a9d1cf
modify SRTable model and make migration
AndrewThien Oct 3, 2024
1d3bc72
add Death value to type and API call
AndrewThien Oct 3, 2024
9939e36
Add UI support and connection for Death table
AndrewThien Oct 3, 2024
6f60394
update name to keep consistency
AndrewThien Oct 3, 2024
0abcc4b
add todo
AndrewThien Oct 3, 2024
99c9ede
Add UI option 2
AndrewThien Oct 4, 2024
b5d924c
Add connection between BE and FE for option 2
AndrewThien Oct 4, 2024
78cb499
modify model of SR table
AndrewThien Oct 4, 2024
e79de51
Clean up
AndrewThien Oct 7, 2024
9848e1d
Merge branch 'feat/769/add-meas-value-field' into feat/646/add-death-…
AndrewThien Oct 7, 2024
4cd4def
add death table notes
AndrewThien Oct 7, 2024
0bdc676
add condition for death table and meas value
AndrewThien Oct 7, 2024
a93609c
add logic supporting death table
AndrewThien Oct 7, 2024
d7012f3
Merge branch 'master' into feat/646/add-death-table
AndrewThien Oct 7, 2024
0e20d9f
update domain that will be added to person table
AndrewThien Oct 9, 2024
a99eb0f
update tooltips details
AndrewThien Oct 9, 2024
1f42b5b
Merge branch 'feat/696/status-columns' into feat/646/add-death-table
AndrewThien Oct 17, 2024
5575622
Merge branch 'master' into feat/646/add-death-table
AndrewThien Oct 17, 2024
01a6c8e
add TODO
AndrewThien Oct 17, 2024
71a6adc
update migration
AndrewThien Oct 17, 2024
abed191
clean up
AndrewThien Oct 17, 2024
62a8a90
black formatting
AndrewThien Oct 17, 2024
8a1a6df
Merge branch 'feat/607/projects-pages' into feat/646/add-death-table
AndrewThien Oct 28, 2024
b3c8cb2
make the confirmation before changing Death setting
AndrewThien Oct 28, 2024
562ea35
clarify the error
AndrewThien Oct 28, 2024
dc856fa
add more info for buttons
AndrewThien Oct 28, 2024
bbde1a8
Merge branch 'master' into feat/646/add-death-table
AndrewThien Oct 28, 2024
de17d16
decrese delay duration of tooltip
AndrewThien Oct 28, 2024
897f9ba
improve the logic of the dialog
AndrewThien Oct 29, 2024
13712be
update content of dialog
AndrewThien Oct 29, 2024
479cd01
add full stops
AndrewThien Oct 29, 2024
7dd6113
clean up
AndrewThien Oct 29, 2024
c1664fd
update info and its style
AndrewThien Oct 30, 2024
7346ad2
modify word style
AndrewThien Oct 30, 2024
9fe68ea
enable turn on/off for Death table
AndrewThien Nov 1, 2024
c3d8bb2
Merge branch 'master' into feat/646/add-death-table
AndrewThien Nov 21, 2024
3399f39
update details of confirmation box
AndrewThien Nov 21, 2024
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
11 changes: 10 additions & 1 deletion app/api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,15 @@ def post(self, request, *args, **kwargs):
pk=body["object_id"]
).scan_report_field.type_column

# Checking death_table and meas value domain relationship
if domain == "meas value" and table.death_table:
return Response(
{
"detail": "Because concepts with 'Meas Value' domain will be mapped to Measurement table as 'value_as_concept_id', they should not be added to DEATH table."
},
status=status.HTTP_400_BAD_REQUEST,
)

# Checking field's datatype for concept with domain Observation
if domain == "observation" and field_datatype.lower() not in [
"real",
Expand All @@ -581,7 +590,7 @@ def post(self, request, *args, **kwargs):
status=status.HTTP_400_BAD_REQUEST,
)
# validate the destination_table
destination_table = _find_destination_table(concept)
destination_table = _find_destination_table(concept, table)
if destination_table is None:
return Response(
{
Expand Down
41 changes: 21 additions & 20 deletions app/next-client-app/api/scanreports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ const fetchKeys = {
field: (
scanReportId: string | number,
tableId: string | number,
fieldId: string | number | undefined,
fieldId: string | number | undefined
) => `v2/scanreports/${scanReportId}/tables/${tableId}/fields/${fieldId}/`,
fields: (scanReportId: string, tableId: string, filter?: string) =>
`v2/scanreports/${scanReportId}/tables/${tableId}/fields/?${filter}`,
values: (
scanReportId: string,
tableId: string,
fieldId: string,
filter?: string,
filter?: string
) =>
`v2/scanreports/${scanReportId}/tables/${tableId}/fields/${fieldId}/values/?${filter}`,
};

export async function getScanReports(
filter: string | undefined,
filter: string | undefined
): Promise<PaginatedResponse<ScanReport>> {
try {
return await request<PaginatedResponse<ScanReport>>(
fetchKeys.index(filter),
fetchKeys.index(filter)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function getScanReport(id: string): Promise<ScanReport | null> {
export async function updateScanReport(
id: number,
data: {},
needRedirect?: boolean,
needRedirect?: boolean
) {
try {
await request(fetchKeys.get(id), {
Expand Down Expand Up @@ -107,7 +107,7 @@ export async function deleteScanReport(id: number) {
* @returns A object with a list of the users permissions.
*/
export async function getScanReportPermissions(
id: string,
id: string
): Promise<PermissionsResponse> {
try {
return await request<PermissionsResponse>(fetchKeys.permissions(id));
Expand All @@ -119,11 +119,11 @@ export async function getScanReportPermissions(

export async function getScanReportTable(
scanReportId: string,
tableId: string,
tableId: string
): Promise<ScanReportTable> {
try {
return await request<ScanReportTable>(
fetchKeys.table(scanReportId, tableId),
fetchKeys.table(scanReportId, tableId)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand All @@ -136,14 +136,15 @@ export async function getScanReportTable(
updated_at: new Date(),
date_event: null,
permissions: [],
death_table: false,
};
}
}

export async function updateScanReportTable(
scanReportId: string | number,
tableId: string | number,
data: {},
data: {}
) {
try {
await request(fetchKeys.table(scanReportId, tableId), {
Expand All @@ -162,11 +163,11 @@ export async function updateScanReportTable(

export async function getScanReportTables(
scanReportId: string,
filter: string | undefined,
filter: string | undefined
): Promise<PaginatedResponse<ScanReportTable>> {
try {
return await request<PaginatedResponse<ScanReportTable>>(
fetchKeys.tables(scanReportId, filter),
fetchKeys.tables(scanReportId, filter)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand All @@ -177,11 +178,11 @@ export async function getScanReportTables(
export async function getScanReportFields(
scanReportId: string,
tableId: string,
filter: string | undefined,
filter: string | undefined
): Promise<PaginatedResponse<ScanReportField>> {
try {
return await request<PaginatedResponse<ScanReportField>>(
fetchKeys.fields(scanReportId, tableId, filter),
fetchKeys.fields(scanReportId, tableId, filter)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand All @@ -192,11 +193,11 @@ export async function getScanReportFields(
export async function getScanReportField(
scanReportId: string,
tableId: string,
fieldId: string | number | undefined,
fieldId: string | number | undefined
): Promise<ScanReportField> {
try {
return await request<ScanReportField>(
fetchKeys.field(scanReportId, tableId, fieldId),
fetchKeys.field(scanReportId, tableId, fieldId)
);
} catch (error) {
console.warn("Failed to fetch data. Passed ID could be null");
Expand Down Expand Up @@ -230,7 +231,7 @@ export async function updateScanReportField(
scanReportId: string | number,
tableId: string | number,
fieldId: string,
data: {},
data: {}
) {
try {
await request(fetchKeys.field(scanReportId, tableId, fieldId), {
Expand All @@ -248,11 +249,11 @@ export async function updateScanReportField(
export async function getAllScanReportFields(
scanReportId: string,
tableId: string,
filter: string | undefined,
filter: string | undefined
): Promise<ScanReportField[]> {
try {
return await fetchAllPages<ScanReportField>(
fetchKeys.fields(scanReportId, tableId, filter),
fetchKeys.fields(scanReportId, tableId, filter)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand All @@ -264,11 +265,11 @@ export async function getScanReportValues(
scanReportId: string,
tableId: string,
fieldId: string,
filter: string | undefined,
filter: string | undefined
): Promise<PaginatedResponse<ScanReportValue>> {
try {
return await request<PaginatedResponse<ScanReportValue>>(
fetchKeys.values(scanReportId, tableId, fieldId, filter),
fetchKeys.values(scanReportId, tableId, fieldId, filter)
);
} catch (error) {
console.warn("Failed to fetch data.");
Expand Down
35 changes: 35 additions & 0 deletions app/next-client-app/app/(protected)/scanreports/[id]/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { ColumnDef } from "@tanstack/react-table";
import { DataTableColumnHeader } from "@/components/data-table/DataTableColumnHeader";
import { EditButton } from "@/components/scanreports/EditButton";
import { Tooltips } from "@/components/Tooltips";

export const columns: ColumnDef<ScanReportTable>[] = [
{
Expand Down Expand Up @@ -48,6 +49,40 @@ export const columns: ColumnDef<ScanReportTable>[] = [
enableHiding: true,
enableSorting: false,
},
{
id: "note",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Note" />
),
cell: ({ row }) => {
const { death_table } = row.original;
return (
<div>
{death_table && (
<h3 className="flex">
{" "}
Death table
<Tooltips
content={
<h2>
Concepts added to this table with domains{" "}
<span className="font-bold">
Race, Ethnicity and Gender
</span>{" "}
will be mapped to the{" "}
<span className="font-bold">Person</span> table. Concepts
with <span className="font-bold">other domains</span> will
be mapped to the <span className="font-bold">Death</span>{" "}
table.
</h2>
}
/>
</h3>
)}
</div>
);
},
},
{
id: "edit",
header: ({ column }) => <DataTableColumnHeader column={column} title="" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ export default async function ScanReportsValue({
id,
tableId,
fieldId,
query,
query
);

const scanReportsConcepts =
scanReportsValues.results.length > 0
? await getAllScanReportConcepts(
`object_id__in=${scanReportsValues.results
.map((item) => item.id)
.join(",")}`,
.join(",")}`
)
: [];
const conceptsFilter =
scanReportsConcepts.length > 0
? await getAllConceptsFiltered(
scanReportsConcepts?.map((item) => item.concept).join(","),
scanReportsConcepts?.map((item) => item.concept).join(",")
)
: [];
return (
Expand All @@ -64,7 +64,7 @@ export default async function ScanReportsValue({
{" "}
<Link href={`/scanreports/${id}/tables/${tableId}`}>
<Button variant={"secondary"} className="mb-3">
Table: {table.name}
Table: {table.name} {table.death_table && "(Death table)"}
</Button>
</Link>
<Button variant={"secondary"} className="mb-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function ScanReportsEditField({
{" "}
<Link href={`/scanreports/${id}/tables/${tableId}`}>
<Button variant={"secondary"} className="mb-3">
Table: {table.name}
Table: {table.name} {table.death_table && "(Death table)"}
</Button>
</Link>
<Button variant={"secondary"} className="mb-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ export default async function ScanReportsField({
? await getAllScanReportConcepts(
`object_id__in=${scanReportsFields.results
.map((item) => item.id)
.join(",")}`,
.join(",")}`
)
: [];

const conceptsFilter =
scanReportsConcepts.length > 0
? await getAllConceptsFiltered(
scanReportsConcepts?.map((item) => item.concept).join(","),
scanReportsConcepts?.map((item) => item.concept).join(",")
)
: [];

return (
<div>
<Button variant={"secondary"} className="mb-3">
Table: {tableName.name}
Table: {tableName.name} {tableName.death_table && "(Death table)"}
</Button>
<div>
<ConceptDataTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default async function UpdateTable({
<div>
<Link href={`/scanreports/${id}/tables/${tableId}`}>
<Button variant={"secondary"} className="mb-3">
Update Table: {table.name}
Update Table: {table.name} {table.death_table && "(Death table)"}
</Button>
</Link>
{(table.date_event === null || table.person_id === null) && (
Expand Down
5 changes: 3 additions & 2 deletions app/next-client-app/components/Tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import {
} from "@/components/ui/tooltip";

import { InfoIcon } from "lucide-react";
import { ReactElement } from "react";

export function Tooltips({
content,
link,
}: {
content: string;
content: string | ReactElement;
link?: string;
}) {
return (
<TooltipProvider>
<TooltipProvider delayDuration={100}>
<Tooltip>
<TooltipTrigger asChild>
<InfoIcon className="ml-1 size-4 text-carrot" />
Expand Down
Loading
Loading