Skip to content

Commit

Permalink
Merge branch 'develop' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
jainvedant392 authored Mar 23, 2024
2 parents 8754922 + 5e750a4 commit b4f73cd
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 339 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Docs
on:
push:
branches:
- master
- develop
paths:
- "docs/**"
pull_request:
branches:
- master
- develop
paths:
- "docs/**"
workflow_dispatch:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
retention-days: 30

deploy-docs:
if: github.repository == 'coronasafe/care' && github.ref == 'refs/heads/master'
if: github.repository == 'coronasafe/care' && github.ref == 'refs/heads/develop'
name: Deploy docs
runs-on: ubuntu-latest
needs: build-docs
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Lint Code Base

on:
pull_request:
branches: [master]
branches:
- develop
- staging
merge_group:

jobs:
Expand All @@ -24,7 +26,7 @@ jobs:
- name: Lint Code Base
uses: github/super-linter/slim@v5
env:
DEFAULT_BRANCH: master
DEFAULT_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_BLACK: true
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args: [--branch, master, --branch, production]
args: [--branch, develop, --branch, staging, --branch, production]
- id: check-merge-conflict
- id: check-builtin-literals
- id: mixed-line-ending
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"githubPullRequests.ignoredPullRequestBranches": ["master"],
"githubPullRequests.ignoredPullRequestBranches": ["develop", "staging"],
"python.formatting.blackPath": "${workspaceFolder}/.venv/bin/black",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pre-commit install

to run pre-commit on your branch:
```bash
pre-commit run --files $(git diff --name-only master...HEAD)
pre-commit run --files $(git diff --name-only develop...HEAD)
```

#### Using Docker
Expand Down
12 changes: 6 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
argon2-cffi = "==23.1.0"
authlib = "==1.2.1"
boto3 = "==1.34.64"
boto3 = "==1.34.65"
celery = "==5.3.6"
django = "==4.2.10"
django-environ = "==0.11.2"
Expand All @@ -23,7 +23,7 @@ django-rest-passwordreset = "==1.3.0"
django-simple-history = "==3.3.0"
djangoql = "==0.17.1"
djangorestframework = "==3.14.0"
djangorestframework-simplejwt = "==5.3.0"
djangorestframework-simplejwt = "==5.3.1"
dry-rest-permissions = "==0.1.10"
drf-nested-routers = "==0.93.4"
drf-spectacular = "==0.26.4"
Expand All @@ -34,7 +34,7 @@ jsonschema = "==4.20.0"
jwcrypto = "==1.5.6"
newrelic = "==9.3.0"
pillow = "==10.2.0"
psycopg = "==3.1.14"
psycopg = "==3.1.18"
pycryptodome = "==3.20.0"
pydantic = "==1.10.12" # fix for fhir.resources < 7.0.2
pyjwt = "==2.8.0"
Expand All @@ -48,17 +48,17 @@ redis-om = "==0.2.1"

[dev-packages]
black = "==23.9.1"
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.34.64"}
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.34.65"}
coverage = "==7.4.0"
debugpy = "==1.7.0"
debugpy = "==1.8.1"
django-coverage-plugin = "==3.1.0"
django-debug-toolbar = "==4.2.0"
django-extensions = "==3.2.3"
django-silk = "==5.0.3"
django-stubs = "==4.2.4"
djangorestframework-stubs = "==3.14.2"
factory-boy = "==3.3.0"
flake8 = "==6.1.0"
flake8 = "==7.0.0"
freezegun = "==1.2.2"
ipython = "==8.15.0"
isort = "==5.12.0"
Expand Down
546 changes: 227 additions & 319 deletions Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ You can find the docs at https://care-be-docs.coronasafe.network

### Staging Deployments

Staging instances for testing are automatically deployed on every commit to the `master` branch. The staging instances
are available at:
Dev and staging instances for testing are automatically deployed on every commit to the `develop` and `staging` branches.
The staging instances are available at:

- https://careapi.ohc.network
- https://careapi-staging.ohc.network

### Self hosting

Expand Down
8 changes: 8 additions & 0 deletions care/facility/api/viewsets/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ def get_serializer_class(self):
else:
return self.serializer_class

def filter_queryset(self, queryset: QuerySet) -> QuerySet:
if self.action == "list" and settings.CSV_REQUEST_PARAMETER in self.request.GET:
for backend in (PatientDRYFilter, filters.DjangoFilterBackend):
queryset = backend().filter_queryset(self.request, queryset, self)
return queryset.filter(last_consultation__discharge_date__isnull=True)

return super().filter_queryset(queryset)

def list(self, request, *args, **kwargs):
"""
Patient List
Expand Down
14 changes: 14 additions & 0 deletions care/facility/migrations/0421_merge_20240318_1434.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 4.2.10 on 2024-03-18 09:04

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("facility", "0415_alter_dailyround_consciousness_level_and_more"),
("facility", "0415_consultationclinician_and_more"),
("facility", "0415_rename_dosage_prescription_base_dosage_and_more"),
("facility", "0420_migrate_shifting_facility_type"),
]

operations = []
6 changes: 4 additions & 2 deletions care/facility/models/file_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class FileCategory(enum.Enum):
FileTypeChoices = [(e.value, e.name) for e in FileType]
FileCategoryChoices = [(e.value, e.name) for e in FileCategory]

name = models.CharField(max_length=2000)
internal_name = models.CharField(max_length=2000)
name = models.CharField(max_length=2000) # name should not contain file extension
internal_name = models.CharField(
max_length=2000
) # internal_name should include file extension
associating_id = models.CharField(max_length=100, blank=False, null=False)
upload_completed = models.BooleanField(default=False)
is_archived = models.BooleanField(default=False)
Expand Down
28 changes: 28 additions & 0 deletions care/facility/tests/test_patient_consultation_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import datetime
from unittest.mock import patch

from django.utils.timezone import make_aware
from rest_framework import status
from rest_framework.test import APITestCase

from care.facility.api.serializers.patient_consultation import MIN_ENCOUNTER_DATE
from care.facility.models.file_upload import FileUpload
from care.facility.models.icd11_diagnosis import (
ConditionVerificationStatus,
ICD11Diagnosis,
Expand Down Expand Up @@ -224,6 +226,32 @@ def test_discharge_as_recovered_with_expired_fields(self):
self.assertIsNone(consultation.death_datetime)
self.assertIsNot(consultation.death_confirmed_doctor, "Dr. Test")

def discharge_summary(self, consultation, **kwargs):
return self.client.post(
f"{self.get_url(consultation)}generate_discharge_summary/", kwargs, "json"
)

def test_discharge_summary(self):
consultation = self.create_admission_consultation(
suggestion=SuggestionChoices.A,
encounter_date=make_aware(datetime.datetime(2020, 4, 1, 15, 30, 00)),
)
with patch.object(FileUpload, "put_object"):
self.discharge_summary(
consultation,
new_discharge_reason=NewDischargeReasonEnum.RECOVERED,
discharge_date="2020-04-02T15:30:00Z",
discharge_notes="Discharge as recovered after admission before future",
)

file_res = FileUpload.objects.filter(
associating_id=consultation.external_id,
upload_completed=True,
is_archived=False,
)
uploaded_file = file_res[0]
self.assertFalse(uploaded_file.name.endswith(".pdf"))

def test_referred_to_external_null(self):
consultation = self.create_admission_consultation(
suggestion=SuggestionChoices.A,
Expand Down
2 changes: 1 addition & 1 deletion care/facility/utils/reports/discharge_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def generate_and_upload_discharge_summary(consultation: PatientConsultation):
try:
current_date = timezone.now()
summary_file = FileUpload(
name=f"discharge_summary-{consultation.patient.name}-{current_date}.pdf",
name=f"discharge_summary-{consultation.patient.name}-{current_date}",
internal_name=f"{uuid4()}.pdf",
file_type=FileUpload.FileType.DISCHARGE_SUMMARY.value,
associating_id=consultation.external_id,
Expand Down
70 changes: 70 additions & 0 deletions data/dummy/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -768,5 +768,75 @@
"groups": [],
"user_permissions": []
}
},
{
"model": "users.user",
"pk": 23,
"fields": {
"password": "argon2$argon2id$v=19$m=102400,t=2,p=8$WDE0YXVzR1dIV09zNWJZalF4QzdXSw$ZTpeDj5sbB3TKfu0DEJ5EkQnL3EmM2vGgvdx+Qt2sAw",
"last_login": "2024-03-18 17:04:08.753272+00",
"is_superuser": false,
"first_name": "Dummy",
"last_name": "Nurse",
"email": "dummynurse1@test.com",
"is_staff": false,
"is_active": true,
"date_joined": "2024-03-08 06:31:23.199154+00",
"username": "dummynurse1",
"user_type": 14,
"created_by": 1,
"ward": null,
"local_body": null,
"district": 7,
"state": 1,
"phone_number": "+918878825662",
"alt_phone_number": "+918878825662",
"gender": 2,
"age": 21,
"home_facility": 1,
"verified": true,
"deleted": false,
"pf_endpoint": null,
"pf_p256dh": null,
"pf_auth": null,
"asset": null,
"groups": [],
"user_permissions": []
}
},
{
"model": "users.user",
"pk": 24,
"fields": {
"password": "argon2$argon2id$v=19$m=102400,t=2,p=8$WlVSNkdVTEd4Vkgzako3SHUxT0xJag$b5A8WE7JdwlysGuiJPwoQneBQHtzjWTs3Br0VnX3XRc",
"last_login": "2024-03-12 16:34:18.859463+00",
"is_superuser": false,
"first_name": "Dummy",
"last_name": "Nurse",
"email": "dummynurse2@test.com",
"is_staff": false,
"is_active": true,
"date_joined": "2024-03-08 06:32:12.270135+00",
"username": "dummynurse2",
"user_type": 14,
"created_by": 1,
"ward": null,
"local_body": null,
"district": 7,
"state": 1,
"phone_number": "+918744587566",
"alt_phone_number": "+918744587566",
"gender": 1,
"age": 35,
"home_facility": 1,
"verified": true,
"deleted": false,
"pf_endpoint": null,
"pf_p256dh": null,
"pf_auth": null,
"asset": null,
"groups": [],
"user_permissions": []
}
}
]
4 changes: 3 additions & 1 deletion docs/github-repo/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ GitHub Repository

The Github Repo available here_ contains the source code for the care project, Apart from the secrets configured at runtime, the exact copy is deployed in production.

The :code:`master` branch auto deploys to the Development instance and is regarded as the Beta version of the application.
The :code:`develop` branch auto deploys to the Development instance and is regarded as the Beta version of the application.

The :code:`staging` branch auto deploys to the Staging instance and is regarded as the Release Candidate version of the application.

The :code:`production` branch auto deploys to Production instance and is regarded as the Stable version of the application.

Expand Down

0 comments on commit b4f73cd

Please sign in to comment.