-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue#6240
- Loading branch information
Showing
28 changed files
with
1,214 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,7 +253,7 @@ jobs: | |
wait-for-service-stability: true | ||
|
||
deploy-staging-gcp: | ||
needs: build-production | ||
needs: build-staging | ||
name: Deploy to staging GCP cluster | ||
runs-on: ubuntu-latest | ||
environment: | ||
|
@@ -527,3 +527,49 @@ jobs: | |
kubectl apply -f care-backend.yaml | ||
kubectl apply -f care-celery-beat.yaml | ||
kubectl apply -f care-celery-worker.yaml | ||
deploy-production-meghalaya: | ||
needs: build-production | ||
name: Deploy to GKE Meghalaya | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: Production-Meghalaya | ||
url: https://careapi.meghealth.gov.in | ||
steps: | ||
- name: Checkout Kube Config | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: coronasafe/ml-care-infra | ||
token: ${{ secrets.GIT_ACCESS_TOKEN }} | ||
path: kube | ||
ref: main | ||
|
||
# Setup gcloud CLI | ||
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
project_id: ${{ secrets.GKE_PROJECT }} | ||
|
||
# Get the GKE credentials, so we can deploy to the cluster | ||
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e | ||
with: | ||
cluster_name: ${{ secrets.GKE_CLUSTER }} | ||
location: ${{ secrets.GKE_ZONE }} | ||
credentials: ${{ secrets.GKE_SA_KEY }} | ||
|
||
- name: install kubectl | ||
uses: azure/[email protected] | ||
with: | ||
version: "v1.23.6" | ||
id: install | ||
|
||
- name: Deploy Care Production Nagaland | ||
run: | | ||
mkdir -p $HOME/.kube/ | ||
cd kube/deployments/ | ||
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-backend.yaml | ||
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-beat.yaml | ||
sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-celery-worker.yaml | ||
kubectl apply -f care-backend.yaml | ||
kubectl apply -f care-celery-beat.yaml | ||
kubectl apply -f care-celery-worker.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
care/facility/api/serializers/consultation_diagnosis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
from typing import Any | ||
|
||
from rest_framework import serializers | ||
|
||
from care.facility.models import ( | ||
INACTIVE_CONDITION_VERIFICATION_STATUSES, | ||
ConsultationDiagnosis, | ||
) | ||
from care.facility.models.icd11_diagnosis import ICD11Diagnosis | ||
from care.facility.static_data.icd11 import get_icd11_diagnosis_object_by_id | ||
from care.users.api.serializers.user import UserBaseMinimumSerializer | ||
|
||
|
||
class ConsultationCreateDiagnosisSerializer(serializers.ModelSerializer): | ||
def validate_verification_status(self, value): | ||
if value in INACTIVE_CONDITION_VERIFICATION_STATUSES: | ||
raise serializers.ValidationError("Verification status not allowed") | ||
return value | ||
|
||
class Meta: | ||
model = ConsultationDiagnosis | ||
fields = ("diagnosis", "verification_status", "is_principal") | ||
|
||
|
||
class ConsultationDiagnosisSerializer(serializers.ModelSerializer): | ||
id = serializers.UUIDField(source="external_id", read_only=True) | ||
diagnosis = serializers.PrimaryKeyRelatedField( | ||
queryset=ICD11Diagnosis.objects.all(), required=True, allow_null=False | ||
) | ||
diagnosis_object = serializers.SerializerMethodField() | ||
created_by = UserBaseMinimumSerializer(read_only=True) | ||
|
||
def get_diagnosis_object(self, obj): | ||
return get_icd11_diagnosis_object_by_id(obj.diagnosis_id, as_dict=True) | ||
|
||
class Meta: | ||
model = ConsultationDiagnosis | ||
exclude = ( | ||
"consultation", | ||
"external_id", | ||
"deleted", | ||
) | ||
read_only_fields = ( | ||
"created_by", | ||
"created_date", | ||
"modified_date", | ||
"is_migrated", | ||
) | ||
|
||
def get_consultation_external_id(self): | ||
return self.context["request"].parser_context["kwargs"][ | ||
"consultation_external_id" | ||
] | ||
|
||
def validate_diagnosis(self, value): | ||
if self.instance and value != self.instance.diagnosis: | ||
raise serializers.ValidationError("Diagnosis cannot be changed") | ||
|
||
if ( | ||
not self.instance | ||
and ConsultationDiagnosis.objects.filter( | ||
consultation__external_id=self.get_consultation_external_id(), | ||
diagnosis=value, | ||
).exists() | ||
): | ||
raise serializers.ValidationError( | ||
"Diagnosis already exists for consultation" | ||
) | ||
|
||
return value | ||
|
||
def validate_verification_status(self, value): | ||
if not self.instance and value in INACTIVE_CONDITION_VERIFICATION_STATUSES: | ||
raise serializers.ValidationError("Verification status not allowed") | ||
return value | ||
|
||
def validate_is_principal(self, value): | ||
if not value: | ||
return value | ||
|
||
qs = ConsultationDiagnosis.objects.filter( | ||
consultation__external_id=self.get_consultation_external_id(), | ||
is_principal=True, | ||
) | ||
|
||
if self.instance: | ||
qs = qs.exclude(id=self.instance.id) | ||
|
||
if qs.exists(): | ||
raise serializers.ValidationError( | ||
"Consultation already has a principal diagnosis. Unset the existing principal diagnosis first." | ||
) | ||
|
||
return value | ||
|
||
def update(self, instance, validated_data): | ||
if ( | ||
"verification_status" in validated_data | ||
and validated_data["verification_status"] | ||
in INACTIVE_CONDITION_VERIFICATION_STATUSES | ||
): | ||
instance.is_principal = False | ||
return super().update(instance, validated_data) | ||
|
||
def validate(self, attrs: Any) -> Any: | ||
validated = super().validate(attrs) | ||
|
||
if ( | ||
"verification_status" in validated | ||
and validated["verification_status"] | ||
in INACTIVE_CONDITION_VERIFICATION_STATUSES | ||
): | ||
validated["is_principal"] = False | ||
|
||
if "is_principal" in validated and validated["is_principal"]: | ||
verification_status = validated.get( | ||
"verification_status", | ||
self.instance.verification_status if self.instance else None, | ||
) | ||
if verification_status in INACTIVE_CONDITION_VERIFICATION_STATUSES: | ||
raise serializers.ValidationError( | ||
{ | ||
"is_principal": "Refuted/Entered in error diagnoses cannot be marked as Principal Diagnosis" | ||
} | ||
) | ||
|
||
return validated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.