Skip to content

Commit

Permalink
Merge pull request #453 from Ram6911/ramp_remove_email_field_on_source
Browse files Browse the repository at this point in the history
Removing Participant Email field from Source submitting page
  • Loading branch information
cassidysymons authored Sep 14, 2022
2 parents 6ba3fca + e2148b5 commit b3f7f0c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 69 deletions.
1 change: 0 additions & 1 deletion microsetta_private_api/LEGACY/locale_data/english_gut.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@
'OBTAINER_NAME': 'Name of person obtaining assent',
'TEXT_I_HAVE_READ_PARENT': 'I have read (or someone has read to me) this form. I am aware that my child is being asked to be in a research study. I voluntarily agree for my child to be in this study.',
'PARTICIPANT_NAME': 'Participant name',
'PARTICIPANT_EMAIL': 'Participant email',
'PARTICIPANT_PARENT_1': 'Parent/Guardian name',
'PARTICIPANT_PARENT_2': 'Parent/Guardian name of second parent',
'PARTICIPANT_DECEASED_PARENTS': 'One parent/guardian is deceased or unable to consent',
Expand Down
1 change: 0 additions & 1 deletion microsetta_private_api/LEGACY/locale_data/spanish_gut.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
'OBTAINER_NAME': 'Nombre de la persona que obtiene el consentimiento',
'TEXT_I_HAVE_READ_PARENT': 'He leído (o alguien me ha leído) este formulario. Soy consciente de que se le está pidiendo a mi hijo que participe en un estudio de investigación. Acepto voluntariamente que mi hijo participe en este estudio',
'PARTICIPANT_NAME': 'Nombre del participante',
'PARTICIPANT_EMAIL': 'Correo electrónico del participante',
'PARTICIPANT_PARENT_1': 'Nombre del Padre de Familia / Guardian',
'PARTICIPANT_PARENT_2': 'Nombre del padre / tutor del segundo padre',
'PARTICIPANT_DECEASED_PARENTS': 'Uno de los padres / tutor ha fallecido o no puede dar su consentimiento',
Expand Down
3 changes: 0 additions & 3 deletions microsetta_private_api/admin/sample_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ def per_sample(project, barcodes, strip_sampleid):
source = diag['source']

account_email = None if account is None else account.email
source_email = None
source_type = None if source is None else source.source_type
vio_id = None

if source is not None and source_type == Source.SOURCE_TYPE_HUMAN:
source_email = source.source_data.email

vio_id = template_repo.get_vioscreen_id_if_exists(account.id,
source.id,
Expand Down Expand Up @@ -75,7 +73,6 @@ def per_sample(project, barcodes, strip_sampleid):
"project": project,
"source-type": source_type,
"site-sampled": sample_site,
"source-email": source_email,
"account-email": account_email,
"vioscreen_username": vio_id,
"ffq-taken": ffq_taken,
Expand Down
4 changes: 0 additions & 4 deletions microsetta_private_api/admin/tests/test_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,6 @@ def test_query_barcode_stats_project_barcodes_without_strip(self):
exp_status = [None, 'no-associated-source', 'sample-is-valid']
self.assertEqual([v['sample-status'] for v in response_obj],
exp_status)
n_src = sum([v['source-email'] is not None for v in response_obj])
self.assertEqual(n_src, 1)

def test_query_barcode_stats_project_barcodes_with_strip(self):
barcodes = ['000010307', '000023344', '000036855']
Expand All @@ -1067,8 +1065,6 @@ def test_query_barcode_stats_project_barcodes_with_strip(self):
exp_status = [None, 'no-associated-source', 'sample-is-valid']
self.assertEqual([v['sample-status'] for v in response_obj],
exp_status)
n_src = sum([v['source-email'] is not None for v in response_obj])
self.assertEqual(n_src, 1)

def test_send_email(self):
def mock_func(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions microsetta_private_api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ._source import (
create_source, read_source, update_source, delete_source,
read_sources, create_human_source_from_consent,
check_duplicate_source_name_email
check_duplicate_source_name
)
from ._survey import (
read_survey_template, read_survey_templates, read_answered_survey,
Expand Down Expand Up @@ -72,7 +72,7 @@
'update_source',
'delete_source',
'read_sources',
'check_duplicate_source_name_email',
'check_duplicate_source_name',
'create_human_source_from_consent',
'read_survey_template',
'read_survey_templates',
Expand Down
8 changes: 3 additions & 5 deletions microsetta_private_api/api/_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def create_human_source_from_consent(account_id, body, token_info):
'source_type': Source.SOURCE_TYPE_HUMAN,
'source_name': body['participant_name'],
'consent': {
'participant_email': body['participant_email'],
'age_range': body['age_range']
}
}
Expand All @@ -156,12 +155,11 @@ def create_human_source_from_consent(account_id, body, token_info):
return create_source(account_id, source, token_info)


def check_duplicate_source_name_email(account_id, body, token_info):
def check_duplicate_source_name(account_id, body, token_info):
_validate_account_access(token_info, account_id)
with Transaction() as t:
source_repo = SourceRepo(t)
source_name = body['participant_name']
email = body['participant_email']
source = source_repo.get_duplicate_source_name_email(
account_id, source_name, email)
source = source_repo.get_duplicate_source_name(
account_id, source_name)
return jsonify(source), 200
22 changes: 1 addition & 21 deletions microsetta_private_api/api/microsetta_private_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ paths:

'/accounts/{account_id}/check_duplicate_source':
post:
operationId: microsetta_private_api.api.check_duplicate_source_name_email
operationId: microsetta_private_api.api.check_duplicate_source_name
tags:
- Account
summary: Get information about duplicate source
Expand All @@ -185,11 +185,8 @@ paths:
properties:
participant_name: # Field is named participant_name, but contents are used to fill source's name
$ref: '#/components/schemas/source_name'
participant_email:
$ref: '#/components/schemas/participant_email'
required:
- participant_name
- participant_email
responses:
'200':
description: Successfully returned source information
Expand Down Expand Up @@ -277,8 +274,6 @@ paths:
type: string
participant_name:
type: string
participant_email:
type: string
participant_parent_1:
type: string
participant_parent_2:
Expand Down Expand Up @@ -325,8 +320,6 @@ paths:
$ref: '#/components/schemas/age_range'
participant_name: # Field is named participant_name, but contents are used to fill source's name
$ref: '#/components/schemas/source_name'
participant_email:
$ref: '#/components/schemas/participant_email'
parent_1_name:
$ref: '#/components/schemas/parent_1_name'
parent_2_name:
Expand All @@ -340,7 +333,6 @@ paths:
required:
- age_range
- participant_name
- participant_email
responses:
'201':
description: Successfully created new human source based on consent form
Expand Down Expand Up @@ -393,13 +385,11 @@ paths:
source_name: "Ophelia Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "18-plus"
- source_id: "df077cd7-f2c7-42e4-b8ed-9c7e9dd47ce5"
source_name: "P. Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "0-6"
child_info:
parent_1_name: "Demeter Doe"
Expand Down Expand Up @@ -2911,10 +2901,6 @@ components:
type: string
enum: [human, animal, environmental]
example: human
participant_email:
type: string
format: email
example: "[email protected]"
age_range:
type: string
enum: ["0-6", "7-12", "13-17", "18-plus", "legacy"]
Expand Down Expand Up @@ -2963,8 +2949,6 @@ components:
consent:
type: object
properties:
participant_email:
$ref: '#/components/schemas/participant_email'
age_range:
$ref: '#/components/schemas/age_range'
child_info:
Expand Down Expand Up @@ -3269,14 +3253,12 @@ components:
source_name: "Nell Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "18-plus"
human_child_source:
value:
source_name: "K. Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "7-12"
child_info:
parent_1_name: "Maman Doe"
Expand All @@ -3294,15 +3276,13 @@ components:
source_name: "Nell Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "18-plus"
human_child_source_w_id:
value:
source_id: "b06825c2-e808-4606-8819-861b0fa8a5ce"
source_name: "K. Doe"
source_type: human
consent:
participant_email: "[email protected]"
age_range: "7-12"
child_info:
parent_1_name: "Maman Doe"
Expand Down
3 changes: 0 additions & 3 deletions microsetta_private_api/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
'source_name': 'Bo',
'source_type': 'human',
'consent': {
'participant_email': '[email protected]',
'age_range': "18-plus"
},
}
Expand Down Expand Up @@ -968,8 +967,6 @@ def test_account_scrub_success(self):

self.assertEqual(response_obj['source_name'],
'scrubbed')
self.assertEqual(response_obj['consent']['participant_email'],
'[email protected]')

# pull the sample details
response = self.client.get(
Expand Down
4 changes: 1 addition & 3 deletions microsetta_private_api/api/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def setup_test_data():
ACCT_ID,
Source.SOURCE_TYPE_HUMAN,
"Bo",
HumanInfo("[email protected]", False, None, None,
HumanInfo(False, None, None,
False, datetime.datetime.utcnow(), None,
"Mr. Obtainer",
"18-plus")
Expand Down Expand Up @@ -940,7 +940,6 @@ def test_create_human_source(self):
data=json.dumps(
{"age_range": "18-plus",
"participant_name": "Joe Schmoe",
"participant_email": "[email protected]",
"parent_1_name": "Mr. Schmoe",
"parent_2_name": "Mrs. Schmoe",
"deceased_parent": 'false',
Expand Down Expand Up @@ -987,7 +986,6 @@ def test_delete_source(self):
data=json.dumps(
{"age_range": "18-plus",
"participant_name": "Joe Schmoe",
"participant_email": "[email protected]",
"parent_1_name": "Mr. Schmoe",
"parent_2_name": "Mrs. Schmoe",
"deceased_parent": 'false',
Expand Down
16 changes: 6 additions & 10 deletions microsetta_private_api/model/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def from_dict(input_dict, consent_date, date_revoked):
child_info = {}

return HumanInfo(
consent["participant_email"],
is_juvenile,
child_info.get("parent_1_name"),
child_info.get("parent_2_name"),
Expand All @@ -23,10 +22,9 @@ def from_dict(input_dict, consent_date, date_revoked):
child_info.get("obtainer_name"),
age_range)

def __init__(self, email, is_juvenile,
def __init__(self, is_juvenile,
parent1_name, parent2_name, deceased_parent,
consent_date, date_revoked, assent_obtainer, age_range):
self.email = email
self.is_juvenile = is_juvenile
self.parent1_name = parent1_name
self.parent2_name = parent2_name
Expand All @@ -37,12 +35,10 @@ def __init__(self, email, is_juvenile,
self.age_range = age_range

def to_api(self):
consent = {"participant_email": self.email,
"age_range": self.age_range}
consent = {"age_range": self.age_range}

if self.is_juvenile:
consent.update({
"participant_email": self.email,
"parent_1_name": self.parent1_name,
"parent_2_name": self.parent2_name,
"deceased_parent": self.deceased_parent,
Expand Down Expand Up @@ -81,10 +77,10 @@ def __init__(self, source_id, account_id, source_type,

def to_api(self):
result = {
"source_type": self.source_type,
"source_name": self.name,
"source_id": self.id
}
"source_type": self.source_type,
"source_name": self.name,
"source_id": self.id
}

result.update(self.source_data.to_api())
return result
19 changes: 7 additions & 12 deletions microsetta_private_api/repo/source_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def _source_to_row(s):
s.account_id,
s.source_type,
s.name,
getattr(d, 'email', None),
getattr(d, 'is_juvenile', None),
getattr(d, 'parent1_name', None),
getattr(d, 'parent2_name', None),
Expand All @@ -31,7 +30,6 @@ def _source_to_row(s):

def _row_to_human_info(r):
return HumanInfo(
r['participant_email'],
r['is_juvenile'],
r['parent_1_name'],
r['parent_2_name'],
Expand Down Expand Up @@ -67,14 +65,14 @@ def __init__(self, transaction):
super().__init__(transaction)

read_cols = "id, account_id, " \
"source_type, source_name, participant_email, " \
"source_type, source_name, " \
"is_juvenile, parent_1_name, parent_2_name, " \
"deceased_parent, date_signed, date_revoked, " \
"assent_obtainer, age_range, description, " \
"creation_time, update_time"

write_cols = "id, account_id, source_type, " \
"source_name, participant_email, " \
"source_name, " \
"is_juvenile, parent_1_name, parent_2_name, " \
"deceased_parent, date_signed, date_revoked, " \
"assent_obtainer, age_range, description"
Expand Down Expand Up @@ -155,7 +153,7 @@ def create_source(self, source):
cur.execute("INSERT INTO source (" + SourceRepo.write_cols + ") "
"VALUES("
"%s, %s, %s, "
"%s, %s, "
"%s, "
"%s, %s, %s, "
"%s, %s, %s, "
"%s, %s, %s)",
Expand Down Expand Up @@ -233,7 +231,6 @@ def scrub(self, account_id, source_id):

name = "scrubbed"
description = "scrubbed"
email = "[email protected]"
parent1_name = "scrubbed"
parent2_name = "scrubbed"
assent_obtainer = "scrubbed"
Expand All @@ -242,15 +239,14 @@ def scrub(self, account_id, source_id):
with self._transaction.cursor() as cur:
cur.execute("""UPDATE source
SET source_name = %s,
participant_email = %s,
description = %s,
parent_1_name = %s,
parent_2_name = %s,
date_revoked = %s,
assent_obtainer = %s,
update_time = %s
WHERE id = %s""",
(name, email, description, parent1_name, parent2_name,
(name, description, parent1_name, parent2_name,
date_revoked, assent_obtainer, date_revoked,
source_id))

Expand All @@ -259,17 +255,16 @@ def scrub(self, account_id, source_id):
else:
return True

def get_duplicate_source_name_email(self, account_id, source_name, email):
def get_duplicate_source_name(self, account_id, source_name):

with self._transaction.dict_cursor() as cur:
cur.execute("SELECT " + SourceRepo.read_cols +
" FROM "
"source "
"WHERE "
"source.account_id = %s "
"AND (source.participant_email ILIKE %s OR"
" source.source_name ILIKE %s)",
(account_id, email, source_name,))
"AND source.source_name ILIKE %s ",
(account_id, source_name))
r = cur.fetchone()
if r is None:
return {'source_duplicate': False}
Expand Down
Loading

0 comments on commit b3f7f0c

Please sign in to comment.