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) add config to display encounter type in generic widgets #1450

Merged
merged 6 commits into from
Nov 9, 2023

Conversation

icrc-jofrancisco
Copy link
Contributor

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This pull request introduces a new configuration option to the generic patient widgets, allowing users to display the encounter type column. By default, this feature is turned off, and to enable it, you can set the showEncounterType property to true.

eg:

"obs-by-encounter-widget#FormCompleteness": {
    "title": "Form Completeness",
    "showEncounterColumn": true,
    "graphOldestFirst": true,
    "Display conditions": {
        "privileges": ["Encounters View"]
    },
    "data": [
        {
            "label": "Status",
            "concept": "my-concept-uuid",
            "color": "green"
        }
    ],
    "table": {
        "pageSize": 6
    }
}

Screenshots

image

Related Issue

--

Other

--

I'm requesting a review of this pull request to ensure the changes are in line with our project's standards and requirements.

Thanks,
CC: @ibacher

Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @icrc-jofrancisco! This mostly looks good. One small thing and one slightly bigger thing.

I would probably make useObs() look like this:

export const useObs(patientUuid: string, includeEncounters: boolean = false) {
  return includeEncounters ? useObsWithEncounters(patientUuid)) : useObsOnly(patientUuid);
}

The common stuff can be factored out into functions. For handling the obs, just take an optional callback that can add the encounter name to the obs result.

Also, please fix the typescript errors, if possible.

@ibacher ibacher changed the title (chore) add config to display encounter type in generic widgets (feat) add config to display encounter type in generic widgets Nov 2, 2023
@icrc-jofrancisco
Copy link
Contributor Author

Thanks @icrc-jofrancisco! This mostly looks good. One small thing and one slightly bigger thing.

I would probably make useObs() look like this:

export const useObs(patientUuid: string, includeEncounters: boolean = false) {
  return includeEncounters ? useObsWithEncounters(patientUuid)) : useObsOnly(patientUuid);
}

The common stuff can be factored out into functions. For handling the obs, just take an optional callback that can add the encounter name to the obs result.

Also, please fix the typescript errors, if possible.

I don't think splitting it into two functions as suggested would have the most optimized version, because there are filters.

However, I made a change to prevent encounters from being processed when they don't need to be. Could you review it again and see if it okay? Thank you @ibacher

ibacher
ibacher previously approved these changes Nov 9, 2023
@ibacher ibacher merged commit 8f117b1 into openmrs:main Nov 9, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants