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

O3-1041: Make list of HFE forms configurable #542

Merged
merged 5 commits into from
Feb 14, 2022

Conversation

icrc-psousa
Copy link
Contributor

@icrc-psousa icrc-psousa commented Feb 8, 2022

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • I checked for feature overlap with existing widgets.

Summary

Refactored so that the list of HTMLFormEntry forms can be configured by an implementation.

Issue

O3-1041

Comment on lines 12 to 13
function useCountOfFormsAvailableOffline(htmlFormEntryForms: Array<HtmlFormEntryForm>) {
const { data: forms } = useValidOfflineFormEncounters(htmlFormEntryForms);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use hooks in hooks. Put the useConfig call here.


/**
* Returns an `SWRResult` of those form encounters that work with offline mode.
*/
export function useValidOfflineFormEncounters() {
export function useValidOfflineFormEncounters(htmlFormEntryForms: Array<HtmlFormEntryForm>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Call useConfig within this hook and make this hook nullary again.

@brandones
Copy link
Contributor

Generally looks good! A couple requests. And don't delete the yarn.lock file.

const headerTitle = t('forms', 'Forms');
const isTablet = useLayoutType() === 'tablet';
const [formsCategory, setFormsCategory] = useState(FormsCategory.All);
const { isValidating, data, error } = useForms(patientUuid, undefined, undefined, isOffline);
const formsToDisplay = data?.filter((formInfo) => isValidOfflineFormEncounter(formInfo.form));
Copy link
Contributor Author

@icrc-psousa icrc-psousa Feb 9, 2022

Choose a reason for hiding this comment

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

To be reviewed - Do we really never want to include non offline valid forms within this list?
All HTML forms are currently considered invalid for offline so, they'll never show up, thus making the new configurable Configurable list of HFE forms useless.

cc @ibacher @brandones

Copy link
Member

Choose a reason for hiding this comment

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

Hey, no, that is not intended. I created a PR to address this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, makes sense. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@icrc-psousa Could you update this branch? I've merged the PR @manuelroemer mentioned and I think that's causing a conflict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibacher I've now resolved the conflicts and updated the PR

@icrc-psousa
Copy link
Contributor Author

Generally looks good! A couple requests. And don't delete the yarn.lock file.

Thanks for the feedback @brandones, I've made the suggested changes. There's also some pending points regarding the list of forms to display or, I may be just missing something...

I'll keep this on draft for now until further feedback is gathered

encounterUuid?: string,
) {
if (currentVisit) {
const htmlForm = findHtmlForm(formUuid);
if (isEmpty(htmlForm)) {
const htmlFormCfg = htmlFormEntryForms.find((form) => form.formUuid === formUuid);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this variable be better named htmlForm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Renamed.

@icrc-psousa icrc-psousa marked this pull request as ready for review February 9, 2022 16:10
@ibacher ibacher changed the title O3-1041: Configurable list of HFE forms O3-1041: Make list of HFE forms configurable Feb 14, 2022
@ibacher ibacher merged commit b82063c into openmrs:master Feb 14, 2022
@gracepotma
Copy link
Contributor

(FYI @makombe)

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.

5 participants