Skip to content

onconova.oncology.controllers.therapy_line

TherapyLineController

Bases: ControllerBase

create_therapy_line(payload)

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

delete_therapy_line(therapyLineId)

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

get_all_therapy_line_history_events(therapyLineId)

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

get_all_therapy_lines_matching_the_query(query)

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

get_reassigned_patient_case_therapy_lines(caseId)

Source code in onconova/oncology/controllers/therapy_line.py
@route.get(
    path="/{caseId}/re-assignments",
    response={200: List[scm.TherapyLine], 404: None, **COMMON_HTTP_ERRORS},
    permissions=[perms.CanViewCases],
    operation_id="getReassignedPatientCaseTherapyLines",
)
def get_reassigned_patient_case_therapy_lines(self, caseId: str):
    return orm.TherapyLine.assign_therapy_lines(
        get_object_or_404(orm.PatientCase, id=caseId)
    )

get_therapy_line_by_id(therapyLineId)

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

get_therapy_line_history_event_by_id(therapyLineId, eventId)

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

revert_therapy_line_to_history_event(therapyLineId, eventId)

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

update_therapy_line(therapyLineId, payload)

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