lib/generator/js.rb in hqmf2js-1.0.1 vs lib/generator/js.rb in hqmf2js-1.1.0

- old
+ new

@@ -44,10 +44,21 @@ def field_method(field_name) HQMF::DataCriteria::FIELDS[field_name][:coded_entry_method].to_s.camelize(:lower) end + def field_library_method(field_name) + field_type = HQMF::DataCriteria::FIELDS[field_name][:field_type] + if field_type == :value + 'filterEventsByField' + elsif field_type == :timestamp + 'adjustBoundsForField' + elsif field_type == :nested_timestamp + 'denormalizeEventsByLocation' + end + end + def js_for_value(value) if value if value.respond_to?(:derived?) && value.derived? value.expression else @@ -117,10 +128,12 @@ end def js_for_code_list(criteria) if criteria.inline_code_list criteria.inline_code_list.to_json + elsif criteria.code_list_id.nil? + "null" else "getCodes(\"#{criteria.code_list_id}\")" end end @@ -185,10 +198,12 @@ #{js_for(population[HQMF::PopulationCriteria::DENOM], HQMF::PopulationCriteria::DENOM, true)} // NUMERATOR #{js_for(population[HQMF::PopulationCriteria::NUMER], HQMF::PopulationCriteria::NUMER)} #{js_for(population[HQMF::PopulationCriteria::DENEX], HQMF::PopulationCriteria::DENEX)} #{js_for(population[HQMF::PopulationCriteria::DENEXCEP], HQMF::PopulationCriteria::DENEXCEP)} + // CV + #{js_for(population[HQMF::PopulationCriteria::MSRPOPL], HQMF::PopulationCriteria::MSRPOPL)} " end def js_initialize_specifics(data_criteria) specific_occurrences = [] @@ -198,11 +213,11 @@ end end json_list = specific_occurrences.map {|occurrence| occurrence.to_json} specifics_list = json_list.join(',') specifics_list = ",#{specifics_list}" unless specifics_list.empty? - "hqmfjs.initializeSpecifics = function(patient_api, hqmfjs) { Specifics.initialize(patient_api,hqmfjs#{specifics_list}) }" + "hqmfjs.initializeSpecifics = function(patient_api, hqmfjs) { hqmf.SpecificsManager.initialize(patient_api,hqmfjs#{specifics_list}) }" end # Generate JS for a HQMF2::PopulationCriteria def js_for(criteria_code, type=nil, when_not_found=false) # for multiple populations, criteria code will be something like IPP_1 and type will be IPP @@ -223,19 +238,24 @@ def self.library_functions ctx = Sprockets::Environment.new(File.expand_path("../../..", __FILE__)) Tilt::CoffeeScriptTemplate.default_bare = true ctx.append_path "app/assets/javascripts" - ["// #########################\n// ###### PATIENT API #######\n// #########################\n", + ["// #########################\n// ###### Underscore.js #######\n// #######################\n", + ctx.find_asset('underscore').to_s, + "// #########################\n// ###### PATIENT API #######\n// #########################\n", HqueryPatientApi::Generator.patient_api_javascript.to_s, + "// #########################\n// ## SPECIFIC OCCURRENCES ##\n// #########################\n", + ctx.find_asset('specifics').to_s, "// #########################\n// ### LIBRARY FUNCTIONS ####\n// #########################\n", ctx.find_asset('hqmf_util').to_s, "// #########################\n// ### PATIENT EXTENSION ####\n// #########################\n", ctx.find_asset('patient_api_extension').to_s, + "// #########################\n// ## CUSTOM CALCULATIONS ###\n// #########################\n", + ctx.find_asset('custom_calculations').to_s, "// #########################\n// ##### LOGGING UTILS ######\n// #########################\n", - ctx.find_asset('logging_utils').to_s, - "// #########################\n// ## SPECIFIC OCCURRENCES ##\n// #########################\n", - ctx.find_asset('specifics').to_s].join("\n") + ctx.find_asset('logging_utils').to_s].join("\n") + end end # Simple class to issue monotonically increasing integer identifiers \ No newline at end of file