NdrWorkflow
** THIS ENGINE IS NOT FOR PUBLIC DEPLOYMENT IN ITS CURRENT FORMAT **
This is the NHS Digital (NHS-D) National Disease Registers (NDR) Workflow ruby gem, providing:
- core model definitions derived from ERA to allow for workflows and batch processing Core tables included: EWorkflow, EBatch, EAction Supporting lookup tables include: ZeActiontype, ZeType, Zprovider, Zuser
Currently excluded: Conformance data Queued_Job Back end daemons ZPostCode - referenced heavily in Zprovider
Considerations
- Postgres only implementation for creating underlying db tables (will work with oracle but no migrations)
- FK constraints managed through DB rather than ActiveRecord
- Table names set in Engine models - not standard rails
Installation
Add this line to your application's Gemfile:
gem 'ndr_workflow', path: "PATH_TO_YOUR_GIT_SVN/non-era/gems/ndr_workflow"
And then execute:
$ bundle install
If the application needs the physical tables creating in Postgres:
$ rails g ndr_workflow:install
$ rake db:migrate
Usage
Rails 3
Protected attributes Disabe globally in your app in conf/application.rb, with config.active_record.whitelist_attributes = false OR for specific models using attr_accessible : create new model definition in your app dir based on template files in enginer in : test/dummy/app/model/NAME.rb
Rails 4
Will need to use strong parameters
When extending already present models (ERA)
copy and uncomment the first line from test/dummy/app/model/NAME.rb to app/model/NAME.rb eg:
require NdrWorkflow::Engine.root.join('app', 'models', 'e_action')
When you want to extend the Engine
create new model definition in your app dir based on file in engines dummy app ie test/dummy/app/model/NAME.rb
Test Data
All test data in this repository is fictitious. Any resemblance to real persons, living or dead, is purely coincidental.
Note: Real codes exist in the tests, postcodes for example, but bear no relation to real patient data. Please ensure that you always only ever commit dummy data when contributing to this project.
Using same class names in app and engine tricky .... (hence use of require)
http://stackoverflow.com/questions/5045068/extending-controllers-of-a-rails-3-engine-in-the-main-app
TESTING
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-3.0.x bundle install BUNDLE_GEMFILE=gemfiles/Gemfile.rails-3.0.x bundle exec rake test
NDR_WORKFLOW
-- Dummy lookup data ZeType.create(:shortdesc => "National Prostate Cancer Audit"){|ze_type| ze_type.ze_typeid = "NPCA"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "NEW"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "AIMP"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "PRECHECK"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "APOST"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "MPOST"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "CREA"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "RECO"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "CHECK"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "AMCH"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "MMCH"} ZeActiontype.create(:shortdesc => "Initialize batch"){|ze_actiontype| ze_actiontype.ze_actiontypeid = "STOP"} -- NO POSTCODES Zprovider.create(:shortdesc => "ECRIC CAMBRIDGE", :exportid => "0402", :startdate => "007-06-01", :sort => 1, :role => "H", :linac => 0){|ze_provider| ze_provider.zproviderid = "0402"} Zuser.create(:zuserid => "ben", :shortdesc => "bens_test_user", :registryid => "0402")
-- Workflow model NPCA SEQUENCE = %wAIMP PRECHECK APOST MPOST CREA RECO CHECK AMCH MMCH STOP SEQUENCE.each_with_index do |action, index| EWorkflow.create(:e_type => 'NPCA', :last_e_actiontype => action, :next_e_actiontype => SEQUENCE) unless SEQUENCE.nil? end
-- Create batch for workflow EBatch.create(:e_type => "NPCA", :provider => "0402", :registryid => "0402", :media => 'Email', :original_filename => 'textfile_batch.txt', :cleaned_filename => '', :numberofrecords => 3, :date_reference1 => '2005.05.05', :date_reference2 => '2007.01.01', :e_batchid_traced => '', :comments => 'Addenbrookes, plain text file', :digest => '1b2bd8aecffcaf099b4d529498615ef2c765d1b5', :lock_version => 0)
-- Create first action for batch EAction.create!(:e_batchid => 1, :e_actiontype => "NEW", :started => Time.now, :finished => nil, :startedby => 'ben', :status => '')
EBatch.new(:e_type => 'NPCA', :original_filename => 'svn/') EBatch.first.e_actions.start_and_finish('NEW','ben')