Bases: FhirBaseController
create_patient(payload)
Source code in onconova/interoperability/fhir/controllers/patient.py
| @route.post(
path="",
response={
200: CancerPatientProfile | OperationOutcome | None,
400: OperationOutcome,
409: OperationOutcome,
},
permissions=[perms.CanManageCases],
operation_id="createPatient",
exclude_none=True,
summary="Create a new resource",
)
def create_patient(self, payload: OnconovaCancerPatient):
return self.create_fhir_resource(CancerPatientProfile.model_validate(payload))
|
delete_patient(rid)
Source code in onconova/interoperability/fhir/controllers/patient.py
| @route.delete(
path="{rid}",
response={
204: None,
404: OperationOutcome,
},
permissions=[perms.CanManageCases],
operation_id="deletePatient",
exclude_none=True,
summary="Delete the resource so that it no exists (no read, search etc)",
)
def delete_patient(self, rid: str):
return self.delete_fhir_resource(rid, PatientCase)
|
fetch_mcode_patient_bundle(rid)
Source code in onconova/interoperability/fhir/controllers/patient.py
| @route.get(
path="{rid}/$mcode-everything",
response={200: BundleProfile, **COMMON_READ_HTTP_ERRORS},
permissions=[perms.CanManageCases],
operation_id="FetchmCODEPatientBundle",
exclude_none=True,
summary="Read the current state of the resource",
)
def fetch_mcode_patient_bundle(self, rid: str):
if not (instance := PatientCase.objects.filter(id=rid).first()):
# If resource not found, check if it was deleted
if PatientCase.pgh_event_model.objects.filter(pgh_obj_id=rid, pgh_label="delete").exists(): # type: ignore
return 410, None
else:
return 404, None
# Set the Last-Modified header if the instance has an updated_at timestamp
if getattr(instance, "updated_at", None):
assert self.context and self.context.response
self.context.response.headers["Last-Modified"] = instance.updated_at.isoformat() # type: ignore
return BundleProfile.construct_bundle(instance)
|
read_patient(rid)
Source code in onconova/interoperability/fhir/controllers/patient.py
| @route.get(
path="{rid}",
response={200: CancerPatientProfile, **COMMON_READ_HTTP_ERRORS},
permissions=[perms.CanManageCases],
operation_id="readPatient",
exclude_none=True,
summary="Read the current state of the resource",
)
def read_patient(self, rid: str):
return self.read_fhir_resource(rid, PatientCase)
|
update_patient(rid, payload)
Source code in onconova/interoperability/fhir/controllers/patient.py
| @route.put(
path="{rid}",
response={
200: CancerPatientProfile | OperationOutcome | None,
**COMMON_UPDATE_HTTP_ERRORS,
},
permissions=[perms.CanManageCases],
operation_id="updatePatient",
exclude_none=True,
summary="Update the current state of the resource",
)
def update_patient(self, rid: str, payload: OnconovaCancerPatient):
return self.update_fhir_resource(
rid, CancerPatientProfile.model_validate(payload)
)
|