Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate ABDM into a plug #22

Closed
5 of 8 tasks
Tracked by #21
khavinshankar opened this issue Apr 16, 2024 · 0 comments · Fixed by ohcnetwork/care#2312 or ohcnetwork/care_fe#8340
Closed
5 of 8 tasks
Tracked by #21

Separate ABDM into a plug #22

khavinshankar opened this issue Apr 16, 2024 · 0 comments · Fixed by ohcnetwork/care#2312 or ohcnetwork/care_fe#8340
Assignees

Comments

@khavinshankar
Copy link
Member

khavinshankar commented Apr 16, 2024

Todo:

  • Clean up the usage or access of the abdm app inside the facility app
    • care/facility/models/patient.py
      abha_number = models.OneToOneField(
          AbhaNumber, on_delete=models.SET_NULL, null=True, blank=True
      )


      # TODO: move this relation inside Abha Number model
      
      patient = models.OneToOneField(
          Patient, on_delete=models.CASCADE, null=True, blank=True
      ) # VERIFY: abha number is deleted when patient is deleted and not vice versa
      
      # TODO: Add the necessary migration
    • care/facility/api/serializers/patient.py
      abha_number = ExternalIdSerializerField(
        queryset=AbhaNumber.objects.all(), required=False, allow_null=True
      )
      abha_number_object = AbhaNumberSerializer(source="abha_number", read_only=True)
      
      # TODO: create an extended serializer in abdm plug for internal use and in the frontend seperate out the api calls for patient and abha number
    • care/facility/api/serializers/patient_consultation.py
      if patient.abha_number:
          abha_number = patient.abha_number
          try:
              AbdmGateway().fetch_modes(
                  {
                      "healthId": abha_number.abha_number,
                      "name": abha_number.name,
                      "gender": abha_number.gender,
                      "dateOfBirth": str(abha_number.date_of_birth),
                      "consultationId": abha_number.external_id,
                      "purpose": "LINK",
                  }
              )
          except Exception:
              pass# TODO: use signals to intercept post_save inside plug
      
      # in signals/consultation.py
      from django.db.models.signals import post_save
      from django.dispatch import receiver
      from facility.models import Consultation  # Import the Consultation model from the facility app
      
      @receiver(post_save, sender=Consultation)
      def create_care_context(sender, instance, created, **kwargs):
          patient = instance.patient
          abha_number = AbhaNumber.objects.filter(patient__external_id=patient.id)
          if created:
              try:
                  AbdmGateway().fetch_modes(
                      {
                          "healthId": abha_number.abha_number,
                          "name": abha_number.name,
                          "gender": abha_number.gender,
                          "dateOfBirth": str(abha_number.date_of_birth),
                          "consultationId": abha_number.external_id,
                          "purpose": "LINK",
                      }
                  )
              except Exception:
                  pass 
  • Move envs and routes to the plug

Extras:

  • Clean up fetch_modes, init, confirm flow
  • Refactor M1 & M2 into the structure used in M3
  • Add standard suffixes for the routes of abdm callback apis
@khavinshankar khavinshankar mentioned this issue Apr 16, 2024
15 tasks
@khavinshankar khavinshankar self-assigned this Apr 16, 2024
@github-project-automation github-project-automation bot moved this to Triage in Care Aug 22, 2024
@khavinshankar khavinshankar moved this from Triage to In Progress in Care Aug 22, 2024
@khavinshankar khavinshankar moved this from In Progress to Review required in Care Aug 22, 2024
@github-project-automation github-project-automation bot moved this from Review required to Done in Care Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants