Skip to content

AMR Surveys

9sneha-n edited this page Nov 29, 2024 · 9 revisions

AMR Surveys is custom React App used by the Anti Microbial Resistance(AMR) team of WHO to survey countries across the world.

Each Survey corresponds to a Program in DHIS. Either a Tracker Program or an Event Program.

The react app generates a form for each survey by fetching the metadata of the program and creating a react "widget" for each element in the Program. Some point to note about creating a survey form from program in the code:

Program Rule Parsing

Program rules created in DHIS for each program, need to applied in the corresponding Survey Form.

Program rule condition parsing

To parse the condition in the program rule, earlier we had custom logic which had lot of issues/bugs. In Nov 24 we changed the code to use DHIS package for expression parsing : https://github.com/dhis2/expression-parser This is a lot more reliable and has no known bugs so far. The wrapper code to use this package can be found at https://github.com/EyeSeeTea/amr-surveys/blob/development/src/data/entities/D2ExpressionParser.ts The expression parser takes as input the condition and the values for the variables for the condition and returns a true or false value.

Program rule action

Program rules have actions like : hide field, hide section, show error, show warn, set mandatory etc.(Check DHIS for complete list) Currently in AMR Survey code we support :

Recursive program rule application

If one question is updated, there could be side-effects for that question. And each of those side effect questions, could cause a another side effect. So the program rules need to be recursively applied to all questions that are effected by that update. In Nov 2024, we have added the code for recursive handling of program rules : https://github.com/EyeSeeTea/amr-surveys/blob/41bdbc087dd217fe2200a97a702c46a1f4c77df8/src/domain/entities/Questionnaire/QuestionnaireQuestion.ts#L162 Arnau has context on this. Please contact him if any issues around this area that are not solvable within the team.

Custom Survey Rules

There are many survey rules - which are customised app specific logic that have been handled. They are a niche scenario and applicable only to certain surveys in certain cases. They are related to Antibiotic Black listing, AST Guidelines, hiding specific sections/field only in specific instances of surveys. All of these configuration details are stored in datastore. Please contact Miquel for details on custom survey rules - the conditions are complex but the code is fairly simple.

#PPS There are 5 forms corresponding to PPS where each form is the child of the previous :

  • Parent : PPSSurveyForm

  • PPSCountryQuestionnaire

  • PPSHospitalForm

  • PPSWardRegister

  • PPSPatientRegister - This is the only form in PPS that is fetched and displayed in a paginated manner. This is the only survey that has search functionality.

  • When listing each child should be filtered by its parent

  • The topmost parent is saved at saved at Global level.

  • Country Surveys are stored at country level. The country is chosen in the UI by the user.

  • Hospital Surveys are stored at hospital level - 6,7,8. The hospital is chosen in the UI by the user.

  • Ward Surveys and Patient Surveys are stored at parents hospital level - 6,7,8.

Prevalence

There are 5 forms corresponding to PPS where each form is the child of the previous :

  • Parent : PrevalenceSurveyForm

  • PrevalenceFacilityLevelForm

  • PrevalenceCaseReportForm - This form and its children in Prevalence are fetched and displayed in a paginated manner. This is the only survey that has search functionality.

  • PrevalenceSampleShipTrackForm, PrevalenceCentralRefLabForm, PrevalencePathogenIsolatesLog, PrevalencePathogenIsolatesLog, PrevalenceSupranationalRefLabForm, PrevalenceD28FollowUp, PrevalenceDischarge, PrevalenceCohortEnrolment

  • When listing each child should be filtered by its parent

  • The topmost parent is saved at saved at country level. The country is chosen in the UI by the user.

  • Facility Surveys are stored at hospital level - 6,7,8. The hospital is chosen in the UI by the user.

  • All other surveys are stored at parents hospital level - 6,7,8.

  • Only PrevalenceCaseReportForm has multiple children, and so the child count logic is different for it. This code is a little convoluted and needs to be improved.

Access/Permissions

  • User needs to have AMR Surveys PPS data capture, AMR Surveys PPS admin or AMR Surveys PPS data visualizer user groups assigned to be able to see PPS module in menu
  • User needs to have AMR Surveys Prevalence data capture, AMR Surveys Prevalence admin or AMR Surveys Prevalence data visualizer user groups assigned to be able to see Prevalence module in menu
  • The following key needs to be adde din datastore under amr-surveys/modules

amr-surveys-modules.json

  • All programs should have appropriate user groups access and org unit access for user to be able to list and create surveys in app:
Screenshot 2024-11-29 at 4 09 17 PM

Notes

To Do:

  • Contexts are not saved to browser local storage, so reloads behave weirdly (not filtered).
  • Child count logic needs to be improved.