Skip to content

Commit 4116a61

Browse files
authored
Merge pull request #214 from hms-dbmi/PPM-766
PPM 766
2 parents 3db15b7 + 1309b8e commit 4116a61

26 files changed

+712
-853
lines changed

app/api/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Wire up our API using automatic URL routing.
1010
# Additionally, we include login URLs for the browsable API.
1111
urlpatterns = [
12-
re_path(r'^consent/(?P<study>[\w\d-]+)/(?P<ppm_id>[\d]+)/?$', views.ConsentView.as_view(), name='consent'),
12+
re_path(r'^consent/(?P<study>[\w\d-]+)/(?P<ppm_id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[\d]+)/?$', views.ConsentView.as_view(), name='consent'),
1313
re_path(r'^consent/(?P<study>[\w\d-]+)/?$', views.ConsentsView.as_view(), name='consents'),
1414
re_path(r'^questionnaire/?$', views.QuestionnaireView.as_view(), name='questionnaire'),
1515
re_path(r'^questionnaire/(?P<questionnaire_id>[\w\d-]+)/?$', views.QuestionnaireView.as_view(), name='questionnaire'),

app/api/views.py

+9-19
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get(self, request, study, ppm_id, format=None):
4949

5050
try:
5151
# Check patient
52-
if not FHIR.query_patient(patient=ppm_id):
52+
if not FHIR.get_patient(patient=ppm_id):
5353
return Response(f'Participant {ppm_id} does not exist', status=status.HTTP_404_NOT_FOUND)
5454

5555
# Check FHIR
@@ -82,7 +82,7 @@ def post(self, request, study, ppm_id=None, format=None):
8282

8383
try:
8484
# Check patient
85-
if not FHIR.query_patient(patient=ppm_id):
85+
if not FHIR.get_patient(patient=ppm_id):
8686
return Response(f'Participant {ppm_id} does not exist', status=status.HTTP_404_NOT_FOUND)
8787

8888
# Check if we should overwrite
@@ -140,18 +140,8 @@ def delete_consent_document_reference(request, study, ppm_id, document_reference
140140
# Get their consent composition
141141
composition = FHIR.get_consent_composition(patient=ppm_id, study=study)
142142
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
155145

156146
# Update it
157147
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):
189179
ppm_id = FHIR.query_patient_id(get_jwt_email(request=request, verify=False))
190180

191181
# 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)
193183

194184
# Get study title
195185
study_title = PPM.Study.title(study)
@@ -204,7 +194,7 @@ def create_consent_document_reference(request, study, ppm_id=None):
204194
# Submit consent PDF
205195
logger.debug(f"PPM/{study}: Rendering consent with template: {template_name}")
206196
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={})
208198

209199
# Hash the content
210200
hash = hashlib.md5(response.content).hexdigest()
@@ -409,9 +399,9 @@ def get(self, request, questionnaire_id=None, format=None):
409399
if questionnaire_id:
410400

411401
# 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,
415405
)
416406

417407
# Return it or 404

app/consent/fhir/example-signature.json

+27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@
66
"subjectType": [
77
"patient"
88
],
9+
"useContext": [
10+
{
11+
"code": {
12+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
13+
"code": "program",
14+
"display": "Program"
15+
},
16+
"valueReference": {"reference": "ResearchStudy/ppm-example"}
17+
},
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "task",
22+
"display": "Workflow Task"
23+
},
24+
"valueCodeableConcept": {
25+
"coding": [
26+
{
27+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
28+
"code": "ppm-example",
29+
"display": "ppm-example"
30+
}
31+
],
32+
"text": "ppm-example"
33+
}
34+
}
35+
],
936
"item": [
1037
{
1138
"linkId": "display-1",

app/consent/fhir/guardian-signature-part-1.json

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-asd",
37+
"display": "ppm-asd"
38+
}
39+
],
40+
"text": "ppm-asd"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",

app/consent/fhir/guardian-signature-part-2.json

+31-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-asd",
37+
"display": "ppm-asd"
38+
}
39+
],
40+
"text": "ppm-asd"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",
@@ -23,9 +50,9 @@
2350
{
2451
"linkId": "question-1",
2552
"text": "I acknowledge that I have explained this study to my child or individual in my care who will be participating.",
26-
"type": "question",
53+
"type": "choice",
2754
"required": true,
28-
"option": [
55+
"answerOption": [
2956
{
3057
"valueString": "yes"
3158
},
@@ -41,7 +68,8 @@
4168
"enableWhen": [
4269
{
4370
"question": "question-1",
44-
"answerString": "no"
71+
"answerString": "no",
72+
"operator": "="
4573
}
4674
],
4775
"required": true

app/consent/fhir/guardian-signature-part-3.json

+27
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@
66
"subjectType": [
77
"patient"
88
],
9+
"useContext": [
10+
{
11+
"code": {
12+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
13+
"code": "program",
14+
"display": "Program"
15+
},
16+
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
17+
},
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "task",
22+
"display": "Workflow Task"
23+
},
24+
"valueCodeableConcept": {
25+
"coding": [
26+
{
27+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
28+
"code": "ppm-asd",
29+
"display": "ppm-asd"
30+
}
31+
],
32+
"text": "ppm-asd"
33+
}
34+
}
35+
],
936
"item": [
1037
{
1138
"linkId": "display-1",

app/consent/fhir/individual-signature-part-1.json

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-asd",
37+
"display": "ppm-asd"
38+
}
39+
],
40+
"text": "ppm-asd"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",

app/consent/fhir/neer-signature-v2.json

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-neer",
37+
"display": "ppm-neer"
38+
}
39+
],
40+
"text": "ppm-neer"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",

app/consent/fhir/neer-signature-v3.json

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-neer",
37+
"display": "ppm-neer"
38+
}
39+
],
40+
"text": "ppm-neer"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",

app/consent/fhir/neer-signature.json

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
"subjectType": [
1515
"patient"
1616
],
17+
"useContext": [
18+
{
19+
"code": {
20+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
21+
"code": "program",
22+
"display": "Program"
23+
},
24+
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
25+
},
26+
{
27+
"code": {
28+
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
29+
"code": "task",
30+
"display": "Workflow Task"
31+
},
32+
"valueCodeableConcept": {
33+
"coding": [
34+
{
35+
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
36+
"code": "ppm-neer",
37+
"display": "ppm-neer"
38+
}
39+
],
40+
"text": "ppm-neer"
41+
}
42+
}
43+
],
1744
"item": [
1845
{
1946
"linkId": "display-1",

0 commit comments

Comments
 (0)