From 85d3dbeb5580ea5f0893d8554e1d366151e4049f Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Thu, 28 Sep 2023 11:40:49 -0700 Subject: [PATCH 01/11] Reactivate Japanese and update translations --- .../LEGACY/locale_data/japanese_gut.py | 18 +- microsetta_private_api/db/patches/0132.sql | 542 ++++++++++++++++++ .../repo/survey_template_repo.py | 1 + .../ja_JP/LC_MESSAGES/messages.po | 256 +++------ 4 files changed, 622 insertions(+), 195 deletions(-) create mode 100644 microsetta_private_api/db/patches/0132.sql diff --git a/microsetta_private_api/LEGACY/locale_data/japanese_gut.py b/microsetta_private_api/LEGACY/locale_data/japanese_gut.py index 119584526..8982c3cdc 100644 --- a/microsetta_private_api/LEGACY/locale_data/japanese_gut.py +++ b/microsetta_private_api/LEGACY/locale_data/japanese_gut.py @@ -6,9 +6,9 @@ _NEW_PARTICIPANT = { 'ADD_HUMAN_TITLE': '新しいプロフィール情報を追加する', 'SEL_AGE_RANGE': '参加者の年齢層を選択する:', - 'AGE_0_6': '', - 'AGE_7_12': '', - 'AGE_13_17': '', + 'AGE_0_6': '3ヶ月 - 6才', + 'AGE_7_12': '7〜12才', + 'AGE_13_17': '13〜17年', 'AGE_18': '18歳以上', 'PARTICIPATION_AGREEMENT': '''''', @@ -16,14 +16,14 @@ 'EXHIBIT_A': '''''', 'BILL_OF_RIGHTS': '''研究被験者の権利章典''', 'TEXT_I_HAVE_READ_1': '私は同意書を読みました (又は代読してもらいました)。研究試験への参加を求められていることを理解し、この試験への参加に自由意志で同意します。私の個人データが処理される方法、関連した私の権利を理解しており、この同意書に記載されているように私のデータが処理されることに同意します。', - 'TEXT_I_HAVE_READ_SIMPLIFIED': '', - 'PERSON_ATTAINING_ASSENT': '', - 'TEXT_ASSENT_WITNESS': '', - 'OBTAINER_NAME': '', - 'TEXT_I_HAVE_READ_PARENT': '', + 'TEXT_I_HAVE_READ_SIMPLIFIED': 'はい、あなたはこの調査研究に参加します。', + 'PERSON_ATTAINING_ASSENT': '同意を得る人の署名', + 'TEXT_ASSENT_WITNESS': '私の判断において、参加者は自発的かつ自主的に同意し、研究に参加する意思を示す法的能力を持っています。', + 'OBTAINER_NAME': '同意を得る人の名前', + 'TEXT_I_HAVE_READ_PARENT': '私はこのフォームを読みました(または誰かが代読した)。私は、我が子の調査研究への参加に、同意を求められていることを理解しました。私は自発的に我が子がこの研究に参加することに同意します。我が子の個人データの処理方法、これに関連する権利、そして提供す', 'PARTICIPANT_NAME': '参加者名', 'PARTICIPANT_EMAIL': 'Eメール', - 'PARTICIPANT_PARENT_1': '', + 'PARTICIPANT_PARENT_1': '親/保護者の名前', 'PARTICIPANT_PARENT_2': '', 'PARTICIPANT_DECEASED_PARENTS': '', 'DATE_SIGNED': 'DATE_SIGNED', diff --git a/microsetta_private_api/db/patches/0132.sql b/microsetta_private_api/db/patches/0132.sql new file mode 100644 index 000000000..29cabfa05 --- /dev/null +++ b/microsetta_private_api/db/patches/0132.sql @@ -0,0 +1,542 @@ +-- Add Japanese translations for survey groups +UPDATE ag.survey_group SET japanese = '基本情報' WHERE group_order = -10; -- Basic Information +UPDATE ag.survey_group SET japanese = '自宅において' WHERE group_order = -11; -- At Home +UPDATE ag.survey_group SET japanese = '生活様式' WHERE group_order = -12; -- Lifestyle +UPDATE ag.survey_group SET japanese = '消化器' WHERE group_order = -13; -- Gut +UPDATE ag.survey_group SET japanese = '健康全般' WHERE group_order = -14; -- General Health +UPDATE ag.survey_group SET japanese = '健康診断' WHERE group_order = -15; -- Health Diagnosis +UPDATE ag.survey_group SET japanese = 'アレルギー' WHERE group_order = -16; -- Allergies +UPDATE ag.survey_group SET japanese = '食事' WHERE group_order = -17; -- Diet +UPDATE ag.survey_group SET japanese = '食事の詳細' WHERE group_order = -18; -- Detailed Diet +UPDATE ag.survey_group SET japanese = '他の' WHERE group_order = -22; -- Other + +-- Add missing Japanese translations for survey questions +UPDATE ag.survey_question SET japanese = 'どれくらい定期的にチームスポーツに参加していますか?' WHERE survey_question_id = 333; +UPDATE ag.survey_question SET japanese = '園芸や庭仕事をする回数は、シーズン中どれくらいですか?' WHERE survey_question_id = 334; +UPDATE ag.survey_question SET japanese = '通常、どのような運動をしますか?該当するものをすべて選択してください。' WHERE survey_question_id = 331; +UPDATE ag.survey_question SET japanese = 'アプリを使用して次のいずれかを追跡していますか?該当するものをすべて選択してください。' WHERE survey_question_id = 328; +UPDATE ag.survey_question SET japanese = '出生時の生物学的性別' WHERE survey_question_id = 502; +UPDATE ag.survey_question SET japanese = '次のうち、ご自身に最もあてはまるものはどれでしょうか?' WHERE survey_question_id = 492; +UPDATE ag.survey_question SET japanese = 'あなたの最終学歴は何ですか?' WHERE survey_question_id = 493; +UPDATE ag.survey_question SET japanese = 'お住まいの地域に最も当てはまるのは、次のうちどれですか?' WHERE survey_question_id = 313; +UPDATE ag.survey_question SET japanese = '家畜をよく触ったり定期的に触ったりすることはありますか?' WHERE survey_question_id = 326; +UPDATE ag.survey_question SET japanese = 'この研究に参加していて、そのことをあなたに自発的に伝えた人々と、あなたとの関係(パートナー、子供など)をお答えください。' WHERE survey_question_id = 316; +UPDATE ag.survey_question SET japanese = '種類/商品名:' WHERE survey_question_id = 490; +UPDATE ag.survey_question SET japanese = 'この研究に参加していて、そのことをあなたに自発的に伝えた同居人は誰ですか?' WHERE survey_question_id = 319; +UPDATE ag.survey_question SET japanese = '参加者名' WHERE survey_question_id = 508; +UPDATE ag.survey_question SET japanese = 'この人とあなたは血のつながりがありますか?' WHERE survey_question_id = 509; +UPDATE ag.survey_question SET japanese = 'この人はあなたと一緒に住んでいますか?' WHERE survey_question_id = 510; +UPDATE ag.survey_question SET japanese = 'あなたの犬は主にどこにいますか?' WHERE survey_question_id = 501; +UPDATE ag.survey_question SET japanese = 'あなたの猫は主にどこにいますか?' WHERE survey_question_id = 503; +UPDATE ag.survey_question SET japanese = '歯磨きは1日何回していますか?' WHERE survey_question_id = 495; +UPDATE ag.survey_question SET japanese = '通常、どれくらい激しい運動をしますか?該当するものをすべて選択してください。' WHERE survey_question_id = 332; +UPDATE ag.survey_question SET japanese = '通常、どのような種類のアルコールを飲みますか?該当するものをすべて選択してください。' WHERE survey_question_id = 494; +UPDATE ag.survey_question SET japanese = '硝酸塩' WHERE survey_question_id = 517; +UPDATE ag.survey_question SET japanese = '回答が「はい」の場合、どのタイプのIBDですか?' WHERE survey_question_id = 360; +UPDATE ag.survey_question SET japanese = '過去1週間に、腹痛や腹部不快感を感じたことはどれくらいありましたか?' WHERE survey_question_id = 362; +UPDATE ag.survey_question SET japanese = '過去1週間に、腹部膨満感が起こったことはどれくらいありましたか?' WHERE survey_question_id = 363; +UPDATE ag.survey_question SET japanese = '過去1週間に、膨満感(おならが出る)を感じたことはどれくらいありましたか?' WHERE survey_question_id = 364; +UPDATE ag.survey_question SET japanese = '過去1週間で、お腹が鳴る/胃が鳴ることはどれくらいありましたか?' WHERE survey_question_id = 365; +UPDATE ag.survey_question SET japanese = 'ホルモン' WHERE survey_question_id = 518; +UPDATE ag.survey_question SET japanese = '今までに皮膚疾患の診断を受けたことはありますか?' WHERE survey_question_id = 500; +UPDATE ag.survey_question SET japanese = '現在、何らかのホルモン避妊法を使用していますか?' WHERE survey_question_id = 497; +UPDATE ag.survey_question SET japanese = 'どのような皮膚疾患と診断されましたか?' WHERE survey_question_id = 374; +UPDATE ag.survey_question SET japanese = 'その皮膚疾患はどのように診断されましたか?' WHERE survey_question_id = 375; +UPDATE ag.survey_question SET japanese = '出産予定日:' WHERE survey_question_id = 370; +UPDATE ag.survey_question SET japanese = '過去1ヶ月間におけるあなたの平均的なストレスレベルを、1を「ストレスがほとんどまたは全くない」、10を「かなりのストレス」とした10段階で評価してください。' WHERE survey_question_id = 387; +UPDATE ag.survey_question SET japanese = '診断されたのはいつ頃ですか?' WHERE survey_question_id = 407; +UPDATE ag.survey_question SET japanese = '今までに精神疾患と診断されたことはありますか?' WHERE survey_question_id = 504; +UPDATE ag.survey_question SET japanese = 'どのような種類のがんを患っています/いましたか?該当するものをすべて選択してください。' WHERE survey_question_id = 409; +UPDATE ag.survey_question SET japanese = 'どのタイプの治療を受け/利用しましたか?該当するものをすべて選択してください。' WHERE survey_question_id = 410; +UPDATE ag.survey_question SET japanese = '次のうち、片頭痛に伴う全ての症状にチェックを入れてください。' WHERE survey_question_id = 487; +UPDATE ag.survey_question SET japanese = '回答が「はい」の場合、どの障害かを次のリストから選択してください:' WHERE survey_question_id = 505; +UPDATE ag.survey_question SET japanese = 'それはどのように診断されましたか?' WHERE survey_question_id = 413; +UPDATE ag.survey_question SET japanese = 'どのような頻度で片頭痛がしますか?' WHERE survey_question_id = 485; +UPDATE ag.survey_question SET japanese = '回答が「はい」の場合、どのタイプの糖尿病かを選択してください:' WHERE survey_question_id = 506; +UPDATE ag.survey_question SET japanese = '現在、がんを患っていますか?' WHERE survey_question_id = 408; +UPDATE ag.survey_question SET japanese = 'あなたの一番血のつながりが近い親族(一親等)で、片頭痛に悩まされている人はいますか?' WHERE survey_question_id = 488; +UPDATE ag.survey_question SET japanese = 'あなたは片頭痛用の薬を飲んでいますか。' WHERE survey_question_id = 489; +UPDATE ag.survey_question SET japanese = '片頭痛を起こす主な原因を、「1」が最も可能性が高い、「2」が2番目に可能性が高いとして、ランク付けしてください。片頭痛を引き起こす原因でないものは、空白のままにしておいてください。' WHERE survey_question_id = 511; +UPDATE ag.survey_question SET japanese = 'カフェイン' WHERE survey_question_id = 512; +UPDATE ag.survey_question SET japanese = '抑うつ' WHERE survey_question_id = 513; +UPDATE ag.survey_question SET japanese = '睡眠不足' WHERE survey_question_id = 514; +UPDATE ag.survey_question SET japanese = '食品(ワイン、チョコレート、イチゴ)' WHERE survey_question_id = 515; +UPDATE ag.survey_question SET japanese = 'バルビツレートまたはオピオイドを含む医薬品' WHERE survey_question_id = 516; +UPDATE ag.survey_question SET japanese = '今までに他に何かの病気の症状で診断を受けたことはありますか?' WHERE survey_question_id = 499; +UPDATE ag.survey_question SET japanese = '症状を和らげるために薬を服用していますか?' WHERE survey_question_id = 415; +UPDATE ag.survey_question SET japanese = '断続的な断食をする場合、どのよう種類の断食をしますか?' WHERE survey_question_id = 423; +UPDATE ag.survey_question SET japanese = '通常、1日に何回食事をしますか?' WHERE survey_question_id = 425; +UPDATE ag.survey_question SET japanese = '通常、1日に何回軽食(おやつ)を食べますか?' WHERE survey_question_id = 426; +UPDATE ag.survey_question SET japanese = '毎日のカロリーのほとんどはいつ摂取しますか?' WHERE survey_question_id = 427; +UPDATE ag.survey_question SET japanese = '繊維サプリメントを服用する場合、どのような種類のものを服用していますか?該当するものをすべて選択してください。' WHERE survey_question_id = 433; +UPDATE ag.survey_question SET japanese = 'あなたは母乳や調整粉乳から栄養のほとんどを受け取っている乳児ですか、それとも成人用栄養シェイクから栄養のほとんど(1日のカロリーの75%以上)を受け取っている成人ですか?' WHERE survey_question_id = 498; +UPDATE ag.survey_question SET japanese = '上記に記載されていないその他の特殊な食事制限があったら列挙/説明してください。' WHERE survey_question_id = 424; +UPDATE ag.survey_question SET japanese = '通常、寝る前の最後の食事や軽食を何時に食べますか?' WHERE survey_question_id = 428; +UPDATE ag.survey_question SET japanese = '繊維サプリメントをどれくらいの回数服用していますか?' WHERE survey_question_id = 434; +UPDATE ag.survey_question SET japanese = '普通の1週間に、繊維含有量の多い強化食品(例: Fiber One )はどれくらい食べていますか?' WHERE survey_question_id = 443; +UPDATE ag.survey_question SET japanese = '自宅で飲む、味のついていない普通の飲料水は主にどういうものですか?これには静水または発泡水/炭酸水も含められます。' WHERE survey_question_id = 474; +UPDATE ag.survey_question SET japanese = '自宅の外で飲む、味のついていない普通の飲料水は主にどういうものですか?これには静水または発泡水/炭酸水も含められます。' WHERE survey_question_id = 476; +UPDATE ag.survey_question SET japanese = '発酵食品を食べ始めたのはいつですか?' WHERE survey_question_id = 478; +UPDATE ag.survey_question SET japanese = '通常、一度にどのくらい飲みますか?' WHERE survey_question_id = 462; +UPDATE ag.survey_question SET japanese = '質問24および/または25の回答が「はい」の場合、定期的に摂取するノンカロリーまたは低カロリーの甘味料はどのような種類のものですか?該当するものをすべて選択してください。' WHERE survey_question_id = 464; +UPDATE ag.survey_question SET japanese = '自宅で水を飲む前に、追加の処理(ろ過を除く)を施していますか(例:沸騰、浄化タブレット、塩素/漂白剤) ?' WHERE survey_question_id = 475; +UPDATE ag.survey_question SET japanese = '自宅の外で水を飲む前に、追加の処理(沸騰、浄化錠、塩素/漂白剤など)を施しますか ?' WHERE survey_question_id = 477; +UPDATE ag.survey_question SET japanese = '今までにがんと診断されたことはありますか?' WHERE survey_question_id = 507; +UPDATE ag.survey_question SET japanese = '自宅で使用する水の水源は何ですか?' WHERE survey_question_id = 519; +UPDATE ag.survey_question SET japanese = 'お住まいの地域の公共用水の水源は何ですか?' WHERE survey_question_id = 520; +UPDATE ag.survey_question SET japanese = '海のアクテビティ(水泳、サーフィン、シュノーケリングなど)を定期的にしていますか?' WHERE survey_question_id = 354; +UPDATE ag.survey_question SET japanese = 'これまで新型コロナウィルスに何回感染しましたか?' WHERE survey_question_id = 521; +UPDATE ag.survey_question SET japanese = '過敏性腸症候群(IBS)と診断されたことはありますか?注:IBSはIBDと異なります。 IBSは症状、通常再発性腹痛と排便の変化によって定義されます。 IBDは、炎症または胃腸管の内側の損傷によって判断されています。' WHERE survey_question_id = 79; +UPDATE ag.survey_question SET japanese = '現在(過去2週間ほど)の寝つき(入眠障害)の程度を教えてください。' WHERE survey_question_id = 229; +UPDATE ag.survey_question SET japanese = '現在(過去2週間ほど)の中途覚醒(何度も目覚める)の程度を教えて下さい。' WHERE survey_question_id = 230; +UPDATE ag.survey_question SET japanese = '現在(過去2週間ほど)の早朝覚醒(朝早く目覚めてしまう)の程度を教えて下さい。' WHERE survey_question_id = 231; +UPDATE ag.survey_question SET japanese = '現在の睡眠パターンにどの程度満足/不満を感じていますか?' WHERE survey_question_id = 232; +UPDATE ag.survey_question SET japanese = '睡眠障害があなたの生活に悪影響を与えている事をまわりの人はどの程度気づいていると思いますか?' WHERE survey_question_id = 233; +UPDATE ag.survey_question SET japanese = 'あなたは自身の睡眠障害をどの程度辛く感じていますか?' WHERE survey_question_id = 234; +UPDATE ag.survey_question SET japanese = '現在、睡眠障害が毎日の生活に支障をきたしていますか?(日中の疲労、機嫌、仕事、家事の生産性、集中力、記憶力など)' WHERE survey_question_id = 235; + +-- Add missing translations for survey responses +UPDATE ag.survey_response SET japanese = '0' WHERE american = '0'; +UPDATE ag.survey_response SET japanese = '10' WHERE american = '10'; +UPDATE ag.survey_response SET japanese = '12 ~ 16液量オンス(355 ~ 473 ml)' WHERE american = '12-16 fl oz (355-473 ml)'; +UPDATE ag.survey_response SET japanese = '16 ~ 20液量オンス(473 ~ 591 ml)' WHERE american = '16-20 fl oz (473-591 ml)'; +UPDATE ag.survey_response SET japanese = '2' WHERE american = '2'; +UPDATE ag.survey_response SET japanese = '1日2回' WHERE american = '2 times a day'; +UPDATE ag.survey_response SET japanese = '週に2~3日' WHERE american = '2-3 days per week'; +UPDATE ag.survey_response SET japanese = '24時間断食(別名、イート・ストップ・イート法)' WHERE american = '24 hour fast (aka eat-stop-eat method)'; +UPDATE ag.survey_response SET japanese = '3' WHERE american = '3'; +UPDATE ag.survey_response SET japanese = '4' WHERE american = '4'; +UPDATE ag.survey_response SET japanese = '週に4~6日' WHERE american = '4-6 days per week'; +UPDATE ag.survey_response SET japanese = '4〜8液量オンス(118〜237 ml)' WHERE american = '4-8 fl oz (118-237 ml)'; +UPDATE ag.survey_response SET japanese = '5' WHERE american = '5'; +UPDATE ag.survey_response SET japanese = '5:2方法' WHERE american = '5:2 method'; +UPDATE ag.survey_response SET japanese = '6' WHERE american = '6'; +UPDATE ag.survey_response SET japanese = '7' WHERE american = '7'; +UPDATE ag.survey_response SET japanese = '8' WHERE american = '8'; +UPDATE ag.survey_response SET japanese = '8〜12液量オンス(237〜355 ml)' WHERE american = '8-12 fl oz (237-355 ml)'; +UPDATE ag.survey_response SET japanese = '9' WHERE american = '9'; +UPDATE ag.survey_response SET japanese = '< 4液量オンス(< 118 ml )' WHERE american = '<4 fl oz (<118 ml)'; +UPDATE ag.survey_response SET japanese = '> 20液量オンス(> 591 ml)' WHERE american = '>20 fl oz (>591 ml)'; +UPDATE ag.survey_response SET japanese = '年に数回' WHERE american = 'A few times a year'; +UPDATE ag.survey_response SET japanese = 'アセスルファムカリウム' WHERE american = 'Acesulfame potassium'; +UPDATE ag.survey_response SET japanese = '身体活動/運動' WHERE american = 'Activity/exercise'; +UPDATE ag.survey_response SET japanese = '副腎がん' WHERE american = 'Adrenal cancer'; +UPDATE ag.survey_response SET japanese = 'エアロビック/有酸素トレーニング' WHERE american = 'Aerobic/cardio training'; +UPDATE ag.survey_response SET japanese = '隔日断食' WHERE american = 'Alternate day fasting'; +UPDATE ag.survey_response SET japanese = 'リンゴの食物繊維' WHERE american = 'Apple fiber'; +UPDATE ag.survey_response SET japanese = 'アジア人' WHERE american = 'Asian'; +UPDATE ag.survey_response SET japanese = 'アスパルターム' WHERE american = 'Aspartame'; +UPDATE ag.survey_response SET japanese = '準学士号(AA、ASなど)' WHERE american = 'Associate''s degree (e.g. AA, AS))'; +UPDATE ag.survey_response SET japanese = 'オーラ' WHERE american = 'Aura'; +UPDATE ag.survey_response SET japanese = '学士号(BA、BSなど)' WHERE american = 'Bachelor''s degree (e.g. BA, BS)'; +UPDATE ag.survey_response SET japanese = 'バランストレーニング' WHERE american = 'Balance training'; +UPDATE ag.survey_response SET japanese = '黒人またはアフリカ系アメリカ人' WHERE american = 'Black or African American'; +UPDATE ag.survey_response SET japanese = '膀胱がん' WHERE american = 'Bladder cancer'; +UPDATE ag.survey_response SET japanese = 'ないはずの体の部分に痛みがある;' WHERE american = 'Body pain where it shouldn''t exist;'; +UPDATE ag.survey_response SET japanese = '瓶詰めされた*精製水(ラベルに「湧き水」あるいは「天然ミネラルウォーター」とは表示されていない)' WHERE american = 'Bottled* purified water (does not indicate "spring water" or "natural mineral water" on the label)'; +UPDATE ag.survey_response SET japanese = '脳がん(神経膠腫および神経膠芽腫を含む)' WHERE american = 'Brain cancer (includes gliomas and glioblastomas)'; +UPDATE ag.survey_response SET japanese = '乳がん' WHERE american = 'Breast cancer'; +UPDATE ag.survey_response SET japanese = 'カロリーは1日にわたって均等に分配している' WHERE american = 'Calories are evenly distributed throughout the day'; +UPDATE ag.survey_response SET japanese = '子宮頸がん' WHERE american = 'Cervical cancer'; +UPDATE ag.survey_response SET japanese = '胆管がん' WHERE american = 'Cholangiocarcinoma'; +UPDATE ag.survey_response SET japanese = '結腸がん' WHERE american = 'Colon cancer'; +UPDATE ag.survey_response SET japanese = '結腸クローン病' WHERE american = 'Colonic Crohn''s disease'; +UPDATE ag.survey_response SET japanese = '現在幼稚園〜高等学校' WHERE american = 'Currently in K-12'; +UPDATE ag.survey_response SET japanese = '毎日の時間制限付き断食(time-restricted eating、TRE)' WHERE american = 'Daily time-restricted eating (TRE)'; +UPDATE ag.survey_response SET japanese = '飲食物' WHERE american = 'Diet'; +UPDATE ag.survey_response SET japanese = '博士号(例:PhD、EdD)' WHERE american = 'Doctorate (eg. PhD, EdD)'; +UPDATE ag.survey_response SET japanese = '食道がん' WHERE american = 'Esophageal cancer'; +UPDATE ag.survey_response SET japanese = '年に数回' WHERE american = 'Few times/year'; +UPDATE ag.survey_response SET japanese = 'ろ過された水道水(ピッチャー、蛇口または流し台下の浄水器、逆浸透システム、軟水器)' WHERE american = 'Filtered tap water (pitcher, faucet or under the sink water purifiers, reverse osmosis systems, water softener)'; +UPDATE ag.survey_response SET japanese = '柔軟性トレーニング' WHERE american = 'Flexibility training'; +UPDATE ag.survey_response SET japanese = '強化ワイン' WHERE american = 'Fortified wine'; +UPDATE ag.survey_response SET japanese = '機能性食品(例:チアシード、ふすま)' WHERE american = 'Functional food (e.g. chia seeds, wheat bran)'; +UPDATE ag.survey_response SET japanese = '全般性不安障害' WHERE american = 'Generalized anxiety disorder'; +UPDATE ag.survey_response SET japanese = 'リンゴ酒' WHERE american = 'Hard cider'; +UPDATE ag.survey_response SET japanese = 'ハードコンブチャ(アルコール入り紅茶キノコ)' WHERE american = 'Hard kombucha'; +UPDATE ag.survey_response SET japanese = 'ハードセルツァー' WHERE american = 'Hard seltzer'; +UPDATE ag.survey_response SET japanese = 'ハードティー' WHERE american = 'Hard tea'; +UPDATE ag.survey_response SET japanese = '頭頚部がん' WHERE american = 'Head and Neck cancer'; +UPDATE ag.survey_response SET japanese = '高校卒業またはGED同等' WHERE american = 'High school diploma or GED equivalent'; +UPDATE ag.survey_response SET japanese = 'ヒスパニック系またはラテン系' WHERE american = 'Hispanic or Latino'; +UPDATE ag.survey_response SET japanese = 'ホメオパシー薬' WHERE american = 'Homeopathic medicines'; +UPDATE ag.survey_response SET japanese = 'ホルモン療法' WHERE american = 'Hormone therapy'; +UPDATE ag.survey_response SET japanese = '温熱療法' WHERE american = 'Hyperthermia'; +UPDATE ag.survey_response SET japanese = '発酵食品は食べていない' WHERE american = 'I do not eat fermented foods'; +UPDATE ag.survey_response SET japanese = '断続的な断食はしていない。' WHERE american = 'I do not practice intermittent fasting'; +UPDATE ag.survey_response SET japanese = '食物繊維サプリメントは服用していません。' WHERE american = 'I do not take fiber supplements'; +UPDATE ag.survey_response SET japanese = '自身の活動はいずれも追跡していません。' WHERE american = 'I do not track any of my activities'; +UPDATE ag.survey_response SET japanese = '味のついていない普通の水は飲んでいない' WHERE american = 'I don''t drink plain, unflavored water'; +UPDATE ag.survey_response SET japanese = 'サプリメントを服用しているが、どのような種類か知らない。' WHERE american = 'I take a supplement, but do not know what kind'; +UPDATE ag.survey_response SET japanese = '回腸クローン病' WHERE american = 'Ileal Crohn''s disease'; +UPDATE ag.survey_response SET japanese = '回腸結腸クローン病' WHERE american = 'Ileal and Colonic Crohn''s disease'; +UPDATE ag.survey_response SET japanese = '免疫療法' WHERE american = 'Immunotherapy'; +UPDATE ag.survey_response SET japanese = '午後' WHERE american = 'In the afternoon'; +UPDATE ag.survey_response SET japanese = '夜' WHERE american = 'In the evening'; +UPDATE ag.survey_response SET japanese = '午前中' WHERE american = 'In the morning'; +UPDATE ag.survey_response SET japanese = 'イヌリン(例:Fiber Choice)' WHERE american = 'Inulin (e.g. Fiber Choice)'; +UPDATE ag.survey_response SET japanese = '刺激性を受けやすい、あるいは日常的な行動を避ける;' WHERE american = 'Irritability or avoidance of routine;'; +UPDATE ag.survey_response SET japanese = '一軒家/農家(人口100人未満)' WHERE american = 'Isolated house/farm (population is less than 100)'; +UPDATE ag.survey_response SET japanese = '腎がん' WHERE american = 'Kidney cancer'; +UPDATE ag.survey_response SET japanese = '白血病' WHERE american = 'Leukemia'; +UPDATE ag.survey_response SET japanese = '肝臓がん' WHERE american = 'Liver cancer'; +UPDATE ag.survey_response SET japanese = '肺がん' WHERE american = 'Lung cancer'; +UPDATE ag.survey_response SET japanese = 'リンパ腫' WHERE american = 'Lymphoma'; +UPDATE ag.survey_response SET japanese = '麦芽酒' WHERE american = 'Malt liquor'; +UPDATE ag.survey_response SET japanese = '修士号(MS、MAなど)' WHERE american = 'Master''s degree (e.g. MS, MA)'; +UPDATE ag.survey_response SET japanese = '黒色腫(皮膚)' WHERE american = 'Melanoma (skin)'; +UPDATE ag.survey_response SET japanese = 'メチルセルロース(例:Citrucel)' WHERE american = 'Methylcellulose (e.g. Citrucel)'; +UPDATE ag.survey_response SET japanese = '主要都市(人口100万人以上)' WHERE american = 'Metropolis (population is more than 1 million)'; +UPDATE ag.survey_response SET japanese = 'モンクフルーツ' WHERE american = 'Monk fruit'; +UPDATE ag.survey_response SET japanese = '毎月' WHERE american = 'Monthly'; +UPDATE ag.survey_response SET japanese = '1日3回以上' WHERE american = 'More than 2 times a day'; +UPDATE ag.survey_response SET japanese = '5杯以上' WHERE american = 'More than 4'; +UPDATE ag.survey_response SET japanese = '多民族' WHERE american = 'Multiracial'; +UPDATE ag.survey_response SET japanese = 'アメリカ先住民またはアラスカ先住民' WHERE american = 'Native American or Alaska Native'; +UPDATE ag.survey_response SET japanese = 'ハワイまたは他の太平洋諸島の先住民' WHERE american = 'Native Hawaiian or Other Pacific Islander'; +UPDATE ag.survey_response SET japanese = '欧州連合の他の国または英国で瓶詰めされた*天然のミネラルウォーターまたは湧き水' WHERE american = 'Natural mineral or spring water bottled* in another country in the European Union or the UK'; +UPDATE ag.survey_response SET japanese = '欧州連合または英国以外の国で瓶詰めされた*天然のミネラルウォーターまたは湧き水' WHERE american = 'Natural mineral or spring water bottled* in another country not in the European Union or the UK'; +UPDATE ag.survey_response SET japanese = '現地(例:居住国)で瓶詰めされた*天然のミネラルウォーターまたは湧き水' WHERE american = 'Natural mineral or spring water bottled* locally (i.e. in your country of residence)'; +UPDATE ag.survey_response SET japanese = '吐き気および/または嘔吐;' WHERE american = 'Nausea and/or vomiting;'; +UPDATE ag.survey_response SET japanese = '正規の教育は受けていない' WHERE american = 'No formal education'; +UPDATE ag.survey_response SET japanese = 'いいえ、この病状はありません。' WHERE american = 'No, I do not have this condition'; +UPDATE ag.survey_response SET japanese = 'いいえ、アレルギー用の薬は一切服用していません。' WHERE american = 'No, I do not take any medications for my allergies'; +UPDATE ag.survey_response SET japanese = 'いいえ、がんはなくなりました。' WHERE american = 'No, I no longer have cancer'; +UPDATE ag.survey_response SET japanese = 'エンバクの食物繊維' WHERE american = 'Oat fiber'; +UPDATE ag.survey_response SET japanese = '週に1回' WHERE american = 'Once per week'; +UPDATE ag.survey_response SET japanese = 'ラマダン期間中のみ' WHERE american = 'Only during Ramadan'; +UPDATE ag.survey_response SET japanese = '卵巣がん' WHERE american = 'Ovarian cancer'; +UPDATE ag.survey_response SET japanese = '膵臓がん' WHERE american = 'Pancreatic cancer'; +UPDATE ag.survey_response SET japanese = '定期的な断食' WHERE american = 'Periodic fasting'; +UPDATE ag.survey_response SET japanese = '褐色細胞腫および傍神経節腫がん' WHERE american = 'Pheochromocytoma and paraganglioma cancer'; +UPDATE ag.survey_response SET japanese = '音恐怖症(音に対する敏感性);' WHERE american = 'Phonophobia (sensitivity to sound);'; +UPDATE ag.survey_response SET japanese = '光力学治療' WHERE american = 'Photodynamic therapy'; +UPDATE ag.survey_response SET japanese = '光恐怖症(光に対する敏感性);' WHERE american = 'Photophobia (sensitivity to light);'; +UPDATE ag.survey_response SET japanese = '専門職学位(MD、DDS、DVMなど)' WHERE american = 'Professional degree (e.g. MD,DDS, DVM)'; +UPDATE ag.survey_response SET japanese = '前立腺がん' WHERE american = 'Prostate cancer'; +UPDATE ag.survey_response SET japanese = 'サイリウム(例:Metamucil)' WHERE american = 'Psyllium (e.g. Metamucil)'; +UPDATE ag.survey_response SET japanese = '放射線療法' WHERE american = 'Radiotherapy'; +UPDATE ag.survey_response SET japanese = '直腸がん' WHERE american = 'Rectal cancer'; +UPDATE ag.survey_response SET japanese = 'ロゼ・ワイン' WHERE american = 'Rose wine'; +UPDATE ag.survey_response SET japanese = 'サッカリン' WHERE american = 'Saccharin'; +UPDATE ag.survey_response SET japanese = '日本酒' WHERE american = 'Sake'; +UPDATE ag.survey_response SET japanese = '肉腫' WHERE american = 'Sarcoma'; +UPDATE ag.survey_response SET japanese = '幼児期/小児期以降' WHERE american = 'Since infancy/childhood'; +UPDATE ag.survey_response SET japanese = '睡眠' WHERE american = 'Sleep'; +UPDATE ag.survey_response SET japanese = '小さな町または村(人口100人超、1,000人未満)' WHERE american = 'Small town or village (population is more than 100 and less than 1,000)'; +UPDATE ag.survey_response SET japanese = 'サワービール' WHERE american = 'Sour beer'; +UPDATE ag.survey_response SET japanese = '発泡ワイン' WHERE american = 'Sparkling wine'; +UPDATE ag.survey_response SET japanese = 'ハードリカー/蒸留酒/強い酒' WHERE american = 'Spirits/liquors/hard alcohol'; +UPDATE ag.survey_response SET japanese = '幹細胞移植' WHERE american = 'Stem cell transplant'; +UPDATE ag.survey_response SET japanese = 'ステビア' WHERE american = 'Stevia'; +UPDATE ag.survey_response SET japanese = '胃がん' WHERE american = 'Stomach cancer'; +UPDATE ag.survey_response SET japanese = '筋力トレーニング' WHERE american = 'Strength training'; +UPDATE ag.survey_response SET japanese = 'スクラロース' WHERE american = 'Sucralose'; +UPDATE ag.survey_response SET japanese = '糖アルコール(ソルビトール、キシリトール、ラクチトール、マンニトール、エリスリトール、マルチトール)' WHERE american = 'Sugar alcohols (sorbitol, xylitol, lactitol, mannitol, erythritol, and maltitol)'; +UPDATE ag.survey_response SET japanese = '手術' WHERE american = 'Surgery'; +UPDATE ag.survey_response SET japanese = '水道水' WHERE american = 'Tap water'; +UPDATE ag.survey_response SET japanese = '標的(薬物)療法' WHERE american = 'Targeted (medication) therapy'; +UPDATE ag.survey_response SET japanese = '精巣胚細胞性がん' WHERE american = 'Testicular germ cell cancer'; +UPDATE ag.survey_response SET japanese = '甲状腺がん' WHERE american = 'Thyroid cancer'; +UPDATE ag.survey_response SET japanese = '町(人口1,000人超、10万人未満)' WHERE american = 'Town (population is more than 1,000 and less than 100,000)'; +UPDATE ag.survey_response SET japanese = '潰瘍性大腸炎' WHERE american = 'Ulcerative Colitis'; +UPDATE ag.survey_response SET japanese = '子宮がん' WHERE american = 'Uterine cancer'; +UPDATE ag.survey_response SET japanese = 'ぶどう膜メラノーマ' WHERE american = 'Uveal melanoma'; +UPDATE ag.survey_response SET japanese = '激しい' WHERE american = 'Vigorous'; +UPDATE ag.survey_response SET japanese = '職業訓練' WHERE american = 'Vocational training'; +UPDATE ag.survey_response SET japanese = '毎週' WHERE american = 'Weekly'; +UPDATE ag.survey_response SET japanese = '井戸水' WHERE american = 'Well water'; +UPDATE ag.survey_response SET japanese = '小麦デキストリン(例: Benefiber )' WHERE american = 'Wheat dextrin (e.g. Benefiber)'; +UPDATE ag.survey_response SET japanese = '過去10年以内' WHERE american = 'Within the last 10 years'; +UPDATE ag.survey_response SET japanese = '過去5年以内' WHERE american = 'Within the last 5 years'; +UPDATE ag.survey_response SET japanese = '過去1年以内' WHERE american = 'Within the last year'; +UPDATE ag.survey_response SET japanese = 'はい、現在がんを患っています。' WHERE american = 'Yes, I currently have cancer'; +UPDATE ag.survey_response SET japanese = 'はい、ホメオパシー薬を服用しています。' WHERE american = 'Yes, I take homeopathic medication'; +UPDATE ag.survey_response SET japanese = 'はい、市販薬を服用しています。' WHERE american = 'Yes, I take over-the-counter medication'; +UPDATE ag.survey_response SET japanese = 'はい、処方薬を服用しています。' WHERE american = 'Yes, I take prescription medication'; +UPDATE ag.survey_response SET japanese = 'はい、避妊用パッチを使用しています。' WHERE american = 'Yes, I use a contraceptive patch'; +UPDATE ag.survey_response SET japanese = 'はい、避妊用の膣リングを使用しています。' WHERE american = 'Yes, I use a contraceptive vaginal ring'; +UPDATE ag.survey_response SET japanese = 'はい、ホルモン子宮内避妊具/インプラントを使用しています。' WHERE american = 'Yes, I use a hormonal IUD/implant'; +UPDATE ag.survey_response SET japanese = 'はい、注射用避妊薬を使用しています。' WHERE american = 'Yes, I use an injected contraceptive'; +UPDATE ag.survey_response SET japanese = 'はい、ここに記載されていない他の種類の薬を使用しています。' WHERE american = 'Yes, I use other types of medication not listed here'; +UPDATE ag.survey_response SET japanese = 'はい、医療専門家(医師、医師助手)によって診断されました。' WHERE american = 'Yes, diagnosed by a medical professional (doctor, physician assistant)'; +UPDATE ag.survey_response SET japanese = 'はい、代替医療の医師によって診断されました。' WHERE american = 'Yes, diagnosed by an alternative or complementary practitioner'; +UPDATE ag.survey_response SET japanese = '両方とも同じくらい' WHERE american = 'Both equally'; +UPDATE ag.survey_response SET japanese = '都市(人口10万人超、100万人未満)' WHERE american = 'City (population is more than 100,000 and less than 1 million)'; +UPDATE ag.survey_response SET japanese = '2021' WHERE american = '2021'; +UPDATE ag.survey_response SET japanese = '2022' WHERE american = '2022'; +UPDATE ag.survey_response SET japanese = 'わからない' WHERE american = 'Don''t know'; +UPDATE ag.survey_response SET japanese = 'はい、認可されたメンタルヘルスの専門家によって診断されました' WHERE american = 'Yes, diagnosed by a licensed mental health professional'; +UPDATE ag.survey_response SET japanese = 'N/A' WHERE american = 'N/A'; +UPDATE ag.survey_response SET japanese = '息切れや呼吸困難' WHERE american = 'Shortness of breath or difficulty breathing'; +UPDATE ag.survey_response SET japanese = '頭痛' WHERE american = 'Headaches'; +UPDATE ag.survey_response SET japanese = '筋肉痛' WHERE american = 'Muscle aches'; +UPDATE ag.survey_response SET japanese = '鼻水または鼻詰まり' WHERE american = 'Runny or stuffy nose'; +UPDATE ag.survey_response SET japanese = '喘鳴(ゼーゼーとした咳)' WHERE american = 'Wheezing'; +UPDATE ag.survey_response SET japanese = '3回以上' WHERE american = '3 or more'; +UPDATE ag.survey_response SET japanese = '両方使います' WHERE american = 'I use both'; +UPDATE ag.survey_response SET japanese = '発酵食品は作りません。' WHERE american = 'I do not produce fermented foods'; +UPDATE ag.survey_response SET japanese = 'いいえ。私は子宮内避妊具銅IUDを使用しています' WHERE american = 'No, I use a copper IUD'; + +-- Load Japanese consent documents +-- Critical to note that we only have adult data/biospecimen documents, so Japanese users may not create profiles for minors +INSERT INTO ag.consent_documents ("consent_type", "locale", "date_time", "consent_content", "reconsent_required", "account_id") + VALUES ('adult_data', 'ja_JP', NOW(), ' + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + + + + + +', TRUE, '000fc4cd-8fa4-db8b-e050-8a800c5d81b7'); +INSERT INTO ag.consent_documents ("consent_type", "locale", "date_time", "consent_content", "reconsent_required", "account_id") + VALUES ('adult_biospecimen', 'ja_JP', NOW(), ' + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ 研究参加者のサンプルが使用される方法 +

+ + + + + + + + + + + + +', TRUE,'000fc4cd-8fa4-db8b-e050-8a800c5d81b7'); diff --git a/microsetta_private_api/repo/survey_template_repo.py b/microsetta_private_api/repo/survey_template_repo.py index 11c64eadf..fc1f2a511 100644 --- a/microsetta_private_api/repo/survey_template_repo.py +++ b/microsetta_private_api/repo/survey_template_repo.py @@ -1183,6 +1183,7 @@ def migrate_responses(self, source_id, survey_template_id, language_tag): localization.EN_GB: "survey_response.british", localization.ES_MX: "survey_response.spanish", localization.ES_ES: "survey_response.spain_spanish", + localization.JA_JP: "survey_response.japanese" } if language_tag not in tag_to_col: diff --git a/microsetta_private_api/translations/ja_JP/LC_MESSAGES/messages.po b/microsetta_private_api/translations/ja_JP/LC_MESSAGES/messages.po index 6f8fc215f..94986e1bd 100644 --- a/microsetta_private_api/translations/ja_JP/LC_MESSAGES/messages.po +++ b/microsetta_private_api/translations/ja_JP/LC_MESSAGES/messages.po @@ -7,16 +7,17 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-06-27 16:30-0700\n" -"PO-Revision-Date: 2022-11-04 10:48-0700\n" +"POT-Creation-Date: 2023-09-18 08:50-0700\n" +"PO-Revision-Date: 2023-09-18 14:22-0700\n" "Last-Translator: \n" -"Language: ja_JP\n" "Language-Team: ja_JP \n" -"Plural-Forms: nplurals=1; plural=0;\n" +"Language: ja_JP\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" "Generated-By: Babel 2.11.0\n" +"X-Generator: Poedit 3.3.2\n" #: admin/email_templates.py:22 msgid "Welcome to The Microsetta Initiative" @@ -48,26 +49,22 @@ msgstr "お申込み承りました" #: admin/email_templates.py:83 admin/email_templates.py:107 msgid "Registration code & kit update!" -msgstr "" +msgstr "登録用コードとキットの更新!" #: admin/email_templates.py:91 msgid "Your questionnaire is ready!" -msgstr "" +msgstr "登録が完了しました!" #: admin/email_templates.py:99 msgid "Your kit is on its way!" -msgstr "" +msgstr "キットを発送しました!" #: templates/email/activation_email.jinja2:221 -msgid "" -"Thank you for your interest and participation in The Microsetta " -"Initiative. We will be shipping out your sample collection kit(s) soon." +msgid "Thank you for your interest and participation in The Microsetta Initiative. We will be shipping out your sample collection kit(s) soon." msgstr "この度は、マイクロゼッタ イニシアティブの研究にご参加いただきありがとうございます。採便キットをまもなく発送いたします。" #: templates/email/activation_email.jinja2:225 -msgid "" -"The kit(s) may still be en route, but you don't have to pause your " -"journey just yet. You can sign up right now to get started at " +msgid "The kit(s) may still be en route, but you don't have to pause your journey just yet. You can sign up right now to get started at " msgstr "採便キットはまだ発送中かもしれませんが、まだ中止する必要はありません。こちらから登録して下さい。 " #: templates/email/activation_email.jinja2:225 @@ -83,10 +80,7 @@ msgid "Activation Code:" msgstr "認証番号:" #: templates/email/activation_email.jinja2:234 -msgid "" -"Not your first foray into the microbiome? No problem, you don't need to " -"sign up again, your kit(s) can be added to your existing account when the" -" order arrives." +msgid "Not your first foray into the microbiome? No problem, you don't need to sign up again, your kit(s) can be added to your existing account when the order arrives." msgstr "既にこの研究に参加済みですか?問題ありません。再度登録する必要はありません。注文が届いた時に、既存のアカウントに採便キットを追加できます。" #: templates/email/activation_email.jinja2:238 @@ -131,23 +125,15 @@ msgid "Hello" msgstr "こんにちは" #: templates/email/address_invalid.jinja2:224 -msgid "" -"Thank you for your interest and participation in The Microsetta " -"Initiative. We are writing as we've encountered an issue processing your " -"transaction, and we would appreciate your assistance in helping to " -"resolve this matter." +msgid "Thank you for your interest and participation in The Microsetta Initiative. We are writing as we've encountered an issue processing your transaction, and we would appreciate your assistance in helping to resolve this matter." msgstr "マイクロゼッタ イニシアティブ の研究にご参加いただきありがとうございます。この度、お取引の際に問題が発生したので、迅速な対応をお願いいたします。" #: templates/email/address_invalid.jinja2:226 -msgid "" -"Specifically, we were unable to verify the address to which you requested" -" we ship you kit(s)." +msgid "Specifically, we were unable to verify the address to which you requested we ship you kit(s)." msgstr "具体的には、採便キットの発送先住所の確認ができませんでした。" #: templates/email/address_invalid.jinja2:232 -msgid "" -"To resolve this issue and ensure we have a valid shipping address, please" -" click the following link or copy and paste the URL into your browser:" +msgid "To resolve this issue and ensure we have a valid shipping address, please click the following link or copy and paste the URL into your browser:" msgstr "問題解決に向け、あなたの配送先住所を確認するため、次のリンクをクリックするかURL をコピーしてアクセスして下さい:" #: templates/email/address_invalid.jinja2:246 @@ -163,9 +149,7 @@ msgid "Thank you," msgstr "ありがとうございます、" #: templates/email/incorrect_sample_type.jinja2:224 -msgid "" -"We recently received the following microbiome sample from you and noticed" -" that it might have been incorrectly labeled." +msgid "We recently received the following microbiome sample from you and noticed that it might have been incorrectly labeled." msgstr "あなたの便サンプルを受け取りましたが、記入された情報が間違っている可能性があります。" #: templates/email/incorrect_sample_type.jinja2:229 @@ -177,75 +161,48 @@ msgid "but appears to be" msgstr "しかし" #: templates/email/incorrect_sample_type.jinja2:236 -msgid "" -"Our lab will need verification of the type of sample you sent in before " -"they can begin processing it to ensure that your sample is sequenced " -"correctly. If you know the sample type then please reply to this email" -msgstr "" +msgid "Our lab will need verification of the type of sample you sent in before they can begin processing it to ensure that your sample is sequenced correctly. If you know the sample type then please reply to this email" +msgstr "当研究所では、参加者のサンプルが正しく処理されるよう、解析を開始する前にお送りいただいたサンプルの種類を確認させていただく必要があります。もしサンプルの種類がお分かりでしたら、このメールに返信してください" #: templates/email/incorrect_sample_type.jinja2:236 -msgid "" -"with this information. We will then update your profile so the collection" -" can be appropriately associated." -msgstr "" +msgid "with this information. We will then update your profile so the collection can be appropriately associated." +msgstr "その後、あなたのプロフィールを更新し、あなたの採便キットをサンプルの種類と関連付けます。" #: templates/email/kit_tracking_number.jinja2:224 -#, fuzzy -msgid "" -"Thank you for your contribution to The Microsetta Initiative. Your " -"collection kit has been shipped." -msgstr "この度は、マイクロゼッタ イニシアティブの研究にご参加いただきありがとうございます。採便キットをまもなく発送いたします。" +msgid "Thank you for your contribution to The Microsetta Initiative. Your collection kit has been shipped." +msgstr "この度は、マイクロセッタ・イニシアチブの研究にご参加いただきありがとうございます。採便キットをまもなく発送いたします。" #: templates/email/kit_tracking_number.jinja2:230 #: templates/email/subscription_ffq_code.jinja2:230 -#, fuzzy msgid "Item: Collection Kit" -msgstr "採便の種類" +msgstr "品名:採便キット" #: templates/email/kit_tracking_number.jinja2:231 msgid "Tracking number:" -msgstr "" +msgstr "追跡番号:" #: templates/email/kit_tracking_number.jinja2:238 -msgid "" -"If you have any questions, please visit our FAQs " -"and instructions pages, or you can email us at " -msgstr "" +msgid "If you have any questions, please visit our FAQs and instructions pages, or you can email us at " +msgstr "ご不明な点がございましたら、よくある質問または説明事項のページをご覧になるか、こちらまでご連絡下さい " #: templates/email/kit_tracking_number.jinja2:245 #: templates/email/subscription_ffq_code.jinja2:256 #: templates/email/thank_you_no_kit.jinja2:262 #: templates/email/thank_you_with_kit.jinja2:264 msgid "Best wishes," -msgstr "" +msgstr "よろしくお願いします、" #: templates/email/missing_sample_info.jinja2:224 -msgid "" -"Thank you for your interest and participation in The Microsetta " -"Initiative. We are writing as we've encountered an issue processing your " -"sample, and we would appreciate your assistance in helping to resolve " -"this matter. To make sure we have the correct information, we require you" -" to confirm the type of sample you sent and the collection date and time " -"with our team. Please click on the URL below to view the collection " -"information." -msgstr "" -"マイクロゼッタ イニシアティブの研究 " -"にご参加いただきありがとうございます。この度、あなたの便サンプルに問題が生じたため、迅速な対応をお願いいたします。正確な情報を入力するため、返送した便サンプルの種類、採取日、及び採取時刻を再度確認する必要があります。下記URLから採取情報をご確認ください。" +msgid "Thank you for your interest and participation in The Microsetta Initiative. We are writing as we've encountered an issue processing your sample, and we would appreciate your assistance in helping to resolve this matter. To make sure we have the correct information, we require you to confirm the type of sample you sent and the collection date and time with our team. Please click on the URL below to view the collection information." +msgstr "マイクロゼッタ イニシアティブの研究 にご参加いただきありがとうございます。この度、あなたの便サンプルに問題が生じたため、迅速な対応をお願いいたします。正確な情報を入力するため、返送した便サンプルの種類、採取日、及び採取時刻を再度確認する必要があります。下記URLから採取情報をご確認ください。" #: templates/email/missing_sample_info.jinja2:236 msgid "Based on what we can see, we think the collection type is:" msgstr "あなたの便サンプルの種類は:" #: templates/email/missing_sample_info.jinja2:250 -msgid "" -"We require this information in order to process the collection in " -"compliance with our human subjects research protocol. Therefore, editing " -"online account information is currently locked as a preventative measure " -"to ensure we meet regulations. Not to worry - by replying to this email " -"our team is ready to assist you with updating the following information." -msgstr "" +msgid "We require this information in order to process the collection in compliance with our human subjects research protocol. Therefore, editing online account information is currently locked as a preventative measure to ensure we meet regulations. Not to worry - by replying to this email our team is ready to assist you with updating the following information." +msgstr "これは、当研究所の被験者研究規約に準拠してサンプルを処理するために必要な情報です。そのため、オンライン上のアカウント情報の編集は、規約に従い現在利用することができません。このEメールに返信していただければ、私たちが以下の情報を更新致します。" #: templates/email/missing_sample_info.jinja2:254 #: templates/email/no_associated_source.jinja2:263 @@ -263,58 +220,36 @@ msgid "Collection type" msgstr "採便の種類" #: templates/email/missing_sample_info.jinja2:263 -msgid "" -"Once we have these details, we will update the record so the specimen can" -" be processed appropriately." +msgid "Once we have these details, we will update the record so the specimen can be processed appropriately." msgstr "これらの詳細を確認次第、採便が適切に処理できるよう記録を更新致します。" #: templates/email/no_associated_source.jinja2:224 -msgid "" -"Thank you for your interest and participation in The Microsetta " -"Initiative. We are writing as we've encountered an issue processing your " -"collection, and we would appreciate your assistance in helping to resolve" -" this matter." +msgid "Thank you for your interest and participation in The Microsetta Initiative. We are writing as we've encountered an issue processing your collection, and we would appreciate your assistance in helping to resolve this matter." msgstr "マイクロゼッタ イニシアティブ の研究にご参加いただきありがとうございます。この度、あなたの採便に問題が発生したので、迅速な対応をお願いいたします。" #: templates/email/no_associated_source.jinja2:226 -msgid "" -"Specifically, the following sample sent to the lab needs more information" -" to be included before it can be processed:" +msgid "Specifically, the following sample sent to the lab needs more information to be included before it can be processed:" msgstr "具体的には、返送された便サンプルを処理する前に、あなたの追加情報が必要になります:" #: templates/email/no_associated_source.jinja2:238 -msgid "" -"We require this information to process this specimen in compliance with " -"our human subjects research protocol. Please log back into the " -"participant website by clicking or copying the following URL:" -msgstr "" -"これは人を対象とする研究規約に従って、便サンプルを処理するために必要な情報です。下記の URL をクリックするかコピーして、参加者用 " -"サイトに再度ログインして下さい:" +msgid "We require this information to process this specimen in compliance with our human subjects research protocol. Please log back into the participant website by clicking or copying the following URL:" +msgstr "これは人を対象とする研究規約に従って、便サンプルを処理するために必要な情報です。下記の URL をクリックするかコピーして、参加者用 サイトに再度ログインして下さい:" #: templates/email/no_associated_source.jinja2:245 msgid "Your account" msgstr "あなたのアカウント" #: templates/email/no_associated_source.jinja2:252 -msgid "" -"After accessing your account using the above URL, you will need to create" -" a source by clicking on one of the buttons under the \"Sources\" " -"section." -msgstr "" +msgid "After accessing your account using the above URL, you will need to create a source by clicking on one of the buttons under the \"Sources\" section." +msgstr "上記のURLからアカウントにアクセスした後、”由来元”の項目からいずれかを選択して、サンプルの由来を作成する必要があります。" #: templates/email/no_associated_source.jinja2:258 -msgid "" -"Once a source has been created, please reply to this email with the " -"following information so that we can link the collection to your source:" -msgstr "" +msgid "Once a source has been created, please reply to this email with the following information so that we can link the collection to your source:" +msgstr "サンプルの由来を作成次第、以下の情報をこのメールに返信してください。あなたの採便とサンプルの由来をリンクいたします:" #: templates/email/sample_is_valid.jinja2:224 -msgid "" -"Thank you for your interest and participation in The Microsetta " -"Initiative. We have received your microbiome collection, and it is now in" -" the processing queue. Samples are processed within 1 – 3 months. Once " -"sequenced, you will receive an update with a link to your results." -msgstr "" +msgid "Thank you for your interest and participation in The Microsetta Initiative. We have received your microbiome collection, and it is now in the processing queue. Samples are processed within 1 – 3 months. Once sequenced, you will receive an update with a link to your results." +msgstr "マイクロセッタ・イニシアチブの研究にご参加いただきありがとうございます。あなたの微生物サンプルを無事に受け取り、サンプルの解析を始めました。サンプル解析は1~3ヶ月かかる予定です。解析が完了次第、解析結果のリンクを含んだ最新情報をお知らせします。" #: templates/email/sample_is_valid.jinja2:232 msgid "Kind regards," @@ -325,26 +260,15 @@ msgid "Dear Volunteer" msgstr "お申し込みの皆様へ" #: templates/email/submit_interest_confirmation.jinja2:224 -msgid "" -"On behalf of Danone Nutricia Research and The Microsetta Initiative (TMI)" -" at UC San Diego, we would like to thank you for your interest in " -"participating in our research study THDMI - The Human Diets and " -"Microbiome Initiative." -msgstr "" -"カリフォルニア大学サンディエゴ校のマイクロゼッタ イニシアティブ(TMI)及びダノン ニュートリシア リサーチ を代表して、TMI " -"THDMI-ジャパン プロジェクトにご参加申し込み頂き心よりお礼申し上げます。" +msgid "On behalf of Danone Nutricia Research and The Microsetta Initiative (TMI) at UC San Diego, we would like to thank you for your interest in participating in our research study THDMI - The Human Diets and Microbiome Initiative." +msgstr "カリフォルニア大学サンディエゴ校のマイクロゼッタ イニシアティブ(TMI)及びダノン ニュートリシア リサーチ を代表して、TMI THDMI-ジャパン プロジェクトにご参加申し込み頂き心よりお礼申し上げます。" #: templates/email/submit_interest_confirmation.jinja2:230 -msgid "" -"Soon you will receive an email letting you know if you were one of the " -"first 800 individuals who signed up to participate in the project and " -"what the next steps will be to take part. " +msgid "Soon you will receive an email letting you know if you were one of the first 800 individuals who signed up to participate in the project and what the next steps will be to take part. " msgstr "参加要件を満たした先着800名の方にのみ本登録用のEメールを後日お送りいたします。あらかじめご了承ください。ご回答まで今しばらくお待ちください。" #: templates/email/submit_interest_confirmation.jinja2:236 -msgid "" -"We are also here to help! Our team is ready to assist you with any " -"questions you may have. Please contact us at" +msgid "We are also here to help! Our team is ready to assist you with any questions you may have. Please contact us at" msgstr "ご質問やご不明な点がございましたらお気軽にお問い合わせください" #: templates/email/submit_interest_confirmation.jinja2:245 @@ -352,111 +276,71 @@ msgid "Tip" msgstr "追記" #: templates/email/submit_interest_confirmation.jinja2:245 -msgid "" -"To ensure our emails make it to your Inbox, not your SPAM folder, " -"remember to add us to your safe sender's list." +msgid "To ensure our emails make it to your Inbox, not your SPAM folder, remember to add us to your safe sender's list." msgstr "本登録用のEメールが迷惑メールフォルダに届く恐れがあります。確実にお手元に届くようmicrosetta@ucsd.eduのメール受信設定をお願い致します。" #: templates/email/subscription_ffq_code.jinja2:220 #: templates/email/thank_you_no_kit.jinja2:220 #: templates/email/thank_you_with_kit.jinja2:220 msgid "Dear" -msgstr "" +msgstr "拝啓" #: templates/email/subscription_ffq_code.jinja2:224 -msgid "" -"Thank you for helping to drive research to discover more about the human " -"microbiome. Once the next kit for your 'Follow Your Gut' ships, we will " -"send you an email with a tracking number so you will know when it's on " -"the way." -msgstr "" +msgid "Thank you for helping to drive research to discover more about the human microbiome. Once the next kit for your 'Follow Your Gut' ships, we will send you an email with a tracking number so you will know when it's on the way." +msgstr "体内の微生物に関する研究にご協力いただきありがとうございます。’あなたの採便キットが発送され次第、追跡番号を記載したメールをお送りいたします。" #: templates/email/subscription_ffq_code.jinja2:236 -msgid "" -"What's next: Your new food frequency questionnaire will " -"be available to complete when you login to your account. Visit the 'My Nutrition' page and enter " -"the following:" -msgstr "" +msgid "What's next: Your new food frequency questionnaire will be available to complete when you login to your account. Visit the 'My Nutrition' page and enter the following:" +msgstr "次の手順について:アカウントにログインすると食物摂取頻度調査票を記入することができます。「私の栄養」ページにアクセスし、以下の情報を入力してください:" #: templates/email/subscription_ffq_code.jinja2:242 #: templates/email/thank_you_no_kit.jinja2:248 #: templates/email/thank_you_with_kit.jinja2:248 -#, fuzzy msgid "Registration code:" -msgstr "認証番号:" +msgstr "登録コード:" #: templates/email/subscription_ffq_code.jinja2:249 -msgid "" -"Thank you for your participation and we hope you enjoy learning more " -"about your gut microbiome! If you have any questions, please visit our FAQs " -"and instructions pages, or you can email us at " -msgstr "" +msgid "Thank you for your participation and we hope you enjoy learning more about your gut microbiome! If you have any questions, please visit our FAQs and instructions pages, or you can email us at " +msgstr "私たちの研究にご協力頂きありがとうございます。腸内細菌について、より詳しく学んでいただければ幸いです。ご不明な点がございましたら、よくある質問又は説明事項のページをご覧いただくか、以下のメールアドレスまでお問い合わせください " #: templates/email/thank_you_no_kit.jinja2:224 -msgid "" -"Thank you for your contribution to The Microsetta Initiative and for " -"helping to drive research to discover more about the human microbiome." -msgstr "" +msgid "Thank you for your contribution to The Microsetta Initiative and for helping to drive research to discover more about the human microbiome." +msgstr "マイクロセッタ・イニチアチブと体内微生物に関する研究の推進にご協力いただき誠にありがとうございます。" #: templates/email/thank_you_no_kit.jinja2:230 #: templates/email/thank_you_with_kit.jinja2:230 -msgid "" -"What's next: If you're joining us for the first time, " -"visit the TMI website to create your account, profile, and fill in the " -"initial forms and surveys. Your email address is linked to " -"this information and must be the same email used to set up your " -"account." -msgstr "" +msgid "What's next: If you're joining us for the first time, visit the TMI website to create your account, profile, and fill in the initial forms and surveys. Your email address is linked to this information and must be the same email used to set up your account." +msgstr "次の手順について:初めて参加される方は、TMIのホームページからアカウントを作成し、プロフィール情報を入力して下さい。その後、必要な情報やアンケートの回答にご協力下さい。あなたのEメールアドレスはこの情報とリンクしているため、アカウント設定時に使用したEメールアドレスを使用する必要があります。" #: templates/email/thank_you_no_kit.jinja2:236 #: templates/email/thank_you_with_kit.jinja2:236 msgid "Create Account or Login" -msgstr "" +msgstr "アカウントを作成、又はアカウントにログインする" #: templates/email/thank_you_no_kit.jinja2:242 -msgid "" -"Once completed you will be ready to take your food frequency " -"questionnaire. Visit the 'My Nutrition' page and enter the following:" -msgstr "" +msgid "Once completed you will be ready to take your food frequency questionnaire. Visit the 'My Nutrition' page and enter the following:" +msgstr "入力完了後、食事摂取頻度調査票に記入することができます。参加する準備が整います。’私の栄養’ページにアクセスし、以下の情報を入力してください:" #: templates/email/thank_you_no_kit.jinja2:255 -msgid "" -"Thank you for your participation! If you have any questions, please visit" -" our FAQs and instructions pages, or you can " -"email us at " -msgstr "" +msgid "Thank you for your participation! If you have any questions, please visit our FAQs and instructions pages, or you can email us at " +msgstr "ご参加ありがとうございます。ご不明な点がございましたら、よくある質問又は説明事項のページをご覧いただくか、こちらまでご連絡ください " #: templates/email/thank_you_with_kit.jinja2:224 -msgid "" -"Thank you for helping to drive research to discover more about the human " -"microbiome. Once your collection kit ships, we will send you an email " -"with a tracking number so you will know when it's on the way." -msgstr "" +msgid "Thank you for helping to drive research to discover more about the human microbiome. Once your collection kit ships, we will send you an email with a tracking number so you will know when it's on the way." +msgstr "体内微生物の研究に関する研究にご協力いただき、ありがとうございます。採便キットが発送されましたら、追跡番号を記載したメールをお送りいたしますので到着予定日をご確認ください。" #: templates/email/thank_you_with_kit.jinja2:242 -msgid "" -"Once your profile is complete you will be ready to take your food " -"frequency questionnaire. Visit the 'My Nutrition' page and enter the " -"following:" -msgstr "" +msgid "Once your profile is complete you will be ready to take your food frequency questionnaire. Visit the 'My Nutrition' page and enter the following:" +msgstr "プロフィールの入力が完成したら、食事摂取頻度調査票に記入することができます。’私の栄養’ページにアクセスし、以下の情報を入力してください:" #: templates/email/thank_you_with_kit.jinja2:255 msgid "For helpful resources, please visit the links below:" -msgstr "" +msgstr "参考資料については、以下のリンクをご覧ください:" #: templates/email/thank_you_with_kit.jinja2:256 msgid "Step-by-step instructions" -msgstr "" +msgstr "説明事項" #: templates/email/thank_you_with_kit.jinja2:257 msgid "FAQs" -msgstr "" - -#~ msgid "Dear" -#~ msgstr "拝啓" - +msgstr "よくある質問" From ed47b7c35be348843d1e4ec078a0f5d857e2898b Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Tue, 17 Oct 2023 20:34:08 -0700 Subject: [PATCH 02/11] External reports infrastructure + load Japanese FFQs --- microsetta_private_api/api/__init__.py | 6 +- microsetta_private_api/api/_source.py | 51 +++++++- .../api/microsetta_private_api.yaml | 112 ++++++++++++++++++ .../db/migration_support.py | 51 ++++++++ .../db/patches/{0132.sql => 0133.sql} | 19 +++ .../model/external_report.py | 22 ++++ microsetta_private_api/repo/source_repo.py | 58 +++++++++ .../repo/tests/test_source.py | 83 +++++++++++++ microsetta_private_api/server_config.json | 4 +- 9 files changed, 403 insertions(+), 3 deletions(-) rename microsetta_private_api/db/patches/{0132.sql => 0133.sql} (97%) create mode 100644 microsetta_private_api/model/external_report.py diff --git a/microsetta_private_api/api/__init__.py b/microsetta_private_api/api/__init__.py index 83fdc680d..9dfab34dc 100644 --- a/microsetta_private_api/api/__init__.py +++ b/microsetta_private_api/api/__init__.py @@ -18,7 +18,8 @@ from ._source import ( create_source, read_source, update_source, read_sources, create_human_source_from_consent, check_duplicate_source_name, - scrub_source, check_source_ffq_prereqs, check_prompt_survey_update + scrub_source, check_source_ffq_prereqs, check_prompt_survey_update, + get_external_reports, get_external_report, get_external_report_bytes ) from ._survey import ( read_survey_template, read_survey_templates, read_answered_survey, @@ -84,6 +85,9 @@ 'read_source', 'check_source_ffq_prereqs', 'check_prompt_survey_update', + 'get_external_reports', + 'get_external_report', + 'get_external_report_bytes', 'update_source', 'scrub_source', 'read_sources', diff --git a/microsetta_private_api/api/_source.py b/microsetta_private_api/api/_source.py index aa52f73f1..42314f4cb 100644 --- a/microsetta_private_api/api/_source.py +++ b/microsetta_private_api/api/_source.py @@ -1,6 +1,7 @@ import uuid +import base64 from datetime import date -from flask import jsonify +from flask import jsonify, make_response from microsetta_private_api.api._account import _validate_account_access from microsetta_private_api.api.literals import SRC_NOT_FOUND_MSG,\ @@ -194,3 +195,51 @@ def check_prompt_survey_update(account_id, source_id, token_info): s_t_r = SurveyTemplateRepo(t) prompt_update = s_t_r.check_prompt_survey_update(source_id) return jsonify({"prompt": prompt_update}), 200 + + +def get_external_reports(account_id, source_id, token_info): + _validate_account_access(token_info, account_id) + + with Transaction() as t: + source_repo = SourceRepo(t) + reports = source_repo.get_external_reports(source_id) + return jsonify(reports), 200 + + +def get_external_report( + account_id, source_id, external_report_id, token_info +): + _validate_account_access(token_info, account_id) + + with Transaction() as t: + source_repo = SourceRepo(t) + report = source_repo.get_external_report( + source_id, external_report_id + ) + # Trying to jsonify the actual contents gets ugly, so we return + # everything else here, and the contents in get_external_report_bytes + report.file_contents = "" + + if report is None: + return jsonify(code=404, message="Report not found"), 404 + return jsonify(report.to_api()), 200 + + +def get_external_report_bytes( + account_id, source_id, external_report_id, token_info +): + _validate_account_access(token_info, account_id) + + with Transaction() as t: + source_repo = SourceRepo(t) + report = source_repo.get_external_report( + source_id, external_report_id + ) + + if report is None: + return jsonify(code=404, message="Report not found"), 404 + + response = make_response(bytes(report.file_contents)) + response.headers.set("Content-Type", "application/pdf") + + return response diff --git a/microsetta_private_api/api/microsetta_private_api.yaml b/microsetta_private_api/api/microsetta_private_api.yaml index 93231e749..5b0e930fa 100644 --- a/microsetta_private_api/api/microsetta_private_api.yaml +++ b/microsetta_private_api/api/microsetta_private_api.yaml @@ -679,6 +679,79 @@ paths: $ref: '#/components/responses/422UnprocessableEntity' # NB: This would be returned if source cannot be deleted bc has a sample assigned to it + '/accounts/{account_id}/sources/{source_id}/external_reports': + get: + operationId: microsetta_private_api.api.get_external_reports + tags: + - Sources + summary: Get external reports attached to the source + description: Get external reports attached to the source + parameters: + - $ref: '#/components/parameters/account_id' + - $ref: '#/components/parameters/source_id' + - $ref: '#/components/parameters/language_tag' + responses: + '200': + description: Successfully returned list of external reports + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/external_report' + '401': + $ref: '#/components/responses/401Unauthorized' + '403': + $ref: '#/components/responses/403Forbidden' + + '/accounts/{account_id}/sources/{source_id}/external_reports/{external_report_id}': + get: + operationId: microsetta_private_api.api.get_external_report + tags: + - Sources + summary: Get full contents of external report + description: Get full contents of external report + parameters: + - $ref: '#/components/parameters/account_id' + - $ref: '#/components/parameters/source_id' + - $ref: '#/components/parameters/external_report_id' + - $ref: '#/components/parameters/language_tag' + responses: + '200': + description: Successfully returned external report information + content: + application/json: + schema: + type: "object" + '401': + $ref: '#/components/responses/401Unauthorized' + '403': + $ref: '#/components/responses/403Forbidden' + '404': + $ref: '#/components/responses/404NotFound' + + '/accounts/{account_id}/sources/{source_id}/external_reports/{external_report_id}/bytes': + get: + operationId: microsetta_private_api.api.get_external_report_bytes + tags: + - Sources + summary: Get full contents of external report + description: Get full contents of external report + parameters: + - $ref: '#/components/parameters/account_id' + - $ref: '#/components/parameters/source_id' + - $ref: '#/components/parameters/external_report_id' + - $ref: '#/components/parameters/language_tag' + responses: + '200': + description: Successfully returned contents of an external report + '401': + $ref: '#/components/responses/401Unauthorized' + '403': + $ref: '#/components/responses/403Forbidden' + '404': + $ref: '#/components/responses/404NotFound' + '/accounts/{account_id}/sources/{source_id}/check_ffq_prereqs': get: operationId: microsetta_private_api.api.check_source_ffq_prereqs @@ -3014,6 +3087,12 @@ components: description: Type of consent schema: $ref: '#/components/schemas/consent_type' + external_report_id: + name: external_report_id + in: path + description: Unique identifier of external report + schema: + $ref: '#/components/schemas/external_report_id' # query parameters activation_code: @@ -3425,6 +3504,18 @@ components: type: string assent_content: type: string + external_report_id: + type: string + file_name: + type: string + file_title: + type: string + file_type: + type: string + file_contents: + type: string + report_type: + enum: ["sample", "ffq"] nonhuman_source: type: object properties: @@ -3472,6 +3563,27 @@ components: type: string additionalProperties: false additionalProperties: false + external_report: + type: object + properties: + external_report_id: + $ref: '#/components/schemas/external_report_id' + source_id: + $ref: '#/components/schemas/source_id' + file_name: + $ref: '#/components/schemas/file_name' + file_title: + $ref: '#/components/schemas/file_title' + file_type: + $ref: '#/components/schemas/file_type' + file_contents: + $ref: '#/components/schemas/file_contents' + report_type: + $ref: '#/components/schemas/report_type' + required: + - external_report_id + - source_id + - report_type # survey template section survey_template_id: diff --git a/microsetta_private_api/db/migration_support.py b/microsetta_private_api/db/migration_support.py index 7be576c46..b81d1913a 100644 --- a/microsetta_private_api/db/migration_support.py +++ b/microsetta_private_api/db/migration_support.py @@ -742,6 +742,56 @@ def migrate_96(TRN): (r[0], hsi)) TRN.execute() + @staticmethod + def migrate_133(TRN): + ffq_key_path = SERVER_CONFIG["japanese_ffqs_path_key"] + ffq_file_path = SERVER_CONFIG["japanese_ffqs_path_reports"] + + # The below string translates to "Food frequency questionnaire" + JFFQ_FILE_LABEL = "食物摂取頻度調査票" + + if not os.path.exists(ffq_key_path): + return + + with open(ffq_key_path) as csv_file: + csv_contents = csv.reader(csv_file) + header = True + + for csv_row in csv_contents: + if header: + header = False + continue + ffq_id, barcode = csv_row + + # Find the source associated with the barcode and make sure + # it wasn't scrubbed or removed + TRN.add( + "SELECT akb.source_id " + "FROM ag.ag_kit_barcodes akb " + "INNER JOIN ag.source s " + "ON akb.source_id = s.id " + "WHERE akb.barcode = %s AND s.date_revoked IS NULL", + (barcode, ) + ) + rows = TRN.execute()[-1] + + if len(rows) == 1: + row = rows[0] + source_id = row[0] + pdf_name = ffq_id + ".pdf" + pdf_path = ffq_file_path + pdf_name + pdf_contents = open(pdf_path, "rb").read() + + TRN.add( + "INSERT INTO ag.external_reports (" + "source_id, file_name, file_title, file_type, " + "file_contents, report_type" + ") VALUES (%s, %s, %s, %s, %s, %s)", + (source_id, pdf_name, JFFQ_FILE_LABEL, + "application/pdf", pdf_contents, "ffq") + ) + TRN.execute() + MIGRATION_LOOKUP = { "0048.sql": migrate_48.__func__, "0050.sql": migrate_50.__func__, @@ -753,6 +803,7 @@ def migrate_96(TRN): # "0082.sql": migrate_82.__func__ # ... "0096.sql": migrate_96.__func__, + "0133.sql": migrate_133.__func__ } @classmethod diff --git a/microsetta_private_api/db/patches/0132.sql b/microsetta_private_api/db/patches/0133.sql similarity index 97% rename from microsetta_private_api/db/patches/0132.sql rename to microsetta_private_api/db/patches/0133.sql index 29cabfa05..bb5bb391c 100644 --- a/microsetta_private_api/db/patches/0132.sql +++ b/microsetta_private_api/db/patches/0133.sql @@ -1,3 +1,22 @@ +-- Create the table that will house external reports +-- NB: The file_title column will not go through any translation mechanisms. It might be wise to revisit this in the future, but since our only current use +-- is for highly specific documents with a pre-defined language (FFQs from the THDMI Japan project), the approach makes sense. + +-- The report_type value will dictate which section of the My Reports tab it displays under. +-- I'm setting the enum up to reflect current structure (sample = My Kits/ffq = My FFQs) but this could be extended to "Other" or various specifics later. +CREATE TYPE EXTERNAL_REPORT_TYPE AS ENUM ('sample', 'ffq'); +CREATE TABLE ag.external_reports ( + external_report_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + source_id UUID NOT NULL, + file_name VARCHAR NOT NULL, -- The file name that will be used when the user downloads the file + file_title VARCHAR NOT NULL, -- The label that will be displayed in the UI when the user views their list of reports + file_type VARCHAR NOT NULL, -- The Content-Type header that Interface will use to render the file for display/download + file_contents BYTEA NOT NULL, + report_type EXTERNAL_REPORT_TYPE NOT NULL, + + CONSTRAINT fk_external_reports_source FOREIGN KEY (source_id) REFERENCES ag.source (id) +); + -- Add Japanese translations for survey groups UPDATE ag.survey_group SET japanese = '基本情報' WHERE group_order = -10; -- Basic Information UPDATE ag.survey_group SET japanese = '自宅において' WHERE group_order = -11; -- At Home diff --git a/microsetta_private_api/model/external_report.py b/microsetta_private_api/model/external_report.py new file mode 100644 index 000000000..830f5b9b8 --- /dev/null +++ b/microsetta_private_api/model/external_report.py @@ -0,0 +1,22 @@ +from microsetta_private_api.model.model_base import ModelBase + + +class ExternalReport(ModelBase): + def __init__(self, **kwargs): + # Minimum requirements + self.external_report_id = kwargs['external_report_id'] + self.source_id = kwargs['source_id'] + self.report_type = kwargs['report_type'] + + # Optional parameters + self.file_name = kwargs.get("file_name", "") + self.file_title = kwargs.get("file_title", "") + self.file_type = kwargs.get("file_type", "") + self.file_contents = kwargs.get("file_contents", "") + + def to_api(self): + return self.__dict__.copy() + + @classmethod + def from_dict(cls, values_dict): + return cls(**values_dict) diff --git a/microsetta_private_api/repo/source_repo.py b/microsetta_private_api/repo/source_repo.py index 300978b82..0a4f64efa 100644 --- a/microsetta_private_api/repo/source_repo.py +++ b/microsetta_private_api/repo/source_repo.py @@ -5,6 +5,7 @@ from microsetta_private_api.repo.account_repo import AccountRepo from microsetta_private_api.repo.base_repo import BaseRepo from microsetta_private_api.model.source import Source, HumanInfo, NonHumanInfo +from microsetta_private_api.model.external_report import ExternalReport from werkzeug.exceptions import NotFound from hashlib import sha512 @@ -57,6 +58,10 @@ def _row_to_source(r): return Source(r[0], r[1], r[2], r[3], row_to_obj(r)) +def _row_to_external_report(r): + return ExternalReport.from_dict(r) + + # Note: By convention, this references sources by both account_id AND source_id # This should make it more difficult to accidentally muck up sources when the # user doesn't have the right permissions @@ -307,3 +312,56 @@ def check_source_post_overhaul(self, account_id, source_id): (account_id, source_id) ) return cur.rowcount == 1 + + def get_external_reports(self, source_id): + """Retrieve list of external reports for a given source, if any + NB: We only extract certain columns because there's no need to waste + resources on the actual file_contents until the user hits the path + to view/download the report + + Parameters + ---------- + source_id : uuid + The associated source ID + + Returns + ------- + List of ExternalReports + """ + with self._transaction.dict_cursor() as cur: + cur.execute( + "SELECT external_report_id, source_id, file_title, " + "report_type " + "FROM ag.external_reports " + "WHERE source_id = %s", + (source_id, ) + ) + rows = cur.fetchall() + return [_row_to_external_report(r) for r in rows] + + def get_external_report(self, source_id, external_report_id): + """ Retrieve the full contents of an external report + + Parameters + ---------- + source_id : uuid + The associated source ID + external_report_id : uuid + The external report ID + + Returns + ------- + ExternalReport object or None if not found + """ + with self._transaction.dict_cursor() as cur: + cur.execute( + "SELECT * " + "FROM ag.external_reports " + "WHERE source_id = %s AND external_report_id = %s", + (source_id, external_report_id) + ) + if cur.rowcount == 1: + row = cur.fetchone() + return _row_to_external_report(row) + else: + return None diff --git a/microsetta_private_api/repo/tests/test_source.py b/microsetta_private_api/repo/tests/test_source.py index 602f720a3..350900894 100644 --- a/microsetta_private_api/repo/tests/test_source.py +++ b/microsetta_private_api/repo/tests/test_source.py @@ -25,10 +25,33 @@ def setUp(self): with Transaction() as t: sr = SourceRepo(t) sr.create_source(HUMAN_SOURCE) + + file_name = "test_source.py" + file_label = "Test Source Repo" + fh = open(file_name, "rb") + file_contents = fh.read() + fh.close() + cur = t.cursor() + cur.execute( + "INSERT INTO ag.external_reports (" + "source_id, file_name, file_title, file_type, " + "file_contents, report_type" + ") VALUES (%s, %s, %s, %s, %s, %s)", + (HUMAN_SOURCE.id, file_name, file_label, + "application/pdf", file_contents, "ffq") + ) + t.commit() def tearDown(self): with Transaction() as t: + cur = t.cursor() + cur.execute( + "DELETE FROM ag.external_reports " + "WHERE source_id = %s", + (HUMAN_SOURCE.id, ) + ) + sr = SourceRepo(t) sr.delete_source(HUMAN_SOURCE.account_id, HUMAN_SOURCE.id) @@ -130,6 +153,66 @@ def test_check_source_post_overhaul_false(self): obs = sr.check_source_post_overhaul(ACCOUNT_ID, HUMAN_SOURCE.id) self.assertFalse(obs) + def test_get_external_reports(self): + with Transaction() as t: + sr = SourceRepo(t) + obs = sr.get_external_reports(HUMAN_SOURCE.id) + + # We should observe one external report + self.assertEqual(len(obs), 1) + + def test_get_external_reports_fake_source(self): + with Transaction() as t: + sr = SourceRepo(t) + # Changed the source ID's second section from "ffff" to "aaaa" + obs = sr.get_external_reports( + "ffffffff-aaaa-cccc-aaaa-aaaaaaaaaaaa" + ) + + # We should observe zero external reports + self.assertEqual(len(obs), 0) + + def test_get_external_report(self): + with Transaction() as t: + sr = SourceRepo(t) + reports = sr.get_external_reports(HUMAN_SOURCE.id) + + er = reports[0] + obs = sr.get_external_report( + HUMAN_SOURCE.id, er.external_report_id + ) + + self.assertEqual(obs.source_id, HUMAN_SOURCE.id) + self.assertEqual(obs.file_title, "Test Source Repo") + + def test_get_external_report_fail(self): + with Transaction() as t: + sr = SourceRepo(t) + reports = sr.get_external_reports(HUMAN_SOURCE.id) + + er = reports[0] + obs = sr.get_external_report( + "ffffffff-aaaa-cccc-aaaa-aaaaaaaaaaaa", er.external_report_id + ) + + self.assertEqual(obs, None) + + def test_get_external_report_bytes(self): + with Transaction() as t: + sr = SourceRepo(t) + reports = sr.get_external_reports(HUMAN_SOURCE.id) + + er = reports[0] + obs = sr.get_external_report( + HUMAN_SOURCE.id, er.external_report_id + ) + + fh = open("test_source.py", "rb") + act = fh.read() + fh.close() + + self.assertEqual(bytes(obs.file_contents), act) + if __name__ == '__main__': unittest.main() diff --git a/microsetta_private_api/server_config.json b/microsetta_private_api/server_config.json index b17ca5653..d49f8a7bd 100644 --- a/microsetta_private_api/server_config.json +++ b/microsetta_private_api/server_config.json @@ -44,5 +44,7 @@ "spain_ffq_url": "sffq_placeholder", "fulfillment_account_id": "000fc4cd-8fa4-db8b-e050-8a800c5d81b7", "google_geocoding_url": "https://maps.googleapis.com/maps/api/geocode/json", - "google_geocoding_key": "geocoding_key_placeholder" + "google_geocoding_key": "geocoding_key_placeholder", + "japanese_ffqs_path_key": "/tmp/japanese_ffqs/key.csv", + "japanese_ffqs_path_reports": "/tmp/japanese_ffqs/" } From 35826d86152027954ee9cea5d42f0184584f708f Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Tue, 17 Oct 2023 21:00:57 -0700 Subject: [PATCH 03/11] Debug migration --- microsetta_private_api/db/migration_support.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsetta_private_api/db/migration_support.py b/microsetta_private_api/db/migration_support.py index b81d1913a..2b1752cff 100644 --- a/microsetta_private_api/db/migration_support.py +++ b/microsetta_private_api/db/migration_support.py @@ -751,8 +751,10 @@ def migrate_133(TRN): JFFQ_FILE_LABEL = "食物摂取頻度調査票" if not os.path.exists(ffq_key_path): + print("Key not found") return + print("Key found, proceeding") with open(ffq_key_path) as csv_file: csv_contents = csv.reader(csv_file) header = True From 8865a768015b2e4c21fc7bb911cf43656e593c4e Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Wed, 18 Oct 2023 09:16:50 -0700 Subject: [PATCH 04/11] Debug migration --- microsetta_private_api/db/migration_support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsetta_private_api/db/migration_support.py b/microsetta_private_api/db/migration_support.py index 2b1752cff..937dfdd0f 100644 --- a/microsetta_private_api/db/migration_support.py +++ b/microsetta_private_api/db/migration_support.py @@ -751,7 +751,7 @@ def migrate_133(TRN): JFFQ_FILE_LABEL = "食物摂取頻度調査票" if not os.path.exists(ffq_key_path): - print("Key not found") + print("Key not found:" + ffq_key_path) return print("Key found, proceeding") From 2539ef17bb439eb9ec1f34ab526e6c3c45542a6d Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Wed, 18 Oct 2023 11:32:11 -0700 Subject: [PATCH 05/11] Add debug for missing mappings --- microsetta_private_api/db/migration_support.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microsetta_private_api/db/migration_support.py b/microsetta_private_api/db/migration_support.py index 937dfdd0f..785ef3ef3 100644 --- a/microsetta_private_api/db/migration_support.py +++ b/microsetta_private_api/db/migration_support.py @@ -754,7 +754,6 @@ def migrate_133(TRN): print("Key not found:" + ffq_key_path) return - print("Key found, proceeding") with open(ffq_key_path) as csv_file: csv_contents = csv.reader(csv_file) header = True @@ -792,6 +791,8 @@ def migrate_133(TRN): (source_id, pdf_name, JFFQ_FILE_LABEL, "application/pdf", pdf_contents, "ffq") ) + else: + print("No mapping: " + ffq_id + " - " + barcode) TRN.execute() MIGRATION_LOOKUP = { From 7347f8352c21c41a34f32fa5ee589031116f1a95 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Wed, 18 Oct 2023 13:14:21 -0700 Subject: [PATCH 06/11] Translation updates --- microsetta_private_api/db/patches/0133.sql | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/microsetta_private_api/db/patches/0133.sql b/microsetta_private_api/db/patches/0133.sql index bb5bb391c..3c6439dc4 100644 --- a/microsetta_private_api/db/patches/0133.sql +++ b/microsetta_private_api/db/patches/0133.sql @@ -19,15 +19,15 @@ CREATE TABLE ag.external_reports ( -- Add Japanese translations for survey groups UPDATE ag.survey_group SET japanese = '基本情報' WHERE group_order = -10; -- Basic Information -UPDATE ag.survey_group SET japanese = '自宅において' WHERE group_order = -11; -- At Home +UPDATE ag.survey_group SET japanese = '住まい' WHERE group_order = -11; -- At Home UPDATE ag.survey_group SET japanese = '生活様式' WHERE group_order = -12; -- Lifestyle UPDATE ag.survey_group SET japanese = '消化器' WHERE group_order = -13; -- Gut -UPDATE ag.survey_group SET japanese = '健康全般' WHERE group_order = -14; -- General Health +UPDATE ag.survey_group SET japanese = '健康状態について' WHERE group_order = -14; -- General Health UPDATE ag.survey_group SET japanese = '健康診断' WHERE group_order = -15; -- Health Diagnosis UPDATE ag.survey_group SET japanese = 'アレルギー' WHERE group_order = -16; -- Allergies -UPDATE ag.survey_group SET japanese = '食事' WHERE group_order = -17; -- Diet +UPDATE ag.survey_group SET japanese = '食習慣' WHERE group_order = -17; -- Diet UPDATE ag.survey_group SET japanese = '食事の詳細' WHERE group_order = -18; -- Detailed Diet -UPDATE ag.survey_group SET japanese = '他の' WHERE group_order = -22; -- Other +UPDATE ag.survey_group SET japanese = 'その他' WHERE group_order = -22; -- Other -- Add missing Japanese translations for survey questions UPDATE ag.survey_question SET japanese = 'どれくらい定期的にチームスポーツに参加していますか?' WHERE survey_question_id = 333; @@ -42,7 +42,7 @@ UPDATE ag.survey_question SET japanese = '家畜をよく触ったり定期的 UPDATE ag.survey_question SET japanese = 'この研究に参加していて、そのことをあなたに自発的に伝えた人々と、あなたとの関係(パートナー、子供など)をお答えください。' WHERE survey_question_id = 316; UPDATE ag.survey_question SET japanese = '種類/商品名:' WHERE survey_question_id = 490; UPDATE ag.survey_question SET japanese = 'この研究に参加していて、そのことをあなたに自発的に伝えた同居人は誰ですか?' WHERE survey_question_id = 319; -UPDATE ag.survey_question SET japanese = '参加者名' WHERE survey_question_id = 508; +UPDATE ag.survey_question SET japanese = 'その参加者の名前' WHERE survey_question_id = 508; UPDATE ag.survey_question SET japanese = 'この人とあなたは血のつながりがありますか?' WHERE survey_question_id = 509; UPDATE ag.survey_question SET japanese = 'この人はあなたと一緒に住んでいますか?' WHERE survey_question_id = 510; UPDATE ag.survey_question SET japanese = 'あなたの犬は主にどこにいますか?' WHERE survey_question_id = 501; @@ -58,7 +58,7 @@ UPDATE ag.survey_question SET japanese = '過去1週間に、膨満感(おな UPDATE ag.survey_question SET japanese = '過去1週間で、お腹が鳴る/胃が鳴ることはどれくらいありましたか?' WHERE survey_question_id = 365; UPDATE ag.survey_question SET japanese = 'ホルモン' WHERE survey_question_id = 518; UPDATE ag.survey_question SET japanese = '今までに皮膚疾患の診断を受けたことはありますか?' WHERE survey_question_id = 500; -UPDATE ag.survey_question SET japanese = '現在、何らかのホルモン避妊法を使用していますか?' WHERE survey_question_id = 497; +UPDATE ag.survey_question SET japanese = '現在、何らかの避妊法を使用していますか?' WHERE survey_question_id = 497; UPDATE ag.survey_question SET japanese = 'どのような皮膚疾患と診断されましたか?' WHERE survey_question_id = 374; UPDATE ag.survey_question SET japanese = 'その皮膚疾患はどのように診断されましたか?' WHERE survey_question_id = 375; UPDATE ag.survey_question SET japanese = '出産予定日:' WHERE survey_question_id = 370; @@ -88,7 +88,7 @@ UPDATE ag.survey_question SET japanese = '通常、1日に何回食事をしま UPDATE ag.survey_question SET japanese = '通常、1日に何回軽食(おやつ)を食べますか?' WHERE survey_question_id = 426; UPDATE ag.survey_question SET japanese = '毎日のカロリーのほとんどはいつ摂取しますか?' WHERE survey_question_id = 427; UPDATE ag.survey_question SET japanese = '繊維サプリメントを服用する場合、どのような種類のものを服用していますか?該当するものをすべて選択してください。' WHERE survey_question_id = 433; -UPDATE ag.survey_question SET japanese = 'あなたは母乳や調整粉乳から栄養のほとんどを受け取っている乳児ですか、それとも成人用栄養シェイクから栄養のほとんど(1日のカロリーの75%以上)を受け取っている成人ですか?' WHERE survey_question_id = 498; +UPDATE ag.survey_question SET japanese = 'あなたは栄養源がほぼ母乳または調整粉ミルクの乳児、または栄養源が1日の摂取カロリーうち75%以上が経腸栄養剤など、液体栄養である成人のいずれかですか?' WHERE survey_question_id = 498; UPDATE ag.survey_question SET japanese = '上記に記載されていないその他の特殊な食事制限があったら列挙/説明してください。' WHERE survey_question_id = 424; UPDATE ag.survey_question SET japanese = '通常、寝る前の最後の食事や軽食を何時に食べますか?' WHERE survey_question_id = 428; UPDATE ag.survey_question SET japanese = '繊維サプリメントをどれくらいの回数服用していますか?' WHERE survey_question_id = 434; @@ -113,6 +113,10 @@ UPDATE ag.survey_question SET japanese = '現在の睡眠パターンにどの UPDATE ag.survey_question SET japanese = '睡眠障害があなたの生活に悪影響を与えている事をまわりの人はどの程度気づいていると思いますか?' WHERE survey_question_id = 233; UPDATE ag.survey_question SET japanese = 'あなたは自身の睡眠障害をどの程度辛く感じていますか?' WHERE survey_question_id = 234; UPDATE ag.survey_question SET japanese = '現在、睡眠障害が毎日の生活に支障をきたしていますか?(日中の疲労、機嫌、仕事、家事の生産性、集中力、記憶力など)' WHERE survey_question_id = 235; +UPDATE ag.survey_question SET japanese = '健康食品サプリ、ハーブサプリメントを服用していますか?' WHERE survey_question_id = 6; +UPDATE ag.survey_question SET japanese = '過去一ヶ月の間に、新型コロナウイルス/COVID -19に感染している可能性が高い人と接触したことはありますか?(該当するもの全てにチェックを入れてください)' WHERE survey_question_id = 211; +UPDATE ag.survey_question SET japanese = '過去一ヶ月の間に、新型コロナウイルス/COVID -19に感染した疑いはありますか?' WHERE survey_question_id = 212; +UPDATE ag.survey_question SET japanese = 'その他、自分自身の微生物に何か影響を与えると思う事柄があればご記入下さい。' WHERE survey_question_id = 116; -- Add missing translations for survey responses UPDATE ag.survey_response SET japanese = '0' WHERE american = '0'; @@ -155,7 +159,7 @@ UPDATE ag.survey_response SET japanese = 'ないはずの体の部分に痛み UPDATE ag.survey_response SET japanese = '瓶詰めされた*精製水(ラベルに「湧き水」あるいは「天然ミネラルウォーター」とは表示されていない)' WHERE american = 'Bottled* purified water (does not indicate "spring water" or "natural mineral water" on the label)'; UPDATE ag.survey_response SET japanese = '脳がん(神経膠腫および神経膠芽腫を含む)' WHERE american = 'Brain cancer (includes gliomas and glioblastomas)'; UPDATE ag.survey_response SET japanese = '乳がん' WHERE american = 'Breast cancer'; -UPDATE ag.survey_response SET japanese = 'カロリーは1日にわたって均等に分配している' WHERE american = 'Calories are evenly distributed throughout the day'; +UPDATE ag.survey_response SET japanese = '1日のうち、均等に摂取するように配分している' WHERE american = 'Calories are evenly distributed throughout the day'; UPDATE ag.survey_response SET japanese = '子宮頸がん' WHERE american = 'Cervical cancer'; UPDATE ag.survey_response SET japanese = '胆管がん' WHERE american = 'Cholangiocarcinoma'; UPDATE ag.survey_response SET japanese = '結腸がん' WHERE american = 'Colon cancer'; @@ -209,7 +213,7 @@ UPDATE ag.survey_response SET japanese = '主要都市(人口100万人以上 UPDATE ag.survey_response SET japanese = 'モンクフルーツ' WHERE american = 'Monk fruit'; UPDATE ag.survey_response SET japanese = '毎月' WHERE american = 'Monthly'; UPDATE ag.survey_response SET japanese = '1日3回以上' WHERE american = 'More than 2 times a day'; -UPDATE ag.survey_response SET japanese = '5杯以上' WHERE american = 'More than 4'; +UPDATE ag.survey_response SET japanese = '5回以上' WHERE american = 'More than 4'; UPDATE ag.survey_response SET japanese = '多民族' WHERE american = 'Multiracial'; UPDATE ag.survey_response SET japanese = 'アメリカ先住民またはアラスカ先住民' WHERE american = 'Native American or Alaska Native'; UPDATE ag.survey_response SET japanese = 'ハワイまたは他の太平洋諸島の先住民' WHERE american = 'Native Hawaiian or Other Pacific Islander'; @@ -273,10 +277,10 @@ UPDATE ag.survey_response SET japanese = 'はい、現在がんを患ってい UPDATE ag.survey_response SET japanese = 'はい、ホメオパシー薬を服用しています。' WHERE american = 'Yes, I take homeopathic medication'; UPDATE ag.survey_response SET japanese = 'はい、市販薬を服用しています。' WHERE american = 'Yes, I take over-the-counter medication'; UPDATE ag.survey_response SET japanese = 'はい、処方薬を服用しています。' WHERE american = 'Yes, I take prescription medication'; -UPDATE ag.survey_response SET japanese = 'はい、避妊用パッチを使用しています。' WHERE american = 'Yes, I use a contraceptive patch'; -UPDATE ag.survey_response SET japanese = 'はい、避妊用の膣リングを使用しています。' WHERE american = 'Yes, I use a contraceptive vaginal ring'; -UPDATE ag.survey_response SET japanese = 'はい、ホルモン子宮内避妊具/インプラントを使用しています。' WHERE american = 'Yes, I use a hormonal IUD/implant'; -UPDATE ag.survey_response SET japanese = 'はい、注射用避妊薬を使用しています。' WHERE american = 'Yes, I use an injected contraceptive'; +UPDATE ag.survey_response SET japanese = 'はい、避妊パッチを使用しています。' WHERE american = 'Yes, I use a contraceptive patch'; +UPDATE ag.survey_response SET japanese = 'はい、避妊リングを使用しています。' WHERE american = 'Yes, I use a contraceptive vaginal ring'; +UPDATE ag.survey_response SET japanese = 'はい、子宮内避妊器具/避妊インプラントを使用しています。' WHERE american = 'Yes, I use a hormonal IUD/implant'; +UPDATE ag.survey_response SET japanese = 'はい、避妊注射を行っています。' WHERE american = 'Yes, I use an injected contraceptive'; UPDATE ag.survey_response SET japanese = 'はい、ここに記載されていない他の種類の薬を使用しています。' WHERE american = 'Yes, I use other types of medication not listed here'; UPDATE ag.survey_response SET japanese = 'はい、医療専門家(医師、医師助手)によって診断されました。' WHERE american = 'Yes, diagnosed by a medical professional (doctor, physician assistant)'; UPDATE ag.survey_response SET japanese = 'はい、代替医療の医師によって診断されました。' WHERE american = 'Yes, diagnosed by an alternative or complementary practitioner'; @@ -295,7 +299,13 @@ UPDATE ag.survey_response SET japanese = '喘鳴(ゼーゼーとした咳)' WH UPDATE ag.survey_response SET japanese = '3回以上' WHERE american = '3 or more'; UPDATE ag.survey_response SET japanese = '両方使います' WHERE american = 'I use both'; UPDATE ag.survey_response SET japanese = '発酵食品は作りません。' WHERE american = 'I do not produce fermented foods'; -UPDATE ag.survey_response SET japanese = 'いいえ。私は子宮内避妊具銅IUDを使用しています' WHERE american = 'No, I use a copper IUD'; +UPDATE ag.survey_response SET japanese = 'いいえ、銅付加子宮内避妊器具を使用しています。' WHERE american = 'No, I use a copper IUD'; +UPDATE ag.survey_response SET japanese = 'はい、検査陽性の人と接触しました。' WHERE american = 'Yes, someone with positive test'; +UPDATE ag.survey_response SET japanese = 'はい、医師の診断は受けたが、検査はしていない人' WHERE american = 'Yes, someone with medical diagnosis, but no test'; +UPDATE ag.survey_response SET japanese = 'はい、陽性の可能性があるが医師による診断を受けていない人と接触しました。' WHERE american = 'Yes, someone with possible symptoms, but no diagnosis by doctor'; +UPDATE ag.survey_response SET japanese = 'はい、検査陽性でした。' WHERE american = 'Yes, with a positive test'; +UPDATE ag.survey_response SET japanese = 'はい、医師の診断は受けたが、検査はしていない人' WHERE american = 'Yes, medical diagnosis, but no test'; +UPDATE ag.survey_response SET japanese = '症状や兆候はありませんでした。' WHERE american = 'No symptoms or signs'; -- Load Japanese consent documents -- Critical to note that we only have adult data/biospecimen documents, so Japanese users may not create profiles for minors From af411e760af538396eb3e4ce7f85a086d73cef02 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Mon, 23 Oct 2023 08:24:04 -0700 Subject: [PATCH 07/11] Lint --- microsetta_private_api/api/_source.py | 1 - 1 file changed, 1 deletion(-) diff --git a/microsetta_private_api/api/_source.py b/microsetta_private_api/api/_source.py index 42314f4cb..b1e8fd94f 100644 --- a/microsetta_private_api/api/_source.py +++ b/microsetta_private_api/api/_source.py @@ -1,5 +1,4 @@ import uuid -import base64 from datetime import date from flask import jsonify, make_response From 77a442ed878f10b0c68c4788f16ecba455da0e85 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Mon, 23 Oct 2023 08:30:33 -0700 Subject: [PATCH 08/11] Adjust unit tests --- microsetta_private_api/repo/tests/test_source.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/microsetta_private_api/repo/tests/test_source.py b/microsetta_private_api/repo/tests/test_source.py index 350900894..db35f7a5c 100644 --- a/microsetta_private_api/repo/tests/test_source.py +++ b/microsetta_private_api/repo/tests/test_source.py @@ -28,9 +28,9 @@ def setUp(self): file_name = "test_source.py" file_label = "Test Source Repo" - fh = open(file_name, "rb") - file_contents = fh.read() - fh.close() + # Opening and reading a file's contents doesn't appear to work on + # GitHub during workflow, so we need to fake the contents + file_contents = b'Imagine a full file here' cur = t.cursor() cur.execute( "INSERT INTO ag.external_reports (" @@ -207,9 +207,7 @@ def test_get_external_report_bytes(self): HUMAN_SOURCE.id, er.external_report_id ) - fh = open("test_source.py", "rb") - act = fh.read() - fh.close() + act = b'Imagine a full file here' self.assertEqual(bytes(obs.file_contents), act) From 974fbe40b8b5cf6412ca266955d3f8f1733b5416 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Mon, 23 Oct 2023 12:28:08 -0700 Subject: [PATCH 09/11] Changes based on PR feedback --- microsetta_private_api/api/_source.py | 17 +++--- microsetta_private_api/db/patches/0133.sql | 4 +- .../model/external_report.py | 11 ++-- microsetta_private_api/repo/source_repo.py | 52 ++++++------------- .../repo/tests/test_source.py | 10 ++-- 5 files changed, 39 insertions(+), 55 deletions(-) diff --git a/microsetta_private_api/api/_source.py b/microsetta_private_api/api/_source.py index b1e8fd94f..dbe837cbe 100644 --- a/microsetta_private_api/api/_source.py +++ b/microsetta_private_api/api/_source.py @@ -212,15 +212,17 @@ def get_external_report( with Transaction() as t: source_repo = SourceRepo(t) - report = source_repo.get_external_report( + reports = source_repo.get_external_reports( source_id, external_report_id ) + if len(reports) != 1: + return jsonify(code=404, message="Report not found"), 404 + + report = reports[0] + # Trying to jsonify the actual contents gets ugly, so we return # everything else here, and the contents in get_external_report_bytes report.file_contents = "" - - if report is None: - return jsonify(code=404, message="Report not found"), 404 return jsonify(report.to_api()), 200 @@ -231,14 +233,15 @@ def get_external_report_bytes( with Transaction() as t: source_repo = SourceRepo(t) - report = source_repo.get_external_report( + reports = source_repo.get_external_reports( source_id, external_report_id ) - if report is None: + if len(reports) != 1: return jsonify(code=404, message="Report not found"), 404 + report = reports[0] response = make_response(bytes(report.file_contents)) - response.headers.set("Content-Type", "application/pdf") + response.headers.set("Content-Type", report.file_type) return response diff --git a/microsetta_private_api/db/patches/0133.sql b/microsetta_private_api/db/patches/0133.sql index 3c6439dc4..88332381c 100644 --- a/microsetta_private_api/db/patches/0133.sql +++ b/microsetta_private_api/db/patches/0133.sql @@ -3,8 +3,8 @@ -- is for highly specific documents with a pre-defined language (FFQs from the THDMI Japan project), the approach makes sense. -- The report_type value will dictate which section of the My Reports tab it displays under. --- I'm setting the enum up to reflect current structure (sample = My Kits/ffq = My FFQs) but this could be extended to "Other" or various specifics later. -CREATE TYPE EXTERNAL_REPORT_TYPE AS ENUM ('sample', 'ffq'); +-- I'm setting the enum up to reflect current structure (kit = My Kits/ffq = My FFQs) but this could be extended later. +CREATE TYPE EXTERNAL_REPORT_TYPE AS ENUM ('kit', 'ffq'); CREATE TABLE ag.external_reports ( external_report_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), source_id UUID NOT NULL, diff --git a/microsetta_private_api/model/external_report.py b/microsetta_private_api/model/external_report.py index 830f5b9b8..0b5eb2316 100644 --- a/microsetta_private_api/model/external_report.py +++ b/microsetta_private_api/model/external_report.py @@ -3,16 +3,13 @@ class ExternalReport(ModelBase): def __init__(self, **kwargs): - # Minimum requirements self.external_report_id = kwargs['external_report_id'] self.source_id = kwargs['source_id'] self.report_type = kwargs['report_type'] - - # Optional parameters - self.file_name = kwargs.get("file_name", "") - self.file_title = kwargs.get("file_title", "") - self.file_type = kwargs.get("file_type", "") - self.file_contents = kwargs.get("file_contents", "") + self.file_name = kwargs['file_name'] + self.file_title = kwargs['file_title'] + self.file_type = kwargs['file_type'] + self.file_contents = kwargs['file_contents'] def to_api(self): return self.__dict__.copy() diff --git a/microsetta_private_api/repo/source_repo.py b/microsetta_private_api/repo/source_repo.py index 0a4f64efa..4e0e2310e 100644 --- a/microsetta_private_api/repo/source_repo.py +++ b/microsetta_private_api/repo/source_repo.py @@ -313,7 +313,7 @@ def check_source_post_overhaul(self, account_id, source_id): ) return cur.rowcount == 1 - def get_external_reports(self, source_id): + def get_external_reports(self, source_id, external_report_id=None): """Retrieve list of external reports for a given source, if any NB: We only extract certain columns because there's no need to waste resources on the actual file_contents until the user hits the path @@ -323,45 +323,27 @@ def get_external_reports(self, source_id): ---------- source_id : uuid The associated source ID + external_report_id : uuid + The ID of a single external report to pull Returns ------- List of ExternalReports """ with self._transaction.dict_cursor() as cur: - cur.execute( - "SELECT external_report_id, source_id, file_title, " - "report_type " - "FROM ag.external_reports " - "WHERE source_id = %s", - (source_id, ) - ) + if external_report_id is None: + cur.execute( + "SELECT * " + "FROM ag.external_reports " + "WHERE source_id = %s", + (source_id, ) + ) + else: + cur.execute( + "SELECT * " + "FROM ag.external_reports " + "WHERE source_id = %s AND external_report_id = %s", + (source_id, external_report_id) + ) rows = cur.fetchall() return [_row_to_external_report(r) for r in rows] - - def get_external_report(self, source_id, external_report_id): - """ Retrieve the full contents of an external report - - Parameters - ---------- - source_id : uuid - The associated source ID - external_report_id : uuid - The external report ID - - Returns - ------- - ExternalReport object or None if not found - """ - with self._transaction.dict_cursor() as cur: - cur.execute( - "SELECT * " - "FROM ag.external_reports " - "WHERE source_id = %s AND external_report_id = %s", - (source_id, external_report_id) - ) - if cur.rowcount == 1: - row = cur.fetchone() - return _row_to_external_report(row) - else: - return None diff --git a/microsetta_private_api/repo/tests/test_source.py b/microsetta_private_api/repo/tests/test_source.py index db35f7a5c..9d7769747 100644 --- a/microsetta_private_api/repo/tests/test_source.py +++ b/microsetta_private_api/repo/tests/test_source.py @@ -178,9 +178,10 @@ def test_get_external_report(self): reports = sr.get_external_reports(HUMAN_SOURCE.id) er = reports[0] - obs = sr.get_external_report( + obs_reports = sr.get_external_reports( HUMAN_SOURCE.id, er.external_report_id ) + obs = obs_reports[0] self.assertEqual(obs.source_id, HUMAN_SOURCE.id) self.assertEqual(obs.file_title, "Test Source Repo") @@ -191,11 +192,11 @@ def test_get_external_report_fail(self): reports = sr.get_external_reports(HUMAN_SOURCE.id) er = reports[0] - obs = sr.get_external_report( + obs_reports = sr.get_external_reports( "ffffffff-aaaa-cccc-aaaa-aaaaaaaaaaaa", er.external_report_id ) - self.assertEqual(obs, None) + self.assertEqual(len(obs_reports), 0) def test_get_external_report_bytes(self): with Transaction() as t: @@ -203,9 +204,10 @@ def test_get_external_report_bytes(self): reports = sr.get_external_reports(HUMAN_SOURCE.id) er = reports[0] - obs = sr.get_external_report( + obs_reports = sr.get_external_reports( HUMAN_SOURCE.id, er.external_report_id ) + obs = obs_reports[0] act = b'Imagine a full file here' From 7163e5b41e4279fa0a24966312fea393a77ed3c1 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Mon, 23 Oct 2023 12:46:40 -0700 Subject: [PATCH 10/11] Changes based on PR feedback --- microsetta_private_api/api/_source.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsetta_private_api/api/_source.py b/microsetta_private_api/api/_source.py index dbe837cbe..d86d425ec 100644 --- a/microsetta_private_api/api/_source.py +++ b/microsetta_private_api/api/_source.py @@ -202,6 +202,8 @@ def get_external_reports(account_id, source_id, token_info): with Transaction() as t: source_repo = SourceRepo(t) reports = source_repo.get_external_reports(source_id) + for r in reports: + r.file_contents = "" return jsonify(reports), 200 From aefab1ad6b29aef69ff26daab1c27aff55e2a134 Mon Sep 17 00:00:00 2001 From: Cassidy Symons Date: Mon, 23 Oct 2023 15:49:10 -0700 Subject: [PATCH 11/11] Fix enum in yaml file --- microsetta_private_api/api/microsetta_private_api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsetta_private_api/api/microsetta_private_api.yaml b/microsetta_private_api/api/microsetta_private_api.yaml index 5b0e930fa..f0535dc2c 100644 --- a/microsetta_private_api/api/microsetta_private_api.yaml +++ b/microsetta_private_api/api/microsetta_private_api.yaml @@ -3515,7 +3515,7 @@ components: file_contents: type: string report_type: - enum: ["sample", "ffq"] + enum: ["kit", "ffq"] nonhuman_source: type: object properties: