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

(refactor) O3-3297: Refactor select concept answers #289

Merged
merged 6 commits into from
May 27, 2024

Conversation

arodidev
Copy link
Contributor

@arodidev arodidev commented May 24, 2024

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

Within AFE, the functionality for select-concept-answers is that the datasource is configured make a network request using the field's conceptUuid. However, in the event that an answer is selected within an associated field, the datasource will make a network request based on the uuid tied to the answer selected in the associated field, thus giving a different list in the dropdown with every different answer selected.

This PR adds this functionality, enabling the dropdown to be populated based on a the answer selected in a referenced field.

It also enables select-concept-answers's list of answers to be populated by data from a Coded concept.

Sample schema:

{
  "name": "Test select concept answers",
  "pages": [
    {
      "label": "page one",
      "sections": [
        {
          "label": "First Section",
          "isExpanded": "true",
          "questions": [
            {
              "label": "Ped WHO stage",
              "type": "obs",
              "id": "pedWhoStage",
              "questionOptions": {
                "concept": "a89b3740-1350-11df-a1f1-0026b9348838",
                "answers": [
                  {
                    "label": "1",
                    "concept": "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                  },
                  {
                    "label": "2",
                    "concept": "2462a9d7-61fb-4bf5-9359-aedecb8d03cb"
                  },
                  {
                    "label": "3",
                    "concept": "167157AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                  },
                  {
                    "label": "4",
                    "concept": "0eaa21e0-5f69-41a9-9dea-942796590bbb"
                  }
                ],
                "rendering": "select"
              },
              "validators": [
                {
                  "type": "js_expression",
                  "failsWhenExpression": "isEmpty(myValue) && arrayContains (['18faa058-4eea-4339-a959-84b3e5cb30be', '03f5b165-c577-4e1e-b7ae-acfc3ba18ebf'], visitTypeUuid)",
                  "message": "Required."
                }
              ]
            },
            {
              "label": "Criteria",
              "id": "criteria",
              "type": "obs",
              "questionOptions": {
                "concept": "162552AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                "rendering": "select-concept-answers",
                "config":{
                  "referencedField":"pedWhoStage"
                }
              }
            },
             {
              "label": " New WHO staging:",
              "type": "obs",
              "required": "false",
              "questionOptions": {
                "concept": "a8a084ca-1350-11df-a1f1-0026b9348838",
                "answers": [
                  {
                    "concept": "a899b35c-1350-11df-a1f1-0026b9348838",
                    "label": "Yes"
                  },
                  {
                    "concept": "a899b42e-1350-11df-a1f1-0026b9348838",
                    "label": "No"
                  }
                ],
                "rendering": "select"
              },
              "id": "__FrEGLuv3v"
            }
          ]
        }
      ]
    }
  ],
  "processor": "EncounterFormProcessor",
  "encounterType": "",
  "referencedForms": [],
  "uuid": "",
  "description": "Sample form for testing select concept answers"
}

Screenshots

Screen.Recording.2024-05-22.at.21.42.54.mov

Related Issue

https://openmrs.atlassian.net/browse/O3-3297

Other

@arodidev arodidev changed the title (fix)Refactor select concept answers (refactor) O3-3297: Refactor select concept answers May 24, 2024
@CynthiaKamau CynthiaKamau mentioned this pull request May 27, 2024
3 tasks
@@ -1,15 +1,15 @@
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { BaseOpenMRSDataSource } from './data-source';

export class ConceptSetMembersDataSource extends BaseOpenMRSDataSource {
export class selectConceptAnswersDatasource extends BaseOpenMRSDataSource {
Copy link
Member

Choose a reason for hiding this comment

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

Can you capitalise the class name? Also don't forget to update the file name accordingly.

@CynthiaKamau CynthiaKamau merged commit 00dc0ab into openmrs:main May 27, 2024
4 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.

3 participants