Example grid report template—CCSCHM search Chunk text with DSC scope search parameter usage
-
Create the following text template file and name it CCSCHM-Srch-Grid.tpl.
CCSCHM-Srch-Grid-using-Search-criteria.tpl{!-- Ventyx-Datasource-Aliases: RSSchemeSearch, SCH_OTHER --}
{.loop in $RSSchemeSearch as $SCH}
Scheme Code: {$SCH.Code}—{$SCH.Description}
{.onEmpty}
No RSScheme data found.
{/loop}
From the DSC:
Schemes:
{.loop in $SCH_OTHER as $SC_O}
{$SC_O.SCHEME}
{.onEmpty}
No other scheme data found.
{/loop}Since this report template is to create a report of the search results in the CCSCHM—Search Sample application, then the RSSchemeSearch data source is, by default, available to the report template. The report template also uses the SCH_OTHER data source, so a DSC file is required to build it. Therefore the template comprises the TPL file and the DSC file, that is, a ZIP file containing both these files.
-
Create the following file and name it CCSCHM-Srch-Grid-using-Search-criteria.dsc.
Note that, whilst most entities in CCLAS 6 can have either org-scope or lab-scope, Schemes can have either org-scope, enabled-scope (an org-scope scheme enabled for use in the lab) or lab-scope. Considering Client entities:
-
A Client entity with org-scope has ORGANISATION_CODE populated and LABORATORY_CODE empty.
-
A Client entity with lab-scope has ORGANISATION_CODE populated and LABORATORY_CODE populated.
However, considering Scheme entities:
-
A Scheme entity with org-scope has ORGANISATION_CODE populated and LABORATORY_CODE empty.
-
A Scheme with enabled-scope has ORGANISATION_CODE populated and LABORATORY_CODE populated.
-
A Scheme entity with lab-scope has ORGANISATION_CODE empty and LABORATORY_CODE populated.
The CCSCHM—Search Sample application also has an organisationCodes search criteria to allow schemes from other organisations to be searched for import into the current organisation.
So although the DSC has access to the :ORGCODE and :LABCODE parameters that contain the organisation code and laboratory code, respectively, of the current logged in user, it is not enough to search for schemes where the scheme's ORGANISATION_CODE matches the value of :ORGCODE and the scheme's LABORATORY_CODE matches the value of :LABCODE.
The following DSC shows how the searchScope and organisationCodes search parameters are considered when searching for schemes.
CCSCHM-Srch-Grid-using-Search-criteria.dsc<?xml version="1.0" ?>
<SQL>
<SQLQUERY>
<SQLTABLE>SCH_OTHER</SQLTABLE>
<SQLCOMMAND>
select
RPAD(S.ORGANISATION_CODE,20) || ' ' || RPAD(S.LABORATORY_CODE,20) || ' ' || RPAD(S.CODE,20) || ' ' || S.NAME AS SCHEME
from
CCSCHEME S
where
1 = case
{{when (^searchScope, 'A' =) and
((S.LABORATORY_ID = (select ID from CCLABORATORY where CODE = :LABCODE))
or ((S.LABORATORY_ID is null or S.LABORATORY_ID = ' ')
and S.ORGANISATION_ID in (select ID from CCORGANISATION where (^organisationCodes, CODE like))
)
)
then 1 }}
when {{(^searchScope, 'A' =)}} and
{{ '1' = q'[(^organisationCodes)]' and }}
((S.LABORATORY_ID = (select ID from CCLABORATORY where CODE = :LABCODE))
or ((S.LABORATORY_ID is null or S.LABORATORY_ID = ' ')
and S.ORGANISATION_ID = (select ORGANISATION_ID from CCLABORATORY LAB1 where LAB1.CODE =:LABCODE)
)
)
then 1
when {{(^searchScope, 'L' =)}} and S.LABORATORY_ID = (select ID from CCLABORATORY where CODE = :LABCODE)
then 1
{{when (^searchScope, 'O' =) and ((S.LABORATORY_ID is null or S.LABORATORY_ID = ' ')
and S.ORGANISATION_ID = (select ID from CCORGANISATION where (^organisationCodes, CODE like)))
then 1
}}
when {{(^searchScope, 'O' =)}} and ((S.LABORATORY_ID is null or S.LABORATORY_ID = ' ')
and S.ORGANISATION_ID = (select ORGANISATION_ID from CCLABORATORY LAB2 where LAB2.CODE =:LABCODE))
then 1
else 2
end
and S.CODE in (:GRIDCODES)
order by
S.CODE, S.ORGANISATION_CODE, S.LABORATORY_CODE
</SQLCOMMAND>
</SQLQUERY>
</SQL> -
-
Zip the CCSCHMSrch-Grid-using-Search-criteria.tpl and CCSCHM-Srch-Grid-using-Search-criteria.dsc file to create CCSCHM-Srch-Grid-using-Search-criteria.zip file.
-
Create the following report template using the CCTPLR—Report Template application:
Organisation Scope: Selected
Report Template Code: CCSCHM-SRCH-1
Name: CCSCHM Search Grid
Is Active: Selected
Type: 00—Grid
File: Upload the CCSCHM-Srch-Grid.tpl file
Report Engine: 03—Text
Default Output Format: TXT—Text
Output File Name: CCSCHM_Search_Results.txt
-
Create the following application preference using the CCPREF—Preference application:
Scope: Instance, or other scope to restrict the report template availability when performing the export to report.
Preference Name: SEARCH_REPORT_CCSCHM
Description: Sample search reports available
Setting Type: STRING
Setting Value: Add CCSCHM-SRCH-1:Schemes returned from search to the comma-separated list of available templates.
Preference Type: PREFERENCE
Is Active: Checked
-
Enter search criteria in the CCSCHM—Search Sample application and click Search.
Note: Until a search is performed, the Export to report button is unavailable. Entering new search criteria also makes this button unavailable.
-
Click Export to report to open the Export to Report dialog and enter the following report details:
Report Template Code: CCSCHM-SRCH-1
Download: Selected
-
Click OK to generate the grid report.
The RSSchemeSearch result set is provided from the CCSCHM—Scheme application to the report template.
The SCH_OTHER result set is built by the DSC.
-
Click the Click to download button, then click the button showing the name of the downloaded file to open and view the report.
