Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Need to populate variable choices into the Patient Type field, which is part of a Multi-Row Variable

prasannasun
Tera Contributor

Hi Everyone.

 

I have created two variable sets one is single row variable set and another is multi row variable set.

 

In single row I have a variable called facility which is select box with choices like MBC, FMC, MNH

and in multi row variable set I have a field called patient types. I have to show the choices in that field based on the choices selected in Facility.

 

I have written catalog client script but that is not populating since it is multi row variable set if not using variable sets logic is fine but here I wanted to work in multirow variable set. Can some one help me with this scenario please

 

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading) return;

  var field = 'patient_type';

  // Clear existing options first
  g_form.clearOptions(field);

  // Add an explicit blank/placeholder option at the top to avoid auto-selection
  g_form.addOption(field, '', '-- None --', 0);

  if (newValue == 'BMC') {
    // BMC options
    g_form.addOption(field, 'B - NEWBORN', 'B - NEWBORN');
    g_form.addOption(field, 'C - INTERMEDIATE/BO', 'C - INTERMEDIATE/BO');
    g_form.addOption(field, 'D - BIRTH ROOM/LDRP', 'D - BIRTH ROOM/LDRP');
    g_form.addOption(field, 'E - NICU B', 'E - NICU B');
    g_form.addOption(field, 'F - SEMIPRIVATE', 'F - SEMIPRIVATE');
    g_form.addOption(field, 'Y - ONE TIME', 'Y - ONE TIME');
    g_form.addOption(field, 'Z - BRL REGISTRATION', 'Z - BRL REGISTRATION');
    g_form.setDisabled(field, false);

  } else if (newValue == 'FMC') {
    // FMC options
    g_form.addOption(field, 'B - NEWBORN', 'B - NEWBORN');
    g_form.addOption(field, 'C - NURSERY-BORDER', 'C - NURSERY-BORDER');
    g_form.addOption(field, 'R - BIRTH ROOM/OBS', 'R - BIRTH ROOM/OBS');
    g_form.addOption(field, 'T - RECURRING', 'T - RECURRING');
    g_form.addOption(field, 'U - DAYSTAY', 'U - DAYSTAY');
    g_form.addOption(field, 'V - OBSERVATION', 'V - OBSERVATION');
    g_form.addOption(field, 'W - EMERGENCY', 'W - EMERGENCY');
    g_form.addOption(field, 'Y - ONE TIME', 'Y - ONE TIME');
    g_form.addOption(field, 'Z - BRL REGISTRATION', 'Z - BRL REGISTRATION');
    g_form.setDisabled(field, false);

  } else if (newValue == 'WING') {
    // WING options
    g_form.addOption(field, 'B - NEWBORN', 'B - NEWBORN');
    g_form.addOption(field, 'C - NURSERY-BORDER', 'C - NURSERY-BORDER');
    g_form.addOption(field, 'P - TELEMETRY', 'P - TELEMETRY');
    g_form.addOption(field, 'Q - OBS HIGH RISK', 'Q - OBS HIGH RISK');
    g_form.addOption(field, 'R - MATERNITY-OBS/S', 'R - MATERNITY-OBS/S');
    g_form.addOption(field, 'T - RECURRING', 'T - RECURRING');
    g_form.addOption(field, 'U - DAY STAY', 'U - DAY STAY');
    g_form.addOption(field, 'V - OBSERVATION', 'V - OBSERVATION');
    g_form.addOption(field, 'W - EMERGENCY', 'W - EMERGENCY');
    g_form.addOption(field, 'Y - ONE TIME', 'Y - ONE TIME');
    g_form.addOption(field, 'Z - BRL REGISTRATION', 'Z - BRL REGISTRATION');
    g_form.setDisabled(field, false);

  } else if (newValue == 'BNH') {
    // BNH options
    g_form.addOption(field, 'C - REHAB SEMIPRIVA', 'C - REHAB SEMIPRIVA');
    g_form.addOption(field, 'D - REHAB PRIVATE', 'D - REHAB PRIVATE');
    g_form.addOption(field, 'E - REHAB LOA', 'E - REHAB LOA');
    g_form.setDisabled(field, false);

  } else {
    // Not a recognized facility - keep field disabled and only the blank option
    g_form.clearOptions(field);
    g_form.addOption(field, '', '-- None --', 0);
    g_form.setDisabled(field, true);
  }

  // Always clear any previously selected value so no auto-selection occurs
  g_form.setValue(field, '');
}
5 REPLIES 5

Hi Ankur,

 

I am good. Hope you are doing good.

 

yeah I have tried but it didn't work. In meanwhile checked  with customer and changed the solution to on submit to only allow 10 checkboxes