Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPM 766 #214

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
re_path(r'^consent/(?P<study>[\w\d-]+)/(?P<ppm_id>[\d]+)/?$', views.ConsentView.as_view(), name='consent'),
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'),
re_path(r'^consent/(?P<study>[\w\d-]+)/?$', views.ConsentsView.as_view(), name='consents'),
re_path(r'^questionnaire/?$', views.QuestionnaireView.as_view(), name='questionnaire'),
re_path(r'^questionnaire/(?P<questionnaire_id>[\w\d-]+)/?$', views.QuestionnaireView.as_view(), name='questionnaire'),
Expand Down
28 changes: 9 additions & 19 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(self, request, study, ppm_id, format=None):

try:
# Check patient
if not FHIR.query_patient(patient=ppm_id):
if not FHIR.get_patient(patient=ppm_id):
return Response(f'Participant {ppm_id} does not exist', status=status.HTTP_404_NOT_FOUND)

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

try:
# Check patient
if not FHIR.query_patient(patient=ppm_id):
if not FHIR.get_patient(patient=ppm_id):
return Response(f'Participant {ppm_id} does not exist', status=status.HTTP_404_NOT_FOUND)

# Check if we should overwrite
Expand Down Expand Up @@ -140,18 +140,8 @@ def delete_consent_document_reference(request, study, ppm_id, document_reference
# Get their consent composition
composition = FHIR.get_consent_composition(patient=ppm_id, study=study)
if not composition:
compositions = FHIR.query_consent_compositions(patient=ppm_id)
if not compositions:
logger.error(f'PPM/{study}/{ppm_id}: No consent compositions')
return False

elif len(compositions) > 1:
logger.error(f'PPM/{study}/{ppm_id}: Too many generic consent '
f'compositions: {[r["resource"]["id"] for r in compositions]}')
return False

else:
composition = compositions[0]
logger.error(f'PPM/{study}/{ppm_id}: No consent compositions')
return False

# Update it
if FHIR.update_consent_composition(patient=ppm_id, study=study, composition=composition):
Expand Down Expand Up @@ -189,7 +179,7 @@ def create_consent_document_reference(request, study, ppm_id=None):
ppm_id = FHIR.query_patient_id(get_jwt_email(request=request, verify=False))

# Pull their record
bundle = FHIR.query_participant(patient=ppm_id, flatten_return=True)
participant = FHIR.get_participant(patient=ppm_id, flatten_return=True)

# Get study title
study_title = PPM.Study.title(study)
Expand All @@ -204,7 +194,7 @@ def create_consent_document_reference(request, study, ppm_id=None):
# Submit consent PDF
logger.debug(f"PPM/{study}: Rendering consent with template: {template_name}")
response = render_pdf(f'People-Powered Medicine {study_title} Consent', request, template_name,
context=bundle.get('composition'), options={})
context=participant.get('composition'), options={})

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

# Try to fetch it
questionnaire = FHIR.get_questionnaire(
questionnaire_id=questionnaire_id,
flatten_return=False
questionnaire = FHIR.fhir_read(
resource_type="Questionnaire",
resource_id=questionnaire_id,
)

# Return it or 404
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/example-signature.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-example"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-example",
"display": "ppm-example"
}
],
"text": "ppm-example"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/guardian-signature-part-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-asd",
"display": "ppm-asd"
}
],
"text": "ppm-asd"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
34 changes: 31 additions & 3 deletions app/consent/fhir/guardian-signature-part-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-asd",
"display": "ppm-asd"
}
],
"text": "ppm-asd"
}
}
],
"item": [
{
"linkId": "display-1",
Expand All @@ -23,9 +50,9 @@
{
"linkId": "question-1",
"text": "I acknowledge that I have explained this study to my child or individual in my care who will be participating.",
"type": "question",
"type": "choice",
"required": true,
"option": [
"answerOption": [
{
"valueString": "yes"
},
Expand All @@ -41,7 +68,8 @@
"enableWhen": [
{
"question": "question-1",
"answerString": "no"
"answerString": "no",
"operator": "="
}
],
"required": true
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/guardian-signature-part-3.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-asd",
"display": "ppm-asd"
}
],
"text": "ppm-asd"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/individual-signature-part-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-asd",
"display": "ppm-asd"
}
],
"text": "ppm-asd"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/neer-signature-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-neer",
"display": "ppm-neer"
}
],
"text": "ppm-neer"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/neer-signature-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-neer",
"display": "ppm-neer"
}
],
"text": "ppm-neer"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/neer-signature.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-neer"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-neer",
"display": "ppm-neer"
}
],
"text": "ppm-neer"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
Loading