Skip to content
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
1 change: 1 addition & 0 deletions backend/api/decorators/filter_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def get_property_value_column(field_type: str) -> str:
"FIELD_TYPE_DATE_TIME": "date_time_value",
"FIELD_TYPE_SELECT": "select_value",
"FIELD_TYPE_MULTI_SELECT": "multi_select_values",
"FIELD_TYPE_USER": "user_value",
}
return field_type_mapping.get(field_type, "text_value")

Expand Down
2 changes: 2 additions & 0 deletions backend/api/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FieldType(Enum):
FIELD_TYPE_DATE_TIME = "FIELD_TYPE_DATE_TIME"
FIELD_TYPE_SELECT = "FIELD_TYPE_SELECT"
FIELD_TYPE_MULTI_SELECT = "FIELD_TYPE_MULTI_SELECT"
FIELD_TYPE_USER = "FIELD_TYPE_USER"


@strawberry.enum
Expand Down Expand Up @@ -67,6 +68,7 @@ class PropertyValueInput:
date_time_value: datetime | None = None
select_value: str | None = None
multi_select_values: list[str] | None = None
user_value: str | None = None


@strawberry.input
Expand Down
2 changes: 2 additions & 0 deletions backend/api/services/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def process_properties(
existing_prop.date_time_value = prop_input.date_time_value
existing_prop.select_value = prop_input.select_value
existing_prop.multi_select_values = multi_select_value
existing_prop.user_value = prop_input.user_value
else:
prop_value = models.PropertyValue(
definition_id=prop_input.definition_id,
Expand All @@ -68,6 +69,7 @@ async def process_properties(
date_time_value=prop_input.date_time_value,
select_value=prop_input.select_value,
multi_select_values=multi_select_value,
user_value=prop_input.user_value,
)

if entity_kind == "patient":
Expand Down
35 changes: 35 additions & 0 deletions backend/api/types/property.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from datetime import date, datetime
from typing import TYPE_CHECKING, Annotated

import strawberry
from api.context import Info
from api.inputs import FieldType, PropertyEntity
from database import models
from sqlalchemy import select

if TYPE_CHECKING:
from api.types.location import LocationNodeType
from api.types.user import UserType


@strawberry.type
Expand All @@ -25,13 +33,15 @@ def allowed_entities(self) -> list[PropertyEntity]:

@strawberry.type
class PropertyValueType:
id: strawberry.ID
definition: PropertyDefinitionType
text_value: str | None
number_value: float | None
boolean_value: bool | None
date_value: date | None
date_time_value: datetime | None
select_value: str | None
user_value: str | None

@strawberry.field
def multi_select_values(self) -> list[str] | None:
Expand All @@ -40,3 +50,28 @@ def multi_select_values(self) -> list[str] | None:
if self.multi_select_values
else None
)

@strawberry.field
async def user(
self,
info: Info,
) -> Annotated["UserType", strawberry.lazy("api.types.user")] | None:
if not self.user_value or self.user_value.startswith("team:"):
return None
result = await info.context.db.execute(
select(models.User).where(models.User.id == self.user_value),
)
return result.scalars().first()

@strawberry.field
async def team(
self,
info: Info,
) -> Annotated["LocationNodeType", strawberry.lazy("api.types.location")] | None:
if not self.user_value or not self.user_value.startswith("team:"):
return None
team_id = self.user_value[5:]
result = await info.context.db.execute(
select(models.LocationNode).where(models.LocationNode.id == team_id),
)
return result.scalars().first()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add user_value column to property_values

Revision ID: add_property_value_user_value
Revises: add_scaffold_import_state
Create Date: 2026-02-03

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

revision: str = "add_property_value_user_value"
down_revision: Union[str, Sequence[str], None] = "add_scaffold_import_state"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
op.add_column(
"property_values",
sa.Column("user_value", sa.String(), nullable=True),
)


def downgrade() -> None:
op.drop_column("property_values", "user_value")
1 change: 1 addition & 0 deletions backend/database/models/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ class PropertyValue(Base):
String,
nullable=True,
)
user_value: Mapped[str | None] = mapped_column(String, nullable=True)
36 changes: 21 additions & 15 deletions web/api/gql/generated.ts

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions web/api/graphql/GetOverviewData.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ query GetOverviewData($recentPatientsFiltering: [FilterInput!], $recentPatientsS
updateDate
}
properties {
id
definition {
id
name
Expand All @@ -33,6 +34,19 @@ query GetOverviewData($recentPatientsFiltering: [FilterInput!], $recentPatientsS
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
recentPatientsTotal(filtering: $recentPatientsFiltering, sorting: $recentPatientsSorting, search: $recentPatientsSearch)
Expand Down Expand Up @@ -65,6 +79,7 @@ query GetOverviewData($recentPatientsFiltering: [FilterInput!], $recentPatientsS
}
}
properties {
id
definition {
id
name
Expand All @@ -81,6 +96,19 @@ query GetOverviewData($recentPatientsFiltering: [FilterInput!], $recentPatientsS
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
recentTasksTotal(filtering: $recentTasksFiltering, sorting: $recentTasksSorting, search: $recentTasksSearch)
Expand Down
14 changes: 14 additions & 0 deletions web/api/graphql/GetPatient.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ query GetPatient($id: ID!) {
}
}
properties {
id
definition {
id
name
Expand All @@ -118,6 +119,19 @@ query GetPatient($id: ID!) {
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
}
14 changes: 14 additions & 0 deletions web/api/graphql/GetPatients.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ query GetPatients($locationId: ID, $rootLocationIds: [ID!], $states: [PatientSta
}
}
properties {
id
definition {
id
name
Expand All @@ -135,6 +136,19 @@ query GetPatients($locationId: ID, $rootLocationIds: [ID!], $states: [PatientSta
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
patientsTotal(locationNodeId: $locationId, rootLocationIds: $rootLocationIds, states: $states, filtering: $filtering, sorting: $sorting, search: $search)
Expand Down
14 changes: 14 additions & 0 deletions web/api/graphql/GetTask.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ query GetTask($id: ID!) {
kind
}
properties {
id
definition {
id
name
Expand All @@ -42,6 +43,19 @@ query GetTask($id: ID!) {
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
}
14 changes: 14 additions & 0 deletions web/api/graphql/GetTasks.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ query GetTasks($rootLocationIds: [ID!], $assigneeId: ID, $assigneeTeamId: ID, $f
kind
}
properties {
id
definition {
id
name
Expand All @@ -63,6 +64,19 @@ query GetTasks($rootLocationIds: [ID!], $assigneeId: ID, $assigneeTeamId: ID, $f
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
tasksTotal(rootLocationIds: $rootLocationIds, assigneeId: $assigneeId, assigneeTeamId: $assigneeTeamId, filtering: $filtering, sorting: $sorting, search: $search)
Expand Down
14 changes: 14 additions & 0 deletions web/api/graphql/PatientMutations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ mutation UpdatePatient($id: ID!, $data: UpdatePatientInput!) {
kind
}
properties {
id
definition {
id
name
Expand All @@ -84,6 +85,19 @@ mutation UpdatePatient($id: ID!, $data: UpdatePatientInput!) {
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions web/api/graphql/TaskMutations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mutation UpdateTask($id: ID!, $data: UpdateTaskInput!) {
isOnline
}
properties {
id
definition {
id
name
Expand All @@ -59,6 +60,19 @@ mutation UpdateTask($id: ID!, $data: UpdateTaskInput!) {
dateTimeValue
selectValue
multiSelectValues
userValue
user {
id
name
avatarUrl
lastOnline
isOnline
}
team {
id
title
kind
}
}
}
}
Expand Down
Loading
Loading