Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dram1964 committed Aug 3, 2018
0 parents commit d3ef917
Show file tree
Hide file tree
Showing 43 changed files with 1,146 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
init.sh
!Build/
/META.yml
/META.json
/MYMETA.*
*.pm.tdy
*.o
*.bs
inc/
/blib/
/_eumm/
/*.gz
/Makefile
/Makefile.old
/MANIFEST.bak
/pm_to_blib
/*.zip
*.saved

4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This file documents the revision history for Perl extension OpenEHR_Web.

0.01 2018-07-31 13:27:47
- initial revision, generated by Catalyst
28 changes: 28 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env perl
# IMPORTANT: if you delete this file your app will not work as
# expected. You have been warned.
use inc::Module::Install 1.02;
use Module::Install::Catalyst; # Complain loudly if you don't have
# Catalyst::Devel installed or haven't said
# 'make dist' to create a standalone tarball.

name 'OpenEHR_Web';
all_from 'lib/OpenEHR_Web.pm';

requires 'Catalyst::Runtime' => '5.90118';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
requires 'Data::Dumper';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
# See Catalyst::Plugin::ConfigLoader for supported formats
requires 'Catalyst::Plugin::StackTrace';
requires 'OpenEHR::REST::AQL';
test_requires 'Test::More' => '0.88';
catalyst;

install_script glob('script/*.pl');
auto_install;
WriteAll;
36 changes: 36 additions & 0 deletions OpenEHR.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Parameters used to authenticate to server

user admin
password admin

# Servers URL - must end in a trailing slash
url http://unihrt:8081/

# language encoding data used for compositions

language_code en
language_terminology ISO_639-1

# territory encoding data used for compositions

territory_code GB
territory_terminology ISO_3166-1

# encoding for test data

encoding_code UTF-8
encoding_terminology IANA_character-sets

# URL for the REST API of your server

base_path http://unihrt:8081/rest/v1/

# Valid compositionUid used for the OpenEHR::REST::PathologyReport
# test suite

test_ehrid 1416b150-e5d4-4659-bbc4-057185f107e3
test_uid 90b0f203-791a-4aab-90f6-e091151a03b8::default::1
test_subject_id 4658572835

# Set default value for composition format
composition_format STRUCTURED
23 changes: 23 additions & 0 deletions OpenEHR_Composition.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Set default value for composition format
composition_format STRUCTURED

# Set composer name
composer_name Aupen Ayre

# language encoding data used for compositions
language_code en
language_terminology ISO_639-1

# territory encoding data used for compositions
territory_code GB
territory_terminology ISO_3166-1

# encoding for test data
encoding_code UTF-8
encoding_terminology IANA_character-sets

# Organisation identifiers
id_namespace UCLH-NS
id_scheme UCLH-NS
facility_name UCLH NHS Foundation Trust
facility_id RRV
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run script/openehr_web_server.pl to test the application.
86 changes: 86 additions & 0 deletions lib/OpenEHR_Web.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package OpenEHR_Web;
use Moose;
use namespace::autoclean;

use Catalyst::Runtime 5.80;

# Set flags and add plugins for the application.
#
# Note that ORDERING IS IMPORTANT here as plugins are initialized in order,
# therefore you almost certainly want to keep ConfigLoader at the head of the
# list if you're using it.
#
# -Debug: activates the debug mode for very useful log messages
# ConfigLoader: will load the configuration from a Config::General file in the
# application's home directory
# Static::Simple: will serve static files from the application's root
# directory

use Catalyst qw/
-Debug
ConfigLoader
Static::Simple
StackTrace
/;

extends 'Catalyst';

our $VERSION = '0.01';

# Configure the application.
#
# Note that settings in openehr_web.conf (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
# with an external configuration file acting as an override for
# local deployment.

__PACKAGE__->config(
name => 'OpenEHR_Web',
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
enable_catalyst_header => 1, # Send X-Catalyst header
);

__PACKAGE__->config(
'View::HTML' => {
INCLUDE_PATH => [
__PACKAGE__->path_to( 'root', 'src' ),
],
},
);

# Start the application
__PACKAGE__->setup();

=encoding utf8
=head1 NAME
OpenEHR_Web - Catalyst based application
=head1 SYNOPSIS
script/openehr_web_server.pl
=head1 DESCRIPTION
[enter your description here]
=head1 SEE ALSO
L<OpenEHR_Web::Controller::Root>, L<Catalyst>
=head1 AUTHOR
Catalyst developer
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

1;
88 changes: 88 additions & 0 deletions lib/OpenEHR_Web/Controller/Compositions.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package OpenEHR_Web::Controller::Compositions;
use Moose;
use namespace::autoclean;
use OpenEHR::REST::Composition;
use JSON;

BEGIN { extends 'Catalyst::Controller'; }

=head1 NAME
OpenEHR_Web::Controller::Compositions - Catalyst Controller
=head1 DESCRIPTION
Catalyst Controller.
=head1 METHODS
=cut


=head2 index
=cut

sub index :Path :Args(0) {
my ( $self, $c ) = @_;

$c->response->body('Matched OpenEHR_Web::Controller::Compositions in Compositions.');
}

sub display :Local :Args(3) {
my ($self, $c, $ehrid, $ptnumber, $uid) = @_;

my $query = OpenEHR::REST::Composition->new();
$query->find_by_uid($uid);
if ($query->err_msg) {
$c->stash->{error_msg} = $query->err_msg;
}
$c->stash(
composition => $query->composition_response,
ehrid => $ehrid,
ptnumber => $ptnumber,
uid => $uid,
template => 'compositions/display.tt2',
);
}

sub display_flat :Local :Args(3) {
my ($self, $c, $ehrid, $ptnumber, $uid) = @_;

my $query = OpenEHR::REST::Composition->new();
$query->request_format('FLAT');
$query->find_by_uid($uid);
if ($query->err_msg) {
$c->stash->{error_msg} = $query->err_msg;
}
my $json_string = to_json($query->composition_response);
$c->log->debug($json_string);
$json_string =~ s/'_name'/'name'/;
my $composition = from_json($json_string);
$c->stash(
composition => $query->composition_response,
ehrid => $ehrid,
ptnumber => $ptnumber,
uid => $uid,
template => 'compositions/display_flat.tt2',
);
}



=encoding utf8
=head1 AUTHOR
A clever guy
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

__PACKAGE__->meta->make_immutable;

1;
76 changes: 76 additions & 0 deletions lib/OpenEHR_Web/Controller/Ehrs.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package OpenEHR_Web::Controller::Ehrs;
use Moose;
use namespace::autoclean;
use OpenEHR::REST::AQL;
use Data::Dumper;

BEGIN { extends 'Catalyst::Controller'; }

=head1 NAME
OpenEHR_Web::Controller::Ehrs - Catalyst Controller
=head1 DESCRIPTION
Catalyst Controller.
=head1 METHODS
=cut


=head2 index
=cut

sub index :Path :Args(0) {
my ( $self, $c ) = @_;


$c->response->body('Matched OpenEHR_Web::Controller::Ehrs in Ehrs.');
}

=head2 list
Fetch all Ehrs and pass to ehrs/list.tt2 in stash to be displayed
=cut

sub list :Local {
my ($self, $c) = @_;
my $stmt = << "END_STMT";
select e/ehr_id/value as ehrid, e/ehr_status/subject/external_ref/id/value as ptnumber,
e/ehr_status/subject/external_ref/namespace as namespace, c/name/value as composition_type,
c/uid/value as uid
from EHR e
contains Composition c
END_STMT
my $query = OpenEHR::REST::AQL->new();
$query->statement($stmt);
$query->run_query;
if ($query->err_msg) {
$c->stash->{error_msg} = $query->err_msg;
}

$c->stash(ehrs => $query->resultset);


$c->stash(template => 'ehrs/list.tt2');
}

=encoding utf8
=head1 AUTHOR
A clever guy
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut

__PACKAGE__->meta->make_immutable;

1;
Loading

0 comments on commit d3ef917

Please sign in to comment.