cql_qdm_patientapi 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d90e0a82b8504ddfea9c98fcfe611dbb10d0844
4
- data.tar.gz: 85e593400fcf1bdca7517af28db957767975b121
3
+ metadata.gz: 659f615743826808dbce1d1ec7dd5e1385426919
4
+ data.tar.gz: 5625c679daf1daee95e4342a0de2fb6eda0a93ea
5
5
  SHA512:
6
- metadata.gz: 68b65eb813a96473005f003ece85a472bfd58516179e6f3d5d8fd7a2260761e65c31e4d32301bc717ad48c2be4e6d444f4cf2cbf45bd88bc5bf79b5669d47527
7
- data.tar.gz: dfd69d85f7a52b462438b68c06329350d218db88562ad23f4716be95d62d367aaa0a0d37c442037ca98a8e3b32799e3d51381f42efa42b7fbb0aafaa153b87d2
6
+ metadata.gz: 4e9f06d1e02c62785c618bc02664dc3c09afd52d885b6bda4ef3b8d88c0fde2bef1411801d225d85d46cf7ed9e332ea3dcba4dae91ed5af5e298e3e5157315c4
7
+ data.tar.gz: c60010d6a24ffd6a08f84913692c50ddcb5f3422a7540792c7189573ff5d5b757cbfbc966e10d149099ee35c3a300c41fe586cfb858d170f4b83c43e8b457965
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cql_qdm_patientapi (1.1.1)
4
+ cql_qdm_patientapi (1.1.2)
5
5
  coffee-rails (~> 4.1)
6
6
  rails (~> 4.2)
7
7
  sprockets-rails (~> 2.3)
@@ -52,8 +52,8 @@ class CQL_QDM.CareGoal extends CQL_QDM.QDMDatatype
52
52
  ###
53
53
  targetOutcome: ->
54
54
  if @_targetOutcome?
55
- if @_targetOutcome?['unit']?
56
- new cql.Quantity({unit: @_targetOutcome['unit'], value: @_targetOutcome['scalar']})
55
+ if @_targetOutcome?['units']?
56
+ new cql.Quantity({unit: @_targetOutcome['units'], value: @_targetOutcome['scalar']})
57
57
  else
58
58
  new cql.Code(@_targetOutcome.code, @_targetOutcome.code_system)
59
59
  else
@@ -11,7 +11,7 @@ QDM datatypes must support.
11
11
  ###
12
12
  class CQL_QDM.QDMDatatype
13
13
  constructor: (@entry) ->
14
- @_codes = @entry.codes
14
+ @_codes = @entry?.codes
15
15
 
16
16
  ###
17
17
  Returns any instances of this attribute currently within this namespace.
@@ -55,3 +55,25 @@ class CQL_QDM.QDMDatatype
55
55
  break
56
56
  null
57
57
 
58
+ ###
59
+ Returns a human readable representation of this datatype.
60
+
61
+ An example looks like:
62
+ "Encounter, Performed: Outpatient Consultation
63
+ START: 09/30/2012 2:00 PM
64
+ STOP: 09/30/2012 2:15 PM
65
+ CODE: CPT 99241"
66
+
67
+ @returns {String}
68
+ ###
69
+ toString: ->
70
+ # Grab description from entry; if blank use classname
71
+ description = if @entry?.description then "#{@entry.description}\n" else "#{@constructor.name}\n"
72
+ # Grab start and end time, format for proper display
73
+ startTime = if @entry?.start_time then "START: #{moment.utc(@entry.start_time, 'X').format('MM/DD/YYYY h:mm A')}\n" else ""
74
+ endTime = if @entry?.end_time then "STOP: #{moment.utc(@entry.end_time, 'X').format('MM/DD/YYYY h:mm A')}\n" else ""
75
+ # Get code if this datatype has one
76
+ code = @code() if @_codes
77
+ codeDisplay = if code then "CODE: #{code['system']} #{code['code']}" else ""
78
+ # Return human readable representation of this datatype
79
+ "#{description}#{startTime}#{endTime}#{codeDisplay}".replace /\n$/, ''
@@ -34,7 +34,7 @@ class CQL_QDM.ImmunizationAdministered extends CQL_QDM.QDMDatatype
34
34
  ###
35
35
  dosage: ->
36
36
  if @_dosage?
37
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
37
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
38
38
  else
39
39
  null
40
40
 
@@ -70,7 +70,7 @@ class CQL_QDM.ImmunizationAdministered extends CQL_QDM.QDMDatatype
70
70
  ###
71
71
  supply: ->
72
72
  if @_supply?
73
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
73
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
74
74
  else
75
75
  null
76
76
 
@@ -111,7 +111,7 @@ class CQL_QDM.ImmunizationOrder extends CQL_QDM.QDMDatatype
111
111
  ###
112
112
  dosage: ->
113
113
  if @_dosage?
114
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
114
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
115
115
  else
116
116
  null
117
117
 
@@ -147,6 +147,6 @@ class CQL_QDM.ImmunizationOrder extends CQL_QDM.QDMDatatype
147
147
  ###
148
148
  supply: ->
149
149
  if @_supply?
150
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
150
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
151
151
  else
152
152
  null
@@ -124,19 +124,19 @@ class CQL_QDM.LaboratoryTestPerformed extends CQL_QDM.QDMDatatype
124
124
  # According to documentation, this is assumed to be a 'Quantity'
125
125
  high = null
126
126
  low = null
127
- if @_referenceRangeHigh?['unit']?
127
+ if @_referenceRangeHigh?['units']?
128
128
  high_obj =
129
129
  unit:
130
- @_referenceRangeHigh['unit']
130
+ @_referenceRangeHigh['units']
131
131
  value:
132
- @_referenceRangeHigh['value']
132
+ @_referenceRangeHigh['scalar']
133
133
  high = new cql.Quantity(high_obj)
134
- if @_referenceRangeLow?['unit']?
134
+ if @_referenceRangeLow?['units']?
135
135
  low_obj =
136
136
  unit:
137
- @_referenceRangeLow['unit']
137
+ @_referenceRangeLow['units']
138
138
  value:
139
- @_referenceRangeLow['value']
139
+ @_referenceRangeLow['scalar']
140
140
  low = new cql.Quantity(low_obj)
141
141
  if low?
142
142
  new cql.Interval(low, high)
@@ -34,7 +34,7 @@ class CQL_QDM.MedicationActive extends CQL_QDM.QDMDatatype
34
34
  ###
35
35
  dosage: ->
36
36
  if @_dosage?
37
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
37
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
38
38
  else
39
39
  null
40
40
 
@@ -43,7 +43,7 @@ class CQL_QDM.MedicationActive extends CQL_QDM.QDMDatatype
43
43
  ###
44
44
  frequency: ->
45
45
  if @_frequency?
46
- new cql.Code(@_frequency.code, @_frequency.code_system, @_frequency.version, @_frequency.title)
46
+ new cql.Code(@_frequency.code, @_frequency.code_system)
47
47
  else
48
48
  null
49
49
 
@@ -72,7 +72,7 @@ class CQL_QDM.MedicationActive extends CQL_QDM.QDMDatatype
72
72
  ###
73
73
  supply: ->
74
74
  if @_supply?
75
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
75
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
76
76
  else
77
77
  null
78
78
 
@@ -114,7 +114,7 @@ class CQL_QDM.MedicationAdministered extends CQL_QDM.QDMDatatype
114
114
  ###
115
115
  dosage: ->
116
116
  if @_dosage?
117
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
117
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
118
118
  else
119
119
  null
120
120
 
@@ -123,7 +123,7 @@ class CQL_QDM.MedicationAdministered extends CQL_QDM.QDMDatatype
123
123
  ###
124
124
  frequency: ->
125
125
  if @_frequency?
126
- new cql.Code(@_frequency.code, @_frequency.code_system, @_frequency.version, @_frequency.title)
126
+ new cql.Code(@_frequency.code, @_frequency.code_system)
127
127
  else
128
128
  null
129
129
 
@@ -170,7 +170,7 @@ class CQL_QDM.MedicationAdministered extends CQL_QDM.QDMDatatype
170
170
  ###
171
171
  supply: ->
172
172
  if @_supply?
173
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
173
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
174
174
  else
175
175
  null
176
176
 
@@ -206,7 +206,7 @@ class CQL_QDM.MedicationDischarge extends CQL_QDM.QDMDatatype
206
206
  ###
207
207
  dosage: ->
208
208
  if @_dosage?
209
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
209
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
210
210
  else
211
211
  null
212
212
 
@@ -215,7 +215,7 @@ class CQL_QDM.MedicationDischarge extends CQL_QDM.QDMDatatype
215
215
  ###
216
216
  frequency: ->
217
217
  if @_frequency?
218
- new cql.Code(@_frequency.code, @_frequency.code_system, @_frequency.version, @_frequency.title)
218
+ new cql.Code(@_frequency.code, @_frequency.code_system)
219
219
  else
220
220
  null
221
221
 
@@ -251,7 +251,7 @@ class CQL_QDM.MedicationDischarge extends CQL_QDM.QDMDatatype
251
251
  ###
252
252
  supply: ->
253
253
  if @_supply?
254
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
254
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
255
255
  else
256
256
  null
257
257
 
@@ -297,7 +297,7 @@ class CQL_QDM.MedicationDispensed extends CQL_QDM.QDMDatatype
297
297
  ###
298
298
  dosage: ->
299
299
  if @_dosage?
300
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
300
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
301
301
  else
302
302
  null
303
303
 
@@ -306,7 +306,7 @@ class CQL_QDM.MedicationDispensed extends CQL_QDM.QDMDatatype
306
306
  ###
307
307
  frequency: ->
308
308
  if @_frequency?
309
- new cql.Code(@_frequency.code, @_frequency.code_system, @_frequency.version, @_frequency.title)
309
+ new cql.Code(@_frequency.code, @_frequency.code_system)
310
310
  else
311
311
  null
312
312
 
@@ -353,7 +353,7 @@ class CQL_QDM.MedicationDispensed extends CQL_QDM.QDMDatatype
353
353
  ###
354
354
  supply: ->
355
355
  if @_supply?
356
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
356
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
357
357
  else
358
358
  null
359
359
 
@@ -403,7 +403,7 @@ class CQL_QDM.MedicationOrder extends CQL_QDM.QDMDatatype
403
403
  ###
404
404
  dosage: ->
405
405
  if @_dosage?
406
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
406
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
407
407
  else
408
408
  null
409
409
 
@@ -412,7 +412,7 @@ class CQL_QDM.MedicationOrder extends CQL_QDM.QDMDatatype
412
412
  ###
413
413
  frequency: ->
414
414
  if @_frequency?
415
- new cql.Code(@_frequency.code, @_frequency.code_system, @_frequency.version, @_frequency.title)
415
+ new cql.Code(@_frequency.code, @_frequency.code_system)
416
416
  else
417
417
  null
418
418
 
@@ -477,6 +477,6 @@ class CQL_QDM.MedicationOrder extends CQL_QDM.QDMDatatype
477
477
  ###
478
478
  supply: ->
479
479
  if @_supply?
480
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
480
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
481
481
  else
482
482
  null
@@ -41,7 +41,7 @@ class CQL_QDM.SubstanceAdministered extends CQL_QDM.QDMDatatype
41
41
  ###
42
42
  dosage: ->
43
43
  if @_dosage?
44
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
44
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
45
45
  else
46
46
  null
47
47
 
@@ -88,7 +88,7 @@ class CQL_QDM.SubstanceAdministered extends CQL_QDM.QDMDatatype
88
88
  ###
89
89
  supply: ->
90
90
  if @_supply?
91
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
91
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
92
92
  else
93
93
  null
94
94
 
@@ -124,7 +124,7 @@ class CQL_QDM.SubstanceOrder extends CQL_QDM.QDMDatatype
124
124
  ###
125
125
  dosage: ->
126
126
  if @_dosage?
127
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
127
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
128
128
  else
129
129
  null
130
130
 
@@ -187,7 +187,7 @@ class CQL_QDM.SubstanceOrder extends CQL_QDM.QDMDatatype
187
187
  ###
188
188
  supply: ->
189
189
  if @_supply?
190
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
190
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
191
191
  else
192
192
  null
193
193
 
@@ -224,7 +224,7 @@ class CQL_QDM.SubstanceRecommended extends CQL_QDM.QDMDatatype
224
224
  ###
225
225
  dosage: ->
226
226
  if @_dosage?
227
- new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['scalar']})
227
+ new cql.Quantity({unit: @_dosage['units'], value: @_dosage['scalar']})
228
228
  else
229
229
  null
230
230
 
@@ -287,6 +287,6 @@ class CQL_QDM.SubstanceRecommended extends CQL_QDM.QDMDatatype
287
287
  ###
288
288
  supply: ->
289
289
  if @_supply?
290
- new cql.Quantity({unit: @_supply['unit'], value: @_supply['scalar']})
290
+ new cql.Quantity({unit: @_supply['units'], value: @_supply['scalar']})
291
291
  else
292
292
  null
@@ -1,3 +1,3 @@
1
1
  module CqlQdmPatientapi
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -551,7 +551,7 @@
551
551
  },{"./clinical":5,"./datetime":7,"./interval":9,"./logic":10,"./uncertainty":11}],7:[function(require,module,exports){
552
552
  // Generated by CoffeeScript 1.12.7
553
553
  (function() {
554
- var DateTime, Uncertainty, moment;
554
+ var DateTime, Uncertainty, convertTimezoneOffset, cqlFormatStringToMomentFormatString, getTimezoneSeparatorFromString, isValidDateTimeStringFormat, moment, normalizeMillisecondsField, normalizeMillisecondsFieldInString;
555
555
 
556
556
  Uncertainty = require('./uncertainty').Uncertainty;
557
557
 
@@ -572,36 +572,51 @@
572
572
  DateTime.FIELDS = [DateTime.Unit.YEAR, DateTime.Unit.MONTH, DateTime.Unit.DAY, DateTime.Unit.HOUR, DateTime.Unit.MINUTE, DateTime.Unit.SECOND, DateTime.Unit.MILLISECOND];
573
573
 
574
574
  DateTime.parse = function(string) {
575
- var arg, args, match, num, regex;
576
- match = regex = /(\d{4})(-(\d{2}))?(-(\d{2}))?(T((\d{2})(\:(\d{2})(\:(\d{2})(\.(\d+))?)?)?)?(Z|(([+-])(\d{2})(\:?(\d{2}))?))?)?/.exec(string);
577
- if ((match != null ? match[0] : void 0) === string) {
578
- args = [match[1], match[3], match[5], match[8], match[10], match[12], match[14]];
579
- if (args[6] != null) {
580
- args[6] = (args[6] + "00").substring(0, 3);
581
- }
582
- args = (function() {
583
- var i, len, results;
584
- results = [];
585
- for (i = 0, len = args.length; i < len; i++) {
586
- arg = args[i];
587
- results.push(arg != null ? parseInt(arg, 10) : void 0);
588
- }
589
- return results;
590
- })();
591
- if (match[18] != null) {
592
- num = parseInt(match[18], 10) + (match[20] != null ? parseInt(match[20], 10) / 60 : 0);
593
- args.push(match[17] === '+' ? num : num * -1);
594
- } else if (match[15] === 'Z') {
595
- args.push(0);
596
- }
597
- return (function(func, args, ctor) {
598
- ctor.prototype = func.prototype;
599
- var child = new ctor, result = func.apply(child, args);
600
- return Object(result) === result ? result : child;
601
- })(DateTime, args, function(){});
602
- } else {
575
+ var arg, args, days, hours, matches, milliseconds, minutes, months, num, seconds, years;
576
+ if (string === null) {
603
577
  return null;
604
578
  }
579
+ matches = /(\d{4})(-(\d{2}))?(-(\d{2}))?(T((\d{2})(\:(\d{2})(\:(\d{2})(\.(\d+))?)?)?)?(Z|(([+-])(\d{2})(\:?(\d{2}))?))?)?/.exec(string);
580
+ if (matches == null) {
581
+ throw new Error('Invalid DateTime String: ' + string);
582
+ }
583
+ years = matches[1];
584
+ months = matches[3];
585
+ days = matches[5];
586
+ hours = matches[8];
587
+ minutes = matches[10];
588
+ seconds = matches[12];
589
+ milliseconds = matches[14];
590
+ if (milliseconds != null) {
591
+ milliseconds = normalizeMillisecondsField(milliseconds);
592
+ }
593
+ if (milliseconds != null) {
594
+ string = normalizeMillisecondsFieldInString(string, matches);
595
+ }
596
+ if (!isValidDateTimeStringFormat(string)) {
597
+ throw new Error('Invalid DateTime String: ' + string);
598
+ }
599
+ args = [years, months, days, hours, minutes, seconds, milliseconds];
600
+ args = (function() {
601
+ var i, len, results;
602
+ results = [];
603
+ for (i = 0, len = args.length; i < len; i++) {
604
+ arg = args[i];
605
+ results.push(arg != null ? parseInt(arg, 10) : void 0);
606
+ }
607
+ return results;
608
+ })();
609
+ if (matches[18] != null) {
610
+ num = parseInt(matches[18], 10) + (matches[20] != null ? parseInt(matches[20], 10) / 60 : 0);
611
+ args.push(matches[17] === '+' ? num : num * -1);
612
+ } else if (matches[15] === 'Z') {
613
+ args.push(0);
614
+ }
615
+ return (function(func, args, ctor) {
616
+ ctor.prototype = func.prototype;
617
+ var child = new ctor, result = func.apply(child, args);
618
+ return Object(result) === result ? result : child;
619
+ })(DateTime, args, function(){});
605
620
  };
606
621
 
607
622
  DateTime.fromDate = function(date, timezoneOffset) {
@@ -1114,6 +1129,82 @@
1114
1129
 
1115
1130
  })();
1116
1131
 
1132
+ normalizeMillisecondsFieldInString = function(string, matches) {
1133
+ var beforeMs, msAndAfter, msString, ref, timezoneField, timezoneSeparator;
1134
+ msString = matches[14];
1135
+ msString = normalizeMillisecondsField(msString);
1136
+ ref = string.split('.'), beforeMs = ref[0], msAndAfter = ref[1];
1137
+ timezoneSeparator = getTimezoneSeparatorFromString(msAndAfter);
1138
+ if (!!timezoneSeparator) {
1139
+ timezoneField = msAndAfter != null ? msAndAfter.split(timezoneSeparator)[1] : void 0;
1140
+ }
1141
+ if (timezoneField == null) {
1142
+ timezoneField = '';
1143
+ }
1144
+ return string = beforeMs + '.' + msString + timezoneSeparator + timezoneField;
1145
+ };
1146
+
1147
+ normalizeMillisecondsField = function(msString) {
1148
+ return msString = (msString + "00").substring(0, 3);
1149
+ };
1150
+
1151
+ isValidDateTimeStringFormat = function(string) {
1152
+ var cqlFormatStringWithLength, cqlFormats, format, i, len, strict;
1153
+ if (typeof string !== 'string') {
1154
+ return false;
1155
+ }
1156
+ cqlFormats = ['YYYY', 'YYYY-MM', 'YYYY-MM-DD', 'YYYY-MM-DDTZ', 'YYYY-MM-DDT+hh', 'YYYY-MM-DDT+hh:mm', 'YYYY-MM-DDT-hh', 'YYYY-MM-DDT-hh:mm', 'YYYY-MM-DDThh', 'YYYY-MM-DDThhZ', 'YYYY-MM-DDThh+hh', 'YYYY-MM-DDThh+hh:mm', 'YYYY-MM-DDThh-hh', 'YYYY-MM-DDThh-hh:mm', 'YYYY-MM-DDThh:mm', 'YYYY-MM-DDThh:mmZ', 'YYYY-MM-DDThh:mm+hh', 'YYYY-MM-DDThh:mm+hh:mm', 'YYYY-MM-DDThh:mm-hh', 'YYYY-MM-DDThh:mm-hh:mm', 'YYYY-MM-DDThh:mm:ss', 'YYYY-MM-DDThh:mm:ssZ', 'YYYY-MM-DDThh:mm:ss+hh', 'YYYY-MM-DDThh:mm:ss+hh:mm', 'YYYY-MM-DDThh:mm:ss-hh', 'YYYY-MM-DDThh:mm:ss-hh:mm', 'YYYY-MM-DDThh:mm:ss.fff', 'YYYY-MM-DDThh:mm:ss.fffZ', 'YYYY-MM-DDThh:mm:ss.fff+hh', 'YYYY-MM-DDThh:mm:ss.fff+hh:mm', 'YYYY-MM-DDThh:mm:ss.fff-hh', 'YYYY-MM-DDThh:mm:ss.fff-hh:mm'];
1157
+ cqlFormatStringWithLength = {};
1158
+ for (i = 0, len = cqlFormats.length; i < len; i++) {
1159
+ format = cqlFormats[i];
1160
+ cqlFormatStringWithLength[format.length] = format;
1161
+ }
1162
+ if (cqlFormatStringWithLength[string.length] == null) {
1163
+ return false;
1164
+ }
1165
+ strict = false;
1166
+ return moment(string, cqlFormatStringToMomentFormatString(cqlFormatStringWithLength[string.length]), strict).isValid();
1167
+ };
1168
+
1169
+ cqlFormatStringToMomentFormatString = function(string) {
1170
+ var momentString, ref, timeAndTimeZoneOffset, timezoneSeparator, yearMonthDay;
1171
+ ref = string.split('T'), yearMonthDay = ref[0], timeAndTimeZoneOffset = ref[1];
1172
+ if (timeAndTimeZoneOffset != null) {
1173
+ timezoneSeparator = getTimezoneSeparatorFromString(timeAndTimeZoneOffset);
1174
+ }
1175
+ momentString = yearMonthDay;
1176
+ if (string.match(/T/) != null) {
1177
+ momentString += '[T]';
1178
+ }
1179
+ if (!!timezoneSeparator) {
1180
+ momentString += timeAndTimeZoneOffset.substring(0, timeAndTimeZoneOffset.search(timezoneSeparator)) + '[Z]';
1181
+ } else {
1182
+ momentString += timeAndTimeZoneOffset;
1183
+ }
1184
+ return momentString = momentString.replace(/f/g, 'S');
1185
+ };
1186
+
1187
+ convertTimezoneOffset = function(matches) {
1188
+ var num;
1189
+ num = parseInt(matches[17], 10) + (matches[19] != null ? parseInt(matches[19], 10) / 60 : 0);
1190
+ if (matches[16] === '+') {
1191
+ return num;
1192
+ } else {
1193
+ return num * -1;
1194
+ }
1195
+ };
1196
+
1197
+ getTimezoneSeparatorFromString = function(string) {
1198
+ var ref, ref1, timezoneSeparator;
1199
+ if ((typeof msAndAfter !== "undefined" && msAndAfter !== null ? (ref = msAndAfter.match(/-/)) != null ? ref.length : void 0 : void 0) === 1) {
1200
+ return timezoneSeparator = '-';
1201
+ } else if ((typeof msAndAfter !== "undefined" && msAndAfter !== null ? (ref1 = msAndAfter.match(/\+/)) != null ? ref1.length : void 0 : void 0) === 1) {
1202
+ return timezoneSeparator = '+';
1203
+ } else {
1204
+ return timezoneSeparator = '';
1205
+ }
1206
+ };
1207
+
1117
1208
  }).call(this);
1118
1209
 
1119
1210
 
@@ -2931,20 +3022,14 @@
2931
3022
  }
2932
3023
 
2933
3024
  Less.prototype.exec = function(ctx) {
2934
- var args, error;
3025
+ var args;
2935
3026
  args = this.execArgs(ctx).map(function(x) {
2936
3027
  return Uncertainty.from(x);
2937
3028
  });
2938
- try {
2939
- return args[0].lessThan(args[1]);
2940
- } catch (error1) {
2941
- error = error1;
2942
- if (error instanceof IncompatibleTypesException) {
2943
- return null;
2944
- } else {
2945
- throw error;
2946
- }
3029
+ if (!((args[0] != null) && (args[1] != null))) {
3030
+ return null;
2947
3031
  }
3032
+ return args[0].lessThan(args[1]);
2948
3033
  };
2949
3034
 
2950
3035
  return Less;
@@ -2959,20 +3044,14 @@
2959
3044
  }
2960
3045
 
2961
3046
  LessOrEqual.prototype.exec = function(ctx) {
2962
- var args, error;
3047
+ var args;
2963
3048
  args = this.execArgs(ctx).map(function(x) {
2964
3049
  return Uncertainty.from(x);
2965
3050
  });
2966
- try {
2967
- return args[0].lessThanOrEquals(args[1]);
2968
- } catch (error1) {
2969
- error = error1;
2970
- if (error instanceof IncompatibleTypesException) {
2971
- return null;
2972
- } else {
2973
- throw error;
2974
- }
3051
+ if (!((args[0] != null) && (args[1] != null))) {
3052
+ return null;
2975
3053
  }
3054
+ return args[0].lessThanOrEquals(args[1]);
2976
3055
  };
2977
3056
 
2978
3057
  return LessOrEqual;
@@ -2987,20 +3066,14 @@
2987
3066
  }
2988
3067
 
2989
3068
  Greater.prototype.exec = function(ctx) {
2990
- var args, error;
3069
+ var args;
2991
3070
  args = this.execArgs(ctx).map(function(x) {
2992
3071
  return Uncertainty.from(x);
2993
3072
  });
2994
- try {
2995
- return args[0].greaterThan(args[1]);
2996
- } catch (error1) {
2997
- error = error1;
2998
- if (error instanceof IncompatibleTypesException) {
2999
- return null;
3000
- } else {
3001
- throw error;
3002
- }
3073
+ if (!((args[0] != null) && (args[1] != null))) {
3074
+ return null;
3003
3075
  }
3076
+ return args[0].greaterThan(args[1]);
3004
3077
  };
3005
3078
 
3006
3079
  return Greater;
@@ -3015,20 +3088,14 @@
3015
3088
  }
3016
3089
 
3017
3090
  GreaterOrEqual.prototype.exec = function(ctx) {
3018
- var args, error;
3091
+ var args;
3019
3092
  args = this.execArgs(ctx).map(function(x) {
3020
3093
  return Uncertainty.from(x);
3021
3094
  });
3022
- try {
3023
- return args[0].greaterThanOrEquals(args[1]);
3024
- } catch (error1) {
3025
- error = error1;
3026
- if (error instanceof IncompatibleTypesException) {
3027
- return null;
3028
- } else {
3029
- throw error;
3030
- }
3095
+ if (!((args[0] != null) && (args[1] != null))) {
3096
+ return null;
3031
3097
  }
3098
+ return args[0].greaterThanOrEquals(args[1]);
3032
3099
  };
3033
3100
 
3034
3101
  return GreaterOrEqual;
@@ -5065,17 +5132,12 @@
5065
5132
  }
5066
5133
 
5067
5134
  Equal.prototype.exec = function(ctx) {
5068
- var error;
5069
- try {
5070
- return equals.apply(null, this.execArgs(ctx));
5071
- } catch (error1) {
5072
- error = error1;
5073
- if (error instanceof IncompatibleTypesException) {
5074
- return null;
5075
- } else {
5076
- throw error;
5077
- }
5135
+ var args;
5136
+ args = this.execArgs(ctx);
5137
+ if (!((args[0] != null) && (args[1] != null))) {
5138
+ return null;
5078
5139
  }
5140
+ return equals.apply(null, this.execArgs(ctx));
5079
5141
  };
5080
5142
 
5081
5143
  return Equal;
@@ -5113,17 +5175,12 @@
5113
5175
  }
5114
5176
 
5115
5177
  NotEqual.prototype.exec = function(ctx) {
5116
- var error;
5117
- try {
5118
- return ThreeValuedLogic.not(equals.apply(null, this.execArgs(ctx)));
5119
- } catch (error1) {
5120
- error = error1;
5121
- if (error instanceof IncompatibleTypesException) {
5122
- return null;
5123
- } else {
5124
- throw error;
5125
- }
5178
+ var args;
5179
+ args = this.execArgs(ctx);
5180
+ if (!((args[0] != null) && (args[1] != null))) {
5181
+ return null;
5126
5182
  }
5183
+ return ThreeValuedLogic.not(equals.apply(null, this.execArgs(ctx)));
5127
5184
  };
5128
5185
 
5129
5186
  return NotEqual;
@@ -5564,7 +5621,7 @@
5564
5621
  },{"./builder":14,"./expression":20}],32:[function(require,module,exports){
5565
5622
  // Generated by CoffeeScript 1.12.7
5566
5623
  (function() {
5567
- var Code, Exception, Expression, FunctionRef, IncompatibleTypesException, Quantity, ValueSet, build, clean_unit, convert_value, createQuantity, decimalAdjust, is_valid_ucum_unit, ref, ucum, ucum_multiply, ucum_time_units, ucum_to_cql_units, ucum_unit, unitValidityCache, units_to_string,
5624
+ var Code, Exception, Expression, FunctionRef, IncompatibleTypesException, Quantity, ValueSet, build, clean_unit, convert_value, createQuantity, decimalAdjust, isValidDecimal, is_valid_ucum_unit, ref, ref1, ucum, ucum_multiply, ucum_time_units, ucum_to_cql_units, ucum_unit, unitValidityCache, units_to_string,
5568
5625
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
5569
5626
  hasProp = {}.hasOwnProperty;
5570
5627
 
@@ -5572,9 +5629,9 @@
5572
5629
 
5573
5630
  FunctionRef = require('./reusable').FunctionRef;
5574
5631
 
5575
- decimalAdjust = require('../util/math').decimalAdjust;
5632
+ ref = require('../util/math'), decimalAdjust = ref.decimalAdjust, isValidDecimal = ref.isValidDecimal;
5576
5633
 
5577
- ref = require('../datatypes/datatypes'), ValueSet = ref.ValueSet, Code = ref.Code;
5634
+ ref1 = require('../datatypes/datatypes'), ValueSet = ref1.ValueSet, Code = ref1.Code;
5578
5635
 
5579
5636
  Exception = require('../datatypes/exception').Exception;
5580
5637
 
@@ -5602,7 +5659,7 @@
5602
5659
  Quantity.__super__.constructor.apply(this, arguments);
5603
5660
  this.unit = json.unit;
5604
5661
  this.value = parseFloat(json.value);
5605
- if (!is_valid_ucum_unit(this.unit)) {
5662
+ if ((this.unit != null) && !is_valid_ucum_unit(this.unit)) {
5606
5663
  throw new Error("\'" + this.unit + "\' is not a valid UCUM unit.");
5607
5664
  }
5608
5665
  }
@@ -5820,15 +5877,15 @@
5820
5877
  module.exports.convert_value = convert_value;
5821
5878
 
5822
5879
  units_to_string = function(units) {
5823
- var denom, i, key, len, numer, pow, ref1, str, unit_string, v;
5880
+ var denom, i, key, len, numer, pow, ref2, str, unit_string, v;
5824
5881
  if (units == null) {
5825
5882
  units = {};
5826
5883
  }
5827
5884
  numer = [];
5828
5885
  denom = [];
5829
- ref1 = Object.keys(units);
5830
- for (i = 0, len = ref1.length; i < len; i++) {
5831
- key = ref1[i];
5886
+ ref2 = Object.keys(units);
5887
+ for (i = 0, len = ref2.length; i < len; i++) {
5888
+ key = ref2[i];
5832
5889
  v = units[key];
5833
5890
  pow = Math.abs(v);
5834
5891
  str = pow === 1 ? key : key + pow;
@@ -5851,7 +5908,7 @@
5851
5908
  };
5852
5909
 
5853
5910
  ucum_multiply = function(t, ms) {
5854
- var b, i, k, len, mterm, ref1, ret, sign, v;
5911
+ var b, i, k, len, mterm, ref2, ret, sign, v;
5855
5912
  if (ms == null) {
5856
5913
  ms = [];
5857
5914
  }
@@ -5864,9 +5921,9 @@
5864
5921
  sign = mterm[0] === '.' ? 1 : -1;
5865
5922
  b = mterm[1];
5866
5923
  ret.value *= Math.pow(b.value, sign);
5867
- ref1 = b.units;
5868
- for (k in ref1) {
5869
- v = ref1[k];
5924
+ ref2 = b.units;
5925
+ for (k in ref2) {
5926
+ v = ref2[k];
5870
5927
  ret.units[k] = ret.units[k] || 0;
5871
5928
  ret.units[k] = ret.units[k] + sign * v;
5872
5929
  if (ret.units[k] === 0) {
@@ -5886,16 +5943,23 @@
5886
5943
 
5887
5944
  module.exports.parseQuantity = function(str) {
5888
5945
  var components, unit, value;
5889
- components = /([+|-]?\d+\.?\d*)\s*'(.+)'/.exec(str);
5890
- if ((components != null) && (components[1] != null) && (components[2] != null)) {
5946
+ components = /([+|-]?\d+\.?\d*)\s*('(.+)')?/.exec(str);
5947
+ if ((components != null) && (components[1] != null)) {
5891
5948
  value = parseFloat(components[1]);
5892
- unit = components[2].trim();
5949
+ if (!isValidDecimal(value)) {
5950
+ return null;
5951
+ }
5952
+ if (components[3] != null) {
5953
+ unit = components[3].trim();
5954
+ } else {
5955
+ unit = "";
5956
+ }
5893
5957
  return new Quantity({
5894
5958
  value: value,
5895
5959
  unit: unit
5896
5960
  });
5897
5961
  } else {
5898
- return null;
5962
+ throw new Error("Unable to parse Quantity");
5899
5963
  }
5900
5964
  };
5901
5965
 
@@ -6848,7 +6912,7 @@
6848
6912
  },{"./builder":14,"./expression":20}],37:[function(require,module,exports){
6849
6913
  // Generated by CoffeeScript 1.12.7
6850
6914
  (function() {
6851
- var As, Concept, Convert, DateTime, Expression, FunctionRef, IntervalTypeSpecifier, Is, ListTypeSpecifier, NamedTypeSpecifier, ToBoolean, ToConcept, ToDateTime, ToDecimal, ToInteger, ToQuantity, ToString, ToTime, TupleTypeSpecifier, UnimplementedExpression, parseQuantity, ref,
6915
+ var As, Concept, Convert, DateTime, Expression, FunctionRef, IntervalTypeSpecifier, Is, ListTypeSpecifier, NamedTypeSpecifier, ToBoolean, ToConcept, ToDateTime, ToDecimal, ToInteger, ToQuantity, ToString, ToTime, TupleTypeSpecifier, UnimplementedExpression, isValidDecimal, isValidInteger, limitDecimalPrecision, parseQuantity, ref, ref1,
6852
6916
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
6853
6917
  hasProp = {}.hasOwnProperty;
6854
6918
 
@@ -6862,15 +6926,17 @@
6862
6926
 
6863
6927
  parseQuantity = require('./quantity').parseQuantity;
6864
6928
 
6929
+ ref1 = require('../util/math'), isValidDecimal = ref1.isValidDecimal, isValidInteger = ref1.isValidInteger, limitDecimalPrecision = ref1.limitDecimalPrecision;
6930
+
6865
6931
  module.exports.As = As = (function(superClass) {
6866
6932
  extend(As, superClass);
6867
6933
 
6868
6934
  function As(json) {
6869
- var ref1;
6935
+ var ref2;
6870
6936
  As.__super__.constructor.apply(this, arguments);
6871
6937
  this.asType = json.asType;
6872
6938
  this.asTypeSpecifier = json.asTypeSpecifier;
6873
- this.strict = (ref1 = json.strict) != null ? ref1 : false;
6939
+ this.strict = (ref2 = json.strict) != null ? ref2 : false;
6874
6940
  }
6875
6941
 
6876
6942
  As.prototype.exec = function(ctx) {
@@ -6959,10 +7025,14 @@
6959
7025
  }
6960
7026
 
6961
7027
  ToDecimal.prototype.exec = function(ctx) {
6962
- var arg;
7028
+ var arg, decimal;
6963
7029
  arg = this.execArgs(ctx);
6964
7030
  if ((arg != null) && typeof arg !== 'undefined') {
6965
- return parseFloat(arg.toString());
7031
+ decimal = parseFloat(arg.toString());
7032
+ decimal = limitDecimalPrecision(decimal);
7033
+ if (isValidDecimal(decimal)) {
7034
+ return decimal;
7035
+ }
6966
7036
  } else {
6967
7037
  return null;
6968
7038
  }
@@ -6980,10 +7050,13 @@
6980
7050
  }
6981
7051
 
6982
7052
  ToInteger.prototype.exec = function(ctx) {
6983
- var arg;
7053
+ var arg, integer;
6984
7054
  arg = this.execArgs(ctx);
6985
7055
  if ((arg != null) && typeof arg !== 'undefined') {
6986
- return parseInt(arg.toString());
7056
+ integer = parseInt(arg.toString());
7057
+ if (isValidInteger(integer)) {
7058
+ return integer;
7059
+ }
6987
7060
  } else {
6988
7061
  return null;
6989
7062
  }
@@ -7001,10 +7074,11 @@
7001
7074
  }
7002
7075
 
7003
7076
  ToQuantity.prototype.exec = function(ctx) {
7004
- var arg;
7077
+ var arg, quantity;
7005
7078
  arg = this.execArgs(ctx);
7006
7079
  if ((arg != null) && typeof arg !== 'undefined') {
7007
- return parseQuantity(arg.toString());
7080
+ quantity = parseQuantity(arg.toString());
7081
+ return quantity;
7008
7082
  } else {
7009
7083
  return null;
7010
7084
  }
@@ -7180,7 +7254,7 @@
7180
7254
 
7181
7255
 
7182
7256
 
7183
- },{"../datatypes/clinical":5,"../datatypes/datetime":7,"./expression":20,"./quantity":32,"./reusable":34}],38:[function(require,module,exports){
7257
+ },{"../datatypes/clinical":5,"../datatypes/datetime":7,"../util/math":134,"./expression":20,"./quantity":32,"./reusable":34}],38:[function(require,module,exports){
7184
7258
  // Generated by CoffeeScript 1.12.7
7185
7259
  (function() {
7186
7260
  window.cql = require('../../cql');
@@ -44099,7 +44173,7 @@
44099
44173
  },{"../datatypes/datetime":7,"../datatypes/uncertainty":11}],134:[function(require,module,exports){
44100
44174
  // Generated by CoffeeScript 1.12.7
44101
44175
  (function() {
44102
- var DateTime, Exception, MAX_DATE_VALUE, MAX_FLOAT_VALUE, MAX_INT_VALUE, MAX_TIME_VALUE, MIN_DATE_VALUE, MIN_FLOAT_PRECISION_VALUE, MIN_FLOAT_VALUE, MIN_INT_VALUE, OverFlowException, Uncertainty, predecessor, successor,
44176
+ var DateTime, Exception, MAX_DATE_VALUE, MAX_FLOAT_VALUE, MAX_INT_VALUE, MAX_TIME_VALUE, MIN_DATE_VALUE, MIN_FLOAT_PRECISION_VALUE, MIN_FLOAT_VALUE, MIN_INT_VALUE, OverFlowException, Uncertainty, isValidDecimal, isValidInteger, predecessor, successor,
44103
44177
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
44104
44178
  hasProp = {}.hasOwnProperty;
44105
44179
 
@@ -44127,6 +44201,46 @@
44127
44201
 
44128
44202
  module.exports.MAX_TIME_VALUE = MAX_TIME_VALUE = DateTime.parse("0000-01-01T23:59:59.999");
44129
44203
 
44204
+ module.exports.isValidInteger = isValidInteger = function(integer) {
44205
+ if (isNaN(integer)) {
44206
+ throw new Error("Unable to parse Integer");
44207
+ }
44208
+ if (integer > MAX_INT_VALUE) {
44209
+ throw new Error("Maximum Integer value exceeded");
44210
+ }
44211
+ if (integer < MIN_INT_VALUE) {
44212
+ throw new Error("Minimum Integer value exceeded");
44213
+ }
44214
+ return true;
44215
+ };
44216
+
44217
+ module.exports.isValidDecimal = isValidDecimal = function(decimal) {
44218
+ if (isNaN(decimal)) {
44219
+ throw new Error("Unable to parse Decimal");
44220
+ }
44221
+ if (decimal > MAX_FLOAT_VALUE) {
44222
+ throw new Error("Maximum Decimal value exceeded");
44223
+ }
44224
+ if (decimal < MIN_FLOAT_VALUE) {
44225
+ throw new Error("Minimum Decimal value exceeded");
44226
+ }
44227
+ return true;
44228
+ };
44229
+
44230
+ module.exports.limitDecimalPrecision = function(decimal) {
44231
+ var decimalPoints, decimalString, splitDecimalString;
44232
+ decimalString = decimal.toString();
44233
+ if (decimalString.indexOf('e') !== -1) {
44234
+ return decimal;
44235
+ }
44236
+ splitDecimalString = decimalString.split('.');
44237
+ decimalPoints = splitDecimalString[1];
44238
+ if ((decimalPoints != null) && decimalPoints.length > 8) {
44239
+ decimalString = splitDecimalString[0] + '.' + splitDecimalString[1].substring(0, 8);
44240
+ }
44241
+ return parseFloat(decimalString);
44242
+ };
44243
+
44130
44244
  module.exports.OverFlowException = OverFlowException = OverFlowException = (function(superClass) {
44131
44245
  extend(OverFlowException, superClass);
44132
44246
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql_qdm_patientapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MITRE Corporation
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.5.2.1
134
+ rubygems_version: 2.6.14
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: QDM CQL execution engine and HDS patient model interface