From a100a1f338c2dbd3614aca897a0fac2d70076ddb Mon Sep 17 00:00:00 2001 From: Bryan Larson Date: Mon, 15 Jul 2024 16:19:26 -0600 Subject: [PATCH] PPM-766 - Updated to new Sentry via dbmi-client; updated base image; fixed missing study reference on new Composition resources --- Dockerfile | 4 +- app/fhirquestionnaire/fhir.py | 9 ++++ app/fhirquestionnaire/settings.py | 22 +++++---- requirements.in | 3 +- requirements.txt | 77 ++++++++++++++++--------------- 5 files changed, 65 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index b41ccc9..767effd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM hmsdbmitc/dbmisvc:debian12-slim-python3.11-0.6.1 AS builder +FROM hmsdbmitc/dbmisvc:debian12-slim-python3.11-0.6.2 AS builder # Install requirements RUN apt-get update \ @@ -22,7 +22,7 @@ RUN pip install -U wheel \ && pip wheel -r /requirements.txt \ --wheel-dir=/root/wheels -FROM hmsdbmitc/dbmisvc:debian12-slim-python3.11-0.6.1 +FROM hmsdbmitc/dbmisvc:debian12-slim-python3.11-0.6.2 # Copy PhantomJS binary COPY --from=builder /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs diff --git a/app/fhirquestionnaire/fhir.py b/app/fhirquestionnaire/fhir.py index 102d55f..792579b 100644 --- a/app/fhirquestionnaire/fhir.py +++ b/app/fhirquestionnaire/fhir.py @@ -87,6 +87,9 @@ def submit_consent(study, patient_email, form, pdf=None, dry=False): # Generate composition composition = PPMFHIR.Resources.composition(patient, timestamp, text, [consent, contract]) + # Add the study reference + composition.setdefault("section", []).append({"entry": [{"reference": f"ResearchStudy/{PPM.Study.fhir_id(study)}"}]}) + # Add it to the resources resources.append(composition) @@ -212,6 +215,9 @@ def submit_asd_individual(patient_email, forms, dry=False): # Generate composition composition = PPMFHIR.Resources.composition(patient, timestamp, text, [consent, contract]) + # Add the study reference + composition.setdefault("section", []).append({"entry": [{"reference": f"ResearchStudy/{PPM.Study.fhir_id(PPM.Study.ASD)}"}]}) + # Bundle it into a transaction bundle = PPMFHIR.Resources.bundle([questionnaire_response, consent, contract, composition, quiz_questionnaire_response]) @@ -337,6 +343,9 @@ def submit_asd_guardian(patient_email, forms, dry=False): # Generate composition composition = PPMFHIR.Resources.composition(patient, timestamp, text, [consent, signature_contract, explained_contract]) + # Add the study reference + composition.setdefault("section", []).append({"entry": [{"reference": f"ResearchStudy/{PPM.Study.fhir_id(PPM.Study.ASD)}"}]}) + # Map exception codes to linkId ward_exception_codes = { 'question-1': '225098009', diff --git a/app/fhirquestionnaire/settings.py b/app/fhirquestionnaire/settings.py index efc7d1f..a0f0ff0 100644 --- a/app/fhirquestionnaire/settings.py +++ b/app/fhirquestionnaire/settings.py @@ -16,7 +16,8 @@ from django.contrib.messages import constants as message_constants from dbmi_client import logging as dbmi_logging -from dbmi_client.environment import get_bool, get_str, get_int, get_list, get_dict +from dbmi_client.environment import get_bool, get_str, get_int, get_list, get_dict, get_float +from dbmi_client import reporting # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -50,7 +51,6 @@ 'bootstrap3', 'crispy_forms', 'health_check', - 'raven.contrib.django.raven_compat', 'dbmi_client', 'api', 'pdf', @@ -217,12 +217,16 @@ CONTACT_FORM_RECIPIENTS = get_str('CONTACT_FORM_RECIPIENTS', required=True) DEFAULT_FROM_EMAIL = get_str('EMAIL_FROM_ADDRESS', required=True) -# Check for sentry -RAVEN_URL = get_str("RAVEN_URL", required=True) -if RAVEN_URL: - RAVEN_CONFIG = { - 'dsn': RAVEN_URL, - } +##################################################################################### +# Logging Configurations +##################################################################################### + +# Configure Sentry +reporting.sentry( + sentry_dsn=get_str("SENTRY_DSN", required=True), + sentry_trace_rate=get_float("SENTRY_TRACES_RATE", default=0.0), + sentry_profile_rate=get_float("SENTRY_PROFILES_RATE", default=0.0), +) # Output the standard logging configuration -LOGGING = dbmi_logging.config('QUESTIONNAIRE', sentry=True, root_level=logging.DEBUG) +LOGGING = dbmi_logging.config('QUESTIONNAIRE', root_level=logging.DEBUG) diff --git a/requirements.in b/requirements.in index 9c04bd3..45df2ad 100644 --- a/requirements.in +++ b/requirements.in @@ -2,10 +2,9 @@ Django<5.0 django-bootstrap3<23.0 https://github.com/b32147/django-bootstrap-datepicker-plus/releases/download/4.0.0/django_bootstrap_datepicker_plus-4.0.0-py3-none-any.whl django-crispy-forms<2.0 -django-dbmi-client<2.0 +django-dbmi-client<3.0 django-health-check<4.0 django-ses<4.0 djangorestframework<4.0 ppm-utils<3 -raven<7.0 requests<3.0 diff --git a/requirements.txt b/requirements.txt index 16e65d4..2ffa65b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.12 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --allow-unsafe --generate-hashes --output-file=requirements.txt requirements.in @@ -8,26 +8,28 @@ asgiref==3.8.1 \ --hash=sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47 \ --hash=sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590 # via django -boto3==1.34.136 \ - --hash=sha256:0314e6598f59ee0f34eb4e6d1a0f69fa65c146d2b88a6e837a527a9956ec2731 \ - --hash=sha256:d41037e2c680ab8d6c61a0a4ee6bf1fdd9e857f43996672830a95d62d6f6fa79 +boto3==1.34.144 \ + --hash=sha256:2f3e88b10b8fcc5f6100a9d74cd28230edc9d4fa226d99dd40a3ab38ac213673 \ + --hash=sha256:b8433d481d50b68a0162c0379c0dd4aabfc3d1ad901800beb5b87815997511c1 # via # django-ses # ppm-utils -botocore==1.34.136 \ - --hash=sha256:7f7135178692b39143c8f152a618d2a3b71065a317569a7102d2306d4946f42f \ - --hash=sha256:c63fe9032091fb9e9477706a3ebfa4d0c109b807907051d892ed574f9b573e61 +botocore==1.34.144 \ + --hash=sha256:4215db28d25309d59c99507f1f77df9089e5bebbad35f6e19c7c44ec5383a3e8 \ + --hash=sha256:a2cf26e1bf10d5917a2285e50257bc44e94a1d16574f282f3274f7a5d8d1f08b # via # boto3 # s3transfer -cachetools==5.3.3 \ - --hash=sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945 \ - --hash=sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105 +cachetools==5.4.0 \ + --hash=sha256:3ae3b49a3d5e28a77a0be2b37dbcb89005058959cb2323858c2657c4a8cab474 \ + --hash=sha256:b8adc2e7c07f105ced7bc56dbb6dfbe7c4a00acce20e2227b3f355be89bc6827 # via google-auth -certifi==2024.6.2 \ - --hash=sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516 \ - --hash=sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56 - # via requests +certifi==2024.7.4 \ + --hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \ + --hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90 + # via + # requests + # sentry-sdk cffi==1.16.0 \ --hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \ --hash=sha256:131fd094d1065b19540c3d72594260f118b231090295d8c34e19a7bbcf2e860a \ @@ -208,9 +210,9 @@ cryptography==42.0.8 \ --hash=sha256:fa76fbb7596cc5839320000cdd5d0955313696d9511debab7ee7278fc8b5c84a \ --hash=sha256:fff12c88a672ab9c9c1cf7b0c80e3ad9e2ebd9d828d955c126be4fd3e5578c9e # via django-dbmi-client -django==4.2.13 \ - --hash=sha256:837e3cf1f6c31347a1396a3f6b65688f2b4bb4a11c580dcb628b5afe527b68a5 \ - --hash=sha256:a17fcba2aad3fc7d46fdb23215095dbbd64e6174bf4589171e732b18b07e426a +django==4.2.14 \ + --hash=sha256:3ec32bc2c616ab02834b9cac93143a7dc1cdcd5b822d78ac95fc20a38c534240 \ + --hash=sha256:fc6919875a6226c7ffcae1a7d51e0f2ceaf6f160393180818f6c95f51b1e7b96 # via # -r requirements.in # django-bootstrap-datepicker-plus @@ -220,6 +222,7 @@ django==4.2.13 \ # django-ses # djangorestframework # ppm-utils + # sentry-sdk django-bootstrap-datepicker-plus @ https://github.com/b32147/django-bootstrap-datepicker-plus/releases/download/4.0.0/django_bootstrap_datepicker_plus-4.0.0-py3-none-any.whl \ --hash=sha256:1006f68c0c7bad2ee59da759633377975b38e80fc621a9e5c71ed6b1bd601ba9 # via -r requirements.in @@ -233,8 +236,9 @@ django-crispy-forms==1.14.0 \ --hash=sha256:35887b8851a931374dd697207a8f56c57a9c5cb9dbf0b9fa54314da5666cea5b \ --hash=sha256:bc4d2037f6de602d39c0bc452ac3029d1f5d65e88458872cc4dbc01c3a400604 # via -r requirements.in -django-dbmi-client==1.0.8 \ - --hash=sha256:34d71b69387b33afd2ae238b441dcc158e02f5c3bab43632002b789f8deb8030 +django-dbmi-client==2.0.0 \ + --hash=sha256:827cf061d83a202e53851530446d85737900a6199999cf72d5bd79f2799486a4 \ + --hash=sha256:cffb7054266e8c0b347814e194a3071bd0f696e43abe74a34d4bb0b8bcbc9c77 # via -r requirements.in django-health-check==3.18.3 \ --hash=sha256:18b75daca4551c69a43f804f9e41e23f5f5fb9efd06cf6a313b3d5031bb87bd0 \ @@ -264,13 +268,13 @@ google-api-core==2.19.1 \ --hash=sha256:f12a9b8309b5e21d92483bbd47ce2c445861ec7d269ef6784ecc0ea8c1fa6125 \ --hash=sha256:f4695f1e3650b316a795108a76a1c416e6afb036199d1c1f1f110916df479ffd # via google-api-python-client -google-api-python-client==2.135.0 \ - --hash=sha256:91742fa4c779d48456c0256ef346fa1cc185ba427176d3277e35141fa3268026 \ - --hash=sha256:b552a28123ed95493035698db80e8ed78c9106a8b422e63a175150b9b55b704e +google-api-python-client==2.137.0 \ + --hash=sha256:a8b5c5724885e5be9f5368739aa0ccf416627da4ebd914b410a090c18f84d692 \ + --hash=sha256:e739cb74aac8258b1886cb853b0722d47c81fe07ad649d7f2206f06530513c04 # via ppm-utils -google-auth==2.30.0 \ - --hash=sha256:8df7da660f62757388b8a7f249df13549b3373f24388cb5d2f1dd91cc18180b5 \ - --hash=sha256:ab630a1320f6720909ad76a7dbdb6841cdf5c66b328d690027e4867bdfb16688 +google-auth==2.32.0 \ + --hash=sha256:49315be72c55a6a37d62819e3573f6b416aca00721f7e3e31a008d928bf64022 \ + --hash=sha256:53326ea2ebec768070a94bee4e1b9194c9646ea0c2bd72422785bd0f9abfad7b # via # google-api-core # google-api-python-client @@ -307,9 +311,9 @@ orderedmultidict==1.0.1 \ --hash=sha256:04070bbb5e87291cc9bfa51df413677faf2141c73c61d2a5f7b26bea3cd882ad \ --hash=sha256:43c839a17ee3cdd62234c47deca1a8508a3f2ca1d0678a3bf791c87cf84adbf3 # via furl -ppm-utils==2.0.1 \ - --hash=sha256:e5772b7a2a99600c3291afa3e6dfc883953956bc0f1a10111a1cc77111c4cc82 \ - --hash=sha256:fa011cd8c8b6cc031d6456791c8162d40bb8790c25d8f448cceaf31281f43420 +ppm-utils==2.0.4 \ + --hash=sha256:8c20e7edf44cd107425a5f7d5281e63408013eac1e69e6f2ce307895c0752b53 \ + --hash=sha256:92755026bd29224025a2c9ad04552a482420891aba86fe81ade3680463994b7f # via -r requirements.in proto-plus==1.24.0 \ --hash=sha256:30b72a5ecafe4406b0d339db35b56c4059064e69227b8c3bda7462397f966445 \ @@ -365,12 +369,6 @@ pytz==2024.1 \ # via # django-dbmi-client # django-ses -raven==6.10.0 \ - --hash=sha256:3fa6de6efa2493a7c827472e984ce9b020797d0da16f1db67197bcc23c8fae54 \ - --hash=sha256:44a13f87670836e153951af9a3c80405d36b43097db869a36e92809673692ce4 - # via - # -r requirements.in - # django-dbmi-client requests==2.32.3 \ --hash=sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760 \ --hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6 @@ -393,6 +391,10 @@ s3transfer==0.10.2 \ --hash=sha256:0711534e9356d3cc692fdde846b4a1e4b0cb6519971860796e6bc4c7aea00ef6 \ --hash=sha256:eca1c20de70a39daee580aef4986996620f365c4e0fda6a86100231d62f1bf69 # via boto3 +sentry-sdk[django]==2.10.0 \ + --hash=sha256:545fcc6e36c335faa6d6cda84669b6e17025f31efbf3b2211ec14efe008b75d1 \ + --hash=sha256:87b3d413c87d8e7f816cc9334bff255a83d8b577db2b22042651c30c19c09190 + # via django-dbmi-client six==1.16.0 \ --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 @@ -401,9 +403,9 @@ six==1.16.0 \ # isodate # orderedmultidict # python-dateutil -sqlparse==0.5.0 \ - --hash=sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93 \ - --hash=sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663 +sqlparse==0.5.1 \ + --hash=sha256:773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4 \ + --hash=sha256:bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e # via django typing-extensions==4.12.2 \ --hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \ @@ -419,3 +421,4 @@ urllib3==2.2.2 \ # via # botocore # requests + # sentry-sdk