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

feat(): data exchange for multiple forms #471

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

nckhell
Copy link
Contributor

@nckhell nckhell commented Oct 1, 2024

PR Type

Enhancement, Tests


Description

  • Enhanced the Healthie SDK schema by adding new types and interfaces for form answer groups and eligibility checks.
  • Implemented new mutations and payloads to manage form answer group connections.
  • Added comprehensive tests for the pushFormResponsesToHealthie and pushFormResponseToHealthie actions.
  • Introduced mock data for form definitions and responses to facilitate testing.
  • Integrated with Awell SDK to retrieve and process form data within the new actions.

Changes walkthrough 📝

Relevant files
Enhancement
2 files
schema.ts
Extend schema with form answer group and eligibility check types

extensions/healthie/lib/sdk/genql/generated/schema.ts

  • Added new types and interfaces for handling form answer groups and
    eligibility checks.
  • Introduced new mutations and payloads for form answer group
    connections.
  • Added new fields to existing interfaces for enhanced functionality.
  • Deprecated certain fields and mutations in favor of new
    implementations.
  • +551/-40
    pushFormResponsesToHealthie.ts
    Implement pushFormResponsesToHealthie action                         

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/pushFormResponsesToHealthie.ts

  • Implemented functionality to push form responses to Healthie.
  • Integrated with Awell SDK to retrieve form data.
  • Handled errors and completed events for the action.
  • +119/-0 
    Tests
    5 files
    formDefinitionResponse.ts
    Add mock data for form definition responses                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/mocks/formDefinitionResponse.ts

  • Added mock data for form definition responses.
  • Included detailed question metadata for testing.
  • +68/-1   
    pushFormResponsesToHealthie.test.ts
    Add tests for pushFormResponsesToHealthie action                 

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/pushFormResponsesToHealthie.test.ts

  • Implemented tests for pushing form responses to Healthie.
  • Mocked Healthie SDK for testing purposes.
  • Verified the integration with Awell SDK.
  • +124/-0 
    getAllFormsInCurrentStep.test.ts
    Add tests for getAllFormsInCurrentStep function                   

    src/lib/awell/getAllFormsInCurrentStep/getAllFormsInCurrentStep.test.ts

  • Added tests for retrieving all forms in the current step.
  • Mocked Awell SDK queries for testing.
  • Validated the response structure and data.
  • +125/-0 
    pushFormResponseToHealthie.test.ts
    Add tests for pushFormResponseToHealthie action                   

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/pushFormResponseToHealthie.test.ts

  • Added tests for pushing a single form response to Healthie.
  • Mocked necessary SDKs for testing.
  • Ensured correct handling of form responses.
  • +105/-1 
    formResponseResponse.ts
    Add mock data for form response responses                               

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/mocks/formResponseResponse.ts

  • Added mock data for form response responses.
  • Included detailed answer metadata for testing.
  • +35/-1   
    Additional files (token-limit)
    36 files
    types.ts
    ...                                                                                                           

    extensions/healthie/lib/sdk/genql/generated/types.ts

    ...

    +24263/-23929
    getSubActivityLogs.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.ts

    ...

    +127/-1 
    getAllFormsInCurrentStep.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/getAllFormsInCurrentStep.ts

    ...

    +128/-0 
    getSubActivityLogs.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/logs/getSubActivityLogs/getSubActivityLogs.ts

    ...

    +126/-0 
    pathwayActivitiesResponse.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/mocks/pathwayActivitiesResponse.ts

    ...

    +89/-0   
    pathwayActivitiesResponse.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/testdata/pathwayActivitiesResponse.ts

    ...

    +89/-0   
    pathwayActivitiesResponse.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/mocks/pathwayActivitiesResponse.ts

    ...

    +78/-1   
    getSubActivityLogs.test.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.ts

    ...

    +80/-1   
    getSubActivityLogs.test.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/logs/getSubActivityLogs/getSubActivityLogs.test.ts

    ...

    +79/-0   
    pushFormResponseToHealthie.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/pushFormResponseToHealthie.ts

    ...

    +6/-6     
    formDefinitionResponse.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/testdata/formDefinitionResponse.ts

    ...

    +41/-0   
    formDefinitionResponse.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/mocks/formDefinitionResponse.ts

    ...

    +37/-0   
    fields.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/config/fields.ts

    ...

    +25/-1   
    fields.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/fields.ts

    ...

    +24/-0   
    errors.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/shared/errors.ts

    ...

    +30/-1   
    formResponseResponse.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/mocks/formResponseResponse.ts

    ...

    +27/-0   
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/index.ts

    ...

    +5/-1     
    formResponseResponse.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/testdata/formResponseResponse.ts

    ...

    +27/-0   
    datapoints.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/config/datapoints.ts

    ...

    +9/-1     
    datapoints.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/datapoints.ts

    ...

    +8/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/mocks/index.ts

    ...

    +4/-1     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/mocks/index.ts

    ...

    +3/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/config/index.ts

    ...

    +3/-1     
    index.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/testdata/index.ts

    ...

    +3/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/config/index.ts

    ...

    +2/-0     
    index.ts
    ...                                                                                                           

    src/lib/awell/index.ts

    ...

    +1/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/index.ts

    ...

    +2/-1     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/index.ts

    ...

    +2/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/logs/getSubActivityLogs/index.ts

    ...

    +2/-1     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/index.ts

    ...

    +1/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponseToHealthie/logs/index.ts

    ...

    +2/-1     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/logs/getSubActivityLogs/index.ts

    ...

    +1/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/logs/index.ts

    ...

    +1/-0     
    index.ts
    ...                                                                                                           

    src/lib/awell/getAllFormsInCurrentStep/index.ts

    ...

    +1/-0     
    index.ts
    ...                                                                                                           

    extensions/healthie/actions/dataExchange/shared/index.ts

    ...

    +1/-0     
    schema.graphql
    ...                                                                                                           

    extensions/healthie/lib/sdk/genql/generated/schema.graphql

    ...

    +339/-36

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @github-actions github-actions bot added enhancement New feature or request tests Adds or updates tests for an extension Review effort [1-5]: 4 labels Oct 1, 2024
    Copy link

    github-actions bot commented Oct 1, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Hardcoded Data
    The mock data for form definitions contains excessively long and hardcoded strings which might not be scalable or easy to manage. Consider simplifying these or using more manageable data structures.

    Error Handling
    The error handling in the onEvent function could be improved by ensuring that all potential error paths are adequately addressed and that the error messages provided to the user are clear and informative.

    Complex Logic
    The logic within the onEvent function is quite complex and involves multiple levels of mapping and data transformation. This could benefit from further decomposition into smaller, more manageable functions.

    Copy link

    github-actions bot commented Oct 1, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add null check for the response from healthieSdk.client.mutation to prevent potential runtime errors

    Consider handling the case where healthieSdk.client.mutation might return null or
    undefined before accessing properties on
    res.createFormAnswerGroup.form_answer_group.id to prevent runtime errors.

    extensions/healthie/actions/dataExchange/pushFormResponsesToHealthie/pushFormResponsesToHealthie.ts [90-91]

    -if (isEmpty(res?.createFormAnswerGroup?.form_answer_group?.id))
    +if (!res || isEmpty(res?.createFormAnswerGroup?.form_answer_group?.id))
       throw new HealthieFormResponseNotCreated(res)
    Suggestion importance[1-10]: 8

    Why: The suggestion correctly identifies a potential runtime error if healthieSdk.client.mutation returns null or undefined. Adding a null check enhances the robustness of the code by preventing possible crashes when accessing properties on a potentially null object.

    8
    Maintainability
    Remove the deprecated and non-functional updateAddendum mutation

    To avoid confusion and maintain clean code, remove the deprecated updateAddendum
    mutation if it no longer performs any function.

    extensions/healthie/lib/sdk/genql/generated/schema.ts [5874-5878]

    -/**
    - * @deprecated Deprecated. Does nothing
    - * THIS MUTATION DOES NOTHING, AND SHOULD NOT BE USED.
    - */
    -updateAddendum: (updateAddendumPayload | null)
    +// This mutation has been removed due to deprecation and no operational functionality.
    Suggestion importance[1-10]: 7

    Why: Removing a non-functional mutation improves code maintainability and prevents potential confusion. However, the suggestion does not provide the improved code, which slightly reduces its effectiveness.

    7
    Remove the deprecated clientMutationId field from LockPayload

    Refactor the LockPayload to remove the deprecated clientMutationId field if it is no
    longer required, to streamline the interface.

    extensions/healthie/lib/sdk/genql/generated/schema.ts [5138-5142]

    -/**
    - * @deprecated DO NOT USE
    - * DO NOT USE
    - */
    -clientMutationId: (Scalars['String'] | null)
    +// The clientMutationId has been removed to simplify the payload structure.
    Suggestion importance[1-10]: 7

    Why: The suggestion to remove an unused field helps streamline the interface, enhancing maintainability. However, the suggestion lacks the improved code, which limits its completeness.

    7
    Best practice
    Mark the insurance_billing_enabled field as deprecated in the code and documentation

    Ensure that the insurance_billing_enabled field in AppointmentTypeCptCodeType is
    properly deprecated in the GraphQL schema to avoid future usage, as it's now
    replaced by appointmentType's insurance_billing_enabled.

    extensions/healthie/lib/sdk/genql/generated/schema.ts [1010-1014]

    -/**
    - * @deprecated Use appointmentType's insurance_billing_enabled instead
    - * DEPRECATED. Use appointmentType's insurance_billing_enabled instead
    - */
    +// This field is deprecated and should not be used in new code.
    +// Refer to the `insurance_billing_enabled` in the `AppointmentType` for enabling insurance billing.
     insurance_billing_enabled: (Scalars['Boolean'] | null)
    Suggestion importance[1-10]: 6

    Why: The suggestion provides a clearer deprecation notice, which can help developers avoid using outdated fields. It aligns with best practices for maintaining code clarity and preventing future usage.

    6
    Enhancement
    Improve the descriptiveness of the comment for the Action type

    Consider adding a more descriptive comment for the Action type to explain the
    context in which these actions are used, enhancing code readability and
    maintainability.

    extensions/healthie/lib/sdk/genql/generated/schema.ts [30-31]

    -/** Enum for `FormAnswerGroupAuditEvent#action` */
    +/** Enum for `FormAnswerGroupAuditEvent#action` describing the possible states of a form in response to user interactions */
     export type Action = 'LOCKED' | 'UNLOCKED' | 'SIGNED' | 'ADDENDUM_CREATED'
    Suggestion importance[1-10]: 5

    Why: The suggestion enhances the comment's clarity, providing better context for the Action type. While it improves readability, the impact is moderate as it doesn't affect functionality.

    5

    @nckhell nckhell merged commit 15e913e into main Oct 1, 2024
    1 check passed
    @nckhell nckhell deleted the push_multiple_awell_forms_to_single_healhtie_form branch October 1, 2024 15:55
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    enhancement New feature or request Review effort [1-5]: 4 tests Adds or updates tests for an extension
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant