diff --git a/.github/workflows/openmis-module-test.yml b/.github/workflows/openmis-module-test.yml index 434a72d..2cbc165 100644 --- a/.github/workflows/openmis-module-test.yml +++ b/.github/workflows/openmis-module-test.yml @@ -40,7 +40,7 @@ jobs: - name: pull openimis backend run: | rm ./openimis -rf - git clone --depth 1 --branch develop https://github.com/openimis/openimis-be_py.git ./openimis + git clone --depth 1 --branch coreMIS https://github.com/openimis/openimis-be_py.git ./openimis - name: copy current branch uses: actions/checkout@v2 with: diff --git a/social_protection/schema.py b/social_protection/schema.py index a0fa8ea..f819bfe 100644 --- a/social_protection/schema.py +++ b/social_protection/schema.py @@ -1,8 +1,11 @@ import graphene +import pandas as pd from django.contrib.auth.models import AnonymousUser from django.db.models import Q from django.core.exceptions import PermissionDenied +from core.gql.export_mixin import ExportableQueryMixin + from django.utils.translation import gettext as _ from core.gql_queries import ValidationMessageGQLType from core.schema import OrderedDjangoFilterConnectionField @@ -28,7 +31,22 @@ import graphene_django_optimizer as gql_optimizer -class Query: +def patch_details(beneficiary_df: pd.DataFrame): + # Transform extension to DF columns + df_unfolded = pd.json_normalize(beneficiary_df['json_ext']) + # Merge unfolded DataFrame with the original DataFrame + df_final = pd.concat([beneficiary_df, df_unfolded], axis=1) + df_final = df_final.drop('json_ext', axis=1) + return df_final + +class Query(ExportableQueryMixin, graphene.ObjectType): + export_patches = { + 'beneficiary': [ + patch_details + ] + } + exportable_fields = ['beneficiary'] + benefit_plan = OrderedDjangoFilterConnectionField( BenefitPlanGQLType, orderBy=graphene.List(of_type=graphene.String),