I have created a template for index page for medical policies. The medical policies are created with a template. This index takes the output medical policy files and takes the title of each and displays the title and is a link to that specific medical policy.
I have this working. My problem is I want to sort this alphabetically and also have a break between each letter's section.
Here is my code:
Default.tpl:
<?xml version="1.0" encoding="UTF-8" ?>
<iw_pt name="Medical Policies Index"><![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=utf-8">
<meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<title>Medical Policies - Wellmark</title>
<link rel="stylesheet" type="text/css" href="../../../../_includes/include.css">
<script language="JavaScript1.2">
<!--
var head="display:''"
function doit(header){
var head=header.style
if (head.display=="none")
head.display=""
else
head.display="none"
}
//-->
</script>
</head>
<body topmargin="0" leftmargin="0">
<!--#include virtual="/_includes/HeaderTop.asp" -->
<!--#include virtual="/_includes/HeaderMiddle_Prov.asp" -->
<!--#include virtual="/_includes/provider/HeaderBottom2_Prov_shared.htm" -->
<table BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
<tr>
<td><img src="/includes/images/spacer.gif" border="0" width="10" height="10" align="left"></td>
<td>
<td>
<center><h1><a name="top"></a>Medical Policies - Alphabetical Listing</h1></center>
<p>To find a medical policy, either browse our alphabetical list, or use
the <a href="../medical_policies.asp">Medical Policy Quick Search</a> to
search by key word or CPT code.</p>
<p align="center">
[ <a href="#A"> A</a> <a href="#B">B</a> <a href="#C">C</a>
<a href="#D">D</a> <a href="#E">E</a> <a href="#F">F</a>
<a href="#G">G</a> <a href="#H">H</a> <a href="#I">I</a>
<a href="#J">J</a> <a href="#K">K</a> <a href="#L">L</a>
<a href="#M">M</a> <a href="#N">N</a> <a href="#O">O</a>
<a href="#P">P</a> <a href="#Q">Q</a> <a href="#R">R</a>
<a href="#S">S</a> <a href="#T">T</a> <a href="#U">U</a>
<a href="#V">V</a> <a href="#W">W</a> <a href="#X">X</a>
<a href="#Y">Y</a> <a href="#Z">Z</a> ]</p>
]]><iw_perl><![CDATA[
#######################################################
### BEGIN - Code to list press releases.
###
my
@list = ("A","a","B","b","C","c","D","d","E","e","F","f","G","g","H","h","I","i","J","j","K","k","L","l","M","m","N","n","O","o","P","p","Q","q","R","r","S","s","T","t","U","u","V","v","W","w","X","x","Y","y","Z","z");
# read list of medical policies
my $tpl_dir = iwpt_get_pt_name('dirname');
my $do_ret = do "$tpl_dir\\pr_list.perl";
if (! defined $do_ret ) {
iwpt_output ( "one = $! <BR>" );
iwpt_output ( "two = $@ <BR>" );
}
# loop over medical policies
my $loop_counter = 0;
foreach my $prec (
@pr_list ) {
my $title = $gen_file->{title};
$title =~ s/<p>//;
(" $title\n");
$loop_counter++;
}
###
### END - Code to list medical policies.
#######################################################
]]></iw_perl><![CDATA[
</td>
</tr>
</table>
<!--#include virtual="/_includes/FooterBottom.asp" -->
</body>
</html>
]]>
</iw_pt>
pr_list.perl:
{
#######################################################
### parameters:
### none
#######################################################
### SETTINGS
use TeamSite::Config;
my $iwhome = TeamSite::Config::iwgethome();
my $rec_source="templatedata\\provider\\medical_policy\\data";
my $rec_destination="docroot\\e_business\\provider\\medicalpolicies\\policies";
#my $tpl_dir ="Y:/main/Internet/www/WORKAREA/Amelia_Adkins/templatedata/provider/index/presentation";
my $tpl_dir=iwpt_get_pt_name('dirname');
$tpl_dir =~ /^(.*)\\templatedata\\/;
my $area_dir = $1;
#######################################################
### Loop over files
opendir SCANDIR, $area_dir."\\".$rec_destination;
readdir(SCANDIR); readdir(SCANDIR);
my
@generated_files = readdir(SCANDIR);
closedir SCANDIR;
my
@list ;
my $count = 0;
foreach my $gen_file (
@generated_files ) {
#iwpt_output("looking at $area_dir\\$rec_destination\\$gen_file <BR>");
# gen_file is the filename of the generated file
chomp $gen_file;
# check if file is private
my $private_flag = qx($iwhome\\bin\\iwprv -g $area_dir\\$rec_destination\\$gen_file );
next if ($private_flag == 1);
# dcr_file is the filename of the dcr (relative to data)
my $dcr_file = "placeholder";
$dcr_file = qx($iwhome\\bin\\iwextattr -g TeamSite/Templating/PrimaryDCR $area_dir\\$rec_destination\\$gen_file );
chomp $dcr_file;
#######################################################
### If the file is a generated medical policy, add
### it to the list.
if (($dcr_file ne "") and -e "$area_dir\\$rec_source\\$dcr_file" ) {
# iwpt_output (" dcr = $dcr_file <BR> ");
#Create the dcr object, parse it
require TeamSite::XMLparser ;
my $dcr_fh = select DCR ;
open DCR, "<$area_dir\\$rec_source\\$dcr_file" ;
my $rootnode;
{
#iwpt_output($dcr_file);
local $/=undef ;
$dcr_data=<DCR> ;
close DCR ;
select $dcr_fh;
my $a_dcr = TeamSite::XMLparser->new() ;
$rootnode = $a_dcr->parse($dcr_data);
}
# Get the title
$list[$count]->{title} = $rootnode->value("Title");
$list[$count]->{file} = $gen_file;
$count++ ;
my $x = $rootnode->value("Title");
iwpt_output (" <a href=$gen_file>$x</a><br>\n");
}
}
#######################################################
}
Does anyone have any suggestion on how to do the alphabetical sort and breaking between each section and where it should be added within the code?
Amelia