Skip to content

Commit b058a81

Browse files
authored
Delete notes of a removed patient (#131)
* Delete notes of a removed patient * Fix flake8 issues
1 parent 1d75261 commit b058a81

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

server/openapi_server/controllers/note_controller.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,23 @@ def delete_note(dataset_id, fhir_store_id, note_id): # noqa: E501
8383
res = None
8484
status = None
8585
try:
86-
db_note = DbNote.objects.get(id=note_id)
87-
db_note.delete()
86+
DbNote.objects.get(id=note_id).delete()
87+
res = {}
88+
status = 200
89+
except DoesNotExist:
90+
status = 404
91+
res = Error("The specified resource was not found", status)
92+
except Exception as error:
93+
status = 500
94+
res = Error("Internal error", status, str(error))
95+
return res, status
96+
97+
98+
def delete_notes_by_patient(patientId):
99+
res = None
100+
status = None
101+
try:
102+
DbNote.objects(patientId=patientId).delete()
88103
res = {}
89104
status = 200
90105
except DoesNotExist:

server/openapi_server/controllers/patient_controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from openapi_server.models.patient_create_request import PatientCreateRequest # noqa: E501
1010
from openapi_server.models.patient_create_response import PatientCreateResponse # noqa: E501
1111
from openapi_server.config import Config
12+
from openapi_server.controllers.note_controller import delete_notes_by_patient # noqa: E501
1213

1314

1415
def create_patient(dataset_id, fhir_store_id): # noqa: E501
@@ -73,6 +74,7 @@ def delete_patient(dataset_id, fhir_store_id, patient_id): # noqa: E501
7374
res = None
7475
status = None
7576
try:
77+
delete_notes_by_patient(patient_id)
7678
db_patient = DbPatient.objects.get(id=patient_id)
7779
db_patient.delete()
7880
res = {}

0 commit comments

Comments
 (0)