From cf33ca428697c9ce0cb627850d2ecbce51179feb Mon Sep 17 00:00:00 2001 From: mikestark Date: Wed, 17 Jun 2020 15:26:25 -0400 Subject: [PATCH 1/2] Add files via upload --- popHealthDocker_v6/PH1/docker-compose.yml | 45 ++++ popHealthDocker_v6/PH2/docker-compose.yml | 45 ++++ .../js-ecqm-engine-docker/Dockerfile | 20 ++ popHealthDocker_v6/pophealthweb/Dockerfile | 73 ++++++ .../apache/conf-available/pophealth | 1 + .../apache/mods-available/pophealth | 5 + .../apache/sites-available/pophealth | 10 + .../pophealthweb/cql_bundle_importer.rb | 152 ++++++++++++ popHealthDocker_v6/pophealthweb/mongoid.yml | 22 ++ .../pophealthweb/pophealth.rake | 222 ++++++++++++++++++ popHealthDocker_v6/pophealthweb/start.sh | 20 ++ 11 files changed, 615 insertions(+) create mode 100644 popHealthDocker_v6/PH1/docker-compose.yml create mode 100644 popHealthDocker_v6/PH2/docker-compose.yml create mode 100644 popHealthDocker_v6/js-ecqm-engine-docker/Dockerfile create mode 100644 popHealthDocker_v6/pophealthweb/Dockerfile create mode 100644 popHealthDocker_v6/pophealthweb/apache/conf-available/pophealth create mode 100644 popHealthDocker_v6/pophealthweb/apache/mods-available/pophealth create mode 100644 popHealthDocker_v6/pophealthweb/apache/sites-available/pophealth create mode 100644 popHealthDocker_v6/pophealthweb/cql_bundle_importer.rb create mode 100644 popHealthDocker_v6/pophealthweb/mongoid.yml create mode 100644 popHealthDocker_v6/pophealthweb/pophealth.rake create mode 100644 popHealthDocker_v6/pophealthweb/start.sh diff --git a/popHealthDocker_v6/PH1/docker-compose.yml b/popHealthDocker_v6/PH1/docker-compose.yml new file mode 100644 index 000000000..27ffa297e --- /dev/null +++ b/popHealthDocker_v6/PH1/docker-compose.yml @@ -0,0 +1,45 @@ +version: "3" +services: + mongo: + image: mongo:3.4.23 + restart: always + ports: + - 27017:27017 + + rabbitmq: + image: rabbitmq:3.7.14 +# environment: +# RABBITMQ_DEFAULT_VHOST: / + restart: always + ports: + - 5672:5672 + - 15672:15672 + + ecqm: + build: + dockerfile: Dockerfile + context: ../js-ecqm-engine-docker + restart: always + depends_on: + - mongo + - rabbitmq + environment: + RABBITMQ_HOST: rabbitmq + MONGODB_HOST: mongo + + pophealthweb: + build: + dockerfile: Dockerfile + context: ../pophealthweb + depends_on: + - mongo + - rabbitmq + - ecqm + environment: + MONGODB_HOST: mongo + MONGODB_PORT: 27017 + NLM_USERNAME: username + NLM_PASSWORD: password + RABBITMQ_URL: 'amqp://rabbitmq' + ports: + - 8082:80 diff --git a/popHealthDocker_v6/PH2/docker-compose.yml b/popHealthDocker_v6/PH2/docker-compose.yml new file mode 100644 index 000000000..8b001a157 --- /dev/null +++ b/popHealthDocker_v6/PH2/docker-compose.yml @@ -0,0 +1,45 @@ +version: "3" +services: + mongo: + image: mongo:3.4.23 + restart: always + ports: + - 27018:27017 + + rabbitmq: + image: rabbitmq:3.7.14 +# environment: +# RABBITMQ_DEFAULT_VHOST: / + restart: always +# ports: +# - 5672:5672 +# - 15672:15672 + + ecqm: + build: + dockerfile: Dockerfile + context: ../js-ecqm-engine-docker + restart: always + depends_on: + - mongo + - rabbitmq + environment: + RABBITMQ_HOST: rabbitmq + MONGODB_HOST: mongo + + pophealthweb: + build: + dockerfile: Dockerfile + context: ../pophealthweb + depends_on: + - mongo + - rabbitmq + - ecqm + environment: + MONGODB_HOST: mongo + MONGODB_PORT: 27017 + NLM_USERNAME: starklogic + NLM_PASSWORD: password + RABBITMQ_URL: 'amqp://rabbitmq' + ports: + - 8083:80 diff --git a/popHealthDocker_v6/js-ecqm-engine-docker/Dockerfile b/popHealthDocker_v6/js-ecqm-engine-docker/Dockerfile new file mode 100644 index 000000000..d1d8c5732 --- /dev/null +++ b/popHealthDocker_v6/js-ecqm-engine-docker/Dockerfile @@ -0,0 +1,20 @@ +FROM node:10.0-slim + +ENV NODE_ENV production + +RUN apt-get update +RUN apt-get install -y git + +WORKDIR /tmp +RUN git clone https://github.com/WorldVistA/js-ecqm-engine.git +RUN cp -R js-ecqm-engine /usr/src/app +RUN rm -rf /tmp/js-ecqm-engine +RUN ls /usr/src/app + +WORKDIR /usr/src/app + +RUN yarn install --only=production + +RUN chmod 755 bin/rabbit_worker.js + +CMD [ "bin/rabbit_worker.js"] diff --git a/popHealthDocker_v6/pophealthweb/Dockerfile b/popHealthDocker_v6/pophealthweb/Dockerfile new file mode 100644 index 000000000..b1fcb3b4e --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/Dockerfile @@ -0,0 +1,73 @@ +FROM ruby:2.3.7 + +RUN gem install bundler -v '1.17.1' + +# install +RUN apt-get update +RUN apt-get install -y --no-install-recommends apt-utils +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +RUN apt-get update +RUN apt-get install -y nodejs +RUN apt-get install -y npm +RUN npm install -g bower +RUN apt-get install -y apache2=2.4.* +RUN apt-get install -y libcurl4-openssl-dev apache2-dev libapr1-dev libaprutil1-dev libssl-dev +RUN apt autoremove -y + +RUN gem install passenger -v '5.3.7' + + +# Pull popHealth +WORKDIR / +RUN git clone https://github.com/WorldVistA/popHealth.git -b v6 popHealth +WORKDIR /popHealth + +# fix fontawesome reference +RUN sed -i 's/"font-awesome": "^4.7.0",/"font-awesome": "~4.7.0",/g' /popHealth/bower.json + +# fix JSON Parse +RUN sed -i 's/collection = JSON.parse(File.read(json_path)),/collection = JSON.parse(File.read(json_path), :max_nesting => false)/g' /popHealth/lib/measures/baseline_loader.rb + +# Use custom config yml +#COPY popHealth.yml /popHealth/config/popHealth.yml + +# custom bundle installer using LOCAL bundle.zip +#COPY pophealth.rake /popHealth/lib/tasks/pophealth.rake + +# fixes to prevent halt of measure import on error (exception handling added) +COPY cql_bundle_importer.rb /popHealth/lib/cql_bundle_importer.rb + +# User local pre-downloaded bundle-2018.zip +#COPY bundle-2018.zip /popHealth/bundles/bundle-2018.zip + +# Add a mongoid.yml config file that supports environment variables to specify the host and port +COPY mongoid.yml config/mongoid.yml + +# finally install popHealth +RUN bundle install + +# bower must be run as a user, not root +RUN bower install --allow-root + +# apache configuration + +RUN passenger-install-apache2-module + +ADD apache/sites-available/pophealth /etc/apache2/sites-available/pophealth +RUN rm /etc/apache2/sites-enabled/000-default* +RUN ln -s /etc/apache2/sites-available/pophealth /etc/apache2/sites-enabled/000-default.conf + +ADD apache/conf-available/pophealth /etc/apache2/conf-available/pophealth +RUN ln -s /etc/apache2/conf-available/pophealth /etc/apache2/conf-enabled/pophealth.conf + +ADD apache/mods-available/pophealth /etc/apache2/mods-available/pophealth +RUN ln -f -s /etc/apache2/mods-available/pophealth /etc/apache2/mods-enabled/pophealth.conf + + +EXPOSE 80 + +# add the startup script +ADD start.sh /popHealth/start.sh +RUN chmod 777 /popHealth/start.sh + +ENTRYPOINT [ "/popHealth/start.sh" ] diff --git a/popHealthDocker_v6/pophealthweb/apache/conf-available/pophealth b/popHealthDocker_v6/pophealthweb/apache/conf-available/pophealth new file mode 100644 index 000000000..4a36bfda5 --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/apache/conf-available/pophealth @@ -0,0 +1 @@ +SetEnv SECRET_KEY_BASE 149be94cda719a98e6428578ea63b6db90a9c58347058bca7ceaeb795ca56b4a \ No newline at end of file diff --git a/popHealthDocker_v6/pophealthweb/apache/mods-available/pophealth b/popHealthDocker_v6/pophealthweb/apache/mods-available/pophealth new file mode 100644 index 000000000..2b92ac4c8 --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/apache/mods-available/pophealth @@ -0,0 +1,5 @@ +LoadModule passenger_module /usr/local/bundle/gems/passenger-5.3.7/buildout/apache2/mod_passenger.so + + PassengerRoot /usr/local/bundle/gems/passenger-5.3.7 + PassengerDefaultRuby /usr/local/bin/ruby + \ No newline at end of file diff --git a/popHealthDocker_v6/pophealthweb/apache/sites-available/pophealth b/popHealthDocker_v6/pophealthweb/apache/sites-available/pophealth new file mode 100644 index 000000000..5b89c03cb --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/apache/sites-available/pophealth @@ -0,0 +1,10 @@ + + PassengerRuby /usr/local/bin/ruby + DocumentRoot /popHealth/public + TimeOut 1200 + + AllowOverride all + Options -MultiViews + Require all granted + + diff --git a/popHealthDocker_v6/pophealthweb/cql_bundle_importer.rb b/popHealthDocker_v6/pophealthweb/cql_bundle_importer.rb new file mode 100644 index 000000000..c4a6efb88 --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/cql_bundle_importer.rb @@ -0,0 +1,152 @@ +require 'id.rb' +module CqlBundle + class CqlBundleImporter + SOURCE_ROOTS = { bundle: 'bundle.json', + measures: 'measures', results: 'results', + valuesets: File.join('value_sets', 'json', '*.json'), + patients: 'patients' }.freeze + COLLECTION_NAMES = ['bundles', 'records', 'measures', 'individual_results', 'system.js'].freeze + DEFAULTS = { type: nil, + update_measures: true, + clear_collections: COLLECTION_NAMES }.freeze + + # Import a quality bundle into the database. This includes metadata, measures, test patients, supporting JS libraries, and expected results. + # + # @param [File] zip The bundle zip file. + # @param [String] Type of measures to import, either 'ep', 'eh' or nil for all + # @param [Boolean] keep_existing If true, delete all current collections related to patients and measures. + + def self.import(zip, options = {}) + options = DEFAULTS.merge(options) + @measure_id_hash = {} + @patient_id_hash = {} + + bundle = nil + Zip::ZipFile.open(zip.path) do |zip_file| + bundle = unpack_bundle(zip_file) + check_bundle_versions(bundle) + + # Store the bundle metadata. + raise bundle.errors.full_messages.join(',') unless bundle.save + puts 'bundle metadata unpacked...' + + unpack_and_store_valuesets(zip_file, bundle) + unpack_and_store_measures(zip_file, options[:type], bundle) + unpack_and_store_qdm_patients(zip_file, options[:type], bundle) + unpack_and_store_results(zip_file, options[:type], bundle) + end + + bundle + ensure + # If the bundle is nil or the bundle has never been saved then do not set done_importing or run save. + if bundle&.created_at + bundle.done_importing = true + bundle.save + end + end + + def self.check_bundle_versions(bundle) + bundle_versions = Hash[* HealthDataStandards::CQM::Bundle.where(deprecated: false).collect { |b| [b.version, b.id] }.flatten] + + # no bundles before 2018 and no non-deprecated bundles with same year + old_year_err = 'Please use bundles for year 2018 or later.' + raise old_year_err if bundle.version[0..3].to_i < 2018 + same_year_err = "A non-deprecated bundle with year #{bundle.version[0..3]} already exists in the database. Please deprecate previous bundles." + raise same_year_err unless bundle_versions.select { |vers, _id| vers[0..3] == bundle.version[0..3] }.empty? + end + + def self.unpack_bundle(zip) + HealthDataStandards::CQM::Bundle.new(JSON.parse(zip.read(SOURCE_ROOTS[:bundle]), max_nesting: 100)) + end + + def self.unpack_and_store_valuesets(zip, bundle) + entries = zip.glob(SOURCE_ROOTS[:valuesets]) + entries.each_with_index do |entry, index| + vs = HealthDataStandards::SVS::ValueSet.new(unpack_json(entry)) + vs['bundle_id'] = bundle.id + HealthDataStandards::SVS::ValueSet.collection.insert_one(vs.as_document) + report_progress('Value Sets', (index * 100 / entries.length)) if (index % 10).zero? + end + puts "\rLoading: Value Sets Complete " + end + + def self.unpack_and_store_measures(zip, type, bundle) + entries = zip.glob(File.join(SOURCE_ROOTS[:measures], type || '**', '*.json')) + entries.each_with_index do |entry, index| + # puts "Processing measure #{entry}" + source_measure = unpack_json(entry) + # we clone so that we have a source without a bundle id + measure = source_measure.clone + measure['bundle_id'] = bundle.id + value_sets = [] + measure['value_set_oid_version_objects'].each do |vsv| + value_sets << HealthDataStandards::SVS::ValueSet.where(oid: vsv['oid'], version: vsv['version']).first.id + end + measure['value_sets'] = value_sets + begin + mes = Mongoid.default_client['measures'].insert_one(measure) + rescue + puts "Error Processing measure #{entry}" + next + end + @measure_id_hash[measure['bonnie_measure_id']] = mes.inserted_id + report_progress('measures', (index * 100 / entries.length)) if (index % 10).zero? + end + puts "\rLoading: Measures Complete " + end + + def self.unpack_and_store_qdm_patients(zip, type, bundle) + entries = zip.glob(File.join(SOURCE_ROOTS[:patients], type || '**', 'json', '*.json')) + entries.each_with_index do |entry, index| + patient = QDM::Patient.new(unpack_json(entry)) + patient['bundleId'] = bundle.id + + reconnect_references(patient) + + @patient_id_hash[patient['extendedData.master_patient_id']] = patient['id'] + patient.save + report_progress('patients', (index * 100 / entries.length)) if (index % 10).zero? + end + puts "\rLoading: Patients Complete " + end + + def self.reconnect_references(patient) + patient.dataElements.each do |data_element| + next unless data_element[:relatedTo] + ref_array = [] + oid_hash = {} + patient.dataElements.each do |de| + oid_hash[{ 'codes' => de['dataElementCodes'].map { |dec| dec['code'] }.flatten, 'start_time' => de['authorDatetime'].to_i }.hash] = de.id + end + data_element[:relatedTo].each do |ref| + ref_array << oid_hash[{ 'codes' => ref['codes'], 'start_time' => ref['start_time'] }.hash] + end + data_element.relatedTo = ref_array + end + end + + def self.unpack_and_store_results(zip, _type, bundle) + zip.glob(File.join(SOURCE_ROOTS[:results], '*.json')).each do |entry| + contents = unpack_json(entry) + contents.each do |document| + # Replace ids in bundle, with ids created during import + document['patient_id'] = @patient_id_hash[document['patient_id']] + document['measure_id'] = @measure_id_hash[document['measure_id']] + document['extendedData'] = {} + document['extendedData']['correlation_id'] = bundle.id.to_s + Mongoid.default_client['qdm_individual_results'].insert_one(document) + end + end + puts "\rLoading: Results Complete " + end + + def self.unpack_json(entry) + JSON.parse(entry.get_input_stream.read, max_nesting: false) + end + + def self.report_progress(label, percent) + print "\rLoading: #{label} #{percent}% complete" + STDOUT.flush + end + end +end \ No newline at end of file diff --git a/popHealthDocker_v6/pophealthweb/mongoid.yml b/popHealthDocker_v6/pophealthweb/mongoid.yml new file mode 100644 index 000000000..d8a886402 --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/mongoid.yml @@ -0,0 +1,22 @@ +development: + clients: + default: + database: pophealth-development + hosts: + - <%= ENV['MONGODB_HOST'] %>:<%= ENV['MONGODB_PORT'] %> +test: + clients: + default: + database: pophealth-test + hosts: + - <%= ENV['MONGODB_HOST'] %>:<%= ENV['MONGODB_PORT'] %> +production: + clients: + default: + database: pophealth-production + hosts: + - <%= ENV['MONGODB_HOST'] %>:<%= ENV['MONGODB_PORT'] %> + # options: + # user: <%= ENV['MONGODB_USER'] %> + # password: <%= ENV['MONGODB_PASSWORD'] %> + diff --git a/popHealthDocker_v6/pophealthweb/pophealth.rake b/popHealthDocker_v6/pophealthweb/pophealth.rake new file mode 100644 index 000000000..fe9b8032d --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/pophealth.rake @@ -0,0 +1,222 @@ +require 'open-uri' +require 'highline/import' +require_relative '../../contrib/measure_dates.rb' + +namespace :pophealth do + task :setup => :environment + + desc "Removes properties from the measures document that are not needed by popHealth" + task :prune_measures => :environment do + HealthDataStandards::CQM::Measure.each do |measure| + measure.remove_attribute(:hqmf_document) + measure.remove_attribute(:data_criteria) + measure.save! + end + end + + desc "Remove a bundle from the db" + task :drop_bundle, [:version] => :environment do |t,args| + if args.version + Bundle.where({version: args.version}).each{|b| b.delete} + end + + end + + + task :download_value_sets, [:username, :password] => :environment do |t, args| + valuesets = Measure.all.collect {|m| m['oids']} + errors = {} + valuesets.flatten! + valuesets.compact! + valuesets.uniq! + config = APP_CONFIG['value_sets'] + api = HealthDataStandards::Util::VSApi.new(config["ticket_url"],config["api_url"],args.username,args.password) + RestClient.proxy = ENV["http_proxy"] + valuesets.each_with_index do |oid,index| + begin + vs_data = api.get_valueset(oid) + vs_data.force_encoding("utf-8") # there are some funky unicodes coming out of the vs response that are not in ASCII as the string reports to be + doc = Nokogiri::XML(vs_data) + + doc.root.add_namespace_definition("vs","urn:ihe:iti:svs:2008") + vs_element = doc.at_xpath("/vs:RetrieveValueSetResponse/vs:ValueSet") + + if vs_element && vs_element["ID"] == oid + vs_element["id"] = oid + vs = HealthDataStandards::SVS::ValueSet.load_from_xml(doc) + # look to see if there is a valueset with the given oid and version already in the db + old = HealthDataStandards::SVS::ValueSet.where({:oid=>vs.oid, :version=>vs.version}).first + if old.nil? + vs.save! + end + else + errors[oid] = "Not Found" + end + rescue + errors[oid] = $!.message + end + print "\r" + print "#{index+1} of #{valuesets.length} processed : error downloading #{errors.keys.length} valuesets" + STDOUT.flush + end + + if !errors.empty? + File.open("oid_errors.txt", "w") do |f| + f.puts errors.to_yaml + end + puts "" + puts "There were errors retreiveing #{errors.keys.length} valuesets. Cypress May not work correctly without thses valusets installed." + puts "A list of the valueset OIDs that were unable to be retrieved have been written to the file oid_errors.txt" + end + end + desc %{ Download measure/test deck bundle. + options + nlm_user - the nlm username to authenticate to the server - will prompt is not supplied + nlm_passwd - the nlm password for authenticating to the server - will prompt if not supplied + version - the version of the bundle to download. This will default to the version + declared in the config/cypress.yml file or to the latest version if one does not exist there" + + example usage: + rake cypress:bundle_download nlm_name=username nlm_passwd=password version=2.1.0-latest + } + + task :download_bundle => :setup do + nlm_user = ENV["nlm_user"] + nlm_passwd = ENV["nlm_pass"] + measures_dir = File.join(Rails.root, "bundles") + while nlm_user.nil? || nlm_user == "" + nlm_user = ask("NLM Username?: "){ |q| q.readline = true } + end + + while nlm_passwd.nil? || nlm_passwd == "" + nlm_passwd = ask("NLM Password?: "){ |q| q.echo = false + q.readline = true } + end + + bundle_version = ENV["version"] || APP_CONFIG["default_bundle"] || "latest" + @bundle_name = "bundle-#{bundle_version}.zip" + + puts "Downloading and saving #{@bundle_name} to #{measures_dir}" + # Pull down the list of bundles and download the version we're looking for + bundle_uri = "https://cypressdemo.healthit.gov/measure_bundles/#{@bundle_name}" + bundle = nil + + tries = 0 + max_tries = 10 + last_error = nil +# while bundle.nil? && tries < max_tries do +# tries = tries + 1 +# begin +# bundle = open(bundle_uri, :proxy => ENV["http_proxy"],:http_basic_authentication=>[nlm_user, nlm_passwd] ) +# rescue OpenURI::HTTPError => oe +# last_error = oe +# if oe.message == "401 Unauthorized" +# puts "Please check your credentials and try again" +# break +# end +# rescue => e +# last_error = e +# sleep 0.5 +# end +# end + +# if bundle.nil? +# puts "An error occured while downloading the bundle" +# raise last_error if last_error +# end + # Save the bundle to the measures directory + FileUtils.mkdir_p measures_dir +# FileUtils.mv(bundle.path, File.join(measures_dir, @bundle_name)) + File.join(measures_dir, @bundle_name) + + # Using Open URI is now redundant. Need to change it local file import + puts "Downloading Static Measure files" + @static_bundle_name = File.join(measures_dir,"static_measures.zip") + static_bundle_uri = "https://github.com/WorldVistA/popHealth/blob/v6/lib/measures/cql_measure_json.zip?raw=true" + static_bundle = nil + + tries = 0 + max_tries = 10 + last_error = nil + while static_bundle.nil? && tries < max_tries do + tries = tries + 1 + begin + static_bundle = open(static_bundle_uri, :proxy => ENV["http_proxy"]) + rescue => e + last_error = e + sleep 0.5 + end + end + + if static_bundle.nil? + puts "An error occured while downloading the bundle" + raise last_error if last_error + end + File.open(@static_bundle_name, 'wb') do |fo| + fo.write static_bundle.read + end + + end + + desc %{ Download and install the measure/test deck bundle. This is essientally delegating to the bundle_download and bundle:import tasks + options + nlm_user - the nlm username to authenticate to the server - will prompt is not supplied + nlm_passwd - the nlm password for authenticating to the server - will prompt if not supplied + version - the version of the bundle to download. This will default to the version + declared in the config/cypress.yml file or to the latest version if one does not exist there" + delete_existing - delete any existing bundles with the same version and reinstall - default is false - will cause error if same version already exists + update_measures - update any existing measures with the same hqmf_id to those contained in this bundle. + Will only work for bundle versions greater than that of the installed version - default is false + type - type of measures to be installed from bundle. A bundle may have measures of different types such as ep or eh. This will constrain the types installed, defautl is all types + example usage: + rake cypress:bundle_download_and_install nlm_name=username nlm_passwd=password version=2.1.0-latest type=ep + } + task :bundle_download_and_install => [:download_bundle] do + de = ENV['delete_existing'] || false + um = ENV['update_measures'] || false + puts "Importing bundle #{@bundle_name} delete_existing: #{de} update_measures: #{um} type: #{ENV['type'] || 'ALL'}" + task("bundle:import").invoke("bundles/#{@bundle_name}",de, um , ENV['type']) + end + + desc 'Modify an existing bundle to support variable dates and then import it' + task :update_import, [:bundle_path, :delete_existing, :update_measures, :type, :create_indexes, :exclude_results] => :environment do |task, args| + puts "Modifying bundle #{args.bundle_path} to support variable date ranges" + modify_bundle_dates(args.bundle_path) + task("bundle:import").invoke(args.bundle_path, args.delete_existing, args.update_measures, args.type, args.create_indexes, args.exclude_results) + end + + desc 'Automatically downloads bundle and modifies for variable dates. See download_bundle for params' + task :download_update_install => [:download_bundle] do + #de = ENV['delete_existing'] || false + #um = ENV['update_measures'] || false + options ={:delete_existing => false, + :update_measures => false} + puts "Modifying bundle #{@bundle_name} to support variable date ranges" + modify_bundle_dates("bundles/#{@bundle_name}") + import_bundle(@bundle_name,options) + import_static_bundle("static_measures.zip") + #task("bundle:import").invoke("bundles/#{@bundle_name}",de, um , ENV['type'],false, er) + + task("pophealth:remove_artifacts").invoke + end + + desc 'Adds date modification to import of bundle on disk' + task :import , [:bundle_path] do |task, args| + de = ENV['delete_existing'] || false + um = ENV['update_measures'] || false + + @bundle_name=args.bundle_path + puts "Modifying bundle #{@bundle_name} to support variable date ranges" + modify_bundle_dates(@bundle_name) + task("bundle:import").invoke(@bundle_name,de, um , ENV['type']) + task("pophealth:remove_artifacts").invoke + end + + desc 'Removes Cypress artifacts of patient_cache, query_cache, and records' + task :remove_artifacts => :environment do + puts "Cleaning out records and caches" + QDM::Patient.delete_all + HealthDataStandards::CQM::QueryCache.delete_all + QDM::IndividualResult.delete_all + end +end \ No newline at end of file diff --git a/popHealthDocker_v6/pophealthweb/start.sh b/popHealthDocker_v6/pophealthweb/start.sh new file mode 100644 index 000000000..245dffe51 --- /dev/null +++ b/popHealthDocker_v6/pophealthweb/start.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +cd /popHealth +sleep 20 + +checkFILE=/popHealth/setupComplete + +if ! test -f "$checkFILE"; then + #echo "Downloading Bundle with user $NLM_USERNAME" + bundle exec rake pophealth:download_update_install nlm_user=$NLM_USERNAME nlm_pass=$NLM_PASSWORD version=2018 RAILS_ENV=production + echo "Creating Admin Account" + bundle exec rake admin:create_admin_account RAILS_ENV=production + echo "Precompiling assest" + rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/popHealth + touch /popHealth/setupComplete + chmod -R 777 /popHealth/ +fi + +echo "Starting popHealth" +bundle exec rake jobs:work RAILS_ENV=production & /usr/sbin/apache2ctl -D FOREGROUND From 7a7717e062eb81dacfdc658d72806e14ee77713c Mon Sep 17 00:00:00 2001 From: mikestark Date: Wed, 17 Jun 2020 15:37:33 -0400 Subject: [PATCH 2/2] Add files via upload --- popHealthDocker_v6/docker ReadMe.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 popHealthDocker_v6/docker ReadMe.md diff --git a/popHealthDocker_v6/docker ReadMe.md b/popHealthDocker_v6/docker ReadMe.md new file mode 100644 index 000000000..efdf73d8d --- /dev/null +++ b/popHealthDocker_v6/docker ReadMe.md @@ -0,0 +1,20 @@ +Some quick notes on popHealth v6 docker-compose: + +1) I have used this project on both Windows Desktop and a couple different Ubuntu server hosts using the CE versions of docker. I had a bit of trouble downloading the 'static measure' section on one server. The work around was to simply pull the content manually and commented out the fetch section in pophealth.rake. This hack (removing the cql_measure_json.zip fetch inside pophealth.rake) is NOT included here. However, I do include a very similar hack to use a local instance of the bundle-2018.zip. In this case, I figured it was easier to grab it once and re-use it rather than downloading every time. + +2) Some optional hacks are available as comments inside the pophealthweb Dockerfile, including both #1 above and using a pre-prepped popHealth.yml. Use what works best for you. + +3) This version works -- but I have not gone back to optimize it. Meaning, some of the image fetches are very specific -- for example the mongo:2.4.23 and the rabbitmq:3.7.14. I have not gone back to complete test how flexible some of these things are -- or what kinds of code updates would be necessary to upgrade. You'll also notice I create a new js-ecqm-engine-docker image. I tried to use the public, available js-ecqm_engine docker image from docker hub. But was not successful, so I ended up copying their docker file to build my own image. + +4) In a similar vein as above (#3), I'm not sure if the #fix JSON Parse bit in the pophealthweb\Dockerfile is necessary. This was an early experiment that was never revisited. It doesn't seem to hurt... but I don't think it is needed. + +5) You'll notice the PH1 and PH2 folder instances. These function as independent running stacks. To create more iterations (PHn) simply copy PH1 and update the pophealthweb port (8082:80) to use a new, unique port (for example: 8084:80). + +6) The start up the running stack by: + PS C:\docker\popHealthDocker - Public\PH1>docker-compose build + -- and -- + PS C:\docker\popHealthDocker - Public\PH1>docker-compose up + + You can also start it up in detached mode. + +7) pophealth v6 is already obsolete. I expect this will have a limited shelf-life. But it might find some use.