Uploaded image for project: 'Reference Application'
  1. Reference Application
  2. RA-1619

Display forms for patients based on the program(s) enrolled

    XMLWordPrintable

    Details

    • Complexity:
      Low

      Description

      In our openmrs implementation, we have three major programs (PMTCT, ART and HTS). Each of the these programs has forms that relate to them. We want a situation where patient is enrolled on a particular program, and only forms that relate to the program should be displayed.

      Similar with what we have in the link below: Conditionally displaying Apps and Extensions but for program areas.

      You can put a blank line after this one: https://github.com/openmrs/openmrs-module-coreapps/blob/master/omod/src/main/java/org/openmrs/module/coreapps/page/controller/clinicianfacing/PatientPageController.java#L96
      Then put code like below:

      List<Program> programs = new ArrayList<Program>();
      List<PatientProgram> patientPrograms = Context.getProgramWorkflowService().getPatientPrograms(patient, null, null, null, null, null, false);
      for (PatientProgram patientProgram : patientPrograms) {
              programs.add(patientProgram.getProgram());
      }
      contextModel.put("patientPrograms", ConversionUtil.convertToRepresentation(programs, Representation.DEFAULT));
      

      Remember to put another blank line after this code.

      Then one should be able to for instance configure a form for patients on the ART program with the show if condition below:

      hasMemberWithProperty (patientPrograms, 'name', 'ART')
      

      or

      hasMemberWithProperty (patientPrograms, 'uuid', 'uuid-for-the-art-program')
      

      After this code has been merged, update the above wiki documentation by adding how one can conditionally show forms based on patient program enrolment.

      Just in case you are not aware of these pull request tips: https://wiki.openmrs.org/display/docs/Pull+Request+Tips

      https://wiki.openmrs.org/display/docs/Using+Git

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aeze Arinze Eze
              Reporter:
              aeze Arinze Eze
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h