                         SELECT
                             study_name,
                             lower(
-                                    item_group_oid
+                                item_group_oid
                             ) AS item_group_oid,
                             item_oid,
                             lower(
-                                    item_name
+                                item_name
                             ) AS item_name,
                             lower(
-                                    CASE
-                                    WHEN length(
-                                                 item_name_hint
-                                         ) > 57
-                                    THEN substr(
-                                            item_name_hint,
-                                            1,
-                                            57
-                                    )
-                                    ELSE item_name_hint
-                                    END
+                                CASE
+                                WHEN length(
+                                         item_name_hint
+                                     ) > 57
+                                THEN substr(
+                                    item_name_hint,
+                                    1,
+                                    57
+                                )
+                                ELSE item_name_hint
+                                END
                             ) AS item_name_hint,
                             item_data_type,
                             max(
-                                    item_form_order
+                                item_form_order
                             ) AS item_form_order,
                             max(
-                                    item_response_set_label
+                                item_response_set_label
                             ) AS item_response_set_label,
                             crf_null_values
                         FROM

                                        THEN item_oid
                                        ELSE
                                            lower(
                                                    FORMAT(
                                                            $$%1$s_%2$s$$,
                                                            substr(
                                                                    dm_clean_name_string(
                                                                            dm_meta.item_name),
                                                                    1,
                                                                    12
                                                            ),
                                                            substr(
                                                                    dm_clean_name_string(
                                                                            dm_meta.item_description),
                                                                    1,
                                                                    45
                                                            )
                                                    )
                                            )
                                        END
                                    ) AS item_name_hint,

CREATE OR REPLACE FUNCTION openclinica_fdw.dm_create_study_itemgroup_matviews(
    alias_views          BOOLEAN DEFAULT FALSE,
    filter_study_name    TEXT DEFAULT $$$$ :: TEXT,
    filter_itemgroup_oid TEXT DEFAULT $$$$ :: TEXT)
    RETURNS TEXT AS
    $BODY$
    DECLARE
        r RECORD;
    BEGIN
