Skip to content

onconova.oncology.controllers.vitals

VitalsController

Bases: ControllerBase

create_vitals(payload)

Source code in onconova/oncology/controllers/vitals.py
@route.post(
    path="",
    response={201: ModifiedResourceSchema, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanManageCases],
    operation_id="createVitals",
)
def create_vitals(self, payload: scm.VitalsCreate):  # type: ignore
    return 201, payload.model_dump_django()

delete_vitals(vitalsId)

Source code in onconova/oncology/controllers/vitals.py
@route.delete(
    path="/{vitalsId}",
    response={204: None, 404: None, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanManageCases],
    operation_id="deleteVitalsById",
)
def delete_vitals(self, vitalsId: str):
    get_object_or_404(orm.Vitals, id=vitalsId).delete()
    return 204, None

get_all_vitals_history_events(vitalsId)

Source code in onconova/oncology/controllers/vitals.py
@route.get(
    path="/{vitalsId}/history/events",
    response={
        200: Paginated[HistoryEvent.bind_schema(scm.VitalsCreate)],
        404: None,
        **COMMON_HTTP_ERRORS,
    },
    permissions=[perms.CanViewCases],
    operation_id="getAllVitalsHistoryEvents",
)
@paginate()
@ordering()
def get_all_vitals_history_events(self, vitalsId: str):
    instance = get_object_or_404(orm.Vitals, id=vitalsId)
    return pghistory.models.Events.objects.tracks(instance).all()  # type: ignore

get_all_vitals_matching_the_query(query)

Source code in onconova/oncology/controllers/vitals.py
@route.get(
    path="",
    response={
        200: Paginated[scm.Vitals],
        **COMMON_HTTP_ERRORS,
    },
    permissions=[perms.CanViewCases],
    operation_id="getVitals",
)
@paginate()
@ordering()
@anonymize()
def get_all_vitals_matching_the_query(self, query: Query[scm.VitalsFilters]):  # type: ignore
    queryset = orm.Vitals.objects.all().order_by("-date")
    return query.filter(queryset)

get_vitals_by_id(vitalsId)

Source code in onconova/oncology/controllers/vitals.py
@route.get(
    path="/{vitalsId}",
    response={200: scm.Vitals, 404: None, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanViewCases],
    operation_id="getVitalsById",
)
@anonymize()
def get_vitals_by_id(self, vitalsId: str):
    return get_object_or_404(orm.Vitals, id=vitalsId)

get_vitals_history_event_by_id(vitalsId, eventId)

Source code in onconova/oncology/controllers/vitals.py
@route.get(
    path="/{vitalsId}/history/events/{eventId}",
    response={
        200: HistoryEvent.bind_schema(scm.VitalsCreate),
        404: None,
        **COMMON_HTTP_ERRORS,
    },
    permissions=[perms.CanViewCases],
    operation_id="getVitalsHistoryEventById",
)
def get_vitals_history_event_by_id(self, vitalsId: str, eventId: str):
    instance = get_object_or_404(orm.Vitals, id=vitalsId)
    return get_object_or_404(
        pghistory.models.Events.objects.tracks(instance), pgh_id=eventId  # type: ignore
    )

revert_vitals_to_history_event(vitalsId, eventId)

Source code in onconova/oncology/controllers/vitals.py
@route.put(
    path="/{vitalsId}/history/events/{eventId}/reversion",
    response={201: ModifiedResourceSchema, 404: None, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanManageCases],
    operation_id="revertVitalsToHistoryEvent",
)
def revert_vitals_to_history_event(self, vitalsId: str, eventId: str):
    instance = get_object_or_404(orm.Vitals, id=vitalsId)
    return 201, get_object_or_404(instance.events, pgh_id=eventId).revert()

update_vitals(vitalsId, payload)

Source code in onconova/oncology/controllers/vitals.py
@route.put(
    path="/{vitalsId}",
    response={200: ModifiedResourceSchema, 404: None, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanManageCases],
    operation_id="updateVitalsById",
)
def update_vitals(self, vitalsId: str, payload: scm.VitalsCreate):  # type: ignore
    instance = get_object_or_404(orm.Vitals, id=vitalsId)
    return payload.model_dump_django(instance=instance)
runner