}//END static convertEvOptionsList method

        // =================================================================================
        /// <summary>
        ///  This static method convert a list of EvFormField into a list of ClientClientDataObjectFields
        /// </summary>
        /// <param name="FormRecordFields">The list of EvFormField objects.</param>
        /// <param name="Section">The EvFormSection defining the section to be displayed.</param>
        /// <param name="EditStatus">Evado.UniForm.Model.EditAccess defining the field edit status.</param>
        /// <returns>ClientClientDataObjectGorup object</returns>
        // ---------------------------------------------------------------------------------
        public static Evado.UniForm.Model.Group convertListOfEvFormFields(
            List <Evado.Digital.Model.EdRecordField> FormRecordFields,
            Evado.Digital.Model.EdRecordSection Section,
            Evado.UniForm.Model.EditAccess EditStatus)
        {
            return(convertListOfEvFormFields(
                       FormRecordFields,
                       Section,
                       EditStatus,
                       Evado.UniForm.Model.GroupLayouts.Full_Width));
        }
    }//END getDataObject_GroupCommands Method

    // ==============================================================================
    /// <summary>
    /// This method returns a client application ResultData object
    /// </summary>
    /// <param name="PageObject">Evado.UniForm.Model.AppData object.</param>
    /// <returns>ClientApplicationData object</returns>
    //  ------------------------------------------------------------------------------
    private void getDataObject_DetailsGroup (
      Evado.UniForm.Model.Page PageObject )
    {
      this.LogMethod ( "getDataObject_DetailsGroup" );
      // 
      // Initialise the methods variables and objects.
      // 
      Evado.UniForm.Model.Field pageField = new Evado.UniForm.Model.Field ( );
      List<EvOption> optionList = new List<EvOption> ( );
      Evado.UniForm.Model.EditAccess adminAccess = Evado.UniForm.Model.EditAccess.Disabled;

      if ( this.Session.UserProfile.hasAdministrationAccess == true )
      {
        adminAccess = Evado.UniForm.Model.EditAccess.Enabled;
      }

      // 
      // create the page pageMenuGroup
      // 
      Evado.UniForm.Model.Group pageGroup = PageObject.AddGroup (
        String.Empty );
      pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Full_Width;
      pageGroup.EditAccess = Evado.UniForm.Model.EditAccess.Enabled;

      //
      // Add the group commands
      //
      this.getDataObject_GroupCommands ( pageGroup );

      // 
      // Create the customer id object
      // 
      pageField = pageGroup.createTextField (
        EdOrganisation.FieldNames.OrgId.ToString ( ),
        EdLabels.Label_Organisation_Id,
        String.Empty,
        this.Session.AdminOrganisation.OrgId, 10 );
      pageField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled;
      pageField.Layout = EuAdapter.DefaultFieldLayout;
      pageField.EditAccess = adminAccess;

      //
      // get the org type selection list.
      //
      optionList = this.AdapterObjects.Settings.GetOrgTypeList ( true );

      //
      // Generate the organisation type radio button list field object.
      //
      pageField = pageGroup.createSelectionListField (
        EdOrganisation.FieldNames.Org_Type.ToString ( ),
        EdLabels.Organisation_Type_Field_Label,
        EdLabels.Organisation_Type_Field_Description,
        this.Session.AdminOrganisation.OrgType,
        optionList );
      pageField.Layout = EuAdapter.DefaultFieldLayout;
      pageField.Mandatory = true;
      pageField.EditAccess = adminAccess;

      if ( this.Session.AdminOrganisation.OrgType == String.Empty )
      {
        pageField.setBackgroundColor (
          Evado.UniForm.Model.FieldParameterList.BG_Mandatory,
          Evado.UniForm.Model.Background_Colours.Red );
      }

      // 
      // Create the customer name object
      // 
      pageField = pageGroup.createTextField (
        EdOrganisation.FieldNames.Name.ToString ( ),
        EdLabels.Organisation_Name_Field_Label,
        this.Session.AdminOrganisation.Name,
        50 );
      pageField.Layout = EuAdapter.DefaultFieldLayout;
      pageField.Mandatory = true;

      pageField.setBackgroundColor (
        Evado.UniForm.Model.FieldParameterList.BG_Mandatory,
        Evado.UniForm.Model.Background_Colours.Red );

      // 
      // Create the customer name object
      //
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField ( EdOrganisation.FieldNames.Image_File_Name ) == false )
      {
        pageField = pageGroup.createImageField (
          EdOrganisation.FieldNames.Image_File_Name.ToString ( ),
          EdLabels.Organisation_ImageFileame_Field_Label,
          this.Session.AdminOrganisation.ImageFileName,
          300, 200 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;

        try
        {
          String stTargetPath = this.UniForm_BinaryFilePath + this.Session.AdminOrganisation.ImageFileName;
          String stImagePath = this.UniForm_ImageFilePath + this.Session.AdminOrganisation.ImageFileName;

          this.LogDebug ( "Target path {0}.", stTargetPath );
          this.LogDebug ( "Image path {0}.", stImagePath );

          //
          // copy the file into the image directory.
          //
          System.IO.File.Copy ( stImagePath, stTargetPath, true );
        }
        catch { }
      }
      else
      {
        this.Session.Organisation.ImageFileName = String.Empty;
      }

      // 
      // Create the street address 1
      //
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Address_1 ) == false )
      {
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_1,
          EdLabels.Organisation_Address_Street_Field_Label,
          this.Session.AdminOrganisation.AddressStreet_1, 50 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;

        // 
        // Create the street address 2
        // 
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_2,
          EdLabels.Organisation_Address_Street_Field_Label,
          this.Session.AdminOrganisation.AddressStreet_2, 50 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the street address city
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Address_City ) == false )
      {
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_City,
          EdLabels.Organisation_Address_City_Field_Label,
          this.Session.AdminOrganisation.AddressCity, 50 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the street address state
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Address_State ) == false )
      {
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_State,
          EdLabels.Organisation_Address_State_Field_Label,
          this.Session.AdminOrganisation.AddressState, 10 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the street address 1
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Address_Post_Code ) == false )
      {
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_Post_Code,
          EdLabels.Organisation_Address_City_Field_Label,
          this.Session.AdminOrganisation.AddressPostCode, 50 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the street address 1
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Address_Country ) == false )
      {
        pageField = pageGroup.createTextField (
          EdOrganisation.FieldNames.Address_Country,
          EdLabels.Organisation_Address_Country_Field_Label,
          this.Session.AdminOrganisation.AddressCountry, 50 );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the organisation telephone number object
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Telephone ) == false )
      {
        pageField = pageGroup.createTelephoneNumberField (
          EdOrganisation.FieldNames.Telephone.ToString ( ),
          EdLabels.Organisation_Telephone_Field_Label,
          this.Session.AdminOrganisation.Telephone );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      // 
      // Create the organisation fax number object
      // 
      if ( this.AdapterObjects.Settings.hasHiddenOrganisationField (
        EdOrganisation.FieldNames.Email_Address ) == false )
      {
        pageField = pageGroup.createEmailAddressField (
          EdOrganisation.FieldNames.Email_Address.ToString ( ),
          EdLabels.Organisation_Email_Field_Label,
          this.Session.AdminOrganisation.EmailAddress );
        pageField.Layout = EuAdapter.DefaultFieldLayout;
      }

      this.LogMethodEnd ( "getDataObject_DetailsGroup" );

    }//END getDataObject_DetailsGroup Method
    }//END getFormPropertiesObject method

    // ==============================================================================
    /// <summary>
    /// This method returns a client application ResultData object
    /// </summary>
    /// <param name="ClientDataObject">Evado.UniForm.Model.AppData object.</param>
    //  ------------------------------------------------------------------------------
    private void getPropertiesDataObject (
      Evado.UniForm.Model.AppData ClientDataObject )
    {
      this.LogMethod ( "getPropertiesDataObject" );

      // 
      // Initialise the client data object.
      // 
      if ( this.Session.EntityLayout.Guid != Guid.Empty )
      {
        ClientDataObject.Id = Guid.NewGuid ( );
        ClientDataObject.Title =
          String.Format ( EdLabels.Form_Page_Title,
            this.Session.EntityLayout.LayoutId,
            this.Session.EntityLayout.Title );
        ClientDataObject.Page.Id = ClientDataObject.Id;
        ClientDataObject.Page.PageDataGuid = ClientDataObject.Id;
        ClientDataObject.Page.PageId = this.Session.EntityLayout.LayoutId;
      }
      else
      {
        ClientDataObject.Id = Guid.NewGuid ( );
        ClientDataObject.Title = EdLabels.Form_Page_New_Form_Title;
        ClientDataObject.Page.Id = ClientDataObject.Id;
        ClientDataObject.Page.PageDataGuid = ClientDataObject.Id;
      }
      ClientDataObject.Page.EditAccess = Evado.UniForm.Model.EditAccess.Disabled;

      if ( this.Session.UserProfile.hasManagementAccess == true )
      {
        ClientDataObject.Page.EditAccess = Evado.UniForm.Model.EditAccess.Enabled;
      }
      //
      // initialise the methods variables and objects.
      //
      this._DesignAccess = ClientDataObject.Page.EditAccess;
        
      //
      // Design access is only available for un-issued layouts.  After issue
      // parameter changes can be made provided that don't change the data integrity.
      //
      if ( ( this.Session.EntityLayout.State == EdRecordObjectStates.Form_Issued
          || this.Session.EntityLayout.State == EdRecordObjectStates.Withdrawn )
        && ( this.Session.UserProfile.hasAdministrationAccess == false ) )
      {
        this._DesignAccess = Evado.UniForm.Model.EditAccess.Disabled;
      }

      //
      // Set the initial configuration access.
      //
      this._InitialAccess = this._DesignAccess;

      if ( this.Session.EntityLayout.Design.Version >= 1 )
      {
        this._InitialAccess = Evado.UniForm.Model.EditAccess.Disabled;
      }
      this.LogDebug ( "Design Access {0}, Initial Acccess {1}",
        this._DesignAccess, this._InitialAccess );



      //
      // Set the user's edit access if they have configuration edit access.
      //
      this.LogValue ( "HasConfigrationEditAccess: "
        + this.Session.UserProfile.hasManagementAccess );

      this.LogValue ( "GENERATE FORM" );

      this.GetDataObject_PageCommands ( ClientDataObject.Page );

      //
      // Add the page layout commands
      //
      this.GetDataObject_LayoutCommands ( ClientDataObject.Page );

      //
      // Add the general field properties pageMenuGroup.
      //
      this.getPropertiesPage_GeneralGroup ( ClientDataObject.Page );

      //
      // Add the settings group
      //
      this.getPropertiesPage_SettingGroup ( ClientDataObject.Page );

      //
      // Add the form sections properties pageMenuGroup.
      //
      this.getPropertiesPage_SectionsGroup ( ClientDataObject.Page );

    }//END getPropertiesDataObject Method
        // =================================================================================
        /// <summary>
        ///  This static method convert a list of EvFormField into a list of ClientClientDataObjectFields
        /// </summary>
        /// <param name="FormRecordFields">The list of EvFormField objects.</param>
        /// <param name="Section">The EvFormSection defining the section to be displayed.</param>
        /// <param name="EditStatus">Evado.UniForm.Model.EditAccess defining the field edit status.</param>
        /// <param name="GroupLayout">Evado.UniForm.Model.GroupLayouts defining the pageMenuGroup layout setting.</param>
        /// <returns>ClientClientDataObjectGorup object</returns>
        // ---------------------------------------------------------------------------------
        public static Evado.UniForm.Model.Group convertListOfEvFormFields(
            List <Evado.Digital.Model.EdRecordField> FormRecordFields,
            Evado.Digital.Model.EdRecordSection Section,
            Evado.UniForm.Model.EditAccess EditStatus,
            Evado.UniForm.Model.GroupLayouts GroupLayout)
        {
            EuConversions._Status = "Evado.UniForm.Clinical.Conversions.convertListOfEvFormFields method "
                                    + " Field Count: " + FormRecordFields.Count
                                    + " Section: " + Section
                                    + " EditStatus: " + EditStatus;

            //
            // Initialise the method variables and objects.
            //
            List <Evado.UniForm.Model.Field> pageFieldList = new List <Evado.UniForm.Model.Field> ( );

            Evado.UniForm.Model.Group pageGroup = new Evado.UniForm.Model.Group(
                Section.Title,
                String.Empty,
                EditStatus);
            pageGroup.Layout = GroupLayout;

            //
            // If null create empty object.
            //
            if (Section == null)
            {
                Section = new  Evado.Digital.Model.EdRecordSection( );
            }

            //
            // if section is empty no sections on the list.
            //
            if (Section.Title != String.Empty)
            {
                EuConversions._Status += "\r\nSection No: " + Section.No + ", Section: " + Section.Title;
                pageGroup              = new Evado.UniForm.Model.Group(
                    Section.Title,
                    Section.Instructions,
                    Evado.UniForm.Model.EditAccess.Inherited);
                pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Full_Width;
            }
            //
            // Iterate through the EV option list.
            //
            foreach (Evado.Digital.Model.EdRecordField field in FormRecordFields)
            {
                EuConversions._Status += "\r\nField: " + field.FieldId + ", Sectn: " + field.Design.SectionNo;

                //
                // IF the section is empty then there are no sections.
                // Process the fields in field order.
                //
                if (Section.Title == String.Empty)
                {
                    Evado.UniForm.Model.Field pageField = convertEvFormfield(field);

                    if (pageField != null)
                    {
                        EuConversions._Status += " >> NO SECTION FIELD CONVERTED";

                        pageGroup.FieldList.Add(pageField);
                    }
                }//END no section
                else
                {
                    //
                    // generate page fields for the fields in the selected section.
                    //
                    if (field.Design.SectionNo == Section.No)
                    {
                        EuConversions._Status = " >> SECTION SELECTED";
                        Evado.UniForm.Model.Field pageField = convertEvFormfield(field);

                        if (pageField != null)
                        {
                            EuConversions._Status = " >> FIELD CONVERTED";
                            pageGroup.FieldList.Add(pageField);
                        }
                    } //END section exists
                }
            }         //END Form field iteration loop.

            //
            // return the device option list.
            //
            return(pageGroup);
        }//END static convertEvOptionsList method