Skip to content

Commit

Permalink
Merge branch 'master' into refactor-icd11-table
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Oct 5, 2023
2 parents 9c8cffc + 0a4a4c4 commit 2d3a894
Show file tree
Hide file tree
Showing 18 changed files with 573 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment-lambda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
touch build/.nojekyll
- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4.3.3
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: build
22 changes: 17 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
MIT License

The MIT License (MIT)
Copyright (c) 2020, 👪
Copyright (c) 2023 Open Healthcare Network

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions aws/backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@
{
"valueFrom": "/care/backend/ABDM_CLIENT_SECRET",
"name": "ABDM_CLIENT_SECRET"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_HOST",
"name": "PLAUSIBLE_HOST"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_SITE_ID",
"name": "PLAUSIBLE_SITE_ID"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_AUTH_TOKEN",
"name": "PLAUSIBLE_AUTH_TOKEN"
}
],
"name": "care-backend"
Expand Down
24 changes: 24 additions & 0 deletions aws/celery.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@
"valueFrom": "/care/backend/HCX_IG_URL",
"name": "HCX_IG_URL"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_HOST",
"name": "PLAUSIBLE_HOST"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_SITE_ID",
"name": "PLAUSIBLE_SITE_ID"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_AUTH_TOKEN",
"name": "PLAUSIBLE_AUTH_TOKEN"
},
{
"valueFrom": "/care/backend/ABDM_CLIENT_ID",
"name": "ABDM_CLIENT_ID"
Expand Down Expand Up @@ -505,6 +517,18 @@
"valueFrom": "/care/backend/HCX_IG_URL",
"name": "HCX_IG_URL"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_HOST",
"name": "PLAUSIBLE_HOST"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_SITE_ID",
"name": "PLAUSIBLE_SITE_ID"
},
{
"valueFrom": "/care/backend/PLAUSIBLE_AUTH_TOKEN",
"name": "PLAUSIBLE_AUTH_TOKEN"
},
{
"valueFrom": "/care/backend/ABDM_CLIENT_ID",
"name": "ABDM_CLIENT_ID"
Expand Down
4 changes: 2 additions & 2 deletions care/facility/api/serializers/prescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class PrescriptionSerializer(serializers.ModelSerializer):
def get_last_administered_on(self, obj):
last_administration = (
MedicineAdministration.objects.filter(prescription=obj)
.order_by("-created_date")
.order_by("-administered_date")
.first()
)
if last_administration:
return last_administration.created_date
return last_administration.administered_date
return None

class Meta:
Expand Down
42 changes: 42 additions & 0 deletions care/facility/api/viewsets/asset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import uuid

from django.conf import settings
from django.core.cache import cache
from django.db.models import Exists, OuterRef, Q
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.http import Http404
from django.shortcuts import get_object_or_404
from django.utils import timezone
Expand Down Expand Up @@ -58,6 +62,13 @@
inverse_asset_status = inverse_choices(StatusChoices)


@receiver(post_save, sender=Asset)
def delete_asset_cache(sender, instance, created, **kwargs):
cache.delete("asset:" + str(instance.external_id))
cache.delete("asset:qr:" + str(instance.qr_code_id))
cache.delete("asset:qr:" + str(instance.id))


class AssetLocationViewSet(
ListModelMixin,
RetrieveModelMixin,
Expand Down Expand Up @@ -122,6 +133,7 @@ class AssetFilter(filters.FilterSet):
method="filter_in_use_by_consultation"
)
is_permanent = filters.BooleanFilter(method="filter_is_permanent")
warranty_amc_end_of_validity = filters.DateFromToRangeFilter()

def filter_in_use_by_consultation(self, queryset, _, value):
if value not in EMPTY_VALUES:
Expand Down Expand Up @@ -174,6 +186,36 @@ def retrieve(self, request, *args, **kwargs):
return Response(hit)


class AssetPublicQRViewSet(GenericViewSet):
queryset = Asset.objects.all()
serializer_class = AssetSerializer
lookup_field = "qr_code_id"

def retrieve(self, request, *args, **kwargs):
is_uuid = True
try:
uuid.UUID(kwargs["qr_code_id"])
except ValueError:
# If the qr_code_id is not a UUID, then it is the pk of the asset
is_uuid = False
if not kwargs["qr_code_id"].isnumeric():
return Response(status=status.HTTP_404_NOT_FOUND)

key = "asset:qr:" + kwargs["qr_code_id"]
hit = cache.get(key)
if not hit:
if is_uuid:
instance = self.get_object()
else:
instance = get_object_or_404(
self.get_queryset(), pk=kwargs["qr_code_id"]
)
serializer = self.get_serializer(instance)
cache.set(key, serializer.data, 60 * 60 * 24)
return Response(serializer.data)
return Response(hit)


class AssetAvailabilityFilter(filters.FilterSet):
external_id = filters.CharFilter(field_name="asset__external_id")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Generated by Django 4.2.2 on 2023-09-06 08:36

import uuid

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("facility", "0387_merge_20230911_2303"),
]

operations = [
migrations.CreateModel(
name="Goal",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"external_id",
models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
),
(
"created_date",
models.DateTimeField(auto_now_add=True, db_index=True, null=True),
),
(
"modified_date",
models.DateTimeField(auto_now=True, db_index=True, null=True),
),
("deleted", models.BooleanField(db_index=True, default=False)),
("name", models.CharField(max_length=200)),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="GoalEntry",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"external_id",
models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
),
(
"created_date",
models.DateTimeField(auto_now_add=True, db_index=True, null=True),
),
(
"modified_date",
models.DateTimeField(auto_now=True, db_index=True, null=True),
),
("deleted", models.BooleanField(db_index=True, default=False)),
("date", models.DateField()),
("visitors", models.IntegerField(null=True)),
("events", models.IntegerField(null=True)),
(
"goal",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="entries",
to="facility.goal",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="GoalProperty",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"external_id",
models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
),
(
"created_date",
models.DateTimeField(auto_now_add=True, db_index=True, null=True),
),
(
"modified_date",
models.DateTimeField(auto_now=True, db_index=True, null=True),
),
("deleted", models.BooleanField(db_index=True, default=False)),
("name", models.CharField(max_length=200)),
(
"goal",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="properties",
to="facility.goal",
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="GoalPropertyEntry",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"external_id",
models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
),
(
"created_date",
models.DateTimeField(auto_now_add=True, db_index=True, null=True),
),
(
"modified_date",
models.DateTimeField(auto_now=True, db_index=True, null=True),
),
("deleted", models.BooleanField(db_index=True, default=False)),
("value", models.CharField(max_length=200)),
("visitors", models.IntegerField(null=True)),
("events", models.IntegerField(null=True)),
(
"goal_entry",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="properties",
to="facility.goalentry",
),
),
(
"goal_property",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="entries",
to="facility.goalproperty",
),
),
],
options={
"abstract": False,
},
),
]
Loading

0 comments on commit 2d3a894

Please sign in to comment.