RSS Git Download  Clone
Raw Blame History
package LIMS::DB::PatientCase;

use base qw(LIMS::RDBO);

#=begin
__PACKAGE__->meta->setup (
    table   => 'patient_case',

    columns => [
        id                 => { type => 'serial', not_null => 1 },
        patient_id         => { type => 'integer', default => '0', not_null => 1 },
        referral_source_id => { type => 'integer', default => '0', not_null => 1 },
        unit_number        => { type => 'varchar', default => 'UNKNOWN', length => 255, not_null => 1 },
        time               => { type => 'timestamp', not_null => 1 },
    ],

    primary_key_columns => [ 'id' ],

    unique_key => [ 'patient_id', 'unit_number', 'referral_source_id' ],

    foreign_keys => [
        patient => {
            class       => 'LIMS::DB::Patient',
            key_columns => { patient_id => 'id' },
        },
        
        referral_source => {
            class       => 'LIMS::DB::ReferralSource',
            key_columns => { referral_source_id => 'id' },
        },
    ],

    relationships => [
        request => {
            class      => 'LIMS::DB::Request',
            column_map => { id => 'patient_case_id' },
            type       => 'one to many',
        },
# not sure these are correct = but needed to get 'as_tree(force_load =>1)' working
#    patient => {
#      class      => 'LIMS::DB::Patient',
#      column_map => { id => 'patient_id' },
#      type       => 'many to one', # reverse this & see output of as_tree()
#    },
#    location => {
#      class      => 'LIMS::DB::Location',
#      column_map => { id => 'location_id' },
#      type       => 'many to one',
#    },
    ],
);
#=cut

#__PACKAGE__->meta->table('patient_case');
#__PACKAGE__->meta->auto_initialize;
# print __PACKAGE__->meta->perl_class_definition(indent => 4);

__PACKAGE__->meta->make_manager_class('patient_cases');

1;