Skip to content

Commit

Permalink
Merge pull request #1648 from coronasafe/master
Browse files Browse the repository at this point in the history
Production Release; Oct Week 1
  • Loading branch information
mathew-alex authored Oct 1, 2023
2 parents 428e122 + 2829067 commit 6b6e0fc
Show file tree
Hide file tree
Showing 17 changed files with 580 additions and 15 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.
16 changes: 16 additions & 0 deletions aws/backend.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
{
"name": "SENTRY_PROFILES_SAMPLE_RATE",
"value": "1.0"
},
{
"name": "SENTRY_ENVIRONMENT",
"value": "staging"
}
],
"repositoryCredentials": {
Expand Down Expand Up @@ -258,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
32 changes: 32 additions & 0 deletions aws/celery.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
{
"name": "SENTRY_PROFILES_SAMPLE_RATE",
"value": "1.0"
},
{
"name": "SENTRY_ENVIRONMENT",
"value": "staging"
}
],
"repositoryCredentials": {
Expand Down Expand Up @@ -244,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 @@ -374,6 +390,10 @@
{
"name": "SENTRY_PROFILES_SAMPLE_RATE",
"value": "1.0"
},
{
"name": "SENTRY_ENVIRONMENT",
"value": "staging"
}
],
"repositoryCredentials": {
Expand Down Expand Up @@ -497,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
Loading

0 comments on commit 6b6e0fc

Please sign in to comment.