From e4411c65e8cb9ce87a26169c2e41b74573d3e571 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Tue, 18 Feb 2025 14:17:05 -0800 Subject: [PATCH 1/6] barcode_meta tweaks --- microsetta_interface/implementation.py | 9 +++++++++ microsetta_interface/templates/sample.jinja2 | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/microsetta_interface/implementation.py b/microsetta_interface/implementation.py index b771edf3..7af0e288 100644 --- a/microsetta_interface/implementation.py +++ b/microsetta_interface/implementation.py @@ -2486,6 +2486,15 @@ def get_update_sample(*, account_id=None, source_id=None, sample_id=None): sample_output['date'] = "" sample_output['time'] = "" + if sample_output['sample_site'] == "Cheek": + # Format date and time to be JavaScript-friendly + if sample_output['barcode_meta']['sample_site_last_washed_date']\ + is None: + sample_output['barcode_meta']['sample_site_last_washed_date'] = "" + if sample_output['barcode_meta']['sample_site_last_washed_time']\ + is None: + sample_output['barcode_meta']['sample_site_last_washed_time'] = "" + profile_has_samples = _check_if_source_has_samples(account_id, source_id) need_reconsent_data = check_current_consent( diff --git a/microsetta_interface/templates/sample.jinja2 b/microsetta_interface/templates/sample.jinja2 index 4596023b..8514e452 100644 --- a/microsetta_interface/templates/sample.jinja2 +++ b/microsetta_interface/templates/sample.jinja2 @@ -188,7 +188,7 @@ timeFormat: 'h:mm p', interval: 30, {% if sample.barcode_meta['sample_site_last_washed_time'] == "" %} - defaultTime: 'now', + defaultTime: '', {% else %} defaultTime: '{{ sample.barcode_meta['sample_site_last_washed_time'] }}', {% endif %} @@ -318,7 +318,7 @@
- +
From 13e912c2811755ec4dd4c384b0bbcd44650ab6a7 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Wed, 19 Feb 2025 09:05:04 -0800 Subject: [PATCH 2/6] Add prompt for skin scoring app --- microsetta_interface/implementation.py | 32 +++++++++++++++++++--- microsetta_interface/routes.yaml | 10 +++++++ microsetta_interface/templates/kits.jinja2 | 5 ++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/microsetta_interface/implementation.py b/microsetta_interface/implementation.py index 7af0e288..223a9462 100644 --- a/microsetta_interface/implementation.py +++ b/microsetta_interface/implementation.py @@ -1991,7 +1991,8 @@ def get_source(*, account_id=None, source_id=None): @prerequisite([SOURCE_PREREQS_MET, BIOSPECIMEN_PREREQS_MET]) -def get_kits(*, account_id=None, source_id=None, check_survey_date=False): +def get_kits(*, account_id=None, source_id=None, check_survey_date=False, + sample_site=None): # Retrieve the account has_error, account, _ = ApiRequest.get('/accounts/%s' % account_id) if has_error: @@ -2073,6 +2074,28 @@ def get_kits(*, account_id=None, source_id=None, check_survey_date=False): prompt_survey_update = prompt_response['prompt'] + # For Cheek samples, we want to display prompt to return to the My Profile + # tab and take the Skin Scoring App external survey. + # Set a default value of False + prompt_skin_app = False + if sample_site == "Cheek": + # We need to verify that they're eligible for the app, which means + # they either already have credentials, or some are availabile. The + # business logic is handled in the API, we just need to see if the + # survey is available to the source. + has_error, surveys_output, _ = ApiRequest.get( + '/accounts/%s/sources/%s/survey_templates' % ( + account_id, source_id + ) + ) + if has_error: + return surveys_output + + for survey in surveys_output: + if survey['survey_template_id'] == SKIN_SCORING_APP_ID: + prompt_skin_app = True + break + need_reconsent_data = check_current_consent( account_id, source_id, "data" ) @@ -2097,7 +2120,8 @@ def get_kits(*, account_id=None, source_id=None, check_survey_date=False): prompt_survey_id=BASIC_INFO_ID, need_reconsent_data=need_reconsent_data, need_reconsent_biospecimen=need_reconsent_biospecimen, - show_update_age=show_update_age + show_update_age=show_update_age, + prompt_skin_app=prompt_skin_app ) @@ -2582,8 +2606,8 @@ def post_update_sample(*, account_id=None, source_id=None, sample_id=None): return sample_output return redirect( - "/accounts/%s/sources/%s/kits?check_survey_date=True" % - (account_id, source_id) + "/accounts/%s/sources/%s/kits?check_survey_date=True&sample_site=%s" % + (account_id, source_id, model['sample_site']) ) diff --git a/microsetta_interface/routes.yaml b/microsetta_interface/routes.yaml index 8cad9bf9..daae2976 100644 --- a/microsetta_interface/routes.yaml +++ b/microsetta_interface/routes.yaml @@ -427,6 +427,7 @@ paths: - $ref: '#/components/parameters/account_id' - $ref: '#/components/parameters/source_id' - $ref: '#/components/parameters/check_survey_date' + - $ref: '#/components/parameters/sample_site' responses: '200': description: Display of kits for a source @@ -1658,6 +1659,12 @@ components: description: T/F flag on whether the Kits page should check user's most recent survey update date schema: $ref: '#/components/schemas/check_survey_date' + sample_site: + name: sample_site + in: query + description: The sample site of the last sample the user edited + schema: + $ref: '#/components/schemas/sample_site' external_report_id: name: external_report_id in: path @@ -1728,6 +1735,9 @@ components: check_survey_date: type: boolean example: True + sample_site: + type: string + example: "Cheek" external_report_id: type: string example: "b0b0b0b0-b0b0-b0b0-b0b0-b0b0b0b0b0b0" diff --git a/microsetta_interface/templates/kits.jinja2 b/microsetta_interface/templates/kits.jinja2 index 1f776999..1b885346 100644 --- a/microsetta_interface/templates/kits.jinja2 +++ b/microsetta_interface/templates/kits.jinja2 @@ -203,6 +203,11 @@ {{ _('Thank you for logging your sample information. It looks like you haven\'t updated your profile recently. Please review') }} {{ _('your survey responses') }} {{ _('to ensure they\'re as current and complete as possible.') }}
{% endif %} + {% if prompt_skin_app %} + + {% endif %} {% if profile_has_samples and (need_reconsent_data or need_reconsent_biospecimen) %}