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

Registration App: Add extension point to registerPatient.gsp to insert custom JavaScript

    Details

    • Type: Story
    • Status: Accepted
    • Priority: TBD
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Undetermined

      Description

      This feature is based on the discussion in this talk thread

      We would like to add an extension point to the registerPatient.gsp page that allows developers to inject javascript into the page.

      Use Case:
      The iSant├ęPlus implementation needs to display a Medical Power of Attorney section only for minors. To do this, we need to manipulate the existing sections using JavaScript.

      Here's the JavaScript code:

          <script id="togglePowerOfAttorneyContact" type="text/javascript">
          var age = 999;
          var today = new Date();
          var nowyear = today.getFullYear();
          var nowmonth = today.getMonth() + 1; //we add 1 because getMonth is zero indexed
          var nowday = today.getDate();
      
          jQuery(function() {
              var birthdateYearField = jQuery('#birthdateYear-field');
              var birthdateMonthField = jQuery('#birthdateMonth-field');
              var birthdateDayField = jQuery('#birthdateDay-field');
              var yearsField = jQuery('#birthdateYears-field');
              var monthsField = jQuery('#birthdateMonths-field');
      
              jQuery(yearsField.change(function() {
                  if((!!monthsField.val() != '' && yearsField.val() == '') || (!!yearsField.val() && yearsField.val() < 18)) {
                      NavigatorController.getSectionById('powerOfAttorneyContact').show();
                  } else {
                      NavigatorController.getSectionById('powerOfAttorneyContact').hide();
                  }
              }));
      
              jQuery(monthsField.change(function() {
                  if((!!monthsField.val() != '' && yearsField.val() == '') || (!!yearsField.val() && yearsField.val() < 18)) {
                      NavigatorController.getSectionById('powerOfAttorneyContact').show();
                  } else {
                      NavigatorController.getSectionById('powerOfAttorneyContact').hide();
                  }
              }));
      
              jQuery(birthdateYearField.change(function() {
                  if (!!birthdateYear && !!birthdateMonth && !!birthdateDay) {
                      togglePowerOfAttorneyContact();
                  }
              }));
      
              jQuery(birthdateMonthField.change(function() {
                  if (!!birthdateYear && !!birthdateMonth && !!birthdateDay) {
                      togglePowerOfAttorneyContact();
                  }
              }));
      
              jQuery(birthdateDayField.change(function() {
                  if (!!birthdateYear && !!birthdateMonth && !!birthdateDay) {
                      togglePowerOfAttorneyContact();
                  }
              }));
          });
      
          jQuery(document).ready(function() {
              NavigatorController.getSectionById('powerOfAttorneyContact').hide();
          });
      
          function togglePowerOfAttorneyContact() {
              var birthdateYear = jQuery('#birthdateYear-field').val();
              age = nowyear - birthdateYear;
              var age_month = nowmonth - birthdateMonth;
              var age_day = nowday - birthdateDay;
             
              if(age_month < 0 || (age_month == 0 && age_day <0)) {
                      age = parseInt(age) -1;
                  }
      
              if(age < 18) {
                  NavigatorController.getSectionById('powerOfAttorneyContact').show();
              } else {
                  NavigatorController.getSectionById('powerOfAttorneyContact').hide();
              }
          };
      </script>
      

        Gliffy Diagrams

          Attachments

            Attachments-Category-Modification

              Activity

                People

                • Assignee:
                  craigappl Craig Appl
                  Reporter:
                  craigappl Craig Appl
                  Designated Committer:
                  Mark Goodrich
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: