@@ -49,7 +49,7 @@ def get(self, request, study, ppm_id, format=None):
49
49
50
50
try :
51
51
# Check patient
52
- if not FHIR .query_patient (patient = ppm_id ):
52
+ if not FHIR .get_patient (patient = ppm_id ):
53
53
return Response (f'Participant { ppm_id } does not exist' , status = status .HTTP_404_NOT_FOUND )
54
54
55
55
# Check FHIR
@@ -82,7 +82,7 @@ def post(self, request, study, ppm_id=None, format=None):
82
82
83
83
try :
84
84
# Check patient
85
- if not FHIR .query_patient (patient = ppm_id ):
85
+ if not FHIR .get_patient (patient = ppm_id ):
86
86
return Response (f'Participant { ppm_id } does not exist' , status = status .HTTP_404_NOT_FOUND )
87
87
88
88
# Check if we should overwrite
@@ -140,18 +140,8 @@ def delete_consent_document_reference(request, study, ppm_id, document_reference
140
140
# Get their consent composition
141
141
composition = FHIR .get_consent_composition (patient = ppm_id , study = study )
142
142
if not composition :
143
- compositions = FHIR .query_consent_compositions (patient = ppm_id )
144
- if not compositions :
145
- logger .error (f'PPM/{ study } /{ ppm_id } : No consent compositions' )
146
- return False
147
-
148
- elif len (compositions ) > 1 :
149
- logger .error (f'PPM/{ study } /{ ppm_id } : Too many generic consent '
150
- f'compositions: { [r ["resource" ]["id" ] for r in compositions ]} ' )
151
- return False
152
-
153
- else :
154
- composition = compositions [0 ]
143
+ logger .error (f'PPM/{ study } /{ ppm_id } : No consent compositions' )
144
+ return False
155
145
156
146
# Update it
157
147
if FHIR .update_consent_composition (patient = ppm_id , study = study , composition = composition ):
@@ -189,7 +179,7 @@ def create_consent_document_reference(request, study, ppm_id=None):
189
179
ppm_id = FHIR .query_patient_id (get_jwt_email (request = request , verify = False ))
190
180
191
181
# Pull their record
192
- bundle = FHIR .query_participant (patient = ppm_id , flatten_return = True )
182
+ participant = FHIR .get_participant (patient = ppm_id , flatten_return = True )
193
183
194
184
# Get study title
195
185
study_title = PPM .Study .title (study )
@@ -204,7 +194,7 @@ def create_consent_document_reference(request, study, ppm_id=None):
204
194
# Submit consent PDF
205
195
logger .debug (f"PPM/{ study } : Rendering consent with template: { template_name } " )
206
196
response = render_pdf (f'People-Powered Medicine { study_title } Consent' , request , template_name ,
207
- context = bundle .get ('composition' ), options = {})
197
+ context = participant .get ('composition' ), options = {})
208
198
209
199
# Hash the content
210
200
hash = hashlib .md5 (response .content ).hexdigest ()
@@ -409,9 +399,9 @@ def get(self, request, questionnaire_id=None, format=None):
409
399
if questionnaire_id :
410
400
411
401
# Try to fetch it
412
- questionnaire = FHIR .get_questionnaire (
413
- questionnaire_id = questionnaire_id ,
414
- flatten_return = False
402
+ questionnaire = FHIR .fhir_read (
403
+ resource_type = "Questionnaire" ,
404
+ resource_id = questionnaire_id ,
415
405
)
416
406
417
407
# Return it or 404
0 commit comments