app/assets/javascripts/logging_utils.js.coffee in hqmf2js-1.2.1 vs app/assets/javascripts/logging_utils.js.coffee in hqmf2js-1.3.0
- old
+ new
@@ -2,15 +2,22 @@
@logger: []
@rationale: {}
@info: (string) ->
if @enable_logging
@logger.push("#{Logger.indent()}#{string}")
+
@record: (id, result) ->
if @enable_rationale and result? and typeof(result.isTrue) == 'function'
- @rationale[id] = result.isTrue()
+ if result.isTrue() and result.length
+ json_results = _.map(result,(item) -> {id: item.id, json: item.json})
+ @rationale[id] = {results: json_results }
+ else
+ @rationale[id] = result.isTrue()
+
@enable_logging: true
@enable_rationale: true
+ @short_circuit: true
@initialized: false
@indentCount = 0
@indent: ->
indent = ''
(indent+=' ' for num in [0..@indentCount*8])
@@ -65,13 +72,14 @@
do (row) ->
Logger.info(row)
Logger.indentCount--
-@injectLogger = (hqmfjs, enable_logging, enable_rationale) ->
+@injectLogger = (hqmfjs, enable_logging, enable_rationale, short_circuit) ->
Logger.enable_logging = enable_logging
Logger.enable_rationale = enable_rationale
+ Logger.short_circuit = short_circuit
# Wrap all of the data criteria functions generated from HQMF
_.each(_.functions(hqmfjs), (method) ->
if method != 'initializeSpecifics'
hqmfjs[method] = _.wrap(hqmfjs[method], (func) ->
@@ -96,23 +104,24 @@
if (!Logger.initialized)
Logger.initialized=true
# Wrap selected hQuery Patient API functions
_.each(_.functions(hQuery.Patient.prototype), (method) ->
- if (hQuery.Patient.prototype[method].length == 0)
- hQuery.Patient.prototype[method] = _.wrap(hQuery.Patient.prototype[method], (func) ->
- Logger.info("called patient.#{method}():")
- func = _.bind(func, this)
- result = func()
- Logger.info("patient.#{method}() -> #{Logger.stringify(result)}")
- return result;);
- else
- hQuery.Patient.prototype[method] = _.wrap(hQuery.Patient.prototype[method], (func) ->
- args = Array.prototype.slice.call(arguments,1)
- Logger.info("called patient.#{method}(#{args}):")
- result = func.apply(this, args)
- Logger.info("patient.#{method}(#{args}) -> #{Logger.stringify(result)}")
- return result;);
+ if method != 'getEvents' && method != 'getAndCacheEvents'
+ if (hQuery.Patient.prototype[method].length == 0)
+ hQuery.Patient.prototype[method] = _.wrap(hQuery.Patient.prototype[method], (func) ->
+ Logger.info("called patient.#{method}():")
+ func = _.bind(func, this)
+ result = func()
+ Logger.info("patient.#{method}() -> #{Logger.stringify(result)}")
+ return result;);
+ else
+ hQuery.Patient.prototype[method] = _.wrap(hQuery.Patient.prototype[method], (func) ->
+ args = Array.prototype.slice.call(arguments,1)
+ Logger.info("called patient.#{method}(#{args}):")
+ result = func.apply(this, args)
+ Logger.info("patient.#{method}(#{args}) -> #{Logger.stringify(result)}")
+ return result;);
);
hQuery.CodedEntryList.prototype.match = _.wrap(hQuery.CodedEntryList.prototype.match, (func, codeSet, start, end) ->
func = _.bind(func, this, codeSet,start,end)