gt:         List<Concept> concepts = new ArrayList<>();
context: /*
   * Copyright (c) The Trustees of Indiana University, Moi University
   * and Vanderbilt University Medical Center. All Rights Reserved.
   *
   * This version of the code is licensed under the MPL 2.0 Open Source license
   * with additional health care disclaimer.
   * If the user is an entity intending to commercialize any application that uses
   * this code in a for-profit venture, please contact the copyright holder.
   */
  
  package com.muzima.view.forms;
  
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.preference.PreferenceManager;
  import android.util.Log;
  import android.webkit.JavascriptInterface;
  import android.widget.Toast;
  
  import com.muzima.MuzimaApplication;
  import com.muzima.R;
  import com.muzima.api.model.CohortMember;
  import com.muzima.api.model.Concept;
  import com.muzima.api.model.Encounter;
  import com.muzima.api.model.FormData;
  import com.muzima.api.model.Location;
  import com.muzima.api.model.Observation;
  import com.muzima.api.model.Patient;
  import com.muzima.api.model.PatientIdentifier;
  import com.muzima.api.model.PatientTag;
  import com.muzima.api.model.Person;
  import com.muzima.api.model.PersonAttribute;
  import com.muzima.api.model.Provider;
  import com.muzima.api.model.Relationship;
  import com.muzima.api.model.RelationshipType;
  import com.muzima.api.model.SetupConfigurationTemplate;
  import com.muzima.controller.CohortController;
  import com.muzima.controller.ConceptController;
  import com.muzima.controller.FormController;
  import com.muzima.controller.LocationController;
  import com.muzima.controller.ObservationController;
  import com.muzima.controller.MuzimaSettingController;
  import com.muzima.controller.PatientController;
  import com.muzima.controller.PersonController;
  import com.muzima.controller.ProviderController;
  import com.muzima.controller.RelationshipController;
  import com.muzima.controller.SetupConfigurationController;
  import com.muzima.domain.Credentials;
  import com.muzima.model.location.MuzimaGPSLocation;
  import com.muzima.scheduler.RealTimeFormUploader;
  import com.muzima.service.HTMLFormObservationCreator;
  import com.muzima.service.MuzimaGPSLocationService;
  import com.muzima.service.MuzimaLoggerService;
  import com.muzima.utils.Constants;
  import com.muzima.utils.DateUtils;
  import com.muzima.utils.NetworkUtils;
  import com.muzima.utils.RelationshipJsonMapper;
  import com.muzima.utils.StringUtils;
  
  import net.minidev.json.JSONValue;
  
  import org.json.JSONException;
  
  import com.muzima.controller.EncounterController;
  
  import java.io.IOException;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.List;
  import java.util.TimeZone;
  
  import org.json.JSONArray;
  import org.json.JSONObject;
  
  import static com.muzima.utils.Constants.STANDARD_DATE_FORMAT;
  import static com.muzima.utils.Constants.STATUS_COMPLETE;
  import static com.muzima.utils.Constants.STATUS_INCOMPLETE;
  
  
  class HTMLFormDataStore {
  
      private final HTMLFormWebViewActivity formWebViewActivity;
      private final FormController formController;
      private final LocationController locationController;
      private final ConceptController conceptController;
      private final ObservationController observationController;
      private final FormData formData;
      private final ProviderController providerController;
      private final EncounterController encounterController;
      private final MuzimaApplication application;
      private final MuzimaSettingController settingController;
      private final CohortController cohortController;
      private final PatientController patientController;
      private final PersonController personController;
  
      public HTMLFormDataStore(HTMLFormWebViewActivity formWebViewActivity, FormData formData, boolean isFormReload, MuzimaApplication application) {
          this.formWebViewActivity = formWebViewActivity;
          this.formData = formData;
  
          this.formController = application.getFormController();
          this.providerController = application.getProviderController();
          this.locationController = application.getLocationController();
          this.settingController = application.getMuzimaSettingController();
          this.conceptController = application.getConceptController();
          this.encounterController = application.getEncounterController();
          this.observationController = application.getObservationController();
          this.cohortController = application.getCohortController();
          this.patientController = application.getPatientController();
          this.personController = application.getPersonController();
          this.application = application;
          logFormStartEvent(isFormReload);
      }
  
      @JavascriptInterface
      public String getStatus() {
          return formData == null ? StringUtils.EMPTY : formData.getStatus();
      }
  
      @JavascriptInterface
      public void saveHTML(String jsonPayload, String status) {
          saveHTML(jsonPayload, status, false);
      }
  
      @JavascriptInterface
      public void saveHTML(String jsonPayload, String status, boolean keepFormOpen) {
          jsonPayload = injectUserSystemIdToEncounterPayload(jsonPayload);
          jsonPayload = injectTimeZoneToEncounterPayload(jsonPayload);
          jsonPayload = injectActiveSetupConfigUuidToEncounterPayload(jsonPayload);
          Log.e(getClass().getSimpleName(),jsonPayload);
          formData.setJsonPayload(jsonPayload);
          formData.setStatus(status);
          String patientUuid = formData.getPatientUuid();
          boolean encounterDetailsValidityStatus = true;
          try {
              if (status.equals("complete")) {
                  encounterDetailsValidityStatus = areMandatoryEncounterDetailsInForm(jsonPayload);
              }
  
              if (encounterDetailsValidityStatus) {
                  if (isRegistrationComplete(status)) {
                      Patient newPatient = formController.createNewPatient(application, formData);
                      formData.setPatientUuid(newPatient.getUuid());
                      formWebViewActivity.startPatientSummaryView(newPatient);
                  }
                  if(formData.getDiscriminator() != null && (formData.getDiscriminator().equals(Constants.FORM_JSON_DISCRIMINATOR_RELATIONSHIP))) {
                      formData.setDiscriminator(Constants.FORM_JSON_DISCRIMINATOR_INDIVIDUAL_OBS);
                      parseObsFromCompletedForm(jsonPayload, status, true);
                  } else if(formData.getDiscriminator() != null &&
                          (formData.getDiscriminator().equals(Constants.FORM_JSON_DISCRIMINATOR_INDIVIDUAL_OBS))) {
  
                      if(personController.getPersonByUuid(patientUuid) != null) {
                          parseObsFromCompletedForm(jsonPayload, status, true);
                      } else {
                          parseObsFromCompletedForm(jsonPayload, status, false);
                      }
                  } else if(formData.getDiscriminator() != null &&
                          (formData.getDiscriminator().equals(Constants.FORM_JSON_DISCRIMINATOR_PERSON_UPDATE))) {
  
                      Person updatePerson = personController.getPersonByUuid(patientUuid);
                      if(updatePerson != null) {
                          formController.updatePerson(application,formData);
                          parseObsFromCompletedForm(jsonPayload, status, true);
                      } else {
                          formController.updatePatient(application, formData);
                          parseObsFromCompletedForm(jsonPayload, status, false);
                      }
                  } else if(status.equals("complete") && formData.getDiscriminator() != null &&
                          formData.getDiscriminator().equals(Constants.FORM_JSON_DISCRIMINATOR_DEMOGRAPHICS_UPDATE)){
                      Patient updatedPatient = formController.updatePatient(application, formData);
                      if(updatedPatient != null) {
                          parseObsFromCompletedForm(jsonPayload, status, false);
                          formWebViewActivity.startPatientSummaryView(updatedPatient);
                      }
                  } else {
                      parseObsFromCompletedForm(jsonPayload, status, false);
                  }
  
                  Date encounterDate = getEncounterDateFromForm(jsonPayload);
                  formData.setEncounterDate(encounterDate);
                  formController.saveFormData(formData);
                  formWebViewActivity.setResult(FormsWithDataActivity.RESULT_OK);
                  if (status.equals("complete")) {
                      JSONObject jsonObject = new JSONObject(jsonPayload);
                      JSONObject jsonObjectInner = jsonObject.getJSONObject("patient");
                      Log.e(getClass().getSimpleName(),jsonObjectInner.toString());
                      if(jsonObjectInner.has("patient.tagName") && jsonObjectInner.has("patient.tagUuid")) {
                          Log.e(getClass().getSimpleName(),"Form Has both tag fields");
                          List<PatientTag> tags = new ArrayList<PatientTag>();
                          Patient patient = patientController.getPatientByUuid(patientUuid);
                          for (PatientTag tag : patient.getTags()) {
                              tags.add(tag);
                          }
  
                          PatientTag tag = new PatientTag();
                          tag.setName(jsonObjectInner.getString("patient.tagName"));
                          tag.setUuid(jsonObjectInner.getString("patient.tagUuid"));
                          tags.add(tag);
                          patient.setTags(tags.toArray(new PatientTag[tags.size()]));
                          patientController.updatePatient(patient);
                          patientController.savePatientTags(tag);
                      }
                  }
                  if (!keepFormOpen) {
                      formWebViewActivity.finish();
                      if (status.equals("complete")) {
                          Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.info_form_data_save_success), Toast.LENGTH_SHORT).show();
                          RealTimeFormUploader.getInstance().uploadAllCompletedForms(formWebViewActivity.getApplicationContext(),false);
                      }
                      if (status.equals("incomplete")) {
                          Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.info_draft_form_save_success), Toast.LENGTH_SHORT).show();
                      }
                      logFormSaveEvent(status);
                  }
              } else {
                  String missingMandatoryEncounterDetailsMessage = checkMissingMandatoryEncounterDetails(jsonPayload);
                  String message = missingMandatoryEncounterDetailsMessage.concat(" ");
                  message = message.concat(formWebViewActivity.getString(R.string.message_missing_form_encounter_details_error));
  
                  formWebViewActivity.showMissingEncounterDetailsDialog(message);
              }
          } catch (FormController.FormDataSaveException e) {
              Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_save), Toast.LENGTH_SHORT).show();
              Log.e(getClass().getSimpleName(), "Exception occurred while saving form data", e);
          } catch (PatientController.PatientLoadException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while fetching patient", e);
          } catch (PersonController.PersonLoadException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while fetching person", e);
          } catch (PatientController.PatientSaveException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while saving patient", e);
          } catch (JSONException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while parsing object", e);
          } catch (IOException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while saving tags", e);
          } catch (FormController.FormDataProcessException e) {
              Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_data_processing), Toast.LENGTH_SHORT).show();
              Log.e(getClass().getSimpleName(), "Exception occurred while processing form data", e);
          }
      }
  
      @JavascriptInterface
      public String getLocationNamesFromDevice() {
          List<Location> locationsOnDevice = new ArrayList<>();
          try {
              locationsOnDevice = locationController.getAllLocations();
          } catch (LocationController.LocationLoadException e) {
              Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_location_load), Toast.LENGTH_SHORT).show();
              Log.e(getClass().getSimpleName(), "Exception occurred while loading locations", e);
          }
          return JSONValue.toJSONString(locationsOnDevice);
      }
  
      @JavascriptInterface
      public String getRelationships(String patientUuid){
          JSONArray relationshipsJsonArray = new JSONArray();
          RelationshipController relationshipController = ((MuzimaApplication)formWebViewActivity.getApplicationContext()).getRelationshipController();
          try {
              List<Relationship> relationships = relationshipController.getRelationshipsForPerson(patientUuid);
  
              for (Relationship relationship:relationships) {
                  JSONObject relationshipJsonObject = new JSONObject();
                  relationshipJsonObject.put("personA",relationship.getPersonA().getUuid());
                  relationshipJsonObject.put("personB",relationship.getPersonB().getUuid());
                  relationshipJsonObject.put("relationshipType",relationship.getRelationshipType().getUuid());
  
                  relationshipsJsonArray.put(relationshipJsonObject);
              }
          } catch (RelationshipController.RetrieveRelationshipException e) {
              Log.e(getClass().getSimpleName(), "Could not retrieve relationships",e);
          } catch (JSONException e) {
              Log.e(getClass().getSimpleName(), "Could not build relationships JSON",e);
          }
          return relationshipsJsonArray.toString();
      }
  
      @JavascriptInterface
      public String getRelationshipForPersons(String person1Uuid, String person2Uuid){
          JSONArray relationshipsJsonArray = new JSONArray();
          RelationshipController relationshipController = ((MuzimaApplication)formWebViewActivity.getApplicationContext()).getRelationshipController();
          try {
              List<Relationship> relationships = relationshipController.getRelationshipsForPerson(person1Uuid);
  
              for (Relationship relationship:relationships) {
                  if(StringUtils.equals(relationship.getPersonA().getUuid(), person2Uuid) ||
                          StringUtils.equals(relationship.getPersonB().getUuid(), person2Uuid)) {
                      JSONObject relationshipJsonObject = new JSONObject();
                      relationshipJsonObject.put("personA", relationship.getPersonA().getUuid());
                      relationshipJsonObject.put("personB", relationship.getPersonB().getUuid());
                      relationshipJsonObject.put("relationshipType", relationship.getRelationshipType().getUuid());
  
                      relationshipsJsonArray.put(relationshipJsonObject);
                  }
              }
          } catch (RelationshipController.RetrieveRelationshipException e) {
              Log.e(getClass().getSimpleName(), "Could not retrieve relationships",e);
          } catch (JSONException e) {
              Log.e(getClass().getSimpleName(), "Could not build relationships JSON",e);
          }
          return relationshipsJsonArray.toString();
      }
  
      @JavascriptInterface
      public String getRelationshipTypesFromDevice(){
          JSONArray relationshipsJsonArray = new JSONArray();
          try {
              List<RelationshipType> relationshipTypeList = application.getRelationshipController().getAllRelationshipTypes();
              for(RelationshipType relationshipType:relationshipTypeList){
                  try {
                      JSONObject relationshipJsonObject = new JSONObject();
                      relationshipJsonObject.put("uuid", relationshipType.getUuid());
                      relationshipJsonObject.put("AIsToB", relationshipType.getAIsToB());
                      relationshipJsonObject.put("BIsToA", relationshipType.getBIsToA());
                      relationshipsJsonArray.put(relationshipJsonObject);
                  } catch(JSONException e){
                      Log.e(getClass().getSimpleName(), "Exception occurred while populating relationship", e);
                  }
              }
          } catch (RelationshipController.RetrieveRelationshipTypeException e) {
              Log.e(getClass().getSimpleName(), "Exception occurred while loading relationships", e);
          }
          return relationshipsJsonArray.toString();
  
      }
  
      @JavascriptInterface
      public String getPersonAttribute(String patientUuid, String attributeTypeNameOrUuid) {
          JSONObject attributeJSONObject = new JSONObject();
          try {
              Person person = patientController.getPatientByUuid(patientUuid);
              if (person == null)
                  person = personController.getPersonByUuid(patientUuid);
  
              if(person != null) {
                  PersonAttribute attribute = person.getAttribute(attributeTypeNameOrUuid);
                  if (attribute != null) {
                      attributeJSONObject.put("attribute_type_uuid", attribute.getAttributeType().getUuid());
                      attributeJSONObject.put("attribute_type_name", attribute.getAttributeType().getName());
                      attributeJSONObject.put("attribute_value", attribute.getAttribute());
                  }
              }
          } catch (PersonController.PersonLoadException | PatientController.PatientLoadException | JSONException e) {
              Log.e(getClass().getSimpleName(), "Could not retrieve patient record",e);
          }
          return attributeJSONObject.toString();
      }
  
      @JavascriptInterface
      public String getPatientIdentifier(String patientUuid, String identifierType) {
          JSONObject identifierJSONObject = new JSONObject();
          try {
              Patient patient = patientController.getPatientByUuid(patientUuid);
              if(patient != null) {
                  PatientIdentifier identifier = patient.getIdentifier(identifierType);
                  if (identifier != null) {
                      identifierJSONObject.put("identifier_type_uuid", identifier.getIdentifierType().getUuid());
                      identifierJSONObject.put("identifier_type_name", identifier.getIdentifierType().getName());
                      identifierJSONObject.put("identifier_value", identifier.getIdentifier());
                  }
              }
          } catch ( PatientController.PatientLoadException | JSONException e) {
              Log.e(getClass().getSimpleName(), "Could not retrieve patient record",e);
          }
          return identifierJSONObject.toString();
      }
  
      @JavascriptInterface
      public String getPatientDetailsFromServerByUuid(String uuid){
          JSONObject patientJsonObject = new JSONObject();
          try {
              Patient patient = patientController.downloadPatientByUUID(uuid);
              if (patient != null) {
                  patientController.savePatient(patient);
                  patientJsonObject.put("uuid", patient.getUuid());
                  patientJsonObject.put("name", patient.getDisplayName());
                  patientJsonObject.put("identifier", patient.getIdentifier());
                  patientJsonObject.put("birth_date", DateUtils.getFormattedDate(patient.getBirthdate()));
                  patientJsonObject.put("birthdate_estimated", Boolean.toString(patient.getBirthdateEstimated()));
                  patientJsonObject.put("sex", patient.getGender());
                  patientJsonObject.put("attributes", patient.getAtributes());
                  patientJsonObject.put("addresses", patient.getAddresses());
              }
          } catch (PatientController.PatientDownloadException | JSONException | PatientController.PatientSaveException e) {
              Log.e(getClass().getSimpleName(), "Could not download patient record",e);
          }
          return patientJsonObject.toString();
      }
  
      @JavascriptInterface
      public String getPersonDetailsFromDeviceByUuid(String uuid){
          JSONObject personJsonObject = new JSONObject();
  
          try {
              Person person = personController.getPersonByUuid(uuid);
              if (person == null) {
                  person = patientController.getPatientByUuid(uuid);
              }
  
              if (person != null) {
                  personJsonObject.put("uuid", person.getUuid());
                  personJsonObject.put("name", person.getDisplayName());
                  personJsonObject.put("birth_date", DateUtils.getFormattedDate(person.getBirthdate()));
                  personJsonObject.put("sex", person.getGender());
                  personJsonObject.put("attributes", person.getAtributes());
                  personJsonObject.put("addresses", person.getAddresses());
              }
          } catch (PersonController.PersonLoadException | PatientController.PatientLoadException | JSONException e){
              Log.e(getClass().getSimpleName(), "Could not retrieve person record",e);
          }
          return personJsonObject.toString();
      }
  
      @JavascriptInterface
      public String searchPersons(String searchTerm, boolean searchServer) {
          if(searchServer){
              return searchPatientOnServer(searchTerm);
          } else {
              return searchPersonsLocally(searchTerm);
          }
      }
  
      @JavascriptInterface
      public String searchPersonsLocally(String searchTerm){
          JSONArray personsJsonArray = new JSONArray();
          try {
              List<Patient> patientsOnDevice = patientController.searchPatientLocally(searchTerm, null);
              for (Patient patient : patientsOnDevice) {
                  if (personController.getPersonByUuid(patient.getUuid()) == null)
                      personsJsonArray.put(createPatientJsonObject(patient));
              }
  
              List<Person> personsOnDevice = personController.searchPersonLocally(searchTerm);
              for (Person person:personsOnDevice){
                  personsJsonArray.put(createPersonJsonObject(person));
              }
          } catch (PersonController.PersonLoadException | PatientController.PatientLoadException e) {
              Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_provider_load), Toast.LENGTH_SHORT).show();
              Log.e(getClass().getSimpleName(), "Exception occurred while loading persons", e);
          } catch (JSONException e){
              Log.e(getClass().getSimpleName(), "Could not add person object into persons array", e);
          }
          return personsJsonArray.toString();
      }
  
      @JavascriptInterface
      public String searchPatientOnServer(String searchTerm){
          JSONArray patientsJsonArray = new JSONArray();
  
          if(searchTerm != null && searchTerm.length() >=3) {
              Credentials credentials = new Credentials(formWebViewActivity);
              Constants.SERVER_CONNECTIVITY_STATUS serverStatus = NetworkUtils.getServerStatus(formWebViewActivity, credentials.getServerUrl());
  
              List<Patient> patientList = new ArrayList<>();
              if (serverStatus == Constants.SERVER_CONNECTIVITY_STATUS.SERVER_ONLINE) {
                  patientList = patientController.searchPatientOnServer(searchTerm);
              }
              for (Patient patient : patientList) {
                  try {
                      patientsJsonArray.put(createPatientJsonObject(patient));
                  } catch (JSONException e) {
                      Log.e(getClass().getSimpleName(), "Could not add person object into persons array", e);
                  }
              }
          }
          return patientsJsonArray.toString();
      }
  
      private JSONObject createPatientJsonObject(Patient patient) throws JSONException {
          JSONObject patientJsonObject = new JSONObject();
          patientJsonObject.put("uuid", patient.getUuid());
          patientJsonObject.put("name", patient.getDisplayName());
          patientJsonObject.put("birth_date", DateUtils.getFormattedDate(patient.getBirthdate()));
          patientJsonObject.put("birthdate_estimated", Boolean.toString(patient.getBirthdateEstimated()));
          patientJsonObject.put("sex", patient.getGender());
          patientJsonObject.put("identifier", patient.getIdentifier());
          return patientJsonObject;
      }
  
      private JSONObject createPersonJsonObject(Person person) throws JSONException {
          JSONObject personJsonObject = new JSONObject();
          personJsonObject.put("uuid", person.getUuid());
          personJsonObject.put("name", person.getDisplayName());
          personJsonObject.put("birth_date", DateUtils.getFormattedDate(person.getBirthdate()));
          personJsonObject.put("birthdate_estimated", Boolean.toString(person.getBirthdateEstimated()));
          personJsonObject.put("sex", person.getGender());
          return personJsonObject;
      }
  
      @JavascriptInterface
      public String getProviderNamesFromDevice() {
          List<Provider> providersOnDevice = new ArrayList<>();
          try {
              providersOnDevice = providerController.getAllProviders();
          } catch (ProviderController.ProviderLoadException e) {
              Toast.makeText(formWebViewActivity, formWebViewActivity.getString(R.string.error_form_provider_load), Toast.LENGTH_SHORT).show();
              Log.e(getClass().getSimpleName(), "Exception occurred while loading providers", e);
          }
          return JSONValue.toJSONString(providersOnDevice);
      }
  
      @JavascriptInterface
      public String getDefaultEncounterProvider() {
          SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(formWebViewActivity.getApplicationContext());
          boolean encounterProviderPreference = preferences.getBoolean("encounterProviderPreference", false);
          List<Provider> providers = new ArrayList<>();
  
          if (encounterProviderPreference) {
              MuzimaApplication applicationContext = (MuzimaApplication) formWebViewActivity.getApplicationContext();
              providers.add(providerController.getProviderBySystemId(applicationContext.getAuthenticatedUser().getSystemId()));
              return JSONValue.toJSONString(providers);
          }
          return JSONValue.toJSONString(providers);
      }
  
      @JavascriptInterface
      public String getFontSizePreference() {
          SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(formWebViewActivity.getApplicationContext());
          return preferences.getString(formWebViewActivity.getResources().getString(R.string.preference_font_size),
                  HTMLFormWebViewActivity.DEFAULT_FONT_SIZE).toLowerCase();
      }
  
  
      private void parseObsFromCompletedForm(String jsonPayload, String status, boolean parseForPerson) {
          if (status.equals(Constants.STATUS_INCOMPLETE)) {
              return;
          }
  
          getFormParser(parseForPerson).createAndPersistObservations(jsonPayload, formData.getUuid());
      }
  
      public Date getEncounterDateFromForm(String jsonPayload) {
          return getFormParser().getEncounterDateFromFormDate(jsonPayload);
      }
  
      HTMLFormObservationCreator getFormParser(boolean parseAsPersonObs) {
          MuzimaApplication applicationContext = (MuzimaApplication) formWebViewActivity.getApplicationContext();
          return new HTMLFormObservationCreator(applicationContext, false, parseAsPersonObs);
      }
  
      HTMLFormObservationCreator getFormParser() {
          return getFormParser(false);
      }
  
      private boolean isRegistrationComplete(String status) {
          return formController.isRegistrationFormData(formData) && status.equals(Constants.STATUS_COMPLETE);
      }
  
      private boolean isRegistrationForm() {
          return formController.isRegistrationFormData(formData);
      }
  
      private boolean isEncounterForm() {
          return formController.isEncounterFormData(formData);
      }
  
      @JavascriptInterface
      public String getStringResource(String stringResourceName) {
          Context context = formWebViewActivity.getBaseContext();
          return context.getString(context.getResources().getIdentifier(stringResourceName, "string", context.getPackageName()));
      }
  
      @JavascriptInterface
      public String getConcepts() {
  