In [6]:
#DocX - TABLE Parser
#Infers a table with arbitrary number of columns from reoccuring patterns in text lines
#(c) Alexander Hirner 2016, no redistribution without permission

#Main assumptions Table identificatin:
#1) each row is either in one line or not a row at all
#2) each column features at least one number (=dollar amount)
#2a) each column features at least one date-like string [for time-series only]
#3) a table exists if rows are in narrow consecutive order and share similarities --> scoring algo [DONE] 
#4) each column is separated by more than x consecutive whitespace indicators (e.g. '  ' or '..')

#Feature List Todo:
#1) Acknowledge footnotes / make lower meta-data available
#2) make delimiter length smartly dependent on number of columns (possible iterative approach)
#3) improve captioning: expand non canonical values in tables [DONE] .. but not to the extent how types match up  --> use this to further
## delineate between caption and headers
#4) UI: parameterize extraction on the show page on the fly
#5) deeper type inference on token level: type complex [DONE], subtype header (centered, capitalized), 
## subtype page nr., type free flow [DONE, need paragraph]
#5a) re
#6) Respect negative values with potential '-' for numerical values
#7)
#8) classify tables with keywords (Muni Bonds) and unsupervised clustering (Hackathon)
#9) Restructure folder and URI around MD5 hash (http://stackoverflow.com/questions/24570066/calculate-md5-from-werkzeug-datastructures-filestorage-without-saving-the-object)

In [7]:
import re
import os
import codecs
import string
from collections import OrderedDict

config = { "min_delimiter_length" : 4, "min_columns": 2, "min_consecutive_rows" : 3, "max_grace_rows" : 3,
          "caption_assign_tolerance" : 10.0, "meta_info_lines_above" : 8, "threshold_caption_extension" : 0.45,
         "header_good_candidate_length" : 3, "complex_leftover_threshold" : 2, "min_canonical_rows" : 0.2}

In [8]:
import json
import sys

from flask import Flask, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename

from flask import jsonify, render_template, make_response
import numpy as np
import pandas as pd

In [51]:
#Regex tester online: https://regex101.com
#Contrast with Basic table parsing capabilities of http://docs.astropy.org/en/latest/io/ascii/index.html

tokenize_pattern = ur"[.]{%i,}|[\ \$]{%i,}|" % ((config['min_delimiter_length'],)*2)
tokenize_pattern = ur"[.\ \$]{%i,}" % (config['min_delimiter_length'],)
footnote_inidicator = ur"[^,_!a-zA-Z0-9.]"

column_pattern = OrderedDict()
#column_pattern['large_num'] = ur"\d{1,3}(,\d{3})*(\.\d+)?"
column_pattern['large_num'] = ur"(([0-9]{1,3})(,\d{3})+(\.[0-9]{2})?)"
column_pattern['small_float'] = ur"[0-9]+\.[0-9]+"
column_pattern['integer'] = ur"^\s*[0-9]+\s*$"
#column_patter['delimiter'] = "[_=]{6,}"
#column_pattern['other'] = ur"([a-zA-Z0-9]{2,}\w)"
column_pattern['other'] = ur".+"

subtype_indicator = OrderedDict()
subtype_indicator['dollar'] = ur".*\$.*"
subtype_indicator['rate'] = ur"[%]"
#enter full set of date patterns here if we want refinement early on
subtype_indicator['year'] = ur"(20[0-9]{2})|(19[0-9]{2})"

In [52]:
#import dateutil.parser as date_parser
#Implement footnote from levtovers
def tag_token(token, ws):
    for t, p in column_pattern.iteritems():
        result = re.search(p, token)
        if result:
            leftover = token[:result.start()], token[result.end():]
            lr = "".join(leftover)
            value = token[result.start():result.end()]
            
            if len(lr) >= config['complex_leftover_threshold']:
                return "complex", "unknown", token, leftover
            
            subtype = "none"
            #First match on left-overs
            for sub, indicator in subtype_indicator.iteritems():
                if re.match(indicator, lr): subtype = sub
            #Only if no indicator matched there, try on full token
            if subtype == "none":
                for sub, indicator in subtype_indicator.iteritems():
                    if re.match(indicator, token): subtype = sub
            #Only if no indicator matched again, try on whitespace
            if subtype == "none":
                for sub, indicator in subtype_indicator.iteritems():
                    if re.match(indicator, ws): subtype = sub
            #print token, ":", ws, ":", subtype
                        
            return t, subtype, value, leftover
    return "unknown", "none", token, ""
    
def row_feature(line):
    matches = re.finditer(tokenize_pattern, line)
    start_end = [ (match.start(), match.end()) for match in matches]
    #No delimiter found so it's free flow text
    if len(start_end) < 1:
        if len(line) == 0:
            return []
        else:
            return [{'start' : 0, 'value' : line, 'type' : 'freeform', 'subtype' : 'none'}]
    
    tokens = re.split(tokenize_pattern, line)
    if tokens[0] == "": 
        tokens = tokens[1:]
    else:
        start_end = [(0,0)] + start_end
    
    features = []
    for se, token in zip(start_end, tokens):
        t, subtype, value, leftover = tag_token(token, line[se[0]:se[1]])
        feature = {"start" : se[1], "value" : value, "type" : t, "subtype" : subtype, "leftover" : leftover}
        features.append(feature)
    return features

In [66]:
#Establish whether amount of rows is above a certain threshold and whether there is at least one number
def row_qualifies(row):
    return len(row) >= config['min_columns'] and sum( 1 if c['type'] in ['large_num', 'small_float', 'integer'] else 0 for c in row) > 0

def row_equal_types(row1, row2):
    same_types = sum (map(lambda t: 1 if t[0]==t[1] else 0, ((c1['type'], c2['type']) for c1, c2 in zip(row1, row2))))
    return same_types

In [67]:
#Non qualified rows arm for consistency check but are tolerated for max_grace_rows (whitespace, breakline, junk)
def filter_row_spans_new(row_features, row_qualifies=row_qualifies, ):    

    min_consecutive = config["min_consecutive_rows"]
    grace_rows = config['max_grace_rows']

    last_qualified = None    
    consecutive = 0
    underqualified = 0
    consistency_check = False
    i = 0
    for j, row in enumerate(row_features):
        
        qualifies = row_qualifies(row)
        if consistency_check:
            if not row_type_check(row_features[last_qualified], row):
                qualifies = False
            consistency_check = False
        #print qualifies, row_to_string(row)
        
        if qualifies:
            if last_qualified is None:
                last_qualified = i
                consecutive = 1
            else:
                consecutive += 1    
        else:
            underqualified += 1
            if underqualified > grace_rows:
                if consecutive >= min_consecutive:
                    
                    yield last_qualified, i-underqualified+1

                last_qualified = None                
                consecutive = 0
                underqualified = 0
                consistency_check = False
            else:
                if last_qualified: 
                    print "BENCHMARKING AGAINST:", row_to_string(row_features[last_qualified], 'type')
                    consistency_check = True
        i += 1
        
    if consecutive >= min_consecutive:
        yield last_qualified, i-underqualified
        
def row_to_string(row, key='value', sep='|'):
    return sep.join(c[key] for c in row)

def row_type_compatible(row_canonical, row_test):
    #Test whether to break because types differ too much
    no_fit = 0
    for c in row_test:
        dist = (abs(c['start']-lc['start']) for lc in row_canonical)
        val, idx = min((val, idx) for (idx, val) in enumerate(dist))
        if c['type'] != row_canonical[idx]['type']:
            no_fit += 1

    fraction_no_fit = no_fit / float(len(row_test))
    #print "test row", row_to_string(row_test), ") against types (", row_to_string(row_canonical, 'type'), ") has %f unmatching types" % fraction_no_fit    
    return fraction_no_fit < config["threshold_caption_extension"]

def filter_row_spans(row_features, row_qualifies):    

    min_consecutive = config["min_consecutive_rows"]
    grace_rows = config['max_grace_rows']

    last_qualified = None    
    consecutive = 0
    underqualified = 0
    underqualified_rows = [] #Tuples of row number and the row    
    
    i = 0
    
    for j, row in enumerate(row_features):
        if row_qualifies(row):
            underqualified = 0
            if last_qualified is None:
                last_qualified = i
                consecutive = 1
            else:
                consecutive += 1    
        else:
            underqualified += 1
            underqualified_rows.append((j, row) )
            if underqualified > grace_rows:
                if consecutive >= min_consecutive:
                    yield last_qualified, i-underqualified+1

                last_qualified = None
                consecutive = 0
                underqualified = 0
        #print i, underqualified, last_qualified, consecutive#, "" or row
        i += 1
        
    if consecutive >= min_consecutive:
        yield last_qualified, i-underqualified

In [68]:
def row_to_string(row, key='value', sep='|'):
    return sep.join(c[key] for c in row)

In [82]:
from collections import Counter

def readjust_cols(feature_row, slots):

    feature_new = [{'value' : 'NaN'}] * len(slots)
    for v in feature_row:
        dist = (abs((float(v['start'])) - s) for s in slots)
        val , idx = min((val, idx) for (idx, val) in enumerate(dist))
        if val <= config['caption_assign_tolerance']: feature_new[idx] = v

    return feature_new


def normalize_rows(rows_in, structure):
    slots = [c['start'] for c in structure] 
    nrcols = len(structure)
    
    for r in rows_in:
        if len(r) != nrcols:
            if len(r)/float(nrcols) > config['threshold_caption_extension']:          
                yield readjust_cols(r, slots)
        else:
            yield r

#TODO: make side-effect free
def structure_rows(row_features, meta_features):
    #Determine maximum nr. of columns
    lengths = Counter(len(r) for r in row_features)
    nrcols = config['min_columns']
    for l in sorted(lengths.keys(), reverse=True):
        nr_of_l_rows = lengths[l]
        if nr_of_l_rows/float(len(row_features)) > config['min_canonical_rows']:
            nrcols = l
            break
            
    canonical = filter(lambda r: len(r) == nrcols , row_features)
    
    for c in canonical: print len(c), row_to_string(c)
        
    structure = []
    for i in range(nrcols):
        col = {}
        col['start'] = float (sum (c[i]['start'] for c in canonical )) / len(canonical)
    
        types = Counter(c[i]['type'] for c in canonical)
        col['type'] = types.most_common(1)[0][0]
        subtypes = Counter(c[i]['subtype'] for c in canonical if c[i]['subtype'] is not "none")        
        subtype = "none" if len(subtypes) == 0 else subtypes.most_common(1)[0][0]
        col['subtype'] = subtype
        structure.append(col)

    #Test how far up the types are compatible and by that are data vs caption
    for r in row_features:
        #if r in canonical:
        if len(r) and row_type_compatible(structure, r):
            break
        else:
            meta_features.append(r)
            row_features.remove(r)
     
    meta_features.reverse()
    #for m in meta_features: print "META", row_to_string(m)
 
    captions = [''] * nrcols
    single_headers = []
    latest_caption_len = 1
    slots = [c['start'] for c in structure] 
    for mf in meta_features:
        #if we have at least two tokens in the line, consider them forming captions
        nr_meta_tokens = len(mf)
        if nr_meta_tokens > 1 and nr_meta_tokens >= latest_caption_len:
            #Find closest match: TODO = allow doubling of captions if it is centered around more than one and len(mf) is at least half of nrcols
            for c in mf:
                dist = (abs((float(c['start'])) - s) for s in slots)
                val, idx = min((val, idx) for (idx, val) in enumerate(dist))
                if val <= config['caption_assign_tolerance']: 
                    captions[idx] = c['value'] + ' ' + captions[idx]
                else: single_headers.append(c['value'])
            #latest_caption_len = nr_meta_tokens
        #otherwise, throw them into headers directly for now                                                                           
        else:
            #Only use single tokens to become headers, throw others away
            if len(mf) == 1: single_headers.append(mf[0]['value'])
    

    #Assign captions as the value in structure
    for i, c in enumerate(captions):
        structure[i]['value'] = c
    #Expand all the non canonical rows with NaN values (Todo: if types are very similar)
    normalized_data = [r for r in normalize_rows(row_features, structure)]            
    
    return structure, normalized_data, single_headers


def convert_to_table(rows, b, e, above):
    table = {'begin_line' : b, 'end_line' : e}

    data_rows = rows[b:e]
    meta_rows = rows[b-above:b]

    structure, data, headers = structure_rows(data_rows, meta_rows)

    captions = [(col['value'] if 'value' in col.keys() else "---") +"\n(%s, %s)" % (col['type'], col['subtype']) for col in structure]
    table['captions'] = captions
    table['data'] = data           
    table['header'] = " | ".join(headers)

    return table 

def indexed_tables_from_rows(row_features):
    
    #Uniquely identify tables by their first row
    tables = OrderedDict()
    last_end = 0
    for b,e in filter_row_spans(row_features, row_qualifies):
        #Slice out the next table and limit the context rows to have no overlaps
        #Todo: manage the lower meta lines
        tables[b] = convert_to_table(row_features, b, e, min(config['meta_info_lines_above'], b - last_end))
        last_end = tables[b]['end_line']
    return tables    
    
def return_tables(txt_path):
    
    #Uniquely identify tables by their first row
    tables = OrderedDict()
    
    with codecs.open(txt_path, "r", "utf-8") as f:
        lines = [l.replace(u'\n', '').replace(u'\r', '') for l in f]
        rows = [row_feature(l) for l in lines] 
        
        return indexed_tables_from_rows(rows)

def table_to_df(table):
    df = pd.DataFrame()
    for i in range(len(table['captions'])):
        values = []
        for r in table['data']:
            values.append(r[i]['value'])
        df[i] = values
    df.columns = table['captions']
    return df

Web App


In [83]:
# TITLE = "TabulaRazr (docX)"

scripts = []
css = [
    "./bower_components/bootstrap/dist/css/bootstrap.min.css",
    "./css/main.css",
    "./css/style.css"
]

import matplotlib.pyplot as plt

UPLOAD_FOLDER = './static/ug'
ALLOWED_EXTENSIONS = set(['txt', 'pdf'])

TITLE = "TabulaRazr"

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

def get_extension(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] 

def allowed_file(filename):
    return get_extension(filename) in ALLOWED_EXTENSIONS

@app.route('/', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        file = request.files['file']
        min_columns = request.form['min_columns']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            extension = get_extension(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], extension, filename))
            return redirect(url_for('uploaded_file',
                                    filename=filename, min_columns=min_columns))

    return render_template('index.html',
        title=TITLE ,
        css=css)

@app.route('/show/<filename>')
def uploaded_file(filename):
    extension = get_extension(filename)
    path = os.path.join(app.config['UPLOAD_FOLDER'], extension, filename)
    txt_path = os.path.join(app.config['UPLOAD_FOLDER'], 'txt', filename)
    if extension == "pdf":
        txt_path += '.txt'
        filename += '.txt'        
        if not os.path.isfile(txt_path):
            #Layout preservation crucial to preserve clues about tabular data
            cmd = "pdftotext -layout %s %s" % (path, txt_path)
            os.system(cmd)

    min_columns = request.args.get('min_columns')
    tables = return_tables(txt_path)

    #Construct histogram
    lines_per_page = 80
    nr_data_rows = []
    for b, t in tables.iteritems():
        e = t['end_line']
        #print b, e
        for l in range(b, e):
            page = l / lines_per_page
            if len(nr_data_rows) <= page:
                nr_data_rows += ([0]*(page-len(nr_data_rows)+1))
            nr_data_rows[page] += 1
    dr = pd.DataFrame()
    dr['value'] = nr_data_rows
    dr['page'] = range(0, len(dr))
    
    #plot the row density
    chart = filename+".jpg"
    fig, ax = plt.subplots( nrows=1, ncols=1, figsize=(8,3) )  # create figure & 1 axis
    ax.set_xlabel('page nr.')
    ax.set_ylabel('number of data rows')
    ax.set_title('Distribution of Rows with Data')
    ax.plot(dr['page'], dr['value'], )
    fig.savefig('./static/ug/'+chart)   # save the figure to file
    plt.close(fig)                      # close the figure

    #Create HTML
    notices = ['Extraction Results for ' + filename, 'Ordered by lines']    
    dfs = (table_to_df(table).to_html() for table in tables.values())
    headers = []
    for t in tables.values():
        if 'header' in t:
            headers.append(t['header'])
        else:
            headers.append('-')
    meta_data = [{'begin_line' : t['begin_line'], 'end_line' : t['end_line']} for t in tables.values()]

    return render_template('viewer.html',
        title=TITLE + ' - ' + filename,
        base_scripts=scripts, filename=filename,
        css=css, notices = notices, tables = dfs, headers=headers, meta_data=meta_data, chart='../static/ug/'+chart)

@app.route('/inspector/<filename>')
def inspector(filename):
    extension = 'txt'
    path = os.path.join(app.config['UPLOAD_FOLDER'], extension, filename)
    begin_line = int(request.args.get('data_begin'))
    end_line = int(request.args.get('data_end'))
    margin_top = config["meta_info_lines_above"]
    margin_bottom = margin_top
    
    notices = ['showing data lines from %i to %i with %i meta-lines above and below' % (begin_line, end_line, margin_top)]
    with codecs.open(path, "r", "utf-8") as file:
        lines = [l.encode('utf-8') for l in file][begin_line - margin_top:end_line + margin_bottom]
        top_lines = lines[:margin_top]
        table_lines = lines[margin_top:margin_top+end_line-begin_line]
        bottom_lines = lines[margin_top+end_line-begin_line:]
    
    offset = begin_line-margin_top
    table_id = begin_line
    
    return render_template('inspector.html',
        title=TITLE,
        base_scripts=scripts, css=css, notices = notices, filename=filename, top_lines=top_lines, 
        table_lines=table_lines, bottom_lines=bottom_lines, offset=offset, table_id=begin_line)

In [84]:
def run_from_ipython():
    try:
        __IPYTHON__
        return True
    except NameError:
        return False

if run_from_ipython():
    app.run(host='0.0.0.0', port = 7080) #Borrow Zeppelin port for now
else:
    app.run(debug=True, host='0.0.0.0', port = 80)


3 2013|555,000 5.000% 100.794%|339511DT1
3 2015|1,235,000 5.000% 105.314%|339511DV6
3 2018|5,150,000 3.750% 101.785%|339511DY0
3 2019|2,350,000 4.000% 101.655%|339511EA1
3 2019|3,000,000 5.000% 107.186%|339511DZ7
test row 2013|555,000 5.000% 100.794%|339511DT1 ) against types ( integer|complex|other ) has 0.000000 unmatching types
4 5,580,000|5.000|Term Bonds due July 1, 2023 Price 104.077% to Yield 4.500%|CUSIP†: 339510BQ1
4 8,355,000|5.250|Term Bonds due July 1, 2028 Price 102.796%* to Yield 4.900%|CUSIP†: 339510BR9
4 8,005,000|5.250|Term Bonds due July 1, 2039 Price 99.286% to Yield 5.300%|CUSIP†: 339510BT5
test row 5,580,000|5.000|Term Bonds due July 1, 2023 Price 104.077% to Yield 4.500%|CUSIP†: 339510BQ1 ) against types ( large_num|small_float|complex|other ) has 0.000000 unmatching types
5 2013|555,000|5.000|100.794|339511DT1
5 2015|1,235,000|5.000|105.314|339511DV6
5 2018|5,150,000|3.750|101.785|339511DY0
5 2019|2,350,000|4.000|101.655|339511DZ7
5 2019|3,000,000|5.000|107.186|339511EA1
5 9,790,000|3.500|Term Bonds due July 1, 2017|Price 101.976% to Yield 3.000%|CUSIP†: 339511DX2
5 8,560,000|4.750|Term Bonds due July 1, 2023|Price 102.027% to Yield 4.500%|CUSIP†: 339511EC7
5 5,950,000|4.750|Term Bonds due July 1, 2028|Price 97.347% to Yield 5.000%|CUSIP†: 339511ED5
test row 2013|555,000|5.000|100.794|339511DT1 ) against types ( integer|large_num|small_float|small_float|other ) has 0.000000 unmatching types
2 INTRODUCTION|1
2 THE SERIES 2013 BONDS|3
2 General|3
2 Discontinuation of Book-Entry System|3
2 Form and Denomination of and Payments on the Series 2013 Bonds|3
2 Redemption|4
2 BOOK-ENTRY SYSTEM|7
2 SECURITY FOR THE SERIES 2013 BONDS|9
2 General|9
2 Designated Affiliates|10
2 RATE AND LIQUIDITY COVENANTS|10
2 PARITY BONDS|11
2 PLAN OF FINANCE|12
2 THE AUTHORITY|12
2 Powers|12
2 Members of the Authority|12
2 ESTIMATED SOURCES AND USES OF FUNDS|13
2 ESTIMATED ANNUAL DEBT SERVICE REQUIREMENTS|14
2 HISTORICAL AND HISTORICAL PRO-FORMA DEBT SERVICE REQUIREMENTS|15
2 BONDHOLDERS’ RISKS|16
2 Introduction|16
2 Concerning the Medical Center’s Operations|16
2 Impact of Recent Economic Recession and Disruption of Credit Markets|17
2 Health Care Reform|18
2 Other Federal and State Regulations|21
2 Medicare|21
2 Medicaid|22
2 Private Health Plans and Insurers|23
2 Blue Cross and Blue Shield of Michigan|24
2 Factors Concerning Enforceability Generally|24
2 Changes in Health Care Delivery|24
2 Audits, Exclusions, Fines, Enforcement and Other Action|25
2 Malpractice Claims and General Liability Insurance|29
2 Workers’ Compensation|29
2 Failure to Obtain Certificates of Need|29
2 Licensing, Surveys, Investigations and Audits|30
2 Antitrust|30
2 Environmental Laws and Regulations|31
2 Certain Matters Relating to Security for the Series 2013 Bonds|31
2 Bankruptcy Filing|32
2 Additional Indebtedness|33
2 Tax-Exempt Status; Continuing Legal Requirements|33
2 Bond Ratings|33
2 Lack of Secondary Market for the Series 2013 Bonds|34
2 Other Risk Factors|34
2 LITIGATION|35
2 The Authority|35
test row INTRODUCTION|1 ) against types ( other|integer ) has 0.000000 unmatching types
2 The Medical Center|35
2 LEGAL MATTERS|36
2 TAX MATTERS|36
2 General|36
2 Tax Treatment of Accruals on Original Issue Discount Bonds|37
2 Amortizable Bond Premium|37
2 Future Developments|37
2 RATINGS|38
2 VERIFICATION OF MATHEMATICAL ACCURACY|38
2 FINANCIAL ADVISOR|39
2 FINANCIAL STATEMENTS|39
2 UNDERWRITING|39
2 CONTINUING DISCLOSURE|39
2 The Medical Center|39
2 The Authority|41
2 MISCELLANEOUS|41
test row The Medical Center|35 ) against types ( other|integer ) has 0.000000 unmatching types
4 2018|15,000|2021|1,300,000
4 2019|530,000|2022|1,365,000
4 2020|935,000|2023|1,435,000
test row 2018|15,000|2021|1,300,000 ) against types ( integer|large_num|integer|large_num ) has 0.000000 unmatching types
4 2024|1,505,000|2027|1,755,000
4 2025|1,580,000|2028|1,850,000
test row 2024|1,505,000|2027|1,755,000 ) against types ( integer|large_num|integer|large_num ) has 0.000000 unmatching types
4 2029|560,000|2035|755,000
4 2030|585,000|2036|795,000
4 2031|615,000|2037|840,000
4 2032|645,000|2038|880,000
4 2033|685,000|2039|930,000
test row 2029|560,000|2035|755,000 ) against types ( integer|large_num|integer|large_num ) has 0.000000 unmatching types
4 2024|1,085,000|2027|1,245,000
4 2025|1,130,000|2028|1,305,000
test row 2024|1,085,000|2027|1,245,000 ) against types ( integer|large_num|integer|large_num ) has 0.000000 unmatching types
4 Series 2013 Bond Proceeds|21,940,000|36,590,000|58,530,000
4 Net Original Issue Premium|403,947|625,543|1,029,489
4 TOTAL SOURCES OF FUNDS|22,343,947|40,697,444|63,041,391
test row Series 2013 Bond Proceeds|21,940,000|36,590,000|58,530,000 ) against types ( other|large_num|large_num|large_num ) has 0.000000 unmatching types
4 Debt Service Reserve Fund|1,873,159|3,659,000|5,532,159
4 Costs of Issuance (1)|484,451|734,762|1,219,213
4 TOTAL USES OF FUNDS|22,343,947|40,697,444|63,041,391
test row Bonds To Be Refunded|36,303,682|36,303,682 ) against types ( other|large_num|large_num|large_num ) has 0.000000 unmatching types
8  2018|15,000|1,137,900|5,150,000|1,126,350|1,304,904|2,343,084|11,077,237
8  2019|530,000|1,137,150|5,350,000|933,225|845,441|2,284,652|11,080,468
8  2020|935,000|1,110,650|5,590,000|689,225|500,000|2,251,825|11,076,700
8  2021|1,300,000|1,063,900|945,000|423,700|210,000|2,222,625|6,165,225
8  2022|1,365,000|998,900|990,000|378,813|225,000|2,207,925|6,165,638
8  2023|1,435,000|930,650|1,035,000|331,788|240,000|2,192,175|6,164,613
8  2024|1,505,000|858,900|1,085,000|282,625|260,000|2,175,375|6,166,900
8  2025|1,580,000|779,888|1,130,000|231,088|280,000|2,157,175|6,158,150
8  2026|1,665,000|696,938|1,185,000|177,413|300,000|2,137,575|6,161,925
8  2027|1,755,000|609,525|1,245,000|121,125|320,000|2,116,575|6,167,225
8  2028|1,850,000|517,388|1,305,000|61,988|335,000|2,094,175|6,163,550
8 TOTAL|21,940,000|17,467,109|36,590,000|10,973,783|50,216,476|51,754,195|188,941,563
test row  2013|338,209|555,000|385,296|5,028,007|2,966,827|9,273,339 ) against types ( integer|large_num|large_num|large_num|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 (Dollars in Thousands)|2010|2011|2012|(Annualized)
5 Expenses|5,150|4,607|4,230|774
5  Depreciation and Amortization|11,115|10,813|13,425|16,600
5  Interest Expense|3,713|3,840|4,441|5,682
5 Income Available for Debt Service|19,978|19,260|22,096|23,056
5 Historical Maximum Annual Debt Service Requirement|9,548|9,548|10,329|10,329
5 Maximum Annual Debt Service Coverage Ratio (x)|2.09|2.02|2.14|2.23
5 Requirement(2)|11,154|11,154|11,154|11,154
5 Pro-Forma Maximum Annual Debt Service Coverage Ratio (x)|1.79|1.73|1.98|2.07
test row (Dollars in Thousands)|2010|2011|2012|(Annualized) ) against types ( other|large_num|large_num|large_num|large_num ) has 0.800000 unmatching types
test row Revenues, Gains and Other Support in Excess of ) against types ( other|large_num|large_num|large_num|large_num ) has 1.000000 unmatching types
test row  Depreciation and Amortization|11,115|10,813|13,425|16,600 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
2 GENERAL BACKGROUND|1
2 Introduction|1
2 Historical Background and Facilities|1
2 MEDICAL CENTER AFFILIATES|2
2 Hurley Health Services|2
2 The Hurley Clinics|3
2 Hurley Practice Management Services|3
2 The Hurley Foundation|3
2 Genesys Hurley Cancer Institute|3
2 SERVICES AND PROGRAMS|4
2 Commitment to Community and Community Involvement|5
2 HONORS AND AWARDS|7
2 EDUCATIONAL PROGRAMS AND ACCREDITATIONS|8
2 STRATEGIC INITIATIVES|8
2 Innovative Access to Health Care|8
2 Community Health|9
2 Clinical Excellence|10
2 Academic Excellence|10
2 Physician Alignment|11
2 GOVERNANCE AND MANAGEMENT|12
2 Corporate Governance|12
2 Executive Management|14
2 SERVICE AREA|18
2 Population|20
2 Economic Activity|20
2 COMPETITION|23
2 MEDICAL STAFF|25
2 EMPLOYEES|30
2 Nursing Staff|30
test row GENERAL BACKGROUND|1 ) against types ( other|integer ) has 0.000000 unmatching types
2 HISTORICAL OPERATIONS|31
2 Licensed and Staffed Beds|31
2 Utilization|31
2 Sources of Patient Service Revenue|32
2 SUMMARY FINANCIAL INFORMATION|32
2 MANAGEMENT’S DISCUSSION OF FINANCIAL PERFORMANCE|35
2 Statement of Net Assets|35
2 Operating Income|35
2 Non-operating Revenues and Expenses|36
2 Capital Asset and Debt Administration|36
2 Historical and Pro Forma Maximum Annual Debt Service Coverage|37
2 Historical and Pro Forma Capitalization|38
2 Historical and Pro Forma Liquidity|39
2 LICENSES, ACCREDITATIONS AND MEMBERSHIPS|39
2 MALPRACTICE AND LIABILITY INSURANCE|40
test row HISTORICAL OPERATIONS|31 ) against types ( other|integer ) has 0.000000 unmatching types
2 Genesee County|88.9
2 Lapeer County|2.8
2 Shiawassee County|1.6
2 Oakland County|1.2
2 Saginaw County|1.1
2 Tuscola County|1.0
2 Other Counties|3.4
2 Total|100.0
test row Genesee County|88.9 ) against types ( other|small_float ) has 0.000000 unmatching types
4 Primary Service Area|124,943|112,900|-9.6%
4 Secondary Service Area|311,198|315,890|1.5
4 Genesee County|436,141|422,080|-3.2%
test row 2011|Percent Change ) against types ( other|large_num|large_num|complex ) has 1.000000 unmatching types
test row Estimate|2000-2011 ) against types ( other|large_num|large_num|complex ) has 1.000000 unmatching types
test row Secondary Service Area|311,198|315,890|1.5 ) against types ( other|large_num|large_num|complex ) has 0.250000 unmatching types
5 Hospital|2009|2010|2011|November 2012
5 City of Flint*|14.5|13.8|10.9|7.8
5 Michigan|13.4|12.6|10.3|8.9
5 National|9.3|9.6|8.9|7.8
test row Hospital|2009|2010|2011|November 2012 ) against types ( other|small_float|small_float|small_float|small_float ) has 0.800000 unmatching types
test row Michigan|13.4|12.6|10.3|8.9 ) against types ( other|small_float|small_float|small_float|small_float ) has 0.000000 unmatching types
4 Population|436,141|422,080|-3.22%
4 Households|170,030|164,683|-3.14%
4 Average Household Income|41,951|43,307|3.23
test row 2000|2011 Estimate|% Change ) against types ( other|large_num|large_num|complex ) has 1.000000 unmatching types
test row Population|436,141|422,080|-3.22% ) against types ( other|large_num|large_num|complex ) has 0.000000 unmatching types
3  Health Care & Social Assistance|22,132|19.89
3  Retail Trade|19,348|17.39
3  Accommodation & Food Services|11,895|10.69
3  Manufacturing|10,413|9.36
3  Administration & Support|8,895|8.00
3  Professional, Scientific & Technical|4,978|4.47
3  Wholesale Trade|4,765|4.28
3  Finance & Insurance|4,590|4.13
3  Public Administration|4,188|3.76
3  Other|3,975|3.57
3  Construction|3,385|3.04
3  Transportation & Warehousing|3,263|2.93
3  Information|3,263|2.93
3  Educational Services|2,700|2.43
3  Arts, Entertainment & Recreation|1,688|1.52
3  Real Estate, Rental & Leasing|1,335|1.20
3  Natural Resources & Mining|238|0.21
3  Management|222|0.20
3  TOTAL|111,273|100.00
test row  Health Care & Social Assistance|22,132|19.89 ) against types ( other|large_num|small_float ) has 0.000000 unmatching types
3 General Motors|7,000|Automotive
3 Genesys Health System|3,000|Healthcare
3 Hurley Medical Center|2,500|Healthcare
3 McLaren Medical Center|1,500|Healthcare
3 US Post Office|800|Government
3 Charles Stewart Mott College|750|Colleges & Universities
3 University of Michigan - Flint|750|Colleges & Universities
3 Meijer|700|Retail
3 Citizens Banking Corporation|600|Banking
test row General Motors|7,000|Automotive ) against types ( other|integer|other ) has 0.333333 unmatching types
4  Genesys Health System|31.5|30.4|30.2
4  Hurley Medical Center|28.5|28.0|27.4
4  McLaren Regional Medical Center|29.0|29.9|30.0
4  All Others|11.0|11.7|12.4
test row 2009|2010|2011 ) against types ( other|small_float|small_float|small_float ) has 1.000000 unmatching types
test row  Hurley Medical Center|28.5|28.0|27.4 ) against types ( other|small_float|small_float|small_float ) has 0.000000 unmatching types
4  Hurley Medical Center|Flint|414|-
4  McLaren Regional Medical Center|Flint|335|2 miles (8 min)
4  Genesys Regional Medical Center|Grand Blanc|410|13 miles (18 min)
test row  Hurley Medical Center|Flint|414|- ) against types ( other|other|integer|other ) has 0.000000 unmatching types
6 General Medicine|40%|36%|17%|5%|6,627
6 Cardiac Services|31%|47%|17%|5%|2,973
6 OB/GYN|64%|12%|22%|1%|2,406
6 Psychiatry|52%|41%|0%|6%|1,368
6 General Surgery|46%|29%|16%|9%|1,241
6 Neurosciences|41%|36%|15%|10%|1,236
6 Orthopedics|40%|28%|20%|11%|902
6 Neonatology - NICU|72%|5%|20%|4%|572
6 Oncology/Hematology|49%|24%|16%|11%|547
6 Vascular Services|29%|37%|22%|11%|476
6 Spine|28%|33%|26%|14%|316
6 Rehabilitation|47%|28%|20%|6%|305
6 ENT|57%|26%|10%|6%|259
6 Urology|23%|47%|12%|20%|230
6 Other Trauma|70%|19%|8%|4%|197
6 Other|27%|38%|16%|21%|139
test row Hurley|Genesys|2011 ) against types ( other|other|other|other|other|integer ) has 0.000000 unmatching types
2 Active|284
2 Courtesy|96
2 Consulting|38
2 Emeritus|2
2 Provisional|92
2 Leave of Absence|3
2 TOTAL|515
test row Active|284 ) against types ( other|integer ) has 0.000000 unmatching types
3 Medicine|138|26.8
3 Surgery|134|26.0
3 Pediatrics|87|16.9
3 Family Practice|43|8.4
3 Obstetrics/Gynecology|29|5.6
3 Emergency Medicine|28|5.4
3 Radiology|22|4.3
3 Psychiatry|9|1.7
3 Psychology|9|1.7
3 Anesthesiology|6|1.2
3 Pathology|5|1.0
3 Radiation Oncology|4|0.8
3 Pediatric Emergency Medicine|1|0.2
3 Total|515|100%
test row Medicine|138|26.8 ) against types ( other|integer|small_float ) has 0.000000 unmatching types
4 1. Internal Medicine|54|614|3.2(1)
4 2. Internal Medicine|61|598|3.1
4 3. OB/Gyn|55|405|2.1(2)
4 4. Internal Medicine/Peds|57|404|2.1
4 5. OB/Gyn|41|394|2.1(2)
4 6. Internal Medicine/Peds|54|385|2.0(1)
4 7. Psychiatry|70|361|1.9(3)
4 8. Pediatric Critical Care Medicine|53|358|1.9(4)
4 9. Pediatric Critical Care Medicine|61|348|1.8(4)
4 10. Neonatology|67|336|1.8
4 11. Geriatric Medicine|54|312|1.6
4 12. Pediatric Medicine|44|294|1.5
4 13. Surgical Critical Care|45|292|1.5
4 14. Internal Medicine Hospitalist|30|280|1.5
4 15. Obstetrics|39|276|1.5
4 16. Pediatric Medicine|71|273|1.4
4 17. Internal Medicine/Peds|39|268|1.4
4 18. Internal Medicine Hospitalist|35|266|1.4
4 19. Psychiatry|38|240|1.3(3)
4 20. Surgery, General|51|236|1.2
test row 1. Internal Medicine|54|614|3.2(1) ) against types ( other|integer|integer|small_float ) has 0.250000 unmatching types
6 Allergy / Immunology|6|68|0.0|-|1
6 Anesthesiology|6|54|0.0|-|-
6 Cardiology|22|52|0.4|5|4
6 Cardiothoracic Surgery|2|58|0.0|1|-
6 Clinical Psychology|1|60|0.0|-|-
6 Critical Care Medicine|1|35|0.0|1|-
6 Dentistry|1|32|0.0|-|-
6 Dermatology|3|55|0.0|-|1
6 Diagnostic Radiology|16|53|0.0|4|6
6 Emergency Medicine|29|43|0.4|5|11
6 Endocrinology|3|55|0.4|-|1
6 Family Practice|26|56|1.6|4|8
6 Gastroenterology|8|58|0.0|1|-
6 General Surgery|11|59|5.1|3|6
6 Geriatric Medicine|3|53|2.6|-|-
6 Hematology/Oncology|7|57|0.2|-|5
6 Infectious Disease|3|59|0.1|1|1
6 Internal Medicine|44|52|23.0|8|26
6 Internal Medicine / Pediatrics|16|51|9.7|-|1
6 Interventional Radiology|3|59|0.0|-|3
6 Maternal / Fetal Medicine|3|56|0.2|2|1
6 Neonatology|6|59|5.3|1|-
6 Nephrology|16|49|0.6|5|2
6 Neurological Surgery|3|55|0.4|-|1
6 Neurology|8|51|0.0|-|3
6 Neuropsychology|1|45|0.0|-|-
6 Neuroradiology|1|45|0.0|-|1
6 Obstetrics / Gynecology|25|54|16.2|2|5
6 Ophthalmic Plastic/Reconstructive Surgery|2|41|0.0|1|-
6 Ophthalmology|16|49|0.0|2|1
6 Oral & Maxillofacial Surgery|4|56|0.0|-|1
6 Orthopedic Surgery|14|50|2.9|5|1
6 Otolaryngology|9|60|0.3|-|-
6 Pathology|5|54|0.0|-|-
6 Pediatric Cardiology|3|52|0.0|-|3
6 Pediatric Critical Care Medicine|4|56|4.7|1|4
6 Pediatric Dentistry|11|49|0.0|2|-
6 Pediatric Endocrinology|4|63|0.1|-|-
6 Pediatric Gastroenterology|1|48|0.1|-|3
6 Pediatric Hematology / Oncology|4|59|1.5|-|-
6 Pediatric Infectious Disease|-|-|0.2|-|1
6 Pediatric Nephrology|5|47|0.0|2|1
test row Allergy / Immunology|6|68|0.0|-|1 ) against types ( other|integer|integer|small_float|other|integer ) has 0.000000 unmatching types
6 Pediatric Neurology|5|56|0.0|-|-
6 Psych|1|40|0.0|-|-
6 Pediatric Ophthalmology|4|52|0.0|4|-
6 Pediatric Psychology|-|-|0.0|-|1
6 Pediatric Pulmonology|5|49|0.0|2|1
6 Pediatric Surgery|9|50|0.0|8|6
6 Pediatrics|45|53|11.1|7|5
6 Physical Medicine & Rehabilitation|8|53|0.0|-|2
6 Plastic Surgery|5|58|0.4|2|-
6 Podiatry|14|48|0.0|1|1
6 Psychiatry|9|62|6.3|-|5
6 Psychology|6|47|0.0|3|5
6 Pulmonary Medicine|9|54|0.8|-|-
6 Pulmonary/Critical Care Medicine|1|41|0.0|1|2
6 Radiation Oncology|4|61|0.0|1|1
6 Reproductive Endocrinology|1|61|0.0|-|-
6 Rheumatology|3|62|0.3|-|1
6 Surgical Critical Care|4|47|3.7|1|1
6 Surgical Oncology|1|59|0.0|1|-
6 Telemedicine|-|-|0.0|-|3
6 Teleradiology|2|43|0.0|2|1
6 Thoracic Surgery|1|63|0.0|-|-
6 Trauma|2|49|0.7|3|1
6 Urology|9|57|0.1|-|-
6 Vascular Surgery|11|51|0.3|3|1
test row Pediatric Neurology|5|56|0.0|-|- ) against types ( other|integer|integer|small_float|integer|integer ) has 0.333333 unmatching types
3 CRNA|9|10
3 Nurse Practitioners|14|16
3 Physician Assistants|14|14
3 Prosthesis|6|3
test row CRNA|9|10 ) against types ( other|integer|integer ) has 0.000000 unmatching types
4 Type of Beds|2010|2011|2012
4 Behavioral Health|60|60|60
4 Burn Care|13|13|13
4 Coronary Care|13|13|13
4 General Medical/Surgical|171|171|171
4 Intensive Care|15|15|15
4 Neonatal Intensive Care|44|44|44
4 Neurotrama|18|18|18
4 Obstetrics|46|46|46
4 Pediatric|28|28|28
4 Pediatric Intensive Care|13|13|13
4 Physical Rehabilitation|22|22|22
4 Total Licensed Beds|443|443|443
4 Total Staffed Beds|414|414|414
test row Type of Beds|2010|2011|2012 ) against types ( other|integer|integer|integer ) has 0.000000 unmatching types
6 Licensed Beds|443|443|443|443|443
6 Discharges|21,438|19,956|19,083|9,428|9,281
6 Patient Days|107,366|106,863|99,822|49,346|49,010
6 Average Length of Stay (days)|5.01|5.35|5.23|5.23|5.28
6 Inpatient Surgeries|4,050|4,214|3,742|1,943|1,953
6 Observations|2,345|2,805|2,971|1,539|1,555
6 Emergency Room Visits|82,631|88,584|94,244|45,543|49,330
6 Other Outpatient Visits|296,735|300,993|310,539|148,677|156,525
6 Ambulatory Surgery Cases|6,735|6,553|6,557|3,216|2,930
6 Medicare Case Mix Index|1.61|1.61|1.56|1.60|1.61
test row 2010|2011|2012|2011|2012 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 1.000000 unmatching types
test row Licensed Beds|443|443|443|443|443 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.833333 unmatching types
test row Patient Days|107,366|106,863|99,822|49,346|49,010 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
6    Medicare|24.2|23.2|22.4|22.3|22.3
6    Medicare HMO|4.0|3.8|5.0|5.1|4.7
6    Medicaid|9.8|10.2|9.9|10.2|10.1
6    Medicaid HMO|27.4|29.1|29.5|29.7|29.6
6    Blue Cross|12.2|12.4|11.7|11.7|11.5
6    Commercial HMOs|6.7|6.4|6.1|5.9|5.5
6    All Others|15.7|14.9|15.4|15.1|16.3
6   Total Gross Revenue|100.0|100.0|100.0|100.0|100.0
test row 2010|2011|2012|2011|2012 ) against types ( other|small_float|small_float|small_float|small_float|small_float ) has 1.000000 unmatching types
test row    Medicare HMO|4.0|3.8|5.0|5.1|4.7 ) against types ( other|small_float|small_float|small_float|small_float|small_float ) has 0.000000 unmatching types
6 Net Patient Service Revenue|330,600|319,875|326,353|160,854|165,729
6 Other Operating Revenue|28,332|31,331|33,152|18,483|17,745
6 Total Operating Revenue|358,932|351,206|359,505|179,337|183,474
6    Amortization|11,115|10,813|13,425|6,765|8,300
6   Interest|3,713|3,840|4,441|1,819|2,841
6   All Other|340,480|335,573|345,074|172,716|172,636
6   Total Operating Expenses|355,308|350,226|362,940|181,300|183,777
6 Operations|3,624|980|(3,435)|(1,963)|(303)
6 Non-Operating Revenues|1,526|3,627|7,665|4,134|690
6 Expenses|5,150|4,607|4,230|2,171|387
test row 2010|2011|2012|2011|2012 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 1.000000 unmatching types
test row Other Operating Revenue|28,332|31,331|33,152|18,483|17,745 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
6 Assets|2010|2011|2012|2011|2012
6 Cash|25,373|7,129|2,601|14,486|6,384
6 Patient Accounts Receivables, Net|29,963|32,846|44,776|34,506|56,481
6 Other Receivables|12,983|11,975|13,394|14,476|9,687
6 Other Assets|9,601|11,899|12,172|11,931|11,901
6 Total Current Assets|77,920|63,849|72,943|75,399|84,453
6 Investments|67,689|77,561|67,381|75,350|57,883
6 Restricted|59,405|44,327|33,577|37,262|26,405
6 Total Other Assets|9,000|6,319|7,857|7,137|8,413
6 Property, Plant and Equipment, Net|73,245|95,341|114,337|100,331|113,940
6 Total Assets|287,259|287,397|296,095|295,479|291,094
test row Assets|2010|2011|2012|2011|2012 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.833333 unmatching types
test row Cash|25,373|7,129|2,601|14,486|6,384 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
6 Liabilities and Fund Net Assets|2010|2011|2012|2011|2012
6 Current Portion of Long-term Debt|3,285|3,965|4,823|4,170|4,649
6 Accounts Payable and Other|18,356|18,889|21,412|15,332|15,139
6 Accrued Expenses|54,255|53,065|50,605|62,168|57,605
6 Total Current Liabilities|75,896|75,919|76,840|81,670|77,393
6 Other Liabilities|32,421|31,085|35,245|29,457|32,368
6 Long-term Debt, Less Current Portion|86,918|83,179|83,276|84,137|79,000
6 Total Liabilities|195,235|190,183|195,361|195,264|188,761
6 Fund Net Assets|92,024|97,214|100,734|100,215|102,333
6 Total Liabilities and Fund Net Assets|287,259|287,397|296,095|295,479|291,094
test row Liabilities and Fund Net Assets|2010|2011|2012|2011|2012 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.833333 unmatching types
test row Current Portion of Long-term Debt|3,285|3,965|4,823|4,170|4,649 ) against types ( other|large_num|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 (Dollars in Thousands)|2010|2011|2012|2012
5 Expenses|5,150|4,607|4,230|774
5  Depreciation and Amortization|11,115|10,813|13,425|16,600
5  Interest Expense|3,713|3,840|4,441|5,682
5 Income Available for Debt Service|19,978|19,260|22,096|23,056
5 Historical Maximum Annual Debt Service Requirement|9,548|9,548|10,329|10,329
5 Maximum Annual Debt Service Coverage Ratio (x)|2.09|2.02|2.14|2.23
5 Pro-Forma Maximum Annual Debt Service Requirement|11,154|11,154|11,154|11,154
5 Pro-Forma Maximum Annual Debt Service Coverage Ratio (x)|1.79|1.73|1.98|2.07
test row (Dollars in Thousands)|2010|2011|2012|2012 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.800000 unmatching types
test row Revenues, Gains and Other Support in Excess of ) against types ( other|large_num|large_num|large_num|large_num ) has 1.000000 unmatching types
test row  Depreciation and Amortization|11,115|10,813|13,425|16,600 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 (Dollars in Thousands)|2010|2011|2012|2012
5 Outstanding Long-Term Debt|86,918|83,179|83,276|106,241
5 Unrestricted Net Assets|87,022|91,629|95,859|95,859
5 Total Capitalization|173,940|174,808|179,135|202,100
5 Long-Term Debt to Capitalization|50.0|47.6|46.5|52.6
test row (Dollars in Thousands)|2010|2011|2012|2012 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.800000 unmatching types
test row Outstanding Long-Term Debt|86,918|83,179|83,276|106,241 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 Cash and Cash Equivalents|2,601|6,384|10,101|13,884
5 Investments|67,381|57,883|67,381|57,883
5 Total|69,982|64,267|77,482|71,767
5 Total Operating Expenses|362,940|367,554|362,940|367,554
5   plus Bad Debt Expense|48,168|46,154|48,168|46,154
5  less Depreciation & Amortization|13,425|16,600|13,425|16,600
5 Total|397,683|397,108|397,683|397,108
5 Days Cash on Hand|64|59|71|66
5 Total Long Term Debt|83,276|79,000|106,241|101,965
5  Long Term Debt|84.04|81.35|72.9 %|70.4 %
test row 2012|2012|2012|2012 ) against types ( other|large_num|large_num|large_num|large_num ) has 1.000000 unmatching types
test row Cash and Cash Equivalents|2,601|6,384|10,101|13,884 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
2 Assets (Deficit)|8
2 Statement of Cash Flows|9-10
2 Statement of Net Assets|11
2 Statement of Changes in Net Assets|12
2    Notes to Financial Statements|13-41
2 Required Supplemental Information|42
2 Retirement System - Analysis of Funding Progress|43
2 Additional Information|44
2 Report Letter|45
2   Consolidating Balance Sheet|46-47
2   Consolidating Statement of Operations|48
test row Assets (Deficit)|8 ) against types ( other|integer ) has 0.000000 unmatching types
4  Current assets|72,943|63,848|77,919
4  Assets limited as to use|100,958|121,889|127,094
4  Capital assets|114,337|95,341|73,245
4  Other assets|7,857|6,319|9,001
4 Total assets|296,095|287,397|287,259
4   Current liabilities|76,840|75,919|75,896
4   Long-term debt|83,276|83,179|86,918
4   Accrued expenses|35,245|31,085|32,421
4 Total liabilities|195,361|190,183|195,235
4    related debt|44,058|36,750|27,185
4    operating activities|4,875|5,585|5,002
4  Unrestricted|51,801|54,879|59,837
4 Total net assets|100,734|97,214|92,024
test row 2012|2011|2010 ) against types ( other|large_num|large_num|large_num ) has 1.000000 unmatching types
test row  Current assets|72,943|63,848|77,919 ) against types ( other|large_num|large_num|large_num ) has 0.000000 unmatching types
4  Net patient service revenue|326,353|319,875|330,600
4  Other operating revenue|33,152|31,331|28,332
4 Total operating revenues|359,505|351,206|358,932
4  Salaries and wages|155,886|150,174|147,091
4  Employee benefits and payroll taxes|59,117|55,342|60,670
4  Operating supplies and expenses|42,256|42,703|44,073
4  Professional services|40,535|38,869|38,769
4  Purchased services and other|47,281|48,485|49,877
4  Depreciation and amortization|13,425|10,813|11,115
4 Total operating expenses|358,500|346,386|351,595
4 Nonoperating Revenues (Expenses)|2,094|(351)|(2,190)
4   Before Other Activity|3,099|4,469|5,147
4  unrestricted|421|721|(25)
4 Increase in Net Assets|3,520|5,190|5,122
4 Net Assets - End of year|100,734|97,214|92,024
test row 2012|2011|2010 ) against types ( other|large_num|large_num|large_num ) has 1.000000 unmatching types
test row  Net patient service revenue|326,353|319,875|330,600 ) against types ( other|large_num|large_num|large_num ) has 0.000000 unmatching types
5  Cash and cash equivalents|2,601,048|458,913|7,128,815|474,720
5 (Note 4)|44,776,227|203,121|32,845,914|291,519
5  Other receivables|6,134,811|668,016|5,274,848|396,707
5 settlements (Note 3)|7,259,116|-|6,700,021|-
5  Assets limited as to use (Note 5)|5,330,565|154,084|5,232,583|153,303
5  Prepaid expenses and other|2,336,387|140,495|2,441,796|551,506
5  Inventory|4,504,727|10,734|4,224,152|20,750
5 Total current assets|72,942,881|1,635,363|63,848,129|1,888,505
5  By the board|67,381,409|154,084|77,561,128|153,303
5  Held by trustee - Bond|18,020,907|-|29,540,804|-
5  Restricted and held in trust - Other|20,886,656|-|20,019,106|-
5 Total assets limited as to use|106,288,972|154,084|127,121,038|153,303
test row  Cash and cash equivalents|2,601,048|458,913|7,128,815|474,720 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 use is limited|100,958,407|-|121,888,455|-
5 Capital Assets - Net (Note 18)|114,336,841|205,733|95,341,253|257,290
5  Investment in joint ventures (Note 15)|6,776,600|6,000|5,175,260|6,000
5  Deferred defeasance loss - Net|336,567|-|414,052|-
5  Bond issue costs - Net|744,070|-|729,810|-
5  Other|-|150,000|-|150,000
5 Total assets|296,095,366|1,997,096|287,396,959|2,301,795
test row use is limited|100,958,407|-|121,888,455|- ) against types ( other|large_num|large_num|large_num|large_num ) has 0.400000 unmatching types
5 (Note 6)|4,823,007|-|3,965,000|-
5   Accounts payable and taxes withheld|21,412,199|1,183,059|18,889,233|289,213
5 settlements (Note 3)|16,555,939|-|18,994,846|-
5   Accrued expenses|34,048,769|930,953|34,069,497|745,068
5 Total current liabilities|76,839,914|2,114,012|75,918,576|1,034,281
5   portion (Note 6)|83,275,749|-|83,179,382|-
5 Accrued Expenses (Note 14)|35,245,413|-|31,084,862|-
5 Total liabilities|195,361,076|2,114,012|190,182,820|1,034,281
5 related debt|44,057,866|205,733|36,750,429|257,290
5 activities|4,874,957|-|5,584,506|-
5  Unrestricted|51,801,467|(322,649)|54,879,204|1,010,224
5 Total fund net assets|100,734,290|(116,916)|97,214,139|1,267,514
5 assets|296,095,366|1,997,096|287,396,959|2,301,795
test row (Note 6)|4,823,007|-|3,965,000|- ) against types ( other|large_num|large_num|large_num|large_num ) has 0.400000 unmatching types
5  Net patient service revenue|326,352,745|2,405,846|319,874,843|2,419,985
5  Other operating revenue|33,151,925|17,830,696|31,331,148|17,910,196
5 Total operating revenues|359,504,670|20,236,542|351,205,991|20,330,181
5  Salaries and wages|155,886,264|14,427,961|150,174,351|14,466,600
5  Employee benefits and payroll taxes|59,116,728|2,813,027|55,342,212|2,693,142
5  Operating supplies and expenses|42,255,917|-|42,702,389|-
5  Professional services|40,535,293|817,500|38,868,577|838,711
5  Purchased services and other|47,280,666|3,520,351|48,484,736|3,295,405
5  Depreciation and amortization|13,424,621|22,613|10,813,334|25,961
5 Total operating expenses|358,499,489|21,601,452|346,385,599|21,319,819
5 Net Operating Income (Loss)|1,005,181|(1,364,910)|4,820,392|(989,638)
5  Investment income (Note 5)|4,251,069|884|2,010,987|3,912
5  Joint venture income|2,281,471|-|1,469,880|-
5  Other income (expense)|2,000|(20,404)|8,302|(9,742)
5  Interest expense|(4,440,616)|-|(3,840,106)|-
5 (expenses)|2,093,924|(19,520)|(350,937)|(5,830)
test row  Net patient service revenue|326,352,745|2,405,846|319,874,843|2,419,985 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5   and Transfer of Funds|3,099,105|(1,384,430)|4,469,455|(995,468)
5   for the purchase of capital assets|1,130,591|-|137,734|-
5   Activity and Transfer of Funds|4,229,696|(1,384,430)|4,607,189|(995,468)
5 Restricted gifts and bequests|1,163,808|-|1,464,010|-
test row   and Transfer of Funds|3,099,105|(1,384,430)|4,469,455|(995,468) ) against types ( other|large_num|complex|large_num|complex ) has 0.000000 unmatching types
5 Increase (Decrease) in Net Assets|3,520,151|(1,384,430)|5,190,414|(995,468)
5 Fund Net Assets - Beginning of year|97,214,139|1,267,514|92,023,725|2,262,982
5 Fund Net Assets (Deficit) - End of year|100,734,290|(116,916)|97,214,139|1,267,514
test row Increase (Decrease) in Net Assets|3,520,151|(1,384,430)|5,190,414|(995,468) ) against types ( other|large_num|complex|large_num|large_num ) has 0.200000 unmatching types
5 activities|5,204,981|(24,449)|10,817,102|(625,108)
5    Capital contributed to joint ventures|(5,000)|-|(800,000)|-
5    Distributions from joint ventures|600,000|-|950,000|-
5    Proceeds on dissolution of joint venture|-|-|3,843,079|-
5    Sale of assets whose use is limited|43,501,473|-|37,206,086|-
5    Purchases of assets whose use is limited|(17,625,319)|(781)|(34,248,707)|(1,824)
5    Investment interest and realized (losses) gains|(718,036)|884|2,299,565|3,912
5 Net cash provided by investing activities|25,753,118|103|9,250,023|2,088
5    specific purposes|1,163,808|-|1,464,010|-
5 Proceeds from issuance of long-term debt|5,074,383|-|-|-
test row activities|5,204,981|(24,449)|10,817,102|(625,108) ) against types ( other|large_num|other|large_num|other ) has 0.400000 unmatching types
5 Proceeds from sale of capital assets|39,246|10,000|65,862|5,600
5 related financing activities|(36,649,674)|8,539|(39,774,932)|2,973
5 Net Decrease in Cash and Cash Equivalents|(4,527,767)|(15,807)|(18,243,797)|(620,047)
5 Cash and Cash Equivalents - Beginning of year|7,128,815|474,720|25,372,612|1,094,767
5 Cash and Cash Equivalents - End of year|2,601,048|458,913|7,128,815|474,720
test row Proceeds from sale of capital assets|39,246|10,000|65,862|5,600 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5 Operating income (loss)|1,005,181|(1,364,910)|4,820,392|(989,638)
5 Depreciation|13,424,621|22,613|10,813,334|25,961
5 Provision for bad debt|49,646,480|101,332|45,363,520|62,686
5 deferred defeasance gain|276,123|-|384,144|-
5 Loss on investment in assets|416,555|-|233,002|-
5 Contribution released from restrictions|(735,614)|-|(722,836)|-
5 settlements|(65,434,758)|(284,243)|(45,568,269)|275,979
5 Inventories|(280,575)|10,016|(107,741)|(8,593)
5 Prepaid expenses and other|110,409|411,011|(242,227)|18,055
5 Accounts payable and taxes withheld|2,522,966|893,847|533,166|62,320
5 Accrued expenses|4,253,593|185,885|(4,689,383)|(71,878)
5    joint venture|2,201,340|-|1,469,880|-
test row Operating income (loss)|1,005,181|(1,364,910)|4,820,392|(989,638) ) against types ( other|large_num|large_num|large_num|large_num ) has 0.400000 unmatching types
3   Cash and cash equivalents|6,560,791|10,705,507
3 Investment in common stock|8,759,309|17,481,605
3 Investment in corporate bonds|11,273,327|-
3 Investment in U.S. government or agency bonds|5,987,098|-
3 Investment in U.S. government CMOs|2,009,049|-
3 Total investments|28,028,783|17,481,605
3   Interest receivable|132,703|51
3 Total assets|34,722,277|28,187,163
3 Liabilities - Accrued expenses|3,286|4,397
3 Net Assets - Held in trust for retiree health benefits|34,718,991|28,182,766
test row   Cash and cash equivalents|6,560,791|10,705,507 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
3 Interest|99|606
3 Dividends|657,529|323,648
3 Realized loss on sale of investment|(820,545)|-
3 Net increase in fair value of investments|1,167,951|3,839,790
3 Less investment expense|(114,389)|(52,767)
3 Net investment income|890,645|4,111,277
3   Employer contributions|7,071,235|7,426,382
3   Retiree contributions|2,202,655|2,083,249
3 Total contributions|9,273,890|9,509,631
3 Total additions|10,164,535|13,620,908
3 Deductions - Benefits payments|3,628,310|6,968,249
3 Net Increase in Net Assets Held in Trust|6,536,225|6,652,659
3  Beginning of year|28,182,766|21,530,107
3   End of year|34,718,991|28,182,766
test row Interest|99|606 ) against types ( other|large_num|large_num ) has 0.666667 unmatching types
test row Realized loss on sale of investment|(820,545)|- ) against types ( other|large_num|large_num ) has 0.666667 unmatching types
test row Less investment expense|(114,389)|(52,767) ) against types ( other|large_num|large_num ) has 0.666667 unmatching types
test row Net investment income|890,645|4,111,277 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
3 charity care|7,743,423|7,441,341
3 patients served|2.16|2.15
test row 2012|2011 ) against types ( other|large_num|large_num ) has 1.000000 unmatching types
test row Charges foregone, based on established rates|23,603,003 $ 22,485,822 ) against types ( other|large_num|large_num ) has 0.500000 unmatching types
test row charity care|7,743,423|7,441,341 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
3 Medicare|17|18
3 Blue Cross/Blue Shield of Michigan|7|6
3 Medicaid|40|40
3 Other third-party payors and patients|36|36
3 Total|100|100
test row 2012|2011 ) against types ( other|integer|integer ) has 0.000000 unmatching types
3 Cash and cash equivalents|2,010,836|3,051,354
3 2011, respectively)|38,839,534|35,728,011
3 Accrued interest receivable|176,849|191,722
3 Cash and cash equivalents|394,833|3,426,385
3 respectively)|25,811,363|34,979,927
3 Accrued interest receivable|147,994|183,729
test row 2012|2011 ) against types ( other|large_num|large_num ) has 1.000000 unmatching types
test row improvements: ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
3 Cash and cash equivalents|18,020,760|20,541,254
3 9,085,000 in 2012 and 2011, respectively)|-|8,934,180
3 Accrued interest receivable|147|65,370
3 Total - Held by trustee - Bond|18,020,907|29,540,804
3 Restricted - Cash and cash equivalents|365,314|376,694
3 Cash and cash equivalents|1,486,881|1,678,011
3 2011, respectively)|18,578,932|17,524,653
3 Accrued interest receivable|142,322|137,707
3 Total - Held in trust - Self-insurance|20,208,135|19,340,371
3 Cash and cash equivalents|74,801|71,207
3 2012 and 2011)|238,406|230,933
3 Total - Held in trust - Retirement|313,207|302,140
3 trust - Other|20,886,656|20,019,106
test row 2012|2011 ) against types ( other|large_num|large_num ) has 1.000000 unmatching types
test row Cash and cash equivalents|18,020,760|20,541,254 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
5 Series 1998B|15,775,000|-|(540,000) 15,235,000|570,000
5 Series 2010|35,215,000|-|(500,000) 34,715,000|500,000
5 Unamortized bond discount   (2,065,618)|212,898|-|(1,852,720)|-
test row 2011|Additions|Reductions   2012|Year ) against types ( other|large_num|other|complex|large_num ) has 0.750000 unmatching types
test row Series 1998A|10,530,000|- $ (825,000) $ 9,705,000|870,000 ) against types ( other|large_num|other|complex|large_num ) has 0.250000 unmatching types
5 2010|Additions|Reductions|2011|Year
5 Series 1998B|16,290,000|-|(515,000) 15,775,000|540,000
5 Unamortized bond discount   (2,291,650)|226,032|-|(2,065,618)|-
test row 2010|Additions|Reductions|2011|Year ) against types ( integer|large_num|other|complex|other ) has 0.600000 unmatching types
test row Series 1998A|11,315,000|- $ (785,000) $ 10,530,000|825,000 ) against types ( integer|large_num|other|complex|other ) has 0.750000 unmatching types
test row Series 2003|29,675,000|-  (1,985,000) 27,690,000|2,100,000 ) against types ( integer|large_num|other|complex|other ) has 0.750000 unmatching types
test row Unamortized bond discount   (2,291,650)|226,032|-|(2,065,618)|- ) against types ( integer|large_num|other|complex|other ) has 0.400000 unmatching types
3 2016|5,575,310   4,420,881|9,996,191
3 2017|5,851,931   4,097,643|9,949,574
3 2018-2022|25,400,345 15,548,831|40,949,176
3 2023-2027|6,665,000 12,075,326|18,740,326
3 2038-2040|9,940,000|781,500   10,721,500
test row 2013|4,823,007 $ 5,300,755 $ 10,123,762 ) against types ( other|complex|large_num ) has 0.500000 unmatching types
test row 2015|5,309,983   4,728,698   10,038,681 ) against types ( other|complex|large_num ) has 0.500000 unmatching types
test row 2017|5,851,931   4,097,643|9,949,574 ) against types ( other|complex|large_num ) has 0.333333 unmatching types
3 OCPP|3.75|5.75
3 Exempt|4.50|6.50
3 Others|7.00|7.00
test row OCPP|3.75|5.75 ) against types ( other|small_float|small_float ) has 0.000000 unmatching types
6 6/30/10|6/30/08|13,041,452|90.7|8,896,382|11.45
6 6/30/11|6/30/09|9,450,745|100.0|5,505,003|8.41
test row 6/30/10|6/30/08|13,041,452|90.7|8,896,382|11.45 ) against types ( other|other|large_num|small_float|large_num|small_float ) has 0.000000 unmatching types
2 Annual required contribution|11,734,785
2 Interest on net pension obligation|384,594
2 Adjustment to annual required contribution|(310,504)
2 Annual pension cost|11,808,875
2 Contributions made|10,809,936
2 Increase in net pension obligation|998,939
2 Net pension obligation - Beginning of year|5,505,003
2 Net pension obligation - End of year|6,503,942
test row Annual required contribution|11,734,785 ) against types ( other|large_num ) has 0.000000 unmatching types
3 2013|1,582,368|275,300
3 2014|1,567,395|270,798
3 2015|1,521,009|246,703
3 2016|1,521,009|239,265
3 2017|1,455,821|239,265
3 Thereafter|2,812,468|618,102
3 required|10,460,070|1,889,433
test row 2013|1,582,368|275,300 ) against types ( integer|large_num|large_num ) has 0.000000 unmatching types
3 Corporate bonds|12,180,908|1,844,211 Counterparty trust dept.
3 Repurchase agreement|10,017|1,176,174 Counterparty
3 Mutual funds|238,406|230,933 Counterparty
test row Investment Type|2012|2011|How Held ) against types ( other|large_num|complex ) has 0.750000 unmatching types
test row Corporate stocks|8,759,309   17,481,605 Counterparty trust dept. ) against types ( other|large_num|complex ) has 0.500000 unmatching types
test row Repurchase agreement|10,017|1,176,174 Counterparty ) against types ( other|large_num|complex ) has 0.000000 unmatching types
3 GNMA pool|39,341|42,903 8.9 years
3 Corporate bonds|12,180,908|1,844,211 6.7 years
3 Repurchase agreement|10,017|1,176,174 Less than one year
test row Investment|2012|2011|Maturity ) against types ( other|large_num|complex ) has 0.750000 unmatching types
test row GNMA pool|39,341|42,903 8.9 years ) against types ( other|large_num|complex ) has 0.000000 unmatching types
4 Corporate bonds|1,854,305|1,844,211   AAA|S&P
4 Corporate bonds|4,552,095|-  AA+ - A-|S&P
4 Corporate bonds|5,218,339|-  BBB+ - B-|S&P
4 Corporate bonds|556,169|-|Not rated
4 Repurchase agreement|10,017|1,176,174|Not rated
test row Investment|2012|2011|Rating|Rating Organization ) against types ( other|large_num|other|other ) has 0.400000 unmatching types
3 Total assets|23,164|22,279
3 Total liabilities|9,946|11,404
3 Net assets|13,218|10,875
3 Operating revenue|10,429|10,531
3 Operating expenses|6,972|6,798
3 Operating income|3,457|3,733
3 Nonoperating income|61|96
3 Excess of revenues over expenses|3,518|3,829
test row 2012|2012 ) against types ( other|large_num|large_num ) has 1.000000 unmatching types
test row Total liabilities|9,946|11,404 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
2 2013|2,655,991
2 2014|104,640
2 2015|96,506
2 2016|87,183
2 2017|58,328
2 Total|3,002,648
test row 2013|2,655,991 ) against types ( integer|large_num ) has 0.000000 unmatching types
5 Land|4,460,723|32,219|-|4,492,942
5 Land improvements|1,660,968|425,000|(152,917)|1,933,051
5 Medical Center building|122,790,462|28,931,234|(1,161,626)|150,560,070
5 Parking structure|5,336,068|108,597|(424,087)|5,020,578
5 Nurses' residence|1,828,336|-|-|1,828,336
5 Interns' apartment|292,494|-|-|292,494
5 Prospect Street apartments|1,472,538|-|(11,132)|1,461,406
5 Power plant|3,884,377|-|(28,886)|3,855,491
5 Rental property|222,047|-|(20,592)|201,455
5 Health and fitness center|4,624,505|-|(10,556)|4,613,949
5 Park Plaza|1,254,271|3,771|-|1,258,042
5 Physicians' office building|340,691|-|-|340,691
5 Davison Clinic|1,956,771|-|-|1,956,771
5 Longway Eastside Campus building|3,643,756|-|-|3,643,756
5 MOB building|167,167|-|(14,365)|152,802
5 Fenton Medical Center|199,941|-|-|199,941
5 Machinery and equipment|78,067,161|33,946,932|(8,253,040)|103,761,053
5 Automotive equipment|374,762|-|(20,407)|354,355
5 Construction in progress|38,185,748|32,834,770|(63,406,513)|7,614,005
5 Total|270,762,786|96,282,523|(73,504,121)|293,541,188
test row 2011|Additions|Transfers|2012 ) against types ( other|large_num|other|complex|large_num ) has 0.750000 unmatching types
test row Land|4,460,723|32,219|-|4,492,942 ) against types ( other|large_num|other|complex|large_num ) has 0.400000 unmatching types
5 Land improvements|1,185,706|75,402|(128,319)|1,132,789
5 Medical Center building|95,310,026|4,034,251|(1,077,584)|98,266,693
5 Parking structure|4,740,547|93,816|(422,489)|4,411,874
5 Nurses' residence|1,601,110|55,976|-|1,657,086
5 Interns' apartment|288,418|2,582|-|291,000
5 Prospect Street apartments|1,234,282|20,634|(11,132)|1,243,784
5 Power plant|2,456,670|113,277|(28,886)|2,541,061
5 Rental property|220,325|689|(20,592)|200,422
5 Health and fitness center|4,557,266|7,362|(10,556)|4,554,072
5 Park Plaza|1,146,365|27,352|-|1,173,717
5 Physicians' office building|309,997|11,223|-|321,220
5 Davison Clinic|779,508|56,765|-|836,273
5 Longway Eastside Campus building|1,344,953|135,859|-|1,480,812
5 MOB building|35,662|19,506|(3,830)|51,338
5 Fenton Medical Center|56,200|22,121|-|78,321
5 Machinery and equipment|59,916,986|8,702,639|(7,918,013)|60,701,612
5 Automotive equipment|237,512|45,167|(20,406)|262,273
5 Total|175,421,533|13,424,621|(9,641,807)|179,204,347
5 Net carrying amount|95,341,253|82,857,902|(63,862,314)|114,336,841
test row 2011|Additions|Transfers|2012 ) against types ( other|large_num|large_num|complex|large_num ) has 1.000000 unmatching types
test row Less accumulated depreciation: ) against types ( other|large_num|large_num|complex|large_num ) has 0.000000 unmatching types
5 Land|4,460,723|-|-|4,460,723
5 Land improvements|1,648,758|78,480|(66,270)|1,660,968
5 Medical Center building|121,550,600|5,767,427|(4,527,565)|122,790,462
5 Parking structure|5,451,002|-|(114,934)|5,336,068
5 Nurses' residence|1,766,711|78,171|(16,546)|1,828,336
5 Interns' apartment|297,961|-|(5,467)|292,494
5 Prospect Street apartments|1,516,629|-|(44,091)|1,472,538
5 Power plant|3,902,678|26,710|(45,011)|3,884,377
5 Rental property|279,550|-|(57,503)|222,047
5 Health and fitness center|4,657,375|-|(32,870)|4,624,505
5 Park Plaza|1,272,534|-|(18,263)|1,254,271
5 Physicians' office building|347,603|-|(6,912)|340,691
5 Davison Clinic|1,956,771|-|-|1,956,771
5 Longway Eastside Campus building|3,643,756|-|-|3,643,756
5 MOB Building|167,167|-|-|167,167
5 Fenton Medical Center|183,090|16,851|-|199,941
5 Machinery and equipment|89,301,839|2,608,676|(13,843,354)|78,067,161
5 Automotive equipment|376,699|12,529|(14,466)|374,762
5 Construction in progress|13,566,515|33,184,576|(8,565,343)|38,185,748
5 Total|256,347,961|41,773,420|(27,358,595)|270,762,786
5 Land improvements|1,204,068|47,909|(66,271)|1,185,706
5 Medical Center building|96,266,464|3,451,134|(4,407,572)|95,310,026
5 Parking structure|4,755,702|99,780|(114,935)|4,740,547
5 Nurses' residence|1,566,643|51,014|(16,547)|1,601,110
5 Interns' apartment|291,303|2,582|(5,467)|288,418
5 Prospect Street apartments|1,257,739|20,634|(44,091)|1,234,282
5 Power plant|2,376,079|124,652|(44,061)|2,456,670
5 Rental property|277,138|689|(57,502)|220,325
5 Health and fitness center|4,473,859|107,577|(24,170)|4,557,266
5 Park Plaza|1,119,014|27,351|-|1,146,365
5 Physicians' office building|304,291|12,618|(6,912)|309,997
5 Davison Clinic|722,272|57,236|-|779,508
5 building|1,208,888|136,065|-|1,344,953
5 MOB building|15,678|19,984|-|35,662
5 Fenton Medical Center|34,641|21,559|-|56,200
5 Machinery and equipment|67,029,051|6,581,641|(13,693,706)|59,916,986
5 Automotive equipment|200,117|50,909|(13,514)|237,512
5 Total|183,102,947|10,813,334|(18,494,748)|175,421,533
5 Net carrying amount|73,245,014|30,960,086|(8,863,847)|95,341,253
test row 2010|Additions|Transfers|2011 ) against types ( other|large_num|large_num|complex|large_num ) has 1.000000 unmatching types
test row Land improvements|1,648,758|78,480|(66,270)|1,660,968 ) against types ( other|large_num|large_num|complex|large_num ) has 0.000000 unmatching types
5 Total|1,111,979|1,461|(122,021)|991,419
5 Leasehold improvements|159,423|7,980|(23,567)|143,836
5 Equipment and furnishings|695,266|14,633|(68,049)|641,850
5 Total|854,689|22,613|(91,616)|785,686
test row 2011|Additions|Transfers|2012 ) against types ( other|large_num|large_num|complex|large_num ) has 1.000000 unmatching types
test row Equipment and furnishings|790,252|1,461   (68,630)   723,083 ) against types ( other|large_num|large_num|complex|large_num ) has 0.333333 unmatching types
5 Total|1,280,505|2,627|(171,153)|1,111,979
5 Leasehold improvements|152,687|8,162|(1,426)|159,423
5 Equipment and furnishings|831,852|17,799|(154,385)|695,266
5 Total|984,539|25,961|(155,811)|854,689
test row 2010|Additions|Transfers|2011 ) against types ( other|large_num|large_num|complex|large_num ) has 1.000000 unmatching types
test row Equipment and furnishings|955,872|2,627  (168,247)  790,252 ) against types ( other|large_num|large_num|complex|large_num ) has 0.333333 unmatching types
8 6/30/99|12/31/97|301,060,938|259,985,429|41,075,509|115.8|87,651,874|-
8 6/30/00|12/31/98|322,497,186|281,563,941|40,933,245|114.5|96,417,303|-
8 6/30/01|12/31/99|340,608,779|306,134,487|34,474,292|111.3|107,246,608|-
8 6/30/02|12/31/00|354,306,658|328,489,881|25,816,777|107.9|105,102,019|-
8 6/30/03|12/31/01|367,058,240|333,802,804|33,255,436|110.0|103,411,340|-
8 6/30/04|12/31/02|357,836,531|399,476,922|(41,640,391)|89.6|103,802,756|40.1
8 6/30/05|12/31/03|357,836,531|399,476,922|(41,640,391)|89.6|103,802,756|40.1
8 6/30/06|6/30/04|338,311,878|430,746,829|(92,434,951)|78.5|110,096,227|84.0
8 6/30/07|6/30/05|341,965,387|431,927,509|(89,962,122)|79.2|108,969,869|82.6
8 6/30/08|6/30/06|345,781,209|459,693,895|(113,912,686)|75.2|104,097,308|109.4
8 6/30/10|6/30/07|358,057,840|497,351,883|(139,294,043)|72.0|111,456,399|125.0
8    6/30/2011|6/30/09|400,567,741|505,722,287|(105,154,546)|79.2|123,943,771|84.8
test row 6/30/99|12/31/97|301,060,938|259,985,429|41,075,509|115.8|87,651,874|- ) against types ( other|other|large_num|large_num|complex|small_float|large_num|small_float ) has 0.250000 unmatching types
6    Cash and cash equivalents|2,601,048|458,913|-|3,059,961|7,603,535
6    Patient accounts receivable - Net|44,776,227|203,121|-|44,979,348|33,137,433
6    Other receivables|6,134,811|668,016|(1,465,122)|5,337,705|5,157,182
6 settlements|7,259,116|-|-|7,259,116|6,700,021
6    Assets limited as to use|5,330,565|154,084|-|5,484,649|5,385,886
6    Prepaid expenses and other|2,336,387|140,495|-|2,476,882|2,993,302
6    Inventory|4,504,727|10,734|-|4,515,461|4,244,902
6 Total current assets|72,942,881|1,635,363|(1,465,122)|73,113,122|65,222,261
6    By the board|67,381,409|154,084|-|67,535,493|77,714,431
6    Held by trustee - Bond|18,020,907|-|-|18,020,907|29,540,804
6 Other|20,886,656|-|-|20,886,656|20,019,106
6 use|106,288,972|154,084|-|106,443,056|127,274,341
test row    Cash and cash equivalents|2,601,048|458,913|-|3,059,961|7,603,535 ) against types ( other|large_num|large_num|other|large_num|large_num ) has 0.000000 unmatching types
6 whose use is limited|100,958,407|-|-|100,958,407|121,888,455
6 Capital Assets - Net|114,336,841|205,733|-|114,542,574|95,598,543
6    Investment in joint ventures|6,776,600|6,000|-|6,782,600|5,181,260
6 Services|(116,916)|-|116,916|-|-
6    Deferred defeasance loss - Net|336,567|-|-|336,567|414,052
6    Bond issue costs - Net|744,070|-|-|744,070|729,810
6    Other|-|150,000|-|150,000|150,000
test row whose use is limited|100,958,407|-|-|100,958,407|121,888,455 ) against types ( other|large_num|other|other|large_num|large_num ) has 0.000000 unmatching types
6 debt|4,823,007|-|-|4,823,007|3,965,000
6 withheld|21,412,199|1,183,059|(1,465,122)|21,130,136|18,664,073
6 settlements|16,555,939|-|-|16,555,939|18,994,846
6    Accrued expenses|34,048,769|930,953|-|34,979,722|34,814,565
6 liabilities|76,839,914|2,114,012|(1,465,122)|77,488,804|76,438,484
6    portion|83,275,749|-|-|83,275,749|83,179,382
6 Accrued Expenses|35,245,413|-|-|35,245,413|31,084,862
6 Total liabilities|195,361,076|2,114,012|(1,465,122)|196,009,966|190,702,728
6 related debt|44,057,866|205,733|-|44,263,599|37,007,719
6 operating activities|4,874,957|-|-|4,874,957|5,584,506
6    Unrestricted|51,684,551|(322,649)|116,916|51,478,818|55,889,428
test row debt|4,823,007|-|-|4,823,007|3,965,000 ) against types ( other|large_num|large_num|other|large_num|large_num ) has 0.166667 unmatching types
6 allowances and discounts|374,520,869|2,405,846|-|376,926,715|367,930,032
6    Provision for bad debt|(48,168,124)|-|-|(48,168,124)|(43,210,387)
6 provision for bad debt|326,352,745|2,405,846|-|328,758,591|324,719,645
6 Other operating revenue|33,151,925|17,830,696|(17,291,641)|33,690,980|29,421,476
6 Total operating revenues|359,504,670|22,642,388|(17,291,641)|364,855,417|354,141,121
6    Salaries and wages|155,886,264|14,427,961|-|170,314,225|164,640,951
6    Employee benefits and payroll taxes|59,116,728|2,813,027|-|61,929,755|58,035,354
6    Operating supplies and expenses|42,255,917|-|-|42,255,917|42,702,389
6    Professional services|40,535,293|817,500|(12,274,986)|29,077,807|26,980,493
6    Purchased services and other|47,280,666|3,520,351|(5,016,655)|45,784,362|47,111,885
6    Depreciation and amortization|13,424,621|22,613|-|13,447,234|10,839,295
6    Interest expense|4,440,616|-|-|4,440,616|3,840,106
6 Total operating expenses|362,940,105|21,601,452|(17,291,641)|367,249,916|354,150,473
6 Net Operating Loss|(3,435,435)|1,040,936|-|(2,394,499)|(9,352)
6    Investment income|4,251,069|884|-|4,251,953|2,014,899
6 income|2,281,471|-|-|2,281,471|1,469,880
6    Other expense|2,000|(20,404)|-|(18,404)|(1,440)
6 (expense)|6,534,540|(19,520)|-|6,515,020|3,483,339
6 Activity and Transfer of Funds|3,099,105|1,021,416|-|4,120,521|3,473,987
6 Decrease in investment in Hurley Health Services|(1,384,430)|-|1,384,430|-|-
6 of capital assets|1,130,591|-|-|1,130,591|137,734
6 Transfer of Funds|2,845,266|(1,384,430)|1,384,430|2,845,266|3,611,721
6 Restricted gifts and bequests|1,163,808|-|-|1,163,808|1,464,010
test row Center|Services|Entries|Totals|2011 ) against types ( other|large_num|large_num|other|large_num|large_num ) has 0.800000 unmatching types
test row    Patient service revenue - Net of contractual ) against types ( other|large_num|large_num|other|large_num|large_num ) has 1.000000 unmatching types
test row    Provision for bad debt|(48,168,124)|-|-|(48,168,124)|(43,210,387) ) against types ( other|large_num|large_num|other|large_num|large_num ) has 0.666667 unmatching types
test row Net patient service revenue less ) against types ( other|large_num|large_num|other|large_num|large_num ) has 0.000000 unmatching types
6 Increase (Decrease) in Fund Net Assets|2,135,721|(1,384,430)|1,384,430|2,135,721|4,194,946
6 Fund Net Assets - Beginning of year|98,481,653|1,267,514|(1,267,514)|98,481,653|94,286,707
6 Fund Net Assets - End of year|100,617,374|(116,916)|116,916|100,617,374|98,481,653
test row Increase (Decrease) in Fund Net Assets|2,135,721|(1,384,430)|1,384,430|2,135,721|4,194,946 ) against types ( other|large_num|complex|large_num|large_num|large_num ) has 0.000000 unmatching types
5 Cash Equivalents|6,383,758|2,601,049|3,782,709|14,485,931
5 Receivable, net|56,481,149|44,776,227|11,704,922|34,505,934
5 Settlements Receivable|3,368,338|7,259,116|(3,890,778)|9,535,248
5 Receivable-Other|6,318,584|6,134,810|183,774|4,940,558
5 Expense|2,689,130|2,331,387|357,743|2,383,413
5 of Assets Whose Use is Limited|4,696,107|5,330,565|{634,458!|5,138,892
5 Current Assets|84,452,743|72,937,882|11,514,861|75,399,169
5 Assets Whose Use is Limited|84,288,534|100,958,406|(16,669,872}|112,611,571
5 and Equipment|301,444,755|293,541 '191|7,903,564|282,517,907
5 Plant and Equipment|113,940,407|114,336,843|(396,436)|100,331 ,273
5 Defeasance, net|301,298|336,567|(35,269)|375,310
5 Cost, net|791,525|744,070|47,455|796,721
5 lrm,m::t!TI<>ntc in Joint Ventures|7,319,819|6,781,600|538,219|5,965,260
5 Total Other Assets|8,412,642|7,862,237|550,405|7,137,291
test row Cash Equivalents|6,383,758|2,601,049|3,782,709|14,485,931 ) against types ( other|large_num|large_num|large_num|large_num ) has 0.000000 unmatching types
5   Portion of Debt|4,648,945|4,823,007|(174,062)|4,170,000
5 Payable|15,139,025|21,412,199|(6,273, 174)|15,331,633
5 Settlements Payable|16,555,939|16,555,939|0|18,994,846
5    Pension|8,370,001|6,821,509|1,548,492|9, 152,192
5 Expenses|32,679,190|27,227,259|5,451,931|34,021,041
5 Current Liabilities|77,393,100|76,839,913|553 187|81,669,712
5    Expenses|32,367,913|35,245,413|(2,877,500)|29,456,862
5 Current Portion|79,000,252|83,275,748|(4,275,496)|84,137,655
5 Noncurrent Liabilities|111,368,165|118,521 '161|(7, 152,996)|113,594,517
5 Total Net Assets|102,333,061|100,734,294|1,598,767|100,215,075
test row   Portion of Debt|4,648,945|4,823,007|(174,062)|4,170,000 ) against types ( other|large_num|large_num|complex|large_num ) has 0.000000 unmatching types
3 59.6|64.4|84.1
3 71.3|75.7|66.3
3 45.0|46.8|47.1
3 11.3|13.3|13.5
test row 59.6|64.4|84.1 ) against types ( small_float|small_float|small_float ) has 0.000000 unmatching types
8 13,057,060|-0.2%|Salaries and Wages|77,473,244|75,081,713|(2,391,531)|-3.2%|77,305,729
8 2,966,852|5.1|ProfesslonaJ Salaries|18,554,805|17,708,066|(846,739)|-4.8%|15,945,267
8    385,128|-23.6%|Agency|3,003,673|2,263,480|(720,193)|-31.5%|3,532,457
8  4,927.447|12.0|Payroll Taxes and Fringes|28,859,632|29,239,591|379,959|1.3|31,132,110
8 3,214,707|-5.3%|Medical Supplies|19,831,152|19,587,396|(243,756)|-1.2%|19,580,819
8    218,636|5.8|Supptles - Non-Clinical|1,313,764|1,340,496|26,732|2.0|1,448.46
8    298,498|23.3|Maintenance and Repairs|1,582,927|1,994,745|411,818|20.S%|1,634,'771
8    579,967|12.6|Utilities|3,222,117|3,688,550|466,443|12.6|2,999,226
8 3,174,990|0.8|Other Purchased Services|18,794,026|18,904,588|110,562|0.6|19,037,091
test row Inpatient Revenue|319,365,311|319,296,749|68,562|0.0|295,648,771 ) against types ( complex|small_float|other|large_num|large_num|large_num|complex|large_num ) has 0.166667 unmatching types
3 at the Beginning of the Year|95,859,334|91,629,638
3 of Revenue over Expense|387.454|2,170,960
test row at the Beginning of the Year|95,859,334|91,629,638 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
3 at the Beginning of the Year|4,874,960|5,584,502
3 :·,:|1,452,507|1,167,680
test row at the Beginning of the Year|4,874,960|5,584,502 ) against types ( other|large_num|large_num ) has 0.000000 unmatching types
4 (357,743)|58,307|finance activities|(4,449,558}
4 Accrued Expenses|2,574,431|4,012,567|Cash at the beginning of year
test row (357,743)|58,307|finance activities|(4,449,558} ) against types ( complex|large_num|large_num|complex ) has 0.500000 unmatching types
test row    Payable|(6,273,174)|(3,557,600)|Net Increase (decrease) in cash|3,782,709|7,357,117 ) against types ( complex|large_num|large_num|complex ) has 0.833333 unmatching types
test row Accrued Expenses|2,574,431|4,012,567|Cash at the beginning of year ) against types ( complex|large_num|large_num|complex ) has 0.500000 unmatching types
test row Cash at the end of the period ) against types ( complex|large_num|large_num|complex ) has 1.000000 unmatching types
test row 12,487,008|11,996,624 ) against types ( complex|large_num|large_num|complex ) has 0.500000 unmatching types
2 DEFINITIONS|1
2 SUMMARY OF CERTAIN PROVISIONS OF THE 2013 RESTATED CONTRACT OF LEASE|12
2 Term of Lease|12
2 Payment of Cash Rentals|12
2 Expenses and Fees|18
2 Acceleration|18
2 Maintenance of Hurley Medical Center|18
2 Insurance|18
2 Damage or Destruction|19
2 Condemnation; Title Insurance|20
2 General Conditions|21
2 Inspections|21
2 Covenant with Bondholders|21
2 Sale, Lease or Other Disposition of Property|21
2 Sale or Assignment of Leasehold|22
2 Release of Unimproved Property|23
2 Affiliate Guaranties|24
2 Affiliate Leases|26
2 Prevention of Affiliate Bankruptcies|29
2 Hurley Medical Center Rates|29
2 Liquidity Covenant|30
2 SUMMARY OF CERTAIN PROVISIONS OF THE INDENTURE|30
2 Application of Series 2013 Bond Proceeds|30
2 Indenture Funds|31
2 Redemption Fund|31
2 Debt Service Reserve Fund (Series 2013A)|31
2 Debt Service Reserve Fund (Series 2013B)|32
test row DEFINITIONS|1 ) against types ( other|integer ) has 0.000000 unmatching types
2 Authority Expense Fund|33
2 Series 2013A Special Fund|33
2 Series 2013B Special Fund|33
2 Series 2013A Rebate Fund|34
2 Series 2013B Rebate Fund|34
2 Acquisition Fund (2013 Project)|35
2 Deposit of Funds with Trustee|35
2 Nonarbitrage and Tax Covenants|35
2 Additional Bonds|36
2 Lien of Indenture|42
2 Default Provisions and Remedies of Trustee and Bondholders|43
2 Protection of Security|43
2 Trustee Remedies|43
2 Bondholder Remedies|44
2 Application of Funds|44
2 Action by Trustee|45
2 Rights of Bondholders|46
2 Supplemental Indentures|46
2 Bondholder Approval|47
2 Defeasance|47
test row Authority Expense Fund|33 ) against types ( other|integer ) has 0.000000 unmatching types

Tests


In [ ]:
test_string = u"""
   9
                                                 CITY OF OAKLAND
                        Management’s Discussion and Analysis (unaudited) (continued)
                                        Year Ended June 30, 2015


The following table indicates the changes in net position for governmental and business-type activities:

                                                 Statement of Activities
                                       For the Years Ended June 30, 2015 and 2014
                                                      (In Thousands)
                                                Governmental                 Business-Type
                                                  Activitie s                  Activities                         Total
                                               2015           2014          2015        2014               2015           2014
Reve nue s:
Program revenues:
  Charges for services                    $     182,293     $ 152,674   $    57,839    $    53,449    $     240,132     $ 206,123
  Operating grants and contributions             92,865       119,063             -              -           92,865       119,063
  Capital grants and contributions               70,322        42,148             -              -           70,322        42,148
General revenues:
  Property taxes                                267,534       240,779             -              -          267,534        240,779
    State taxes:
    Sales and use taxes                          63,895        58,912             -              -           63,895         58,912
    Gas tax                                      12,030        13,085             -              -           12,030         13,085
  Local taxes:
    Business license                             66,677        62,905             -              -           66,677         62,905
    Utility consumption                          50,594        50,422             -              -           50,594         50,422
    Real estate transfer                         62,665        59,060             -              -           62,665         59,060
    Transient occupancy                 6         21,569        18,468             -              -           21,569         18,468
    Parking                                      18,398        16,661             -              -           18,398         16,661
    Voter approved special tax                   37,443        38,835             -              -           37,443         38,835
    Franchise                                    18,150        16,666             -              -           18,150         16,666
  Interest and investment income                  6,362         6,653           142            165            6,504          6,818
  Other                                          12,745        19,671             -              -           12,745         19,671
Total revenues                                  983,542       916,002        57,981         53,614        1,041,523        969,616
Expenses:
 General government               $              82,493        79,806             -              -           82,493         79,806
 Public safety                                  383,904       379,809             -              -          383,904        379,809
 Community Services                             121,740       116,961             -              -          121,740        116,961
 Community & economic development                75,268        83,657             -              -           75,268         83,657
 Public works                                   105,619       109,177             -              -          105,619        109,177
 Interest on long-term debt                      68,033        59,026             -              -           68,033         59,026
 Sewer                                                -             -        36,957         37,306           36,957         37,306
 Parks and recreation                                 -             -           681            855              681            855
Total expenses                                  837,057       828,436        37,638         38,161          874,695        866,597

Change in net position before transfers         146,485        87,566        20,343         15,453          166,828        103,019
Transfers                                         2,002         2,002        (2,002)        (2,002)               -              -
Special Item - Transfer of excess tax
allocation bond                                 107,696        88,309             -              -          107,696         88,309
Change in net position                          256,183       177,877        18,341         13,451          274,524        191,328
Net position at beginning of year               981,818       803,941       196,334        182,883        1,178,152        986,824
Adjustment due to implementation of
GASB Statement No. 68                         (1,506,760)                   (32,236)                      (1,538,996)             -
Net position at end of year               $    (268,759)    $ 981,818   $ 182,439      $ 196,334      $     (86,320)    $ 1,178,152


Governmental activities: Net position for governmental activities, excluding the special item of
$107.7 million from ORSA transfer of excess bond proceeds to the City, decreased by $58.9 million during
fiscal year 2014-15. Total revenue increased by 7.4 percent and expenses increased by 1.0 percent. During
FY 2013-14, revenues increased at a rate of 10.8 percent and expenses increased by 5.6 percent.


""".split(u"\n")

In [ ]:
from IPython.display import display

rows = [row_feature(l) for l in test_string]

tables = indexed_tables_from_rows(rows)
for b, e in filter_row_spans(rows, row_qualifies):
    print b, row_to_string(rows[b]), " --> \n", e, row_to_string(rows[e])
    for i in range(b,e):
        print i, len(rows[i]), row_to_string(rows[i])

for begin_line, t in tables.iteritems():
    df = table_to_df(t)
    
    for d in t['data']: print row_to_string(d)
    
    for j in range(t['begin_line']-4, t['begin_line']):
        pass
        
    for j in range(t['begin_line'], t['end_line']):
        pass #print len(rows[j]), test_string[j], "|".join([c['type']+'_'+c['subtype'] for c in rows[j]])
    print t['header']
    display(df)

In [ ]:
test_string ="""
        The following table sets forth statistical information relating to the Water System during the five
Fiscal Years shown.
                                                 TABLE 1
                                   WATER SYSTEM STATISTICS
                                                                               Fiscal Year Ended June 30
                                                                  2014         2013       2012     2011      2010
Anaheim Population Served ..................................     348,305      346,161   343,793   341,034   336,265
Population Served Outside City (Est.) ...................          8,457        9,000     9,000     9,000     9,000
        Total Population Served ...........................      356,762      355,161   352,793   350,034   345,265

  Total Water Sales (Million Gallons) ...................         20,740       20,465    19,672    19,526    20,488

Capacity (Million Gallons Per Day)
  From MWD Connections ...................................             110       110       110       110       110
  From Water System Wells (Average) ...............                     79        86        88        81        75
        Total Supply Capacity .............................            189       196       198       191       185

   Treatment Plant Capacity ..................................          15        15        15        15        15

Peak Day Distribution (Million Gallons) ...............                82.2      78.7     79.2      87.2      87.2
Average Daily Distribution (Million Gallons) .......                   60.3      58.9     57.3      59.4      56.1
Average Daily Sales Per Capita (Gallons) .............                159.3     157.9    152.8     152.8     162.6
__________________
Source: Anaheim

Existing Facilities

""".decode('ascii', 'ignore').split("\n")

In [ ]:
test_string ="""
                         CALIFORNIA MUNICIPAL FINANCE AUTHORITY
                                   Revenue Bonds, Series 2015-A
                              (City of Anaheim Water System Project)

                                          MATURITY SCHEDULE

                                            $58,205,000 Serial Bonds

  Maturity Date              Principal                Interest
   (October 1)               Amount                     Rate                   Yield                  CUSIP†
       2015                 $ 775,000                 2.000%                   0.100%             13048TTV5
       2016                  1,575,000                2.000                    0.300              13048TTW3
       2017                  1,620,000                3.000                    0.660              13048TTX1
       2018                  1,675,000                4.000                    0.930              13048TTY9
       2019                  2,045,000                5.000                    1.150              13048TTZ6
       2020                  2,155,000                5.000                    1.320              13048TUA9
       2021                  2,250,000                4.000                    1.520              13048TUB7
       2022                  2,610,000                5.000                    1.670              13048TUC5
       2023                  2,730,000                4.000                    1.810              13048TUD3
       2024                  2,875,000                5.000                    1.920              13048TUE1
       2025                  3,025,000                5.000                    2.030(c)           13048TUF8
       2026                  3,190,000                5.000                    2.200(c)           13048TUG6
       2027                  3,355,000                5.000                    2.320(c)           13048TUH4
       2028                  3,520,000                5.000                    2.450(c)           13048TUJ0
       2029                  3,700,000                5.000                    2.520(c)           13048TUK7
       2030                  3,880,000                5.000                    2.600(c)           13048TUL5
       2031                  4,055,000                4.000                    3.140(c)           13048TUM3
       2032                  4,220,000                4.000                    3.190(c)           13048TUN1
       2033                  4,390,000                4.000                    3.230(c)           13048TUP6
       2034                  4,560,000                4.000                    3.270(c)           13048TUQ4

     $24,535,000 4.000% Term Bonds due October 1, 2040 – Yield: 3.400%(c); CUSIP†: 13048TUR2
     $13,145,000 5.250% Term Bonds due October 1, 2045 – Yield: 2.970%(c); CUSIP†: 13048TUS0
          
""".decode('ascii', 'ignore').split("\n")

In [ ]:
test_string = """

                                       SCHEDULED DEBT SERVICE
        The scheduled debt service for the Bonds is as follows, assuming no optional redemptions prior to maturity:
                               FORESTVILLE UNION SCHOOL DISTRICT
                            General Obligation Bonds (Election of 2010, Series 2012)
                                     Semi-Annual Debt Service Payments

                                                             Compounded         Total Periodic    Total Annual Debt
Period Ending        Principal            Interest             Interest         Debt Service            Service
 Feb. 1, 2013                –              $57,033.85                 –             $57,033.85                –
 Aug. 1, 2013                –               37,331.25                 –              37,331.25          $94,365.10
 Feb. 1, 2014                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2014                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2015                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2015                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2016                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2016                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2017                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2017                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2018                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2018                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2019                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2019                –               37,331.25                 –              37,331.25           74,662.50
 Feb. 1, 2020                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2020           $5,725.80            37,331.25            $9,274.20           52,331.25           89,662.50
 Feb. 1, 2021                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2021            5,095.95            37,331.25             9,904.05           52,331.25           89,662.50
 Feb. 1, 2022                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2022            6,047.20            37,331.25            13,952.80           57,331.25           94,662.50
 Feb. 1, 2023                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2023            6,727.50            37,331.25            18,272.50           62,331.25           99,662.50
 Feb. 1, 2024                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2024            7,184.70            37,331.25            22,815.30           67,331.25          104,662.50
 Feb. 1, 2025                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2025            7,460.25            37,331.25            27,539.75           72,331.25          109,662.50
 Feb. 1, 2026                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2026            6,639.50            37,331.25            28,360.50           72,331.25          109,662.50
 Feb. 1, 2027                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2027            7,597.35            37,331.25            37,402.65           82,331.25          119,662.50
 Feb. 1, 2028                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2028            6,761.70            37,331.25            38,238.30           82,331.25          119,662.50
 Feb. 1, 2029                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2029            6,686.50            37,331.25            43,313.50           87,331.25          124,662.50
 Feb. 1, 2030                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2030            6,546.10            37,331.25            48,453.90           92,331.25          129,662.50
 Feb. 1, 2031                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2031            6,885.45            37,331.25            58,114.55          102,331.25          139,662.50
 Feb. 1, 2032                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2032            6,598.90            37,331.25            63,401.10          107,331.25          144,662.50
 Feb. 1, 2033                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2033            6,292.50            37,331.25            68,707.50          112,331.25          149,662.50
 Feb. 1, 2034                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2034            6,346.95            37,331.25            78,653.05          122,331.25          159,662.50
 Feb. 1, 2035                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2035            5,649.10            37,331.25            79,350.90          122,331.25          159,662.50
 Feb. 1, 2036                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2036            5,619.25            37,331.25            89,380.75          132,331.25          169,662.50
 Feb. 1, 2037                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2037           44,881.20            37,331.25           375,118.80          457,331.25          494,662.50
 Feb. 1, 2038                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2038           92,550.60            37,331.25           342,449.40          472,331.25          509,662.50
 Feb. 1, 2039                –               37,331.25                 –              37,331.25                –
 Aug. 1, 2039          287,012.60            37,331.25           167,987.40          492,331.25          529,662.50
 Feb. 1, 2040                –               32,278.13                 –              32,278.13                –
 Aug. 1, 2040          480,000.00            32,278.13                 –             512,278.13          544,556.26
 Feb. 1, 2041                –               22,378.13                 –              22,378.13                –
 Aug. 1, 2041          520,000.00            22,378.13                 –             542,378.13          564,756.26
 Feb. 1, 2042                –               11,653.13                 –              11,653.13                –
 Aug. 1, 2042          565,000.00            11,653.13                 –             576,653.13          588,306.26
 TOTAL               2,099,309.10        $2,168,208.88        $1,620,690.90       $5,888,208.88       $5,888,208.88






""".split(u"\n")

In [ ]:
#How to split this one? Three distinct tables because different types (but matching)
test_string = u"""
    THE SERIES 2013 BONDS DO NOT CONSTITUTE A DEBT, LIABILITY OR OBLIGATION OF THE STATE OF MICHIGAN AND NEITHER THE FULL FAITH AND
CREDIT NOR THE TAXING POWER OF THE STATE OF MICHIGAN, THE CITY OF FLINT OR ANY AGENCY OR POLITICAL SUBDIVISION THEREOF IS PLEDGED
TO THE PAYMENT OF THE PRINCIPAL OF OR INTEREST ON THE SERIES 2013 BONDS. THE OBLIGATION OF THE CITY OF FLINT TO MAKE PAYMENTS OF
CASH RENTALS IS A SPECIAL, LIMITED OBLIGATION OF THE CITY OF FLINT PAYABLE SOLELY FROM THE NET REVENUES OF THE MEDICAL CENTER. THE
AUTHORITY HAS NO TAXING POWER.
                                                   AMOUNT, MATURITY, INTEREST RATE, PRICE, YIELD AND CUSIP†
                                                                              Series 2013A Bonds
                               $5,580,000      5.000%      Term Bonds due July 1, 2023 Price 104.077% to Yield 4.500%               CUSIP†: 339510BQ1
                               $8,355,000      5.250%      Term Bonds due July 1, 2028 Price 102.796%* to Yield 4.900%              CUSIP†: 339510BR9
                               $8,005,000      5.250%      Term Bonds due July 1, 2039 Price 99.286% to Yield 5.300%                CUSIP†: 339510BT5
                              _____________________
                              * Priced to the call date.
                                                                                 Series 2013B Bonds
                                                                              $12,290,000 Serial Bonds
                                            Maturity                                Interest
                                            (July 1)             Amount               Rate           Price                        CUSIP†
                                              2013               $555,000             5.000%        100.794%                     339511DT1
                                              2015              $1,235,000            5.000%        105.314%                     339511DV6
                                              2018              $5,150,000            3.750%        101.785%                     339511DY0
                                              2019              $2,350,000            4.000%        101.655%                     339511DZ7
                                              2019              $3,000,000            5.000%        107.186%                     339511EA1
                                                                              $24,300,000 Term Bonds
                              $9,790,000      3.500%       Term Bonds due July 1, 2017       Price 101.976% to Yield 3.000%         CUSIP†: 339511DX2
                              $8,560,000      4.750%       Term Bonds due July 1, 2023       Price 102.027% to Yield 4.500%         CUSIP†: 339511EC7
                              $5,950,000      4.750%       Term Bonds due July 1, 2028       Price 97.347% to Yield 5.000%          CUSIP†: 339511ED5
     The Series 2013 Bonds are being offered when, as and if issued and received by the Underwriter, subject to prior sale, withdrawal or modification of the offer
without any notice, and to the approval of legality of the Series 2013 Bonds by Dickinson Wright PLLC, Troy, Michigan, Bond Counsel. Certain legal matters will be
passed upon for the Medical Center by its General Counsel and for the Authority by its disclosure counsel, Miller, Canfield, Paddock and Stone, P.L.C., Ann Arbor,
Michigan. It is expected that the Series 2013A Bonds in definitive form will be available for delivery to the Underwriter through the facilities of DTC on or about
March 14, 2013 and that the Series 2013B Bonds in definitive form will be available for delivery to the Underwriter through the facilities of DTC on or about April 2, 2013.
     This cover page contains certain information for quick reference only. It is not a summary of the Series 2013 Bonds or the security for the Series 2013 Bonds.
Potential investors must read the entire Official Statement, including the Appendices, to obtain information essential to the making of an informed investment decision.

""".split(u"\n")

In [ ]:
from IPython.display import display

rows = [row_feature(l) for l in test_string]

tables = indexed_tables_from_rows(rows)
for begin_line, t in tables.iteritems():
    df = table_to_df(t)

    for j in range(t['begin_line']-4, t['begin_line']):
        print len(rows[j]), rows[j]
        
    for j, row in enumerate(t['data']):
        print len(rows[t['begin_line'] + j]), rows[t['begin_line'] + j]
    print t['header']
    display(df)

In [ ]:
test_string

In [ ]:
rstr ="""
Population Served Outside City (Est.) ...................          8,457        9,000     9,000     9,000     9,000
        Total Population Served ...........................      356,762      355,161   352,793   350,034   345,265
""".decode('ascii', 'ignore').split("\n")
for r in rstr:
    print "split", re.split(tokenize_pattern, r)
    print "token", [v['value'] for v in row_feature(r)], row_feature(r)

In [ ]:
#subtype_indicator['test'] = r'.*\$.*'
for sub, indicator in subtype_indicator.iteritems():
    print sub, indicator, re.match(indicator, "  ..........................................................     $  ")