ohcnetwork / care_fe

Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.
https://care.ohc.network
MIT License
208 stars 382 forks source link

Export function is not working Sample Test #7628

Closed nihal467 closed 4 months ago

nihal467 commented 5 months ago

Describe the bug

the export function is not working for the sample test homepage

To Reproduce

  1. Go to /sample
  2. Click on export button
  3. See error

Expected behavior

the export function should be working for the sample test homepage as expected

Screenshots

image

AshrafMd-1 commented 5 months ago

@nihal467 The URL seems to be wrong

image image
Ashesh3 commented 5 months ago

@nihal467 The URL seems to be wrong

image image

api url is correct.

This is the stacktrace of the crash:

FieldError
Unsupported lookup 'age' for BigAutoField or join on the field not permitted, perhaps you meant range or gte?

Cannot resolve keyword 'age' into field. Choices are: abha_number, abha_number_id, action, address, allergies, allow_transfer, assigned_to, assigned_to_id, blood_group, cluster_name, consultations, contact_with_confirmed_carrier, contact_with_suspected_carrier, contacted_patients, contacts, countries_travelled, countries_travelled_old, covin_id, created_by, created_by_id, created_date, date_declared_positive, date_of_birth, date_of_delivery, date_of_receipt_of_information, date_of_result, date_of_return, date_of_test, death_datetime, deleted, designation_of_health_care_worker, disease_status, district, district_id, emergency_phone_number, estimated_contact_date, external_id, facility, facility_id, fit_for_blood_donation, frontline_worker, gender, has_SARI, id, instituion_of_health_care_worker, is_active, is_antenatal, is_declared_positive, is_medical_worker, is_migrant_worker, is_vaccinated, last_consultation, last_consultation_id, last_edited, last_edited_id, last_menstruation_start_date, last_vaccinated_...

Crashed in non-app: django/db/models/sql/query.py in names_to_path

Show 6 more frames

care/facility/api/viewsets/patient_sample.py in list at line 127
In App

            and request.user.user_type < User.TYPE_VALUE_MAP["Doctor"]
        ):
            raise PermissionDenied()
        if settings.CSV_REQUEST_PARAMETER in request.GET:
            queryset = self.filter_queryset(self.get_queryset()).values(
                *PatientSample.CSV_MAPPING.keys()
            )
            return render_to_csv_response(
                queryset,
                field_header_map=PatientSample.CSV_MAPPING,
__class__   
<class 'care.facility.api.viewsets.patient_sample.PatientSampleViewSet'>
args    
[]
kwargs  
{}
request 
<rest_framework.request.Request: GET '/api/v1/test_sample/?csv=1&'>
self    
<care.facility.api.viewsets.patient_sample.PatientSampleViewSet object at 0x7f7fd3d49510>

Show More
Called from: rest_framework/views.py in dispatch
AshrafMd-1 commented 5 months ago

@Ashesh3 It seems like a backend issue most probably because there is no age field in the DB Even in the frontend we calculate age by using data of birth also adding a backend tag would be better

github-actions[bot] commented 5 months ago

:warning: Refrain from assigning this issue to yourself if you have another P1 issue assigned that is not yet closed.

sentry-io[bot] commented 5 months ago

Sentry Issue: CARE-B0N

sentry-io[bot] commented 5 months ago

Sentry Issue: CARE-B8X