Skip to content

Commit

Permalink
Merge pull request #247 from hms-dbmi/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
b32147 authored Jul 26, 2024
2 parents 3a0c976 + 8b4d1ad commit e389ba9
Show file tree
Hide file tree
Showing 40 changed files with 7,093 additions and 894 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release Build

on:
push:
branches: [ master, development ]
pull_request:
branches: [ master, development ]
workflow_dispatch:
inputs:
force:
type: boolean
default: false

jobs:
test-image:
uses: hms-dbmi/actions/.github/workflows/test-image-build.yml@main
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.BLHMSDBMI_DOCKERHUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.BLHMSDBMI_DOCKERHUB_PASSWORD }}
with:
repository: ${{ github.repository }}
commit: ${{ github.sha }}

scan-image:
uses: hms-dbmi/actions/.github/workflows/scan.yml@main
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.BLHMSDBMI_DOCKERHUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.BLHMSDBMI_DOCKERHUB_PASSWORD }}
with:
repository: ${{ github.repository }}
commit: ${{ github.sha }}

metadata:
runs-on: "ubuntu-latest"
outputs:
branch: ${{ steps.set_branch.outputs.branch }}
force: ${{ steps.force.outputs.force }}
steps:
- name: Set the current branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: set_branch
- name: Manage force input
id: force
env:
FORCE_INPUT: ${{ inputs.force }}
run: echo "force=${FORCE_INPUT:=false}" >> $GITHUB_OUTPUT

deploy:
uses: hms-dbmi/actions/.github/workflows/dbmisvc-app-deploy.yml@main
needs:
- "test-image"
- "metadata"
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: "${{ github.event.repository.name }}-${{ needs.metadata.outputs.branch }}.zip"
app: ${{ github.event.repository.name }}
role: ${{ vars[ format('BLHMSDBMI_PPM_DEPLOYMENT_{0}_ROLE_ARN', needs.metadata.outputs.branch) ] }}
bucket: ${{ vars[ format('BLHMSDBMI_PPM_DEPLOYMENT_{0}_BUCKET', needs.metadata.outputs.branch) ] }}
force: ${{ fromJson(needs.metadata.outputs.force) }}
4 changes: 0 additions & 4 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Scan

on:
push:
branches: [ master, development ]
pull_request:
branches: [ master, development ]
schedule:
- cron: '0 12 * * 1' # runs at 12:00 UTC on Mondays
workflow_dispatch:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Test Image Build

on:
push:
branches: [ master, development ]
pull_request:
branches: [ master, development ]
workflow_dispatch:

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# Node modules
node_modules

# End of https://www.gitignore.io/api/osx,linux,django,python,windows,pycharm,pycharm+iml,pycharm+all
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
minimum_pre_commit_version: "2.13.0"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
Expand All @@ -11,6 +11,10 @@ repos:
- repo: https://github.com/jazzband/pip-tools
rev: 7.4.1
hooks:
- id: pip-compile
name: pip-compile test-requirements.in
args: [test-requirements.in, --upgrade, --generate-hashes, --allow-unsafe, --output-file, test-requirements.txt]
files: ^test-requirements\.(in|txt)$
- id: pip-compile
name: pip-compile dev-requirements.in
args: [dev-requirements.in, --upgrade, --generate-hashes, --allow-unsafe, --output-file, dev-requirements.txt]
Expand Down
29 changes: 29 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"branches": [
"master",
"main",
"+([0-9])?(.{+([0-9]),x}).x",
{"name": "development", "channel": "pre/rc", "prerelease": "rc"},
{"name": "beta", "prerelease": true},
{"name": "alpha", "prerelease": true}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
["@semantic-release/exec", {
"prepareCmd": "sed -ie \"s/^version.*/version = \\x22${nextRelease.version}\\x22/g\" pyproject.toml"
}],
["@semantic-release/git", {
"assets": ["pyproject.toml", "CHANGELOG.md"]
}],
["@semantic-release/github", {
"successComment": false,
"failComment": false,
"failTitle": false
}]
],
"preset": "angular"
}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 1.0.0-rc.1 (2024-07-25)


### Bug Fixes

* **ci:** Refactored deployment; added versioning; passes app version to Sentry initialization ([76f3c2e](https://github.com/hms-dbmi/fhirquestionnaire/commit/76f3c2ed11d28f02abf10547710c7165bb5aebc3))
* **dockerfile:** Fixed incorrect phantomjs library being used ([ea4414a](https://github.com/hms-dbmi/fhirquestionnaire/commit/ea4414a613f4265209029853c1b21d44edf9092b))
* **requirements:** Updated Python requirements ([f3b1ab4](https://github.com/hms-dbmi/fhirquestionnaire/commit/f3b1ab48bdfccd5885ea60d43a3a1b83c66bba52))
* **requirements:** Updated Python requirements ([a02bbd5](https://github.com/hms-dbmi/fhirquestionnaire/commit/a02bbd53a4423fd7de71f9d992cf545740f5928c))
* **requirements:** Updated Python requirements ([11cca88](https://github.com/hms-dbmi/fhirquestionnaire/commit/11cca88467a621a7e85dd8f2ff1455cfef461e5b))
* **requirements:** Updated Python requirements ([ef1a121](https://github.com/hms-dbmi/fhirquestionnaire/commit/ef1a121db605d937b8139826d88f972cefeaf087))
* **requirements:** Updated Python requirements ([3713378](https://github.com/hms-dbmi/fhirquestionnaire/commit/37133781b68e6688cb20e74d8ef6e4437bed7467))
* **requirements:** Updated Python requirements ([638cc84](https://github.com/hms-dbmi/fhirquestionnaire/commit/638cc84be3b3ce04e1ad6beaefaa344fff3e6746))
* **requirements:** Updated Python requirements ([3154ba8](https://github.com/hms-dbmi/fhirquestionnaire/commit/3154ba8c7932d5787578d1c7d10090ea3ecc6552))
* **requirements:** Updated Python requirements ([6a7e453](https://github.com/hms-dbmi/fhirquestionnaire/commit/6a7e45327346c36359d9787c30b5911e478b783f))
* **requirements:** Updated Python requirements ([9351a10](https://github.com/hms-dbmi/fhirquestionnaire/commit/9351a10cac12580dd1d6c55593e4e5ed6cdec2b3))
* **requirements:** Updated Python requirements ([b391c77](https://github.com/hms-dbmi/fhirquestionnaire/commit/b391c77ea9cadd67a99f0e6cd29a0eceab8d86ec))
* **requirements:** Updated Python requirements ([68281b6](https://github.com/hms-dbmi/fhirquestionnaire/commit/68281b689de4d2b70141e924905f3b07c9bf6008))
* **requirements:** Updated Python requirements ([7d4e6d9](https://github.com/hms-dbmi/fhirquestionnaire/commit/7d4e6d9fd1f7355c627b7364a98c4de17c476792))
24 changes: 22 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -22,7 +22,23 @@ 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

ARG APP_NAME="ppm-questionnaire"
ARG APP_CODENAME="fhirquestionnaire"
ARG VERSION
ARG COMMIT
ARG DATE

LABEL org.label-schema.schema-version=1.0 \
org.label-schema.vendor="HMS-DBMI" \
org.label-schema.version=${VERSION} \
org.label-schema.name=${APP_NAME} \
org.label-schema.build-date=${DATE} \
org.label-schema.description="PPM questionnaire service" \
org.label-schema.url="https://github.com/hms-dbmi/fhirquestionnaire" \
org.label-schema.vcs-url="https://github.com/hms-dbmi/fhirquestionnaire" \
org.label-schema.vcf-ref=${COMMIT}

# Copy PhantomJS binary
COPY --from=builder /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
Expand Down Expand Up @@ -62,6 +78,10 @@ ENV DBMI_PARAMETER_STORE_PREFIX=ppm.questionnaire.${DBMI_ENV}
ENV DBMI_PARAMETER_STORE_PRIORITY=true
ENV DBMI_AWS_REGION=us-east-1

ENV DBMI_APP_NAME=${APP_NAME}
ENV DBMI_APP_CODENAME=${APP_CODENAME}
ENV DBMI_APP_VERSION=${VERSION}
ENV DBMI_APP_COMMIT=${COMMIT}
ENV DBMI_APP_WSGI=fhirquestionnaire
ENV DBMI_APP_ROOT=/app
ENV DBMI_APP_DOMAIN=p2m2.dbmi.hms.harvard.edu
Expand Down
2 changes: 1 addition & 1 deletion app/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
re_path(r'^consent/(?P<study>[\w\d-]+)/(?P<ppm_id>[\d]+)/?$', views.ConsentView.as_view(), name='consent'),
re_path(r'^consent/(?P<study>[\w\d-]+)/(?P<ppm_id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[\d]+)/?$', views.ConsentView.as_view(), name='consent'),
re_path(r'^consent/(?P<study>[\w\d-]+)/?$', views.ConsentsView.as_view(), name='consents'),
re_path(r'^questionnaire/?$', views.QuestionnaireView.as_view(), name='questionnaire'),
re_path(r'^questionnaire/(?P<questionnaire_id>[\w\d-]+)/?$', views.QuestionnaireView.as_view(), name='questionnaire'),
Expand Down
28 changes: 9 additions & 19 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get(self, request, study, ppm_id, format=None):

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

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

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

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

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

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

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

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

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

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

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

# Return it or 404
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/example-signature.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-example"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-example",
"display": "ppm-example"
}
],
"text": "ppm-example"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
27 changes: 27 additions & 0 deletions app/consent/fhir/guardian-signature-part-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
"subjectType": [
"patient"
],
"useContext": [
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "program",
"display": "Program"
},
"valueReference": {"reference": "ResearchStudy/ppm-asd"}
},
{
"code": {
"system": "http://terminology.hl7.org/CodeSystem/usage-context-type",
"code": "task",
"display": "Workflow Task"
},
"valueCodeableConcept": {
"coding": [
{
"system": "https://peoplepoweredmedicine.org/fhir/questionnaire/context",
"code": "ppm-asd",
"display": "ppm-asd"
}
],
"text": "ppm-asd"
}
}
],
"item": [
{
"linkId": "display-1",
Expand Down
Loading

0 comments on commit e389ba9

Please sign in to comment.