open_ehr 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/History.txt +3 -0
  2. data/README.rdoc +3 -3
  3. data/VERSION +1 -1
  4. data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +61 -34
  5. data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +27 -0
  6. data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +18 -0
  7. data/lib/open_ehr/am/openehr_profile/data_types/text.rb +22 -0
  8. data/lib/open_ehr/am/openehr_profile/data_types.rb +12 -0
  9. data/lib/open_ehr/am/openehr_profile.rb +10 -0
  10. data/lib/open_ehr/am.rb +2 -0
  11. data/lib/open_ehr/assumed_library_types.rb +30 -25
  12. data/lib/open_ehr/parser/cadl_grammar.tt +479 -163
  13. data/lib/open_ehr/parser/shared_token_grammar.tt +63 -43
  14. data/lib/open_ehr/rm/data_types/quantity/date_time.rb +27 -14
  15. data/lib/open_ehr.rb +1 -1
  16. data/open_ehr.gemspec +17 -6
  17. data/spec/lib/open_ehr/am/archetype/assertion/operator_kind_spec.rb +4 -0
  18. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_spec.rb +20 -48
  19. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +33 -8
  20. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +19 -52
  21. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +2 -3
  22. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +27 -7
  23. data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +0 -1
  24. data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +35 -0
  25. data/spec/lib/open_ehr/parser/adl14/adl-test-SOME_TYPE.generic_type_basic.draft.adl +1 -1
  26. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_slot.test.adl +1 -1
  27. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_slot.test2.adl +1 -1
  28. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.basic_types.test.adl +3 -3
  29. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_code_phrase.test.adl +1 -1
  30. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.datetime.test.adl +1 -1
  31. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.durations.test.adl +2 -4
  32. data/spec/lib/open_ehr/parser/adl_archetype_internal_ref_with_generics_spec.rb +6 -6
  33. data/spec/lib/open_ehr/parser/adl_archetype_slot_cluster_spec.rb +101 -0
  34. data/spec/lib/open_ehr/parser/adl_archetype_slot_spec.rb +193 -0
  35. data/spec/lib/open_ehr/parser/adl_archetype_uncommon_term_keys_spec.rb +25 -0
  36. data/spec/lib/open_ehr/parser/adl_parser_spec.rb +6 -6
  37. data/spec/lib/open_ehr/parser/basic_generic_type_spec.rb +18 -0
  38. data/spec/lib/open_ehr/parser/basic_type_spec.rb +2922 -0
  39. data/spec/lib/open_ehr/parser/code_phrase_spec.rb +91 -0
  40. data/spec/lib/open_ehr/parser/date_time_spec.rb +1953 -0
  41. data/spec/lib/open_ehr/parser/duration_spec.rb +475 -0
  42. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_duration_spec.rb +44 -0
  43. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb +6 -2
  44. data/spec/spec_helper.rb +3 -2
  45. metadata +52 -41
  46. data/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb +0 -21
  47. data/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb +0 -29
  48. data/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb +0 -19
  49. data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +0 -15
@@ -1,4 +1,5 @@
1
1
  require 'open_ehr/assumed_library_types'
2
+ require 'open_ehr/rm/data_types/quantity'
2
3
 
3
4
  module OpenEHR
4
5
  module Parser
@@ -45,7 +46,7 @@ module OpenEHR
45
46
  def value
46
47
  true
47
48
  end
48
- }
49
+ }
49
50
  / SYM_FALSE {
50
51
  def value
51
52
  false
@@ -71,7 +72,7 @@ module OpenEHR
71
72
  end
72
73
 
73
74
  rule integer_value
74
- ('+' / '-')? V_INTEGER {
75
+ [+-]? V_INTEGER '' {
75
76
  def value
76
77
  text_value.to_i
77
78
  end
@@ -79,7 +80,7 @@ module OpenEHR
79
80
  end
80
81
 
81
82
  rule integer_list_value
82
- integer_value (',' white_space more_i:(integer_value))* {
83
+ integer_value more_i:(',' white_space integer_value)+ {
83
84
  def value
84
85
  integers.map { |i| i.value }
85
86
  end
@@ -152,10 +153,10 @@ module OpenEHR
152
153
  :lower_included => false)
153
154
  end
154
155
  }
155
- / SYM_INTERVAL_DELIM SYM_GE integer_value SYM_INTERVAL_DELIM {
156
+ / SYM_INTERVAL_DELIM SYM_GE iv:integer_value SYM_INTERVAL_DELIM {
156
157
  def value
157
158
  OpenEHR::AssumedLibraryTypes::Interval.new(
158
- :lower => up.value,
159
+ :lower => iv.value,
159
160
  :upper_unbounded => true,
160
161
  :lower_included => true)
161
162
  end
@@ -164,7 +165,7 @@ module OpenEHR
164
165
  def value
165
166
  OpenEHR::AssumedLibraryTypes::Interval.new(
166
167
  :lower => val.value,
167
- :lower => val.value,
168
+ :upper => val.value,
168
169
  :upper_included => true,
169
170
  :lower_included => true)
170
171
  end
@@ -180,7 +181,7 @@ module OpenEHR
180
181
  end
181
182
 
182
183
  rule real_list_value
183
- real_value (',' white_space more_i:(real_value) '')* {
184
+ real_value more_i:(',' white_space real_value)* {
184
185
  def value
185
186
  reals.map { |i| i.value }
186
187
  end
@@ -265,7 +266,7 @@ module OpenEHR
265
266
  def value
266
267
  OpenEHR::AssumedLibraryTypes::Interval.new(
267
268
  :lower => val.value,
268
- :lower => val.value,
269
+ :upper => val.value,
269
270
  :upper_included => true,
270
271
  :lower_included => true)
271
272
  end
@@ -323,9 +324,10 @@ module OpenEHR
323
324
  end
324
325
 
325
326
  rule date_value
326
- V_ISO8601_EXTENDED_DATE '' {
327
+ ed:V_ISO8601_EXTENDED_DATE '' {
327
328
  def value
328
- OpenEHR::AssumedLibraryTypes::ISO8601Date.new(V_ISO8601_EXTENDED_DATE.text_value)
329
+ ::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDate.new(
330
+ :value => ed.text_value)
329
331
  end
330
332
  }
331
333
  end
@@ -340,7 +342,7 @@ module OpenEHR
340
342
  [date_value] + more_dates.elements.map {|d| d.date_value}
341
343
  end
342
344
  }
343
- / date_value ',' SYM_LIST_CONTINUE {
345
+ / date_value ',' white_space SYM_LIST_CONTINUE {
344
346
  def value
345
347
  [date_value.value]
346
348
  end
@@ -404,10 +406,10 @@ module OpenEHR
404
406
  :lower_included => false)
405
407
  end
406
408
  }
407
- / SYM_INTERVAL_DELIM SYM_GE date_value SYM_INTERVAL_DELIM {
409
+ / SYM_INTERVAL_DELIM SYM_GE val:date_value SYM_INTERVAL_DELIM {
408
410
  def value
409
411
  OpenEHR::AssumedLibraryTypes::Interval.new(
410
- :lower => up.value,
412
+ :lower => val.value,
411
413
  :upper_unbounded => true,
412
414
  :lower_included => true)
413
415
  end
@@ -416,7 +418,7 @@ module OpenEHR
416
418
  def value
417
419
  OpenEHR::AssumedLibraryTypes::Interval.new(
418
420
  :lower => val.value,
419
- :lower => val.value,
421
+ :upper => val.value,
420
422
  :upper_included => true,
421
423
  :lower_included => true)
422
424
  end
@@ -424,15 +426,16 @@ module OpenEHR
424
426
  end
425
427
 
426
428
  rule time_value
427
- V_ISO8601_EXTENDED_TIME '' {
429
+ ti:V_ISO8601_EXTENDED_TIME '' {
428
430
  def value
429
- OpenEHR::AssumedLibraryTypes::ISO8601Time(V_ISO8601_EXTENDED_TIME.text_value)
431
+ ::OpenEHR::RM::DataTypes::Quantity::DateTime::DvTime.new(
432
+ :value => ti.text_value)
430
433
  end
431
434
  }
432
435
  end
433
436
 
434
437
  rule time_list_value
435
- time_value more_t:(',' time_value)+ {
438
+ time_value more_t:(',' white_space time_value)+ {
436
439
  def value
437
440
  times.map {|t| t.value}
438
441
  end
@@ -441,7 +444,7 @@ module OpenEHR
441
444
  [time_value] + more_t.elements.map {|t| t.time_value}
442
445
  end
443
446
  }
444
- / time_value ',' SYM_LIST_CONTINUE {
447
+ / time_value ',' white_space SYM_LIST_CONTINUE {
445
448
  def value
446
449
  [time_value.value]
447
450
  end
@@ -505,10 +508,10 @@ module OpenEHR
505
508
  :lower_included => false)
506
509
  end
507
510
  }
508
- / SYM_INTERVAL_DELIM SYM_GE time_value SYM_INTERVAL_DELIM {
511
+ / SYM_INTERVAL_DELIM SYM_GE tv:time_value SYM_INTERVAL_DELIM {
509
512
  def value
510
513
  OpenEHR::AssumedLibraryTypes::Interval.new(
511
- :lower => up.value,
514
+ :lower => tv.value,
512
515
  :upper_unbounded => true,
513
516
  :lower_included => true)
514
517
  end
@@ -517,7 +520,7 @@ module OpenEHR
517
520
  def value
518
521
  OpenEHR::AssumedLibraryTypes::Interval.new(
519
522
  :lower => val.value,
520
- :lower => val.value,
523
+ :upper => val.value,
521
524
  :upper_included => true,
522
525
  :lower_included => true)
523
526
  end
@@ -527,13 +530,14 @@ module OpenEHR
527
530
  rule date_time_value
528
531
  dt:V_ISO8601_EXTENDED_DATE_TIME '' {
529
532
  def value
530
- OpenEHR::AssumedLibraryTypes::ISO8601DateTime.new(dt.text_value)
533
+ ::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDateTime.new(
534
+ :value => dt.text_value)
531
535
  end
532
536
  }
533
537
  end
534
538
 
535
539
  rule date_time_list_value
536
- date_time_value more_dt:(',' date_time_value)+ {
540
+ date_time_value (',' more_dt:date_time_value)+ {
537
541
  def value
538
542
  date_times.map {|t| t.value}
539
543
  end
@@ -606,10 +610,10 @@ module OpenEHR
606
610
  :lower_included => false)
607
611
  end
608
612
  }
609
- / SYM_INTERVAL_DELIM SYM_GE date_time_value SYM_INTERVAL_DELIM {
613
+ / SYM_INTERVAL_DELIM SYM_GE dt:date_time_value SYM_INTERVAL_DELIM {
610
614
  def value
611
615
  OpenEHR::AssumedLibraryTypes::Interval.new(
612
- :lower => up.value,
616
+ :lower => dt.value,
613
617
  :upper_unbounded => true,
614
618
  :lower_included => true)
615
619
  end
@@ -618,7 +622,7 @@ module OpenEHR
618
622
  def value
619
623
  OpenEHR::AssumedLibraryTypes::Interval.new(
620
624
  :lower => val.value,
621
- :lower => val.value,
625
+ :upper => val.value,
622
626
  :upper_included => true,
623
627
  :lower_included => true)
624
628
  end
@@ -626,9 +630,10 @@ module OpenEHR
626
630
  end
627
631
 
628
632
  rule duration_value
629
- V_ISO8601_DURATION '' {
633
+ du:V_ISO8601_DURATION '' {
630
634
  def value
631
- OpenEHR::AssumedLibraryTypes::ISO8601Duration(V_ISO8601_DURATION.text_value)
635
+ ::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDuration.new(
636
+ :value => du.text_value)
632
637
  end
633
638
  }
634
639
  end
@@ -645,7 +650,7 @@ module OpenEHR
645
650
  }
646
651
  / duration_value ',' SYM_LIST_CONTINUE {
647
652
  def value
648
- [duration_valuel.value]
653
+ [duration_value.value]
649
654
  end
650
655
  }
651
656
  end
@@ -707,10 +712,10 @@ module OpenEHR
707
712
  :lower_included => false)
708
713
  end
709
714
  }
710
- / SYM_INTERVAL_DELIM SYM_GE duration_value SYM_INTERVAL_DELIM {
715
+ / SYM_INTERVAL_DELIM SYM_GE val:duration_value SYM_INTERVAL_DELIM {
711
716
  def value
712
717
  OpenEHR::AssumedLibraryTypes::Interval.new(
713
- :lower => up.value,
718
+ :lower => val.value,
714
719
  :upper_unbounded => true,
715
720
  :lower_included => true)
716
721
  end
@@ -718,7 +723,7 @@ module OpenEHR
718
723
  / SYM_INTERVAL_DELIM val:duration_value SYM_INTERVAL_DELIM {
719
724
  def value
720
725
  OpenEHR::AssumedLibraryTypes::Interval.new(
721
- :lower => val.value,
726
+ :upper => val.value,
722
727
  :lower => val.value,
723
728
  :upper_included => true,
724
729
  :lower_included => true)
@@ -839,11 +844,11 @@ module OpenEHR
839
844
  end
840
845
 
841
846
  rule SYM_GE
842
- '=>' / '>=' white_space
847
+ ('=>' / '>=') white_space
843
848
  end
844
849
 
845
850
  rule SYM_LE
846
- '<=' / '=>' white_space
851
+ ('<=' / '=>') white_space
847
852
  end
848
853
 
849
854
  rule SYM_LT
@@ -867,7 +872,7 @@ module OpenEHR
867
872
  end
868
873
 
869
874
  rule SYM_END_CBLOCK
870
- '}' space
875
+ '}'
871
876
  end
872
877
 
873
878
  rule SYM_ELLIPSIS
@@ -955,7 +960,7 @@ module OpenEHR
955
960
  end
956
961
 
957
962
  rule SYM_UNIQUE
958
- [Uu] [Nn] [Ii] [Qq] [Uu] [Ee] white_space
963
+ [Uu] [Nn] [Ii] [Qq] [Uu] [Ee] space
959
964
  end
960
965
 
961
966
  rule SYM_INFINITY
@@ -1098,12 +1103,21 @@ module OpenEHR
1098
1103
  }
1099
1104
  end
1100
1105
 
1106
+ rule V_TERM_CODE
1107
+ '[' code:([a-zA-Z0-9()._\-]+) '::' white_space {
1108
+ def value
1109
+ ::OpenEHR::RM::Support::Identification::TerminologyID.new(
1110
+ :value => code.text_value)
1111
+ end
1112
+ }
1113
+ end
1114
+
1101
1115
  rule V_ISO8601_EXTENDED_DATE_TIME
1102
1116
  ([0-9] 4..4 '-' [0-1] [0-9] '-' [0-3] [0-9] 'T' [0-2] [0-9] ':' [0-6] [0-9] ':' [0-6] [0-9] (',' [0-9]+)? ('Z' / [+-] [0-9] 4..4)? ) / ([0-9] 4..4 '-' [0-1] [0-9] '-' [0-3] [0-9] 'T' [0-2] [0-9] ':' [0-6] [0-9] ('Z' / [+-] [0-9] 4..4)?) / ([0-9] 4..4 '-' [0-1] [0-9] '-' [0-3] [0-9] 'T' [0-2] [0-9] ('Z' / [+-] [0-9] 4..4)?)
1103
1117
  end
1104
1118
 
1105
1119
  rule V_ISO8601_EXTENDED_TIME
1106
- [0-2] [0-9] ':' [0-6] [0-9] ':' [0-6] [0-9] (',' [0-9]+)? ('Z' / [+-] [0-9] 4..4)? / [0-2] [0-9] ':' [0-6] [0-9] (Z / [+-] [0-9] 4..4)?
1120
+ [0-2] [0-9] ':' [0-6] [0-9] ':' [0-6] [0-9] (',' [0-9]+)? ('Z' / [+-] [0-9] 4..4)? / [0-2] [0-9] ':' [0-6] [0-9] ('Z' / [+-] [0-9] 4..4)?
1107
1121
  end
1108
1122
 
1109
1123
  rule V_ISO8601_EXTENDED_DATE
@@ -1111,7 +1125,7 @@ module OpenEHR
1111
1125
  end
1112
1126
 
1113
1127
  rule V_ISO8601_DURATION
1114
- 'P' ([0-9]+ [yY])? ([0-9]+ [mM])? ([0-9]+ [wW])? ([0-9]+ [dD])? 'T' ([0-9]+ [hH])? ([0-9]+ [mM])? ([0-9]+ [sS])?
1128
+ 'P' ([0-9]+ [yY])? ([0-9]+ [mM])? ([0-9]+ [wW])? ([0-9]+ [dD])? ('T' ([0-9]+ [hH])? ([0-9]+ [mM])? ([0-9]+ ('.' [0-9]+)? [sS])?)?
1115
1129
  end
1116
1130
 
1117
1131
  rule V_ISO8601_DATE_CONSTRAINT_PATTERN
@@ -1123,11 +1137,17 @@ module OpenEHR
1123
1137
  end
1124
1138
 
1125
1139
  rule V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
1126
- [yY] [yY] [yY] [yY] '-' [mM?X] [mM?X] '-' [dD?X] [dD?X] [Tt] [hH?X] [hH?X] ':' [mM?X] [mM?X] ':' [sS?X] [sS?X]
1140
+ [yY] [yY] [yY] [yY] '-' [mM?X] [mM?X] '-' [dD?X] [dD?X] [Tt ] [hH?X] [hH?X] ':' [mM?X] [mM?X] ':' [sS?X] [sS?X]
1127
1141
  end
1128
1142
 
1129
1143
  rule V_ISO8601_DURATION_CONSTRAINT_PATTERN
1130
- 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH]? [mM]? [sS]? / 'P' [yY]? [mM]? [wW]? [dD]?
1144
+ 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH] [mM]? [sS]?
1145
+ / 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH]? [mM] [sS]?
1146
+ / 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH]? [mM]? [sS]
1147
+ / 'P' [yY] [mM]? [wW]? [dD]?
1148
+ / 'P' [yY]? [mM] [wW]? [dD]?
1149
+ / 'P' [yY]? [mM]? [wW] [dD]?
1150
+ / 'P' [yY]? [mM]? [wW]? [dD]
1131
1151
  end
1132
1152
 
1133
1153
  rule V_TYPE_IDENTIFIER
@@ -1155,7 +1175,7 @@ module OpenEHR
1155
1175
  end
1156
1176
 
1157
1177
  rule V_INTEGER
1158
- [0-9] {
1178
+ [0-9]+ [eE] [+-]? [0-9] {
1159
1179
  def value
1160
1180
  text_value.to_i
1161
1181
  end
@@ -1165,7 +1185,7 @@ module OpenEHR
1165
1185
  text_value.to_i
1166
1186
  end
1167
1187
  }
1168
- / [0-9]+ [eE] [+-]? [0-9] {
1188
+ / [0-9] {
1169
1189
  def value
1170
1190
  text_value.to_i
1171
1191
  end
@@ -1173,7 +1193,7 @@ module OpenEHR
1173
1193
  end
1174
1194
 
1175
1195
  rule V_REAL
1176
- [0-9] '.' [0-9]+ / [1-9] [0-9]+ '.' [0-9]+ / [0-9]+ '.' [0-9]+ [eE] [+-]? [0-9]+ {
1196
+ [0-9]+ '.' [0-9]+ [eE] [+-]? [0-9]+ / [1-9] [0-9]+ '.' [0-9]+ / [0-9] '.' [0-9]+ {
1177
1197
  def value
1178
1198
  text_value.to_f
1179
1199
  end
@@ -96,13 +96,18 @@ module OpenEHR
96
96
  @minute = iso8601_time.minute
97
97
  @second = iso8601_time.second
98
98
  @fractional_second = iso8601_time.fractional_second
99
+ @timezone = iso8601_time.timezone
99
100
  end
100
101
 
101
102
  def magnitude
102
- if @fractional_second.nil?
103
+ if @fractional_second.nil? && @second.nil? && @minute.nil?
104
+ return @hour * 60 * 60
105
+ elsif @fractional_second.nil? && @second.nil?
106
+ return @hour * 60 * 60 + @minute * 60
107
+ elsif @fractional_second.nil?
103
108
  return @hour * 60 * 60 + @minute * 60 + @second
104
109
  else
105
- return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second
110
+ return @hour*60*60+@minute* 60 + @second + @fractional_second
106
111
  end
107
112
  end
108
113
 
@@ -187,16 +192,12 @@ module OpenEHR
187
192
  end
188
193
  end
189
194
 
190
- class DvDuration < DvAmount
195
+ class DvDuration < DvTemporal
191
196
  include AssumedLibraryTypes::ISO8601DurationModule
192
197
  attr_reader :value
193
198
 
194
199
  def initialize(args = { })
195
- self.value = args[:value]
196
- self.magnitude_status = args[:magnitude_status]
197
- self.normal_range = args[:normal_range]
198
- self.normal_status = args[:normal_status]
199
- self.other_reference_ranges = args[:other_reference_ranges]
200
+ super
200
201
  end
201
202
 
202
203
  def value=(value)
@@ -214,13 +215,25 @@ module OpenEHR
214
215
  end
215
216
 
216
217
  def magnitude
217
- return ((((@year + @month/MONTH_IN_YEAR)*NOMINAL_DAYS_IN_MONTH) +
218
- @week * DAYS_IN_WEEK + @days) * HOURS_IN_DAY * MINUTES_IN_HOUR*
219
- SECONDS_IN_MINUTE) + @second + @fractional_second
218
+ months = 0
219
+ months += @months if @months
220
+ months += @years * MONTH_IN_YEAR if @years
221
+ days = 0
222
+ days += months * NOMINAL_DAYS_IN_MONTH if months
223
+ days += @weeks * DAYS_IN_WEEK if @weeks
224
+ days += @days if @days
225
+ hours = 0
226
+ hours += days * HOURS_IN_DAY if days
227
+ hours += @hours if @hours
228
+ minutes = 0
229
+ minutes += hours * MINUTES_IN_HOUR if hours
230
+ minutes += @minutes if @minutes
231
+ seconds = 0
232
+ seconds += @seconds if @seconds
233
+ seconds += @fractional_second if @fractional_second
234
+ seconds += minutes * SECONDS_IN_MINUTE if minutes
235
+ return seconds
220
236
  end
221
-
222
- undef magnitude=
223
-
224
237
  end
225
238
  end # of DateTime
226
239
  end # of Quantity
data/lib/open_ehr.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module OpenEHR
5
- VERSION = '0.6.0'
5
+ VERSION = '0.9.5'
6
6
  autoload :AssumedLibraryTypes, 'open_ehr/assumed_library_types'
7
7
  autoload :RM, 'open_ehr/rm'
8
8
  autoload :AM, 'open_ehr/am'
data/open_ehr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "open_ehr"
8
- s.version = "0.9.4"
8
+ s.version = "0.9.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shinji KOBAYASHI", "Akimichi Tatsukawa"]
12
- s.date = "2011-11-22"
12
+ s.date = "2011-12-02"
13
13
  s.description = "This project is an implementation of the openEHR specification on Ruby."
14
14
  s.email = "skoba@moss.gr.jp"
15
15
  s.extra_rdoc_files = [
@@ -28,14 +28,15 @@ Gem::Specification.new do |s|
28
28
  "lib/open_ehr.rb",
29
29
  "lib/open_ehr/am.rb",
30
30
  "lib/open_ehr/am/archetype.rb",
31
- "lib/open_ehr/am/archetype/archetype_description/archetype_description.rb",
32
31
  "lib/open_ehr/am/archetype/assertion.rb",
33
32
  "lib/open_ehr/am/archetype/constraint_model.rb",
34
33
  "lib/open_ehr/am/archetype/constraint_model/primitive.rb",
35
34
  "lib/open_ehr/am/archetype/ontology.rb",
36
- "lib/open_ehr/am/open_ehr_profile/data_types/basic.rb",
37
- "lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb",
38
- "lib/open_ehr/am/open_ehr_profile/data_types/text.rb",
35
+ "lib/open_ehr/am/openehr_profile.rb",
36
+ "lib/open_ehr/am/openehr_profile/data_types.rb",
37
+ "lib/open_ehr/am/openehr_profile/data_types/basic.rb",
38
+ "lib/open_ehr/am/openehr_profile/data_types/quantity.rb",
39
+ "lib/open_ehr/am/openehr_profile/data_types/text.rb",
39
40
  "lib/open_ehr/assumed_library_types.rb",
40
41
  "lib/open_ehr/parser.rb",
41
42
  "lib/open_ehr/parser/adl.rb",
@@ -124,6 +125,7 @@ Gem::Specification.new do |s|
124
125
  "spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb",
125
126
  "spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb",
126
127
  "spec/lib/open_ehr/am/archetype/validity_kind_spec.rb",
128
+ "spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb",
127
129
  "spec/lib/open_ehr/assumed_library_types/interval_spec.rb",
128
130
  "spec/lib/open_ehr/assumed_library_types/iso8601_date_spec.rb",
129
131
  "spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb",
@@ -227,6 +229,9 @@ Gem::Specification.new do |s|
227
229
  "spec/lib/open_ehr/parser/adl_archetype_internal_ref_with_generics_spec.rb",
228
230
  "spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb",
229
231
  "spec/lib/open_ehr/parser/adl_archetype_ontology_spec.rb",
232
+ "spec/lib/open_ehr/parser/adl_archetype_slot_cluster_spec.rb",
233
+ "spec/lib/open_ehr/parser/adl_archetype_slot_spec.rb",
234
+ "spec/lib/open_ehr/parser/adl_archetype_uncommon_term_keys_spec.rb",
230
235
  "spec/lib/open_ehr/parser/adl_description_spec.rb",
231
236
  "spec/lib/open_ehr/parser/adl_identification_spec.rb",
232
237
  "spec/lib/open_ehr/parser/adl_language_no_accreditation_spec.rb",
@@ -237,6 +242,11 @@ Gem::Specification.new do |s|
237
242
  "spec/lib/open_ehr/parser/adl_parser_spec.rb",
238
243
  "spec/lib/open_ehr/parser/adl_path_spec.rb",
239
244
  "spec/lib/open_ehr/parser/base_spec.rb",
245
+ "spec/lib/open_ehr/parser/basic_generic_type_spec.rb",
246
+ "spec/lib/open_ehr/parser/basic_type_spec.rb",
247
+ "spec/lib/open_ehr/parser/code_phrase_spec.rb",
248
+ "spec/lib/open_ehr/parser/date_time_spec.rb",
249
+ "spec/lib/open_ehr/parser/duration_spec.rb",
240
250
  "spec/lib/open_ehr/parser/parser_spec_helper.rb",
241
251
  "spec/lib/open_ehr/rm/common/archetyped/archetyped_spec.rb",
242
252
  "spec/lib/open_ehr/rm/common/archetyped/feeder_audit_details_spec.rb",
@@ -295,6 +305,7 @@ Gem::Specification.new do |s|
295
305
  "spec/lib/open_ehr/rm/data_types/encapsulated/dv_parsable_spec.rb",
296
306
  "spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_spec.rb",
297
307
  "spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb",
308
+ "spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_duration_spec.rb",
298
309
  "spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_tempral_spec.rb",
299
310
  "spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb",
300
311
  "spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb",
@@ -26,6 +26,10 @@ describe OperatorKind do
26
26
  OperatorKind::OP_GT.should be_equal 2006
27
27
  end
28
28
 
29
+ it 'op_matches should be equal 2007' do
30
+ OperatorKind::OP_MATCHES.should be_equal 2007
31
+ end
32
+
29
33
  it 'op_not should be equal 2010' do
30
34
  OperatorKind::OP_NOT.should be_equal 2010
31
35
  end
@@ -1,20 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/../../../../../../spec_helper'
2
2
  include OpenEHR::AM::Archetype
3
3
  include OpenEHR::AM::Archetype::ConstraintModel::Primitive
4
- include OpenEHR::AssumedLibraryTypes
4
+ include OpenEHR::RM::DataTypes::Quantity::DateTime
5
5
 
6
6
  describe CDate do
7
- before(:each) do
8
- default_value = ISO8601Date.new('2010-01-18')
9
- assumed_value = ISO8601Date.new('2007-02-19')
10
- range = Interval.new(:lower => ISO8601Date.new('2001-01-01'),
11
- :upper => ISO8601Date.new('2010-12-31'))
7
+ before(:all) do
8
+ default_value = DvDate.new(:value => '2010-01-18')
9
+ assumed_value = DvDate.new(:value => '2007-02-19')
10
+ range = Interval.new(:lower => DvDate.new(:value => '2001-01-01'),
11
+ :upper => DvDate.new(:value => '2010-12-31'))
12
12
  @c_date = CDate.new(:default_value => default_value,
13
13
  :assumed_value => assumed_value,
14
- :range => range,
15
- :month_validity => ValidityKind::MANDATORY,
16
- :day_validity => ValidityKind::OPTIONAL,
17
- :timezone_validity => ValidityKind::DISALLOWED)
14
+ :range => range)
18
15
  end
19
16
 
20
17
  it 'should be an instance of CDate' do
@@ -25,56 +22,31 @@ describe CDate do
25
22
  @c_date.range.upper.month.should be_equal 12
26
23
  end
27
24
 
28
- it 'month_validity should be assigned properly by constructor' do
29
- @c_date.month_validity.should be_equal ValidityKind::MANDATORY
30
- end
31
-
32
25
  it 'validity_is_range should be true if range is assigned' do
33
26
  @c_date.should be_validity_is_range
34
27
  end
35
28
 
36
- it 'validity_is_range should not be true if range is nil' do
37
- @c_date.range = nil
38
- @c_date.should_not be_validity_is_range
29
+ it 'raise ArgumentError unless range xor pattern' do
30
+ @c_date.range.should raise_error
39
31
  end
40
32
 
41
- it 'day_validity should be assigned properly by constructor' do
42
- @c_date.day_validity.should be_equal ValidityKind::OPTIONAL
43
- end
44
-
45
- it 'timezone should be assigned properly' do
46
- @c_date.timezone_validity.should be_equal ValidityKind::DISALLOWED
47
- end
48
-
49
- describe 'method' do
50
- it 'month_validity should be assigned by method properly' do
51
- @c_date.month_validity = ValidityKind::OPTIONAL
52
- @c_date.month_validity.should be_equal ValidityKind::OPTIONAL
53
- end
54
-
55
- it 'day_validity should be assigned by method properly' do
56
- @c_date.day_validity = ValidityKind::MANDATORY
57
- @c_date.day_validity.should be_equal ValidityKind::MANDATORY
33
+ describe 'pattern attribute' do
34
+ before(:all) do
35
+ @c_date = CDate.new(:pattern => 'yyyy-mm-dd')
58
36
  end
59
37
 
60
- it 'should raise ArgumentError if month_validity is optional and day validity is mandatory' do
61
- @c_date.day_validity = ValidityKind::MANDATORY
62
- lambda {
63
- @c_date.month_validity = ValidityKind::OPTIONAL
64
- }.should raise_error ArgumentError
38
+ it 'pattern should be yyyy-mm-dd' do
39
+ @c_date.pattern.should == 'yyyy-mm-dd'
65
40
  end
41
+ end
66
42
 
67
- it 'should raise ArgumentError if month_validity is disallowed and day_validity is mandatory' do
68
- @c_date.day_validity = ValidityKind::MANDATORY
69
- lambda {
70
- @c_date.month_validity = ValidityKind::DISALLOWED
71
- }.should raise_error ArgumentError
43
+ describe 'list attribute' do
44
+ before(:all) do
45
+ @c_date = CDate.new(:list => [DvDate.new(:value => '2011-11-28')])
72
46
  end
73
47
 
74
- it 'should raise ArgumentError if month_validity is disallowed and day_validity is optional' do
75
- lambda {
76
- @c_date.month_validity = ValidityKind::DISALLOWED
77
- }.should raise_error ArgumentError
48
+ it 'head of list is 2011-11-28' do
49
+ @c_date.list[0].value.should == '2011-11-28'
78
50
  end
79
51
  end
80
52
  end