openehr 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/openehr.rb +0 -1
- data/lib/openehr/parser/adl_grammar.tt +3094 -10
- data/lib/openehr/parser/{adl.rb → adl_helper.rb} +41 -2
- data/lib/openehr/parser/adl_parser.rb +1 -1
- data/openehr.gemspec +4 -8
- data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.apgar.v1.adl +1216 -545
- data/spec/lib/openehr/parser/openehr_apgar_spec.rb +16 -0
- metadata +41 -45
- data/lib/openehr/parser/cadl_grammar.tt +0 -1527
- data/lib/openehr/parser/cadl_node.rb +0 -44
- data/lib/openehr/parser/dadl.rb +0 -13
- data/lib/openehr/parser/dadl_grammar.tt +0 -358
- data/lib/openehr/parser/shared_token_grammar.tt +0 -1229
data/History.txt
CHANGED
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/lib/openehr.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
1
|
+
require 'openehr/assumed_library_types'
|
2
|
+
require 'openehr/rm/data_types/quantity'
|
3
|
+
require 'openehr/am/archetype/constraint_model'
|
4
|
+
require 'openehr/am/openehr_profile/data_types/text'
|
5
|
+
require 'openehr/am/openehr_profile/data_types/quantity'
|
6
|
+
require 'adl_helper'
|
5
7
|
|
6
8
|
module OpenEHR
|
7
9
|
module Parser
|
8
10
|
grammar ADLGrammar
|
9
|
-
|
10
|
-
include SharedToken
|
11
|
-
include DADLGrammar
|
12
|
-
include CADL
|
13
|
-
|
14
11
|
rule archetype
|
15
|
-
arch_identification
|
12
|
+
arch_identification
|
16
13
|
spec:(arch_specialisation)?
|
17
14
|
arch_concept
|
18
15
|
lang:(arch_language)?
|
@@ -240,6 +237,3093 @@ module OpenEHR
|
|
240
237
|
end
|
241
238
|
}
|
242
239
|
end # of arch_ontology
|
240
|
+
|
241
|
+
# cADL grammar section
|
242
|
+
|
243
|
+
rule V_CADL_TEXT
|
244
|
+
c_complex_object '' {
|
245
|
+
def value
|
246
|
+
c_complex_object.value
|
247
|
+
end
|
248
|
+
}
|
249
|
+
/ assertions '' {
|
250
|
+
def value
|
251
|
+
assertions.value
|
252
|
+
end
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
rule c_complex_object
|
257
|
+
head:c_complex_object_head SYM_MATCHES SYM_START_CBLOCK body:c_complex_object_body SYM_END_CBLOCK space {
|
258
|
+
def value(node = ArchetypeNode.new)
|
259
|
+
args = head.value
|
260
|
+
args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
|
261
|
+
:lower => 1, :upper => 1)
|
262
|
+
node.id = args[:node_id]
|
263
|
+
if node.root? or node.id.nil?
|
264
|
+
args[:path] = node.path
|
265
|
+
else
|
266
|
+
args[:path] = node.path + '[' + node.id + ']'
|
267
|
+
end
|
268
|
+
args.update body.value(node)
|
269
|
+
OpenEHR::AM::Archetype::ConstraintModel::CComplexObject.new(args)
|
270
|
+
end
|
271
|
+
}
|
272
|
+
/ c_complex_object_head '' {
|
273
|
+
def value(node = ArchetypeNode.new)
|
274
|
+
args = c_complex_object_head.value
|
275
|
+
args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
|
276
|
+
:lower => 1, :upper => 1)
|
277
|
+
node.id = args[:node_id]
|
278
|
+
args[:path] = node.path
|
279
|
+
OpenEHR::AM::Archetype::ConstraintModel::CComplexObject.new(args)
|
280
|
+
end
|
281
|
+
}
|
282
|
+
end
|
283
|
+
|
284
|
+
rule c_complex_object_head
|
285
|
+
c_complex_object_id c_occurrences {
|
286
|
+
def value
|
287
|
+
args = c_complex_object_id.value
|
288
|
+
args[:occurrences] = c_occurrences.value
|
289
|
+
args
|
290
|
+
end
|
291
|
+
}
|
292
|
+
/ c_complex_object_id '' {
|
293
|
+
def value
|
294
|
+
c_complex_object_id.value
|
295
|
+
end
|
296
|
+
}
|
297
|
+
end
|
298
|
+
|
299
|
+
rule c_complex_object_id
|
300
|
+
ti:type_identifier lo:V_LOCAL_TERM_CODE_REF space {
|
301
|
+
def value
|
302
|
+
{:rm_type_name => ti.value,
|
303
|
+
:node_id => lo.value}
|
304
|
+
end
|
305
|
+
}
|
306
|
+
/ ti:type_identifier space {
|
307
|
+
def value
|
308
|
+
{:rm_type_name => ti.value}
|
309
|
+
end
|
310
|
+
}
|
311
|
+
end
|
312
|
+
|
313
|
+
rule c_complex_object_body
|
314
|
+
c_any '' {
|
315
|
+
def value(node)
|
316
|
+
Hash[:attributes => [c_any.value(node)]]
|
317
|
+
end
|
318
|
+
}
|
319
|
+
/ c_attributes '' {
|
320
|
+
def value(node)
|
321
|
+
Hash[:attributes => c_attributes.value(node)]
|
322
|
+
end
|
323
|
+
}
|
324
|
+
end
|
325
|
+
|
326
|
+
rule c_object
|
327
|
+
c_dv_quantity '' {
|
328
|
+
def value(node)
|
329
|
+
c_dv_quantity.value(node)
|
330
|
+
end
|
331
|
+
}
|
332
|
+
/ c_ordinal '' {
|
333
|
+
def value(node)
|
334
|
+
args = c_ordinal.value
|
335
|
+
args[:path] = node.path
|
336
|
+
args[:rm_type_name] = 'DvOrdinal'
|
337
|
+
args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
|
338
|
+
:upper => 1, :lower => 1)
|
339
|
+
OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvOrdinal.new(
|
340
|
+
args)
|
341
|
+
end
|
342
|
+
}
|
343
|
+
/ c_primitive_object '' {
|
344
|
+
def value(node)
|
345
|
+
c_primitive_object.value
|
346
|
+
end
|
347
|
+
}
|
348
|
+
/ c_complex_object '' {
|
349
|
+
def value(node)
|
350
|
+
c_complex_object.value(node)
|
351
|
+
end
|
352
|
+
}
|
353
|
+
/ c_code_phrase '' {
|
354
|
+
def value(node)
|
355
|
+
c_code_phrase.value(node)
|
356
|
+
end
|
357
|
+
}
|
358
|
+
/ constraint_ref '' {
|
359
|
+
def value(node)
|
360
|
+
constraint_ref.value(node)
|
361
|
+
end
|
362
|
+
}
|
363
|
+
/ archetype_slot '' {
|
364
|
+
def value(node)
|
365
|
+
archetype_slot.value(node)
|
366
|
+
end
|
367
|
+
}
|
368
|
+
/ archetype_internal_ref '' {
|
369
|
+
def value(node = nil)
|
370
|
+
archetype_internal_ref.value(node)
|
371
|
+
end
|
372
|
+
}
|
373
|
+
/ V_C_DOMAIN_TYPE '' {
|
374
|
+
def value(node = nil)
|
375
|
+
p elemetns
|
376
|
+
end
|
377
|
+
}
|
378
|
+
# / ERR_V_C_DOMAIN_TYPE
|
379
|
+
end
|
380
|
+
|
381
|
+
rule archetype_internal_ref
|
382
|
+
SYM_USE_NODE type_identifier c_occurrences object_path space {
|
383
|
+
def value(node)
|
384
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeInternalRef.new(
|
385
|
+
:rm_type_name => type_identifier.value,
|
386
|
+
:occurrences => c_occurrences.value,
|
387
|
+
:path => node.path,
|
388
|
+
:target_path => object_path.value)
|
389
|
+
end
|
390
|
+
}
|
391
|
+
/ SYM_USE_NODE type_identifier object_path space {
|
392
|
+
def value(node = nil)
|
393
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeInternalRef.new(
|
394
|
+
:rm_type_name => type_identifier.value,
|
395
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
|
396
|
+
:lower => 1, :upper => 1),
|
397
|
+
:path => node.path,
|
398
|
+
:target_path => object_path.value)
|
399
|
+
end
|
400
|
+
}
|
401
|
+
end
|
402
|
+
|
403
|
+
rule archetype_slot
|
404
|
+
c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes c_excludes SYM_END_CBLOCK space {
|
405
|
+
def value(node)
|
406
|
+
args = c_archetype_slot_head.value(node)
|
407
|
+
args[:includes] = c_includes.value
|
408
|
+
args[:excludes] = c_excludes.value
|
409
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
|
410
|
+
end
|
411
|
+
}
|
412
|
+
/ c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes SYM_END_CBLOCK space {
|
413
|
+
def value(node)
|
414
|
+
args = c_archetype_slot_head.value(node)
|
415
|
+
args[:includes] = c_includes.value
|
416
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
|
417
|
+
end
|
418
|
+
}
|
419
|
+
/ c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_excludes SYM_END_CBLOCK space {
|
420
|
+
def value(node)
|
421
|
+
args = c_archetype_slot_head.value(node)
|
422
|
+
args[:excludes] = c_excludes.value
|
423
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
|
424
|
+
end
|
425
|
+
}
|
426
|
+
end
|
427
|
+
|
428
|
+
rule c_archetype_slot_head
|
429
|
+
c_archetype_slot_id white_space c_occurrences {
|
430
|
+
def value(node)
|
431
|
+
args = c_archetype_slot_id.value(node)
|
432
|
+
args[:occurrences] = c_occurrences.value
|
433
|
+
args
|
434
|
+
end
|
435
|
+
}
|
436
|
+
/ c_archetype_slot_id white_space {
|
437
|
+
def value(node)
|
438
|
+
args = c_archetype_slot_id.value(node)
|
439
|
+
args[:occurrences] = OpenEHR::AssumedLibraryTypes::Interval.new(
|
440
|
+
:upper => 1, :lower => 1)
|
441
|
+
args
|
442
|
+
end
|
443
|
+
}
|
444
|
+
end
|
445
|
+
|
446
|
+
rule c_archetype_slot_id
|
447
|
+
SYM_ALLOW_ARCHETYPE type_identifier lt:V_LOCAL_TERM_CODE_REF {
|
448
|
+
def value(node)
|
449
|
+
{:rm_type_name => type_identifier.value,
|
450
|
+
:node_id => lt.value,
|
451
|
+
:path => node.path + "[#{lt.value}]"}
|
452
|
+
end
|
453
|
+
}
|
454
|
+
/ SYM_ALLOW_ARCHETYPE type_identifier {
|
455
|
+
def value(node)
|
456
|
+
{:rm_type_name => type_identifier.value,
|
457
|
+
:path => node.path}
|
458
|
+
end
|
459
|
+
}
|
460
|
+
end
|
461
|
+
|
462
|
+
rule c_primitive_object
|
463
|
+
c_primitive '' {
|
464
|
+
def value
|
465
|
+
c_primitive.value
|
466
|
+
end
|
467
|
+
}
|
468
|
+
end
|
469
|
+
|
470
|
+
rule c_primitive
|
471
|
+
c_boolean '' {
|
472
|
+
def value
|
473
|
+
c_boolean.value
|
474
|
+
end
|
475
|
+
}
|
476
|
+
/ c_date_time '' {
|
477
|
+
def value
|
478
|
+
c_date_time.value
|
479
|
+
end
|
480
|
+
}
|
481
|
+
/ c_time '' {
|
482
|
+
def value
|
483
|
+
c_time.value
|
484
|
+
end
|
485
|
+
}
|
486
|
+
/ c_date '' {
|
487
|
+
def value
|
488
|
+
c_date.value
|
489
|
+
end
|
490
|
+
}
|
491
|
+
/ c_duration '' {
|
492
|
+
def value
|
493
|
+
c_duration.value
|
494
|
+
end
|
495
|
+
}
|
496
|
+
/ c_real '' {
|
497
|
+
def value
|
498
|
+
c_real.value
|
499
|
+
end
|
500
|
+
}
|
501
|
+
/ c_integer '' {
|
502
|
+
def value
|
503
|
+
c_integer.value
|
504
|
+
end
|
505
|
+
}
|
506
|
+
/ c_string '' {
|
507
|
+
def value
|
508
|
+
c_string.value
|
509
|
+
end
|
510
|
+
}
|
511
|
+
end
|
512
|
+
|
513
|
+
rule c_any
|
514
|
+
'*' space {
|
515
|
+
def value(node)
|
516
|
+
OpenEHR::AM::Archetype::ConstraintModel::CAttribute.new(
|
517
|
+
:path => node.path, :rm_attribute_name => 'ANY',
|
518
|
+
:exsitence => OpenEHR::AssumedLibraryTypes::Interval.new(
|
519
|
+
:lower => 1, :upper => 1))
|
520
|
+
end
|
521
|
+
}
|
522
|
+
end
|
523
|
+
|
524
|
+
rule c_attributes
|
525
|
+
c_attribute more_attr:(c_attribute white_space)* {
|
526
|
+
def value(node)
|
527
|
+
attributes.map {|c| c.value(node)}
|
528
|
+
end
|
529
|
+
|
530
|
+
def attributes
|
531
|
+
[c_attribute] + more_attr.elements.map {|e| e.c_attribute}
|
532
|
+
end
|
533
|
+
}
|
534
|
+
end
|
535
|
+
|
536
|
+
rule c_attribute
|
537
|
+
c_attr_head c_attr_body {
|
538
|
+
def value(node)
|
539
|
+
val = c_attr_head.value(node)
|
540
|
+
child_node = ArchetypeNode.new(node)
|
541
|
+
child_node.path = val.path
|
542
|
+
val.children = c_attr_body.value(child_node)
|
543
|
+
val
|
544
|
+
end
|
545
|
+
}
|
546
|
+
end
|
547
|
+
|
548
|
+
rule c_attr_head
|
549
|
+
id:(V_ATTRIBUTE_IDENTIFIER) white_space c_existence c_cardinality {
|
550
|
+
def value(node)
|
551
|
+
if node.root?
|
552
|
+
path = node.path + id.value
|
553
|
+
elsif node.id
|
554
|
+
path = node.path + "[#{node.id}]/" + id.value
|
555
|
+
elsif
|
556
|
+
path = node.path + '/' + id.value
|
557
|
+
end
|
558
|
+
OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(
|
559
|
+
:rm_attribute_name => id.value,
|
560
|
+
:path => path,
|
561
|
+
:existence => c_existence.value,
|
562
|
+
:cardinality => c_cardinality.value)
|
563
|
+
end
|
564
|
+
}
|
565
|
+
/ id:V_ATTRIBUTE_IDENTIFIER white_space c_existence {
|
566
|
+
def value(node)
|
567
|
+
if node.root?
|
568
|
+
path = node.path + id.value
|
569
|
+
elsif node.id
|
570
|
+
path = node.path + "[#{node.id}]/" + id.value
|
571
|
+
elsif
|
572
|
+
path = node.path + '/' + id.value
|
573
|
+
end
|
574
|
+
OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(
|
575
|
+
:rm_attribute_name => id.value,
|
576
|
+
:path => path,
|
577
|
+
:existence => c_existence.value)
|
578
|
+
end
|
579
|
+
}
|
580
|
+
/ id:(V_ATTRIBUTE_IDENTIFIER) white_space c_cardinality {
|
581
|
+
def value(node)
|
582
|
+
if node.root?
|
583
|
+
path = node.path + id.value
|
584
|
+
elsif node.id
|
585
|
+
path = node.path + "[#{node.id}]/" + id.value
|
586
|
+
elsif
|
587
|
+
path = node.path + '/' + id.value
|
588
|
+
end
|
589
|
+
OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(
|
590
|
+
:rm_attribute_name => id.value,
|
591
|
+
:path => path,
|
592
|
+
:cardinality => c_cardinality.value)
|
593
|
+
end
|
594
|
+
}
|
595
|
+
/ id:(V_ATTRIBUTE_IDENTIFIER) white_space {
|
596
|
+
def value(node)
|
597
|
+
if node.root?
|
598
|
+
path = node.path + id.value
|
599
|
+
elsif node.id
|
600
|
+
path = node.path + "[#{node.id}]/" + id.value
|
601
|
+
elsif
|
602
|
+
path = node.path + '/' + id.value
|
603
|
+
end
|
604
|
+
OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(
|
605
|
+
:rm_attribute_name => id.value, :path => path)
|
606
|
+
end
|
607
|
+
}
|
608
|
+
end
|
609
|
+
|
610
|
+
rule c_attr_body
|
611
|
+
SYM_MATCHES SYM_START_CBLOCK c_attr_values SYM_END_CBLOCK space {
|
612
|
+
def value(node)
|
613
|
+
c_attr_values.value(node)
|
614
|
+
end
|
615
|
+
}
|
616
|
+
end
|
617
|
+
|
618
|
+
rule c_attr_values
|
619
|
+
c_any '' {
|
620
|
+
def value(node)
|
621
|
+
[c_any.value(node)]
|
622
|
+
end
|
623
|
+
}
|
624
|
+
/ c_object more_co:(c_object '')* {
|
625
|
+
def value(node)
|
626
|
+
c_objects.map {|c| c.value(node)}
|
627
|
+
end
|
628
|
+
|
629
|
+
def c_objects
|
630
|
+
[c_object] + more_co.elements.map {|e| e.c_object }
|
631
|
+
end
|
632
|
+
}
|
633
|
+
end
|
634
|
+
|
635
|
+
rule c_includes
|
636
|
+
SYM_INCLUDE assertions {
|
637
|
+
def value
|
638
|
+
assertions.value
|
639
|
+
end
|
640
|
+
}
|
641
|
+
end
|
642
|
+
|
643
|
+
rule c_excludes
|
644
|
+
SYM_EXCLUDE assertions {
|
645
|
+
def value
|
646
|
+
assertions.value
|
647
|
+
end
|
648
|
+
}
|
649
|
+
end
|
650
|
+
|
651
|
+
rule c_existence
|
652
|
+
SYM_EXISTENCE SYM_MATCHES SYM_START_CBLOCK existence_spec SYM_END_CBLOCK space {
|
653
|
+
def value
|
654
|
+
existence_spec.value
|
655
|
+
end
|
656
|
+
}
|
657
|
+
end
|
658
|
+
|
659
|
+
rule existence_spec
|
660
|
+
lo:V_INTEGER SYM_ELLIPSIS up:V_INTEGER {
|
661
|
+
def value
|
662
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value, :upper => up.value)
|
663
|
+
end
|
664
|
+
}
|
665
|
+
/ V_INTEGER '' {
|
666
|
+
def value
|
667
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => V_INTEGER.value, :upper => V_INTEGER.value)
|
668
|
+
end
|
669
|
+
}
|
670
|
+
end
|
671
|
+
|
672
|
+
rule c_cardinality
|
673
|
+
SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK space {
|
674
|
+
def value
|
675
|
+
cardinality_spec.value
|
676
|
+
end
|
677
|
+
}
|
678
|
+
end
|
679
|
+
|
680
|
+
rule cardinality_spec
|
681
|
+
occurrence_spec ';' white_space SYM_ORDERED ';' white_space SYM_UNIQUE {
|
682
|
+
def value
|
683
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
684
|
+
:interval => occurrence_spec.value,
|
685
|
+
:is_unique => true,
|
686
|
+
:is_orderd => true)
|
687
|
+
end
|
688
|
+
}
|
689
|
+
/ occurrence_spec ';' white_space SYM_ORDERED {
|
690
|
+
def value
|
691
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
692
|
+
:interval => occurrence_spec.value,
|
693
|
+
:is_orderd => true)
|
694
|
+
end
|
695
|
+
}
|
696
|
+
/ occurrence_spec ';' white_space SYM_UNORDERD ';' white_space SYM_UNIQUE {
|
697
|
+
def value
|
698
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
699
|
+
:interval => occurrence_spec.value,
|
700
|
+
:is_unique => true,
|
701
|
+
:is_orderd => false)
|
702
|
+
end
|
703
|
+
}
|
704
|
+
/ occurrence_spec ';' white_space SYM_UNORDERD {
|
705
|
+
def value
|
706
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
707
|
+
:interval => occurrence_spec.value,
|
708
|
+
:is_orderd => false)
|
709
|
+
end
|
710
|
+
}
|
711
|
+
/ occurrence_spec SYM_UNIQUE ';' white_space SYM_ORDERED {
|
712
|
+
def value
|
713
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
714
|
+
:interval => occurrence_spec.value,
|
715
|
+
:is_unique => true,
|
716
|
+
:is_orderd => true)
|
717
|
+
end
|
718
|
+
}
|
719
|
+
/ occurrence_spec SYM_UNIQUE ';' white_space SYM_UNORDERD {
|
720
|
+
def value
|
721
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
722
|
+
:interval => occurrence_spec.value,
|
723
|
+
:is_unique => true,
|
724
|
+
:is_ordered => false)
|
725
|
+
end
|
726
|
+
}
|
727
|
+
/ occurrence_spec SYM_UNIQUE {
|
728
|
+
def value
|
729
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
730
|
+
:interval => occurrence_spec.value,
|
731
|
+
:is_unique => true)
|
732
|
+
end
|
733
|
+
}
|
734
|
+
/ occurrence_spec space {
|
735
|
+
def value
|
736
|
+
OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
|
737
|
+
:interval => occurrence_spec.value)
|
738
|
+
end
|
739
|
+
}
|
740
|
+
end
|
741
|
+
|
742
|
+
rule c_occurrences
|
743
|
+
SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK space {
|
744
|
+
def value
|
745
|
+
occurrence_spec.value
|
746
|
+
end
|
747
|
+
}
|
748
|
+
end
|
749
|
+
|
750
|
+
rule occurrence_spec
|
751
|
+
st:integer_value SYM_ELLIPSIS ed:cardinality_limit_value {
|
752
|
+
def value
|
753
|
+
if ed.value == '*'
|
754
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
755
|
+
:lower => st.value)
|
756
|
+
else
|
757
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
758
|
+
:lower => st.value,
|
759
|
+
:upper => ed.value)
|
760
|
+
end
|
761
|
+
end
|
762
|
+
}
|
763
|
+
/ cardinality_limit_value '' {
|
764
|
+
def value
|
765
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
766
|
+
:lower => cardinality_limit_value.value,
|
767
|
+
:upper => cardinality_limit_value.value)
|
768
|
+
end
|
769
|
+
}
|
770
|
+
end
|
771
|
+
|
772
|
+
rule cardinality_limit_value
|
773
|
+
integer_value '' {
|
774
|
+
def value
|
775
|
+
text_value.to_i
|
776
|
+
end
|
777
|
+
}
|
778
|
+
/ '*' {
|
779
|
+
def value
|
780
|
+
'*'
|
781
|
+
end
|
782
|
+
}
|
783
|
+
end
|
784
|
+
|
785
|
+
rule c_integer
|
786
|
+
c_integer_spec ';' white_space integer_value {
|
787
|
+
def value
|
788
|
+
args = c_integer_spec.value
|
789
|
+
args[:assumed_value] = integer_value.value
|
790
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CInteger.new(args)
|
791
|
+
end
|
792
|
+
}
|
793
|
+
/ c_integer_spec '' {
|
794
|
+
def value
|
795
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CInteger.new(
|
796
|
+
c_integer_spec.value)
|
797
|
+
end
|
798
|
+
}
|
799
|
+
end
|
800
|
+
|
801
|
+
rule c_integer_spec
|
802
|
+
integer_list_value '' {
|
803
|
+
def value
|
804
|
+
{:list => integer_list_value.value}
|
805
|
+
end
|
806
|
+
}
|
807
|
+
/ integer_interval_value '' {
|
808
|
+
def value
|
809
|
+
{:range => integer_interval_value.value}
|
810
|
+
end
|
811
|
+
}
|
812
|
+
/ integer_value !'..' '' {
|
813
|
+
def value
|
814
|
+
{:list => [integer_value.value]}
|
815
|
+
end
|
816
|
+
}
|
817
|
+
/ occurrence_spec '' {
|
818
|
+
def value
|
819
|
+
{:range => occurrence_spec.value}
|
820
|
+
end
|
821
|
+
}
|
822
|
+
end
|
823
|
+
|
824
|
+
rule c_real_spec
|
825
|
+
real_list_value '' {
|
826
|
+
def value
|
827
|
+
{:list => real_list_value.value}
|
828
|
+
end
|
829
|
+
}
|
830
|
+
/ real_interval_value '' {
|
831
|
+
def value
|
832
|
+
{:range => real_interval_value.value}
|
833
|
+
end
|
834
|
+
}
|
835
|
+
/ real_value '' {
|
836
|
+
def value
|
837
|
+
{:list => [real_value.value]}
|
838
|
+
end
|
839
|
+
}
|
840
|
+
end
|
841
|
+
|
842
|
+
rule c_real
|
843
|
+
c_real_spec ';' white_space real_value {
|
844
|
+
def value
|
845
|
+
args = c_real_spec.value
|
846
|
+
args[:assumed_value] = real_value.value
|
847
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CReal.new(args)
|
848
|
+
end
|
849
|
+
}
|
850
|
+
/ c_real_spec '' {
|
851
|
+
def value
|
852
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CReal.new(
|
853
|
+
c_real_spec.value)
|
854
|
+
end
|
855
|
+
}
|
856
|
+
end
|
857
|
+
|
858
|
+
rule c_date_constraint
|
859
|
+
date_interval_value '' {
|
860
|
+
def value
|
861
|
+
{:range => date_interval_value.value}
|
862
|
+
end
|
863
|
+
}
|
864
|
+
/ date_list_value '' {
|
865
|
+
def value
|
866
|
+
{:list => date_list_value.value}
|
867
|
+
end
|
868
|
+
}
|
869
|
+
/ date_value '' {
|
870
|
+
def value
|
871
|
+
{:list => [date_value.value]}
|
872
|
+
end
|
873
|
+
}
|
874
|
+
/ con:V_ISO8601_DATE_CONSTRAINT_PATTERN '' {
|
875
|
+
def value
|
876
|
+
{:pattern => con.text_value}
|
877
|
+
end
|
878
|
+
}
|
879
|
+
end
|
880
|
+
|
881
|
+
rule c_date
|
882
|
+
c_date_constraint ';' white_space date_value {
|
883
|
+
def value
|
884
|
+
args = c_date_constraint.value
|
885
|
+
args[:assumed_value] = date_value.value
|
886
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDate.new(
|
887
|
+
args)
|
888
|
+
end
|
889
|
+
}
|
890
|
+
/ c_date_constraint '' {
|
891
|
+
def value
|
892
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDate.new(
|
893
|
+
c_date_constraint.value)
|
894
|
+
end
|
895
|
+
}
|
896
|
+
end
|
897
|
+
|
898
|
+
rule c_time_constraint
|
899
|
+
time_interval_value '' {
|
900
|
+
def value
|
901
|
+
{:range => time_interval_value.value}
|
902
|
+
end
|
903
|
+
}
|
904
|
+
/ time_list_value '' {
|
905
|
+
def value
|
906
|
+
{:list => time_list_value.value}
|
907
|
+
end
|
908
|
+
}
|
909
|
+
/ time_value '' {
|
910
|
+
def value
|
911
|
+
{:list => [time_value.value]}
|
912
|
+
end
|
913
|
+
}
|
914
|
+
/ tc:V_ISO8601_TIME_CONSTRAINT_PATTERN '' {
|
915
|
+
def value
|
916
|
+
{:pattern => tc.text_value}
|
917
|
+
end
|
918
|
+
}
|
919
|
+
end
|
920
|
+
|
921
|
+
rule c_time
|
922
|
+
c_time_constraint ';' white_space time_value {
|
923
|
+
def value
|
924
|
+
args = c_time_constraint.value
|
925
|
+
args[:assumed_value] = time_value.value
|
926
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CTime.new(
|
927
|
+
args)
|
928
|
+
end
|
929
|
+
}
|
930
|
+
/ c_time_constraint '' {
|
931
|
+
def value
|
932
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CTime.new(
|
933
|
+
c_time_constraint.value)
|
934
|
+
end
|
935
|
+
}
|
936
|
+
end
|
937
|
+
|
938
|
+
rule c_date_time_constraint
|
939
|
+
date_time_interval_value '' {
|
940
|
+
def value
|
941
|
+
{:range => date_time_interval_value.value}
|
942
|
+
end
|
943
|
+
}
|
944
|
+
/ date_time_value '' {
|
945
|
+
def value
|
946
|
+
{:list => [date_time_value.value]}
|
947
|
+
end
|
948
|
+
}
|
949
|
+
/ dtc:V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN '' {
|
950
|
+
def value
|
951
|
+
{:pattern => dtc.text_value}
|
952
|
+
end
|
953
|
+
}
|
954
|
+
end
|
955
|
+
|
956
|
+
rule c_date_time
|
957
|
+
c_date_time_constraint ';' white_space date_time_value {
|
958
|
+
def value
|
959
|
+
args = c_date_time_constraint.value
|
960
|
+
args[:assumed_value] = date_time_value.value
|
961
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDateTime.new(
|
962
|
+
args)
|
963
|
+
end
|
964
|
+
}
|
965
|
+
/ c_date_time_constraint '' {
|
966
|
+
def value
|
967
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDateTime.new(
|
968
|
+
c_date_time_constraint.value)
|
969
|
+
end
|
970
|
+
}
|
971
|
+
end
|
972
|
+
|
973
|
+
rule c_duration_constraint
|
974
|
+
duration_pattern '/' duration_interval_value '' {
|
975
|
+
def value
|
976
|
+
{:pattern => duration_pattern.value}
|
977
|
+
end
|
978
|
+
}
|
979
|
+
/ duration_pattern '' {
|
980
|
+
def value
|
981
|
+
{:pattern => duration_pattern.value}
|
982
|
+
end
|
983
|
+
}
|
984
|
+
/ duration_interval_value '' {
|
985
|
+
def value
|
986
|
+
{:range => duration_interval_value.value}
|
987
|
+
end
|
988
|
+
}
|
989
|
+
/ duration_value '' {
|
990
|
+
def value
|
991
|
+
{:list => [duration_value.value]}
|
992
|
+
end
|
993
|
+
}
|
994
|
+
end
|
995
|
+
|
996
|
+
rule duration_pattern
|
997
|
+
dp:V_ISO8601_DURATION_CONSTRAINT_PATTERN '' {
|
998
|
+
def value
|
999
|
+
dp.text_value
|
1000
|
+
end
|
1001
|
+
}
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
rule c_duration
|
1005
|
+
c_duration_constraint ';' white_space duration_value '' {
|
1006
|
+
def value
|
1007
|
+
args = c_duration_constraint.value
|
1008
|
+
args[:assumed_value] = duration_value.value
|
1009
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDuration.new(
|
1010
|
+
args)
|
1011
|
+
end
|
1012
|
+
}
|
1013
|
+
/ c_duration_constraint '' {
|
1014
|
+
def value
|
1015
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDuration.new(
|
1016
|
+
c_duration_constraint.value)
|
1017
|
+
end
|
1018
|
+
}
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
rule c_string_spec
|
1022
|
+
string_list_value ',' white_space SYM_LIST_CONTINUE {
|
1023
|
+
def value
|
1024
|
+
{:list => string_list_value.value}
|
1025
|
+
end
|
1026
|
+
}
|
1027
|
+
/ string_list_value '' {
|
1028
|
+
def value
|
1029
|
+
{:list => string_list_value.value}
|
1030
|
+
end
|
1031
|
+
}
|
1032
|
+
/ pat:V_REGEXP '' {
|
1033
|
+
def value
|
1034
|
+
{:pattern => pat.value}
|
1035
|
+
end
|
1036
|
+
}
|
1037
|
+
/ str:V_STRING '' {
|
1038
|
+
def value
|
1039
|
+
{:list => [str.value]}
|
1040
|
+
end
|
1041
|
+
}
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
rule c_string
|
1045
|
+
c_string_spec white_space ';' white_space string_value {
|
1046
|
+
def value
|
1047
|
+
args = c_string_spec.value
|
1048
|
+
args[:assumed_value] = string_value.value
|
1049
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(
|
1050
|
+
args)
|
1051
|
+
end
|
1052
|
+
}
|
1053
|
+
/ c_string_spec '' {
|
1054
|
+
def value
|
1055
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(
|
1056
|
+
c_string_spec.value)
|
1057
|
+
end
|
1058
|
+
}
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
rule c_boolean_spec
|
1062
|
+
SYM_TRUE ',' white_space SYM_FALSE {
|
1063
|
+
def value
|
1064
|
+
{:true_valid => true, :false_valid => true}
|
1065
|
+
end
|
1066
|
+
}
|
1067
|
+
/ SYM_TRUE white_space '' {
|
1068
|
+
def value
|
1069
|
+
{:true_valid => true, :false_valid => false}
|
1070
|
+
end
|
1071
|
+
}
|
1072
|
+
/ SYM_FALSE white_space ',' white_space SYM_TRUE {
|
1073
|
+
def value
|
1074
|
+
{:true_valid => true, :false_valid => true}
|
1075
|
+
end
|
1076
|
+
}
|
1077
|
+
/ SYM_FALSE white_space '' {
|
1078
|
+
def value
|
1079
|
+
{:false_valid => true, :true_valid => false}
|
1080
|
+
end
|
1081
|
+
}
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
rule c_boolean
|
1085
|
+
c_boolean_spec ';' white_space boolean_value {
|
1086
|
+
def value
|
1087
|
+
args = c_boolean_spec.value
|
1088
|
+
args[:assumed_value] = boolean_value.value
|
1089
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CBoolean.new(
|
1090
|
+
args)
|
1091
|
+
end
|
1092
|
+
}
|
1093
|
+
/ c_boolean_spec '' {
|
1094
|
+
def value
|
1095
|
+
OpenEHR::AM::Archetype::ConstraintModel::Primitive::CBoolean.new(
|
1096
|
+
c_boolean_spec.value)
|
1097
|
+
end
|
1098
|
+
}
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
rule constraint_ref
|
1102
|
+
vltcr:V_LOCAL_TERM_CODE_REF '' {
|
1103
|
+
def value(node)
|
1104
|
+
OpenEHR::AM::Archetype::ConstraintModel::ConstraintRef.new(
|
1105
|
+
:path => node.path,
|
1106
|
+
:rm_type_name => 'ConstraintRef',
|
1107
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(:upper => 1, :lower => 1),
|
1108
|
+
:reference => vltcr.value)
|
1109
|
+
end
|
1110
|
+
}
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
rule V_REGEXP
|
1114
|
+
(('=' / '!') '~')? (('/' ('\/' / !'/' .)* '/') / ('^' (!'^' .)* '^') ) {
|
1115
|
+
def value
|
1116
|
+
text_value
|
1117
|
+
end
|
1118
|
+
}
|
1119
|
+
end
|
1120
|
+
|
1121
|
+
rule code_string
|
1122
|
+
NAMECHAR+ '' {
|
1123
|
+
def value
|
1124
|
+
text_value
|
1125
|
+
end
|
1126
|
+
}
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
rule code_string_list
|
1130
|
+
first:code_string more:(',' space code_string)+ space {
|
1131
|
+
def value
|
1132
|
+
codes.map {|c| c.value}
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
def codes
|
1136
|
+
[first] + more.elements.map {|e| e.code_string}
|
1137
|
+
end
|
1138
|
+
}
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
rule code_string_spec
|
1142
|
+
code_string_list '' {
|
1143
|
+
def value
|
1144
|
+
code_string_list.value
|
1145
|
+
end
|
1146
|
+
}
|
1147
|
+
/ code_string '' {
|
1148
|
+
def value
|
1149
|
+
[code_string.value]
|
1150
|
+
end
|
1151
|
+
}
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
rule c_code_phrase
|
1155
|
+
ti:V_TERM_CODE code_string_spec ';' space code_string ']' space {
|
1156
|
+
def value(node)
|
1157
|
+
::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
|
1158
|
+
:rm_type_name => 'CodePhrase',
|
1159
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
|
1160
|
+
:upper => 1, :lower => 1),
|
1161
|
+
:terminology_id => ti.value, :code_list => code_string_spec.value,
|
1162
|
+
:assumed_value => code_string.value,
|
1163
|
+
:path => node.path)
|
1164
|
+
end
|
1165
|
+
}
|
1166
|
+
/ ti:V_TERM_CODE code_string_spec ']' space {
|
1167
|
+
def value(node)
|
1168
|
+
::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
|
1169
|
+
:rm_type_name => 'CodePhrase',
|
1170
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
|
1171
|
+
:upper => 1, :lower => 1),
|
1172
|
+
:terminology_id => ti.value, :code_list => code_string_spec.value,
|
1173
|
+
:path => node.path)
|
1174
|
+
end
|
1175
|
+
}
|
1176
|
+
/ ti:V_TERM_CODE ']' space {
|
1177
|
+
def value(node)
|
1178
|
+
::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
|
1179
|
+
:rm_type_name => 'CodePhrase',
|
1180
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
|
1181
|
+
:upper => 1, :lower => 1),
|
1182
|
+
:terminology_id => ti.value, :code_list => [], :path => node.path)
|
1183
|
+
end
|
1184
|
+
}
|
1185
|
+
end
|
1186
|
+
|
1187
|
+
rule SYM_C_DV_ORDINAL
|
1188
|
+
'C_DV_ORDINAL' space
|
1189
|
+
end
|
1190
|
+
|
1191
|
+
rule c_ordinal
|
1192
|
+
c_ordinal_spec ';' space integer_value space {
|
1193
|
+
def value
|
1194
|
+
args = c_ordinal_spec.value
|
1195
|
+
args[:assumed_value] = integer_value.value
|
1196
|
+
args
|
1197
|
+
end
|
1198
|
+
}
|
1199
|
+
/ c_ordinal_spec space '' {
|
1200
|
+
def value
|
1201
|
+
c_ordinal_spec.value
|
1202
|
+
end
|
1203
|
+
}
|
1204
|
+
/ SYM_C_DV_ORDINAL SYM_LT white_space SYM_GT space {
|
1205
|
+
def value
|
1206
|
+
{:list => nil}
|
1207
|
+
end
|
1208
|
+
}
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
rule c_ordinal_spec
|
1212
|
+
ordinal_list '' {
|
1213
|
+
def value
|
1214
|
+
{:list => ordinal_list.value}
|
1215
|
+
end
|
1216
|
+
}
|
1217
|
+
/ ordinal '' {
|
1218
|
+
def value
|
1219
|
+
{:list => [ordinal.value]}
|
1220
|
+
end
|
1221
|
+
}
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
rule ordinal_list
|
1225
|
+
first:ordinal more:(',' space ordinal)+ {
|
1226
|
+
def value
|
1227
|
+
ordinals.map {|o| o.value}
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
def ordinals
|
1231
|
+
[first] + more.elements.map {|e| e.ordinal}
|
1232
|
+
end
|
1233
|
+
}
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
rule ordinal
|
1237
|
+
integer_value SYM_INTERVAL_DELIM vqtc:V_QUALIFIED_TERM_CODE_REF !SYM_INTERVAL_DELIM '' {
|
1238
|
+
def value
|
1239
|
+
symbol = ::OpenEHR::RM::DataTypes::Text::DvCodedText.new(
|
1240
|
+
:value => vqtc.text_value, :defining_code => vqtc.value)
|
1241
|
+
::OpenEHR::RM::DataTypes::Quantity::DvOrdinal.new(
|
1242
|
+
:value => integer_value.value,
|
1243
|
+
:symbol => symbol)
|
1244
|
+
end
|
1245
|
+
}
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
rule c_dv_quantity
|
1249
|
+
SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1250
|
+
prop:property? ql:quantity_list? aqv:assumed_quantity_value?
|
1251
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1252
|
+
/ SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1253
|
+
prop:property? aqv:assumed_quantity_value? ql:quantity_list?
|
1254
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1255
|
+
/ SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1256
|
+
aqv:assumed_quantity_value? prop:property? ql:quantity_list?
|
1257
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1258
|
+
/ SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1259
|
+
aqv:assumed_quantity_value? ql:quantity_list? prop:property?
|
1260
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1261
|
+
/ SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1262
|
+
ql:quantity_list? aqv:assumed_quantity_value? prop:property?
|
1263
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1264
|
+
/ SYM_C_DV_QUANTITY SYM_START_DBLOCK
|
1265
|
+
ql:quantity_list? prop:property? aqv:assumed_quantity_value?
|
1266
|
+
SYM_END_DBLOCK <CDvQuantityItems>
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
rule SYM_C_DV_QUANTITY
|
1270
|
+
'C_DV_QUANTITY' space
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
rule property
|
1274
|
+
SYM_PROPERTY SYM_EQ SYM_START_DBLOCK
|
1275
|
+
prop:V_QUALIFIED_TERM_CODE_REF SYM_END_DBLOCK {
|
1276
|
+
def value
|
1277
|
+
prop.value
|
1278
|
+
end
|
1279
|
+
}
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
rule SYM_PROPERTY
|
1283
|
+
'property' space
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
rule quantity_list
|
1287
|
+
SYM_QUANTITY_LIST SYM_EQ SYM_START_DBLOCK
|
1288
|
+
c_quantity_items SYM_END_DBLOCK {
|
1289
|
+
def value(node)
|
1290
|
+
c_quantity_items.value(node)
|
1291
|
+
end
|
1292
|
+
}
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
rule assumed_quantity_value
|
1296
|
+
SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1297
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1298
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1299
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1300
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1301
|
+
/ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1302
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1303
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1304
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1305
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1306
|
+
/ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1307
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1308
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1309
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1310
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1311
|
+
/ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1312
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1313
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1314
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1315
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1316
|
+
/ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1317
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1318
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1319
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1320
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1321
|
+
/ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
|
1322
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
|
1323
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1324
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
|
1325
|
+
SYM_END_DBLOCK <AssumedValueItems>
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
rule SYM_QUANTITY_LIST
|
1329
|
+
'list' space
|
1330
|
+
end
|
1331
|
+
|
1332
|
+
rule c_quantity_items
|
1333
|
+
c_quantity_item more_cdv:(c_quantity_item white_space)* {
|
1334
|
+
def value(node)
|
1335
|
+
quantities.map {|q| q.value(node)}
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def quantities
|
1339
|
+
[c_quantity_item] + more_cdv.elements.map {|e| e.c_quantity_item}
|
1340
|
+
end
|
1341
|
+
}
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
rule c_quantity_item
|
1345
|
+
'[' V_STRING ']' white_space SYM_EQ SYM_START_DBLOCK
|
1346
|
+
SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
|
1347
|
+
mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK int:real_interval_value SYM_END_DBLOCK)?
|
1348
|
+
prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK int:integer_interval_value SYM_END_DBLOCK)?
|
1349
|
+
SYM_END_DBLOCK {
|
1350
|
+
def value(node)
|
1351
|
+
magnitude, precision = nil
|
1352
|
+
magnitude = mag.int.value unless mag.empty?
|
1353
|
+
precision = prec.int.value unless prec.empty?
|
1354
|
+
OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CQuantityItem.new(
|
1355
|
+
:path => node.path, :rm_type_name => 'DvQuantity',
|
1356
|
+
:occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
|
1357
|
+
:upper => 1, :lower => 1),
|
1358
|
+
:units => units.value,
|
1359
|
+
:magnitude => magnitude, :precision => precision)
|
1360
|
+
end
|
1361
|
+
}
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
rule SYM_UNITS
|
1365
|
+
'units' space
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
rule SYM_MAGNITUDE
|
1369
|
+
'magnitude' space
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
rule SYM_PRECISION
|
1373
|
+
'precision' space
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
rule SYM_ASSUMED_VALUE
|
1377
|
+
'assumed_value' space
|
1378
|
+
end
|
1379
|
+
|
1380
|
+
rule V_C_DOMAIN_TYPE
|
1381
|
+
'('? [A-Z] IDCHAR* ')'? [ \n]* '<' [^>]* '>'
|
1382
|
+
end
|
1383
|
+
|
1384
|
+
# assertion block
|
1385
|
+
|
1386
|
+
rule V_ASSERTION_TEXT
|
1387
|
+
assertions '' {
|
1388
|
+
def value
|
1389
|
+
assertions.value
|
1390
|
+
end
|
1391
|
+
}
|
1392
|
+
end
|
1393
|
+
|
1394
|
+
rule assertions
|
1395
|
+
assertion more_a:(assertion '')* {
|
1396
|
+
def value
|
1397
|
+
assertions.map {|a| a.value}
|
1398
|
+
end
|
1399
|
+
|
1400
|
+
def assertions
|
1401
|
+
[assertion] + more_a.elements.map {|a| a.assertion}
|
1402
|
+
end
|
1403
|
+
}
|
1404
|
+
end
|
1405
|
+
|
1406
|
+
rule assertion
|
1407
|
+
id:(any_identifier ':')? boolean_expression space {
|
1408
|
+
def value
|
1409
|
+
if (id && !id.empty?)
|
1410
|
+
OpenEHR::AM::Archetype::Assertion::Assertion.new(
|
1411
|
+
:tag => id.value, :expression => boolean_expression.value,
|
1412
|
+
:string_expression => id.text_value + boolean_expression.text_value)
|
1413
|
+
else
|
1414
|
+
OpenEHR::AM::Archetype::Assertion::Assertion.new(
|
1415
|
+
:expression => boolean_expression.value,
|
1416
|
+
:string_expression => boolean_expression.text_value)
|
1417
|
+
end
|
1418
|
+
end
|
1419
|
+
}
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
rule boolean_expression
|
1423
|
+
boolean_node '' {
|
1424
|
+
def value
|
1425
|
+
boolean_node.value
|
1426
|
+
end
|
1427
|
+
}
|
1428
|
+
/ boolean_leaf '' {
|
1429
|
+
def value
|
1430
|
+
boolean_leaf.value
|
1431
|
+
end
|
1432
|
+
}
|
1433
|
+
end
|
1434
|
+
|
1435
|
+
rule boolean_node
|
1436
|
+
SYM_EXISTS absolute_path {
|
1437
|
+
def value
|
1438
|
+
item = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
|
1439
|
+
:type => 'String',
|
1440
|
+
:item => absolute_path.value,
|
1441
|
+
:reference_type => 'CONSTANT')
|
1442
|
+
OpenEHR::AM::Archetype::Assertion::ExprUnaryOperator.new(
|
1443
|
+
:type => 'Boolean',
|
1444
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EXISTS,
|
1445
|
+
:operand => item,
|
1446
|
+
:precedence_overridden => false)
|
1447
|
+
end
|
1448
|
+
}
|
1449
|
+
/ relative_path white_space SYM_MATCHES SYM_START_CBLOCK c_primitive SYM_END_CBLOCK {
|
1450
|
+
def value
|
1451
|
+
left_op = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
|
1452
|
+
:type => 'String',
|
1453
|
+
:item => relative_path.value,
|
1454
|
+
:reference_type => 'Constant')
|
1455
|
+
right_op = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
|
1456
|
+
:item => c_primitive.value,
|
1457
|
+
:type => c_primitive.value.type,
|
1458
|
+
:reference_type => 'Constant')
|
1459
|
+
op = OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MATCHES
|
1460
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1461
|
+
:type => 'Boolean',
|
1462
|
+
:operator => op,
|
1463
|
+
:right_operand => right_op,
|
1464
|
+
:left_operand => left_op,
|
1465
|
+
:reference_type => 'Constraint')
|
1466
|
+
end
|
1467
|
+
}
|
1468
|
+
/ SYM_NOT boolean_leaf '' {
|
1469
|
+
def value
|
1470
|
+
OpenEHR::AM::Archetype::Assertion::ExprUnaryOperator.new(
|
1471
|
+
:type => 'Boolean',
|
1472
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_NOT,
|
1473
|
+
:operand => boolean_leaf.value,
|
1474
|
+
:precedence_overridden => false)
|
1475
|
+
end
|
1476
|
+
}
|
1477
|
+
/ arithmetic_leaf SYM_EQ arithmetic_expression {
|
1478
|
+
def value
|
1479
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1480
|
+
:type => 'Boolean',
|
1481
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EQ,
|
1482
|
+
:left_operand => arithmetic_leaf.value,
|
1483
|
+
:right_operand => arithmetic_expression.value,
|
1484
|
+
:reference_type => 'Constraint')
|
1485
|
+
end
|
1486
|
+
}
|
1487
|
+
/ arithmetic_leaf SYM_NE arithmetic_expression {
|
1488
|
+
def value
|
1489
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1490
|
+
:type => 'Boolean',
|
1491
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_NE,
|
1492
|
+
:left_operand => arithmetic_leaf.value,
|
1493
|
+
:right_operand => arithmetic_expression.value,
|
1494
|
+
:reference_type => 'Constraint')
|
1495
|
+
end
|
1496
|
+
}
|
1497
|
+
/ arithmetic_leaf SYM_LT arithmetic_expression {
|
1498
|
+
def value
|
1499
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1500
|
+
:type => 'Boolean',
|
1501
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_LT,
|
1502
|
+
:left_operand => arithmetic_leaf.value,
|
1503
|
+
:right_operand => arithmetic_expression.value,
|
1504
|
+
:reference_type => 'Constraint')
|
1505
|
+
end
|
1506
|
+
}
|
1507
|
+
/ arithmetic_leaf SYM_GT arithmetic_expression {
|
1508
|
+
def value
|
1509
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1510
|
+
:type => 'Boolean',
|
1511
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_GT,
|
1512
|
+
:left_operand => arithmetic_leaf.value,
|
1513
|
+
:right_operand => arithmetic_expression.value,
|
1514
|
+
:reference_type => 'Constraint')
|
1515
|
+
end
|
1516
|
+
}
|
1517
|
+
/ arithmetic_leaf SYM_LE arithmetic_expression {
|
1518
|
+
def value
|
1519
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1520
|
+
:type => 'Boolean',
|
1521
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_LE,
|
1522
|
+
:left_operand => arithmetic_leaf.value,
|
1523
|
+
:right_operand => arithmetic_expression.value,
|
1524
|
+
:reference_type => 'Constraint')
|
1525
|
+
end
|
1526
|
+
}
|
1527
|
+
/ arithmetic_leaf SYM_GE arithmetic_expression {
|
1528
|
+
def value
|
1529
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1530
|
+
:type => 'Boolean',
|
1531
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_GE,
|
1532
|
+
:left_operand => arithmetic_leaf.value,
|
1533
|
+
:right_operand => arithmetic_expression.value,
|
1534
|
+
:reference_type => 'Constraint')
|
1535
|
+
end
|
1536
|
+
}
|
1537
|
+
/ boolean_leaf SYM_AND boolean_expression {
|
1538
|
+
def value
|
1539
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1540
|
+
:type => 'Boolean',
|
1541
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_AND,
|
1542
|
+
:left_operand => boolean_leaf.value,
|
1543
|
+
:right_operand => boolean_expression.value,
|
1544
|
+
:reference_type => 'Constraint')
|
1545
|
+
end
|
1546
|
+
}
|
1547
|
+
/ boolean_leaf SYM_OR boolean_expression {
|
1548
|
+
def value
|
1549
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1550
|
+
:type => 'Boolean',
|
1551
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_OR,
|
1552
|
+
:left_operand => boolean_leaf.value,
|
1553
|
+
:right_operand => boolean_expression.value,
|
1554
|
+
:reference_type => 'Constraint')
|
1555
|
+
end
|
1556
|
+
}
|
1557
|
+
/ boolean_leaf SYM_XOR boolean_expression {
|
1558
|
+
def value
|
1559
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1560
|
+
:type => 'Boolean',
|
1561
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_XOR,
|
1562
|
+
:left_operand => boolean_leaf.value,
|
1563
|
+
:right_operand => boolean_expression.value,
|
1564
|
+
:reference_type => 'Constraint')
|
1565
|
+
end
|
1566
|
+
}
|
1567
|
+
/ boolean_leaf SYM_IMPLIES boolean_expression {
|
1568
|
+
def value
|
1569
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1570
|
+
:type => 'Boolean',
|
1571
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_IMPLIES,
|
1572
|
+
:left_operand => boolean_leaf.value,
|
1573
|
+
:right_operand => boolean_expression.value,
|
1574
|
+
:reference_type => 'Constraint')
|
1575
|
+
end
|
1576
|
+
}
|
1577
|
+
end
|
1578
|
+
|
1579
|
+
rule boolean_leaf
|
1580
|
+
'(' boolean_expression ')' {
|
1581
|
+
def value
|
1582
|
+
boolean_expression.value
|
1583
|
+
end
|
1584
|
+
}
|
1585
|
+
/ SYM_TRUE '' {
|
1586
|
+
def value
|
1587
|
+
OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
|
1588
|
+
:type => 'Boolean',
|
1589
|
+
:item => true,
|
1590
|
+
:reference_type => 'CONSTANT')
|
1591
|
+
end
|
1592
|
+
}
|
1593
|
+
/ SYM_FALSE '' {
|
1594
|
+
def value
|
1595
|
+
OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
|
1596
|
+
:type => 'Boolean',
|
1597
|
+
:item => false,
|
1598
|
+
:reference_type => 'CONSTANT')
|
1599
|
+
end
|
1600
|
+
}
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
rule arithmetic_expression
|
1604
|
+
arithmetic_node '' {
|
1605
|
+
def value
|
1606
|
+
arithmetic_node.value
|
1607
|
+
end
|
1608
|
+
}
|
1609
|
+
/ arithmetic_leaf '' {
|
1610
|
+
def value
|
1611
|
+
arithmetic_leaf.value
|
1612
|
+
end
|
1613
|
+
}
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
rule arithmetic_node
|
1617
|
+
arithmetic_leaf '+' arithmetic_expression {
|
1618
|
+
def value
|
1619
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1620
|
+
:type => 'Boolean',
|
1621
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_PLUS,
|
1622
|
+
:left_operand => arithmetic_leaf.value,
|
1623
|
+
:right_operand => arithmetic_expression.value,
|
1624
|
+
:reference_type => 'Constraint')
|
1625
|
+
end
|
1626
|
+
}
|
1627
|
+
/ arithmetic_leaf '-' arithmetic_expression {
|
1628
|
+
def value
|
1629
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1630
|
+
:type => 'Boolean',
|
1631
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MINUS,
|
1632
|
+
:left_operand => arithmetic_leaf.value,
|
1633
|
+
:right_operand => arithmetic_expression.value,
|
1634
|
+
:reference_type => 'Constraint')
|
1635
|
+
end
|
1636
|
+
}
|
1637
|
+
/ arithmetic_leaf '*' arithmetic_expression {
|
1638
|
+
def value
|
1639
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1640
|
+
:type => 'Boolean',
|
1641
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MULTIPLY,
|
1642
|
+
:left_operand => arithmetic_leaf.value,
|
1643
|
+
:right_operand => arithmetic_expression.value,
|
1644
|
+
:reference_type => 'Constraint')
|
1645
|
+
end
|
1646
|
+
}
|
1647
|
+
/ arithmetic_leaf '/' arithmetic_expression {
|
1648
|
+
def value
|
1649
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1650
|
+
:type => 'Boolean',
|
1651
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_DIVIDE,
|
1652
|
+
:left_operand => arithmetic_leaf.value,
|
1653
|
+
:right_operand => arithmetic_expression.value,
|
1654
|
+
:reference_type => 'Constraint')
|
1655
|
+
end
|
1656
|
+
}
|
1657
|
+
/ arithmetic_leaf '^' arithmetic_expression {
|
1658
|
+
def value
|
1659
|
+
OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
|
1660
|
+
:type => 'Boolean',
|
1661
|
+
:operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EXP,
|
1662
|
+
:left_operand => arithmetic_leaf.value,
|
1663
|
+
:right_operand => arithmetic_expression.value,
|
1664
|
+
:reference_type => 'Constraint')
|
1665
|
+
end
|
1666
|
+
}
|
1667
|
+
end
|
1668
|
+
|
1669
|
+
rule arithmetic_leaf
|
1670
|
+
'(' arithmetic_expression ')' space {
|
1671
|
+
def value
|
1672
|
+
arithmetic_expression.value
|
1673
|
+
end
|
1674
|
+
}
|
1675
|
+
/ integer_value '' {
|
1676
|
+
def value
|
1677
|
+
OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
|
1678
|
+
:type => 'Integer',
|
1679
|
+
:item => integer_value.value,
|
1680
|
+
:reference_type => 'CONSTANT')
|
1681
|
+
end
|
1682
|
+
}
|
1683
|
+
/ real_value '' {
|
1684
|
+
def value
|
1685
|
+
OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
|
1686
|
+
:type => 'Real',
|
1687
|
+
:item => real_value.value,
|
1688
|
+
:reference_type => 'CONSTANT')
|
1689
|
+
end
|
1690
|
+
}
|
1691
|
+
/ absolute_path space {
|
1692
|
+
def value
|
1693
|
+
OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
|
1694
|
+
:type => 'String',
|
1695
|
+
:item => absolute_path.value,
|
1696
|
+
:reference_type => 'CONSTANT')
|
1697
|
+
|
1698
|
+
end
|
1699
|
+
}
|
1700
|
+
end
|
1701
|
+
|
1702
|
+
# path block
|
1703
|
+
rule object_path
|
1704
|
+
movable_path '' {
|
1705
|
+
def value
|
1706
|
+
movable_path.value
|
1707
|
+
end
|
1708
|
+
}
|
1709
|
+
/ absolute_path '' {
|
1710
|
+
def value
|
1711
|
+
absolute_path.value
|
1712
|
+
end
|
1713
|
+
}
|
1714
|
+
/ relative_path '' {
|
1715
|
+
def value
|
1716
|
+
relative_path.value
|
1717
|
+
end
|
1718
|
+
}
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
rule movable_path
|
1722
|
+
SYM_MOVABLE_LEADER relative_path '' {
|
1723
|
+
def value
|
1724
|
+
text_value
|
1725
|
+
end
|
1726
|
+
}
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
rule absolute_path
|
1730
|
+
'/' relative_path? '' {
|
1731
|
+
def value
|
1732
|
+
text_value
|
1733
|
+
end
|
1734
|
+
}
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
rule relative_path
|
1738
|
+
path_segment ('/' path_segment)* '' {
|
1739
|
+
def value
|
1740
|
+
text_value
|
1741
|
+
end
|
1742
|
+
}
|
1743
|
+
end
|
1744
|
+
|
1745
|
+
rule path_segment
|
1746
|
+
V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF? '' {
|
1747
|
+
def value
|
1748
|
+
text_value
|
1749
|
+
end
|
1750
|
+
}
|
1751
|
+
end
|
1752
|
+
|
1753
|
+
rule SYM_MOVABLE_LEADER
|
1754
|
+
'//'
|
1755
|
+
end # of cADL grammar
|
1756
|
+
|
1757
|
+
# biginning of dADL grammar
|
1758
|
+
|
1759
|
+
rule V_DADL_TEXT
|
1760
|
+
attr_vals space {
|
1761
|
+
def value
|
1762
|
+
attr_vals.value
|
1763
|
+
end
|
1764
|
+
}
|
1765
|
+
/ complex_object_block space {
|
1766
|
+
def value
|
1767
|
+
complex_object_block.value
|
1768
|
+
end
|
1769
|
+
}
|
1770
|
+
end
|
1771
|
+
|
1772
|
+
rule attr_vals
|
1773
|
+
first:attr_val second:(';'? space attr_val space)* {
|
1774
|
+
def value
|
1775
|
+
attrs.inject({ }) {|val, a| val.update a.value}
|
1776
|
+
end
|
1777
|
+
|
1778
|
+
def attrs
|
1779
|
+
[first] + second.elements.map {|e| e.attr_val}
|
1780
|
+
end
|
1781
|
+
}
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
rule attr_val
|
1785
|
+
attr_id SYM_EQ object_block {
|
1786
|
+
def value
|
1787
|
+
{attr_id.value => object_block.value}
|
1788
|
+
end
|
1789
|
+
}
|
1790
|
+
end
|
1791
|
+
|
1792
|
+
rule attr_id
|
1793
|
+
id:V_ATTRIBUTE_IDENTIFIER white_space {
|
1794
|
+
def value
|
1795
|
+
id.value
|
1796
|
+
end
|
1797
|
+
}
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
rule object_block
|
1801
|
+
complex_object_block space {
|
1802
|
+
def value
|
1803
|
+
complex_object_block.value
|
1804
|
+
end
|
1805
|
+
}
|
1806
|
+
/ primitive_object_block space {
|
1807
|
+
def value
|
1808
|
+
primitive_object_block.value
|
1809
|
+
end
|
1810
|
+
}
|
1811
|
+
end
|
1812
|
+
|
1813
|
+
rule complex_object_block
|
1814
|
+
single_attr_object_block '' {
|
1815
|
+
def value
|
1816
|
+
single_attr_object_block.value
|
1817
|
+
end
|
1818
|
+
}
|
1819
|
+
/ multiple_attr_object_block '' {
|
1820
|
+
def value
|
1821
|
+
multiple_attr_object_block.value
|
1822
|
+
end
|
1823
|
+
}
|
1824
|
+
end
|
1825
|
+
|
1826
|
+
rule multiple_attr_object_block
|
1827
|
+
type_identifier? untyped_multiple_attr_object_block {
|
1828
|
+
def value
|
1829
|
+
untyped_multiple_attr_object_block.value
|
1830
|
+
end
|
1831
|
+
}
|
1832
|
+
end
|
1833
|
+
|
1834
|
+
rule untyped_multiple_attr_object_block
|
1835
|
+
multiple_attr_object_block_head keyed_objects SYM_END_DBLOCK {
|
1836
|
+
def value
|
1837
|
+
keyed_objects.value
|
1838
|
+
end
|
1839
|
+
}
|
1840
|
+
end
|
1841
|
+
|
1842
|
+
rule multiple_attr_object_block_head
|
1843
|
+
SYM_START_DBLOCK
|
1844
|
+
end
|
1845
|
+
|
1846
|
+
rule keyed_objects
|
1847
|
+
keyed_object+ {
|
1848
|
+
def value
|
1849
|
+
elements.inject({ }) {|val, e| val.update e.value}
|
1850
|
+
end
|
1851
|
+
}
|
1852
|
+
end
|
1853
|
+
|
1854
|
+
rule keyed_object
|
1855
|
+
object_key SYM_EQ object_block {
|
1856
|
+
def value
|
1857
|
+
{object_key.value => object_block.value}
|
1858
|
+
end
|
1859
|
+
}
|
1860
|
+
end
|
1861
|
+
|
1862
|
+
rule object_key
|
1863
|
+
'[' simple_value ']' white_space {
|
1864
|
+
def value
|
1865
|
+
simple_value.value
|
1866
|
+
end
|
1867
|
+
}
|
1868
|
+
end
|
1869
|
+
|
1870
|
+
rule single_attr_object_block
|
1871
|
+
type_identifier? untyped_single_attr_object_block {
|
1872
|
+
def value
|
1873
|
+
untyped_single_attr_object_block.value
|
1874
|
+
end
|
1875
|
+
}
|
1876
|
+
end
|
1877
|
+
|
1878
|
+
rule untyped_single_attr_object_block
|
1879
|
+
single_attr_object_complex_head attr_vals SYM_END_DBLOCK {
|
1880
|
+
def value
|
1881
|
+
elements[1].value
|
1882
|
+
end
|
1883
|
+
}
|
1884
|
+
/ single_attr_object_complex_head SYM_END_DBLOCK {
|
1885
|
+
def value
|
1886
|
+
nil
|
1887
|
+
end
|
1888
|
+
}
|
1889
|
+
end
|
1890
|
+
|
1891
|
+
rule single_attr_object_complex_head
|
1892
|
+
SYM_START_DBLOCK
|
1893
|
+
end
|
1894
|
+
|
1895
|
+
rule primitive_object_block
|
1896
|
+
type_identifier? untyped_primitive_object_block {
|
1897
|
+
def value
|
1898
|
+
untyped_primitive_object_block.value
|
1899
|
+
end
|
1900
|
+
}
|
1901
|
+
end
|
1902
|
+
|
1903
|
+
rule untyped_primitive_object_block
|
1904
|
+
SYM_START_DBLOCK primitive_object_value SYM_END_DBLOCK {
|
1905
|
+
def value
|
1906
|
+
primitive_object_value.value
|
1907
|
+
end
|
1908
|
+
}
|
1909
|
+
end
|
1910
|
+
|
1911
|
+
rule primitive_object_value
|
1912
|
+
term_code_list_value '' {
|
1913
|
+
def value
|
1914
|
+
term_code_list_value.value
|
1915
|
+
end
|
1916
|
+
}
|
1917
|
+
/ term_code '' {
|
1918
|
+
def value
|
1919
|
+
term_code.value
|
1920
|
+
end
|
1921
|
+
}
|
1922
|
+
/ simple_list_value '' {
|
1923
|
+
def value
|
1924
|
+
simple_list_value.value
|
1925
|
+
end
|
1926
|
+
}
|
1927
|
+
/ simple_interval_value '' {
|
1928
|
+
def value
|
1929
|
+
simple_interval_value.value
|
1930
|
+
end
|
1931
|
+
}
|
1932
|
+
/ simple_value '' {
|
1933
|
+
def value
|
1934
|
+
simple_value.value
|
1935
|
+
end
|
1936
|
+
}
|
1937
|
+
end
|
1938
|
+
|
1939
|
+
rule simple_value
|
1940
|
+
integer_value '' {
|
1941
|
+
def value
|
1942
|
+
integer_value.value
|
1943
|
+
end
|
1944
|
+
}
|
1945
|
+
/ real_value '' {
|
1946
|
+
def value
|
1947
|
+
real_value.value
|
1948
|
+
end
|
1949
|
+
}
|
1950
|
+
/ boolean_value '' {
|
1951
|
+
def value
|
1952
|
+
boolean_value.value
|
1953
|
+
end
|
1954
|
+
}
|
1955
|
+
/ uri_value '' {
|
1956
|
+
def value
|
1957
|
+
uri_value.value
|
1958
|
+
end
|
1959
|
+
}
|
1960
|
+
/ date_value '' {
|
1961
|
+
def value
|
1962
|
+
date_value.value
|
1963
|
+
end
|
1964
|
+
}
|
1965
|
+
/ time_value '' {
|
1966
|
+
def value
|
1967
|
+
time_value.value
|
1968
|
+
end
|
1969
|
+
}
|
1970
|
+
/ date_time_value '' {
|
1971
|
+
def value
|
1972
|
+
date_time_value.value
|
1973
|
+
end
|
1974
|
+
}
|
1975
|
+
/ duration_value '' {
|
1976
|
+
def value
|
1977
|
+
duration_value.value
|
1978
|
+
end
|
1979
|
+
}
|
1980
|
+
/ string_value '' {
|
1981
|
+
def value
|
1982
|
+
string_value.value
|
1983
|
+
end
|
1984
|
+
}
|
1985
|
+
/ character_value '' {
|
1986
|
+
def value
|
1987
|
+
character_value.value
|
1988
|
+
end
|
1989
|
+
}
|
1990
|
+
end
|
1991
|
+
|
1992
|
+
rule simple_list_value
|
1993
|
+
integer_list_value '' {
|
1994
|
+
def value
|
1995
|
+
integer_list_value.value
|
1996
|
+
end
|
1997
|
+
}
|
1998
|
+
/ real_list_value '' {
|
1999
|
+
def value
|
2000
|
+
real_list_value.value
|
2001
|
+
end
|
2002
|
+
}
|
2003
|
+
/ boolean_list_value '' {
|
2004
|
+
def value
|
2005
|
+
boolean_list_value.value
|
2006
|
+
end
|
2007
|
+
}
|
2008
|
+
/ character_list_value '' {
|
2009
|
+
def value
|
2010
|
+
character_list_value.value
|
2011
|
+
end
|
2012
|
+
}
|
2013
|
+
/ date_list_value '' {
|
2014
|
+
def value
|
2015
|
+
date_list_value.value
|
2016
|
+
end
|
2017
|
+
}
|
2018
|
+
/ time_list_value '' {
|
2019
|
+
def value
|
2020
|
+
time_list_value.value
|
2021
|
+
end
|
2022
|
+
}
|
2023
|
+
/ date_time_list_value '' {
|
2024
|
+
def value
|
2025
|
+
date_time_list_value.value
|
2026
|
+
end
|
2027
|
+
}
|
2028
|
+
/ duration_list_value '' {
|
2029
|
+
def value
|
2030
|
+
duration_list_value.value
|
2031
|
+
end
|
2032
|
+
}
|
2033
|
+
/ string_list_value '' {
|
2034
|
+
def value
|
2035
|
+
string_list_value.value
|
2036
|
+
end
|
2037
|
+
}
|
2038
|
+
end
|
2039
|
+
|
2040
|
+
rule simple_interval_value
|
2041
|
+
integer_interval_value '' {
|
2042
|
+
def value
|
2043
|
+
integer_interval_value.value
|
2044
|
+
end
|
2045
|
+
}
|
2046
|
+
/ real_interval_value '' {
|
2047
|
+
def value
|
2048
|
+
real_interval_value.value
|
2049
|
+
end
|
2050
|
+
}
|
2051
|
+
/ date_interval_value '' {
|
2052
|
+
def value
|
2053
|
+
date_interval_value.value
|
2054
|
+
end
|
2055
|
+
}
|
2056
|
+
/ time_interval_value '' {
|
2057
|
+
def value
|
2058
|
+
time_interval_value.value
|
2059
|
+
end
|
2060
|
+
}
|
2061
|
+
/ date_time_interval_value '' {
|
2062
|
+
def value
|
2063
|
+
date_time_interval_value.value
|
2064
|
+
end
|
2065
|
+
}
|
2066
|
+
/ duration_interval_value '' {
|
2067
|
+
def value
|
2068
|
+
duration_interval_value.value
|
2069
|
+
end
|
2070
|
+
}
|
2071
|
+
end
|
2072
|
+
|
2073
|
+
rule term_code
|
2074
|
+
vtref:V_QUALIFIED_TERM_CODE_REF '' {
|
2075
|
+
def value
|
2076
|
+
vtref.value
|
2077
|
+
end
|
2078
|
+
}
|
2079
|
+
end
|
2080
|
+
|
2081
|
+
rule term_code_list_value
|
2082
|
+
first:term_code more:(',' term_code)+ {
|
2083
|
+
def value
|
2084
|
+
term_codes.map {|t| t.value}
|
2085
|
+
end
|
2086
|
+
|
2087
|
+
def term_codes
|
2088
|
+
[first] + more.elements.map {|e| e.term_code}
|
2089
|
+
end
|
2090
|
+
}
|
2091
|
+
/ term_code ',' SYM_LIST_CONTINUE {
|
2092
|
+
def value
|
2093
|
+
[term_code.value]
|
2094
|
+
end
|
2095
|
+
}
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
rule uri_value
|
2099
|
+
uri:V_URI '' {
|
2100
|
+
def value
|
2101
|
+
uri.value
|
2102
|
+
end
|
2103
|
+
}
|
2104
|
+
end # of dADL grammar
|
2105
|
+
|
2106
|
+
# beginning of shared token section
|
2107
|
+
|
2108
|
+
rule any_identifier
|
2109
|
+
type_identifier '' {
|
2110
|
+
def value
|
2111
|
+
type_identifier.value
|
2112
|
+
end
|
2113
|
+
}
|
2114
|
+
/ V_ATTRIBUTE_IDENTIFIER '' {
|
2115
|
+
def value
|
2116
|
+
V_ATTRIBUTE_IDENTIFIER.value
|
2117
|
+
end
|
2118
|
+
}
|
2119
|
+
end
|
2120
|
+
|
2121
|
+
rule type_identifier
|
2122
|
+
'(' id:V_GENERIC_TYPE_IDENTIFIER ')' white_space {
|
2123
|
+
def value
|
2124
|
+
id.value
|
2125
|
+
end
|
2126
|
+
}
|
2127
|
+
/ id:V_GENERIC_TYPE_IDENTIFIER white_space {
|
2128
|
+
def value
|
2129
|
+
id.value
|
2130
|
+
end
|
2131
|
+
}
|
2132
|
+
/ '(' id:V_TYPE_IDENTIFIER ')' white_space {
|
2133
|
+
def value
|
2134
|
+
id.value
|
2135
|
+
end
|
2136
|
+
}
|
2137
|
+
/ id:V_TYPE_IDENTIFIER white_space {
|
2138
|
+
def value
|
2139
|
+
id.value
|
2140
|
+
end
|
2141
|
+
}
|
2142
|
+
end
|
2143
|
+
|
2144
|
+
rule boolean_value
|
2145
|
+
SYM_TRUE {
|
2146
|
+
def value
|
2147
|
+
true
|
2148
|
+
end
|
2149
|
+
}
|
2150
|
+
/ SYM_FALSE {
|
2151
|
+
def value
|
2152
|
+
false
|
2153
|
+
end
|
2154
|
+
}
|
2155
|
+
end
|
2156
|
+
|
2157
|
+
rule boolean_list_value
|
2158
|
+
boolean_value (',' white_space more_bool:(boolean_value ''))+ {
|
2159
|
+
def value
|
2160
|
+
booelans.map {|b| b.value}
|
2161
|
+
end
|
2162
|
+
|
2163
|
+
def booleans
|
2164
|
+
[boolean_value] + more_bool.elements.map { |b| b.boolean_value }
|
2165
|
+
end
|
2166
|
+
}
|
2167
|
+
/ boolean_value white_space SYM_LIST_CONTINUE {
|
2168
|
+
def value
|
2169
|
+
[boolean_value.value]
|
2170
|
+
end
|
2171
|
+
}
|
2172
|
+
end
|
2173
|
+
|
2174
|
+
rule integer_value
|
2175
|
+
[+-]? V_INTEGER '' {
|
2176
|
+
def value
|
2177
|
+
text_value.to_i
|
2178
|
+
end
|
2179
|
+
}
|
2180
|
+
end
|
2181
|
+
|
2182
|
+
rule integer_list_value
|
2183
|
+
integer_value more_i:(',' white_space integer_value)+ {
|
2184
|
+
def value
|
2185
|
+
integers.map { |i| i.value }
|
2186
|
+
end
|
2187
|
+
|
2188
|
+
def integers
|
2189
|
+
[integer_value] + more_i.elements.map { |i| i.integer_value }
|
2190
|
+
end
|
2191
|
+
}
|
2192
|
+
/ integer_value ',' white_space SYM_LIST_CONTINUE {
|
2193
|
+
def value
|
2194
|
+
[integer_value.value]
|
2195
|
+
end
|
2196
|
+
}
|
2197
|
+
end
|
2198
|
+
|
2199
|
+
rule integer_interval_value
|
2200
|
+
SYM_INTERVAL_DELIM SYM_GT lo:integer_value SYM_ELLIPSIS SYM_LT up:integer_value SYM_INTERVAL_DELIM {
|
2201
|
+
def value
|
2202
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2203
|
+
:upper => up.value,
|
2204
|
+
:lower_included => false,
|
2205
|
+
:upper_included => false)
|
2206
|
+
end
|
2207
|
+
}
|
2208
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:integer_value SYM_ELLIPSIS up:integer_value SYM_INTERVAL_DELIM {
|
2209
|
+
def value
|
2210
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2211
|
+
:upper => up.value,
|
2212
|
+
:lower_included => false,
|
2213
|
+
:upper_included => true)
|
2214
|
+
end
|
2215
|
+
}
|
2216
|
+
/ SYM_INTERVAL_DELIM lo:integer_value SYM_ELLIPSIS SYM_LT up:integer_value SYM_INTERVAL_DELIM {
|
2217
|
+
def value
|
2218
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2219
|
+
:upper => up.value,
|
2220
|
+
:lower_included => true,
|
2221
|
+
:upper_included => false)
|
2222
|
+
end
|
2223
|
+
}
|
2224
|
+
/ SYM_INTERVAL_DELIM lo:integer_value SYM_ELLIPSIS up:integer_value SYM_INTERVAL_DELIM {
|
2225
|
+
def value
|
2226
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2227
|
+
:upper => up.value,
|
2228
|
+
:lower_included => true,
|
2229
|
+
:upper_included => true)
|
2230
|
+
end
|
2231
|
+
}
|
2232
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:integer_value SYM_INTERVAL_DELIM {
|
2233
|
+
def value
|
2234
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2235
|
+
:upper => up.value,
|
2236
|
+
:lower_unbounded => true,
|
2237
|
+
:upper_included => false)
|
2238
|
+
end
|
2239
|
+
}
|
2240
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:integer_value SYM_INTERVAL_DELIM {
|
2241
|
+
def value
|
2242
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2243
|
+
:upper => up.value,
|
2244
|
+
:lower_unbounded => true,
|
2245
|
+
:upper_included => true)
|
2246
|
+
end
|
2247
|
+
}
|
2248
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:integer_value SYM_INTERVAL_DELIM {
|
2249
|
+
def value
|
2250
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2251
|
+
:lower => lo.value,
|
2252
|
+
:uppper_unbounded => true,
|
2253
|
+
:lower_included => false)
|
2254
|
+
end
|
2255
|
+
}
|
2256
|
+
/ SYM_INTERVAL_DELIM SYM_GE iv:integer_value SYM_INTERVAL_DELIM {
|
2257
|
+
def value
|
2258
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2259
|
+
:lower => iv.value,
|
2260
|
+
:upper_unbounded => true,
|
2261
|
+
:lower_included => true)
|
2262
|
+
end
|
2263
|
+
}
|
2264
|
+
/ SYM_INTERVAL_DELIM val:integer_value SYM_INTERVAL_DELIM {
|
2265
|
+
def value
|
2266
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2267
|
+
:lower => val.value,
|
2268
|
+
:upper => val.value,
|
2269
|
+
:upper_included => true,
|
2270
|
+
:lower_included => true)
|
2271
|
+
end
|
2272
|
+
}
|
2273
|
+
end
|
2274
|
+
|
2275
|
+
rule real_value
|
2276
|
+
('+' / '-')? V_REAL {
|
2277
|
+
def value
|
2278
|
+
text_value.to_f
|
2279
|
+
end
|
2280
|
+
}
|
2281
|
+
end
|
2282
|
+
|
2283
|
+
rule real_list_value
|
2284
|
+
real_value more_i:(',' white_space real_value)* {
|
2285
|
+
def value
|
2286
|
+
reals.map { |i| i.value }
|
2287
|
+
end
|
2288
|
+
|
2289
|
+
def reals
|
2290
|
+
[real_value] + more_i.elements.map { |i| i.real_value }
|
2291
|
+
end
|
2292
|
+
}
|
2293
|
+
/ real_value ',' white_space SYM_LIST_CONTINUE {
|
2294
|
+
def value
|
2295
|
+
[real_value.value]
|
2296
|
+
end
|
2297
|
+
}
|
2298
|
+
end
|
2299
|
+
|
2300
|
+
rule real_interval_value
|
2301
|
+
SYM_INTERVAL_DELIM SYM_GT lo:real_value SYM_ELLIPSIS SYM_LT up:real_value SYM_INTERVAL_DELIM {
|
2302
|
+
def value
|
2303
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2304
|
+
:upper => up.value,
|
2305
|
+
:lower_included => false,
|
2306
|
+
:upper_included => false)
|
2307
|
+
end
|
2308
|
+
}
|
2309
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:real_value SYM_ELLIPSIS up:real_value SYM_INTERVAL_DELIM {
|
2310
|
+
def value
|
2311
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2312
|
+
:upper => up.value,
|
2313
|
+
:lower_included => false,
|
2314
|
+
:upper_included => true)
|
2315
|
+
end
|
2316
|
+
}
|
2317
|
+
/ SYM_INTERVAL_DELIM lo:real_value SYM_ELLIPSIS SYM_LT up:real_value SYM_INTERVAL_DELIM {
|
2318
|
+
def value
|
2319
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2320
|
+
:upper => up.value,
|
2321
|
+
:lower_included => true,
|
2322
|
+
:upper_included => false)
|
2323
|
+
end
|
2324
|
+
}
|
2325
|
+
/ SYM_INTERVAL_DELIM lo:real_value SYM_ELLIPSIS up:real_value SYM_INTERVAL_DELIM {
|
2326
|
+
def value
|
2327
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2328
|
+
:upper => up.value,
|
2329
|
+
:lower_included => true,
|
2330
|
+
:upper_included => true)
|
2331
|
+
end
|
2332
|
+
}
|
2333
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:real_value SYM_INTERVAL_DELIM {
|
2334
|
+
def value
|
2335
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2336
|
+
:upper => up.value,
|
2337
|
+
:lower_unbounded => true,
|
2338
|
+
:upper_included => false)
|
2339
|
+
end
|
2340
|
+
}
|
2341
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:real_value SYM_INTERVAL_DELIM {
|
2342
|
+
def value
|
2343
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2344
|
+
:upper => up.value,
|
2345
|
+
:lower_unbounded => true,
|
2346
|
+
:upper_included => true)
|
2347
|
+
end
|
2348
|
+
}
|
2349
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:real_value SYM_INTERVAL_DELIM {
|
2350
|
+
def value
|
2351
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2352
|
+
:lower => lo.value,
|
2353
|
+
:uppper_unbounded => true,
|
2354
|
+
:lower_included => false)
|
2355
|
+
end
|
2356
|
+
}
|
2357
|
+
/ SYM_INTERVAL_DELIM SYM_GE lo:real_value SYM_INTERVAL_DELIM {
|
2358
|
+
def value
|
2359
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2360
|
+
:lower => lo.value,
|
2361
|
+
:upper_unbounded => true,
|
2362
|
+
:lower_included => true)
|
2363
|
+
end
|
2364
|
+
}
|
2365
|
+
/ SYM_INTERVAL_DELIM val:real_value SYM_INTERVAL_DELIM {
|
2366
|
+
def value
|
2367
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2368
|
+
:lower => val.value,
|
2369
|
+
:upper => val.value,
|
2370
|
+
:upper_included => true,
|
2371
|
+
:lower_included => true)
|
2372
|
+
end
|
2373
|
+
}
|
2374
|
+
end
|
2375
|
+
|
2376
|
+
rule character_value
|
2377
|
+
V_CHAR '' {
|
2378
|
+
def value
|
2379
|
+
text_value
|
2380
|
+
end
|
2381
|
+
}
|
2382
|
+
end
|
2383
|
+
|
2384
|
+
rule character_list_value
|
2385
|
+
character_value (',' white_space more_chars:(character_value))+ {
|
2386
|
+
def value
|
2387
|
+
characters.map {|c| c.value }
|
2388
|
+
end
|
2389
|
+
|
2390
|
+
def characters
|
2391
|
+
[character_value] + more_chars.elements.map {|c| c.character_value}
|
2392
|
+
end
|
2393
|
+
}
|
2394
|
+
/ character_value ',' SYM_LIST_CONTINUE {
|
2395
|
+
def value
|
2396
|
+
[character_value.value]
|
2397
|
+
end
|
2398
|
+
}
|
2399
|
+
end
|
2400
|
+
|
2401
|
+
rule string_value
|
2402
|
+
str:V_STRING '' {
|
2403
|
+
def value
|
2404
|
+
str.value
|
2405
|
+
end
|
2406
|
+
}
|
2407
|
+
end
|
2408
|
+
|
2409
|
+
rule string_list_value
|
2410
|
+
first:string_value second:(',' white_space string_value)+ {
|
2411
|
+
def value
|
2412
|
+
strings.map {|s| s.value}
|
2413
|
+
end
|
2414
|
+
|
2415
|
+
def strings
|
2416
|
+
[first] + second.elements.map {|s| s.string_value}
|
2417
|
+
end
|
2418
|
+
}
|
2419
|
+
/ str:V_STRING ',' white_space SYM_LIST_CONTINUE {
|
2420
|
+
def value
|
2421
|
+
[str.value]
|
2422
|
+
end
|
2423
|
+
}
|
2424
|
+
end
|
2425
|
+
|
2426
|
+
rule date_value
|
2427
|
+
ed:V_ISO8601_EXTENDED_DATE '' {
|
2428
|
+
def value
|
2429
|
+
::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDate.new(
|
2430
|
+
:value => ed.text_value)
|
2431
|
+
end
|
2432
|
+
}
|
2433
|
+
end
|
2434
|
+
|
2435
|
+
rule date_list_value
|
2436
|
+
date_value more_dates:(',' white_space date_value)+ {
|
2437
|
+
def value
|
2438
|
+
dates.map {|d| d.value}
|
2439
|
+
end
|
2440
|
+
|
2441
|
+
def dates
|
2442
|
+
[date_value] + more_dates.elements.map {|d| d.date_value}
|
2443
|
+
end
|
2444
|
+
}
|
2445
|
+
/ date_value ',' white_space SYM_LIST_CONTINUE {
|
2446
|
+
def value
|
2447
|
+
[date_value.value]
|
2448
|
+
end
|
2449
|
+
}
|
2450
|
+
end
|
2451
|
+
|
2452
|
+
rule date_interval_value
|
2453
|
+
SYM_INTERVAL_DELIM SYM_GT lo:date_value SYM_ELLIPSIS SYM_LT up:date_value SYM_INTERVAL_DELIM {
|
2454
|
+
def value
|
2455
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2456
|
+
:upper => up.value,
|
2457
|
+
:lower_included => false,
|
2458
|
+
:upper_included => false)
|
2459
|
+
end
|
2460
|
+
}
|
2461
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:date_value SYM_ELLIPSIS up:date_value SYM_INTERVAL_DELIM {
|
2462
|
+
def value
|
2463
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2464
|
+
:upper => up.value,
|
2465
|
+
:lower_included => false,
|
2466
|
+
:upper_included => true)
|
2467
|
+
end
|
2468
|
+
}
|
2469
|
+
/ SYM_INTERVAL_DELIM lo:date_value SYM_ELLIPSIS SYM_LT up:date_value SYM_INTERVAL_DELIM {
|
2470
|
+
def value
|
2471
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2472
|
+
:upper => up.value,
|
2473
|
+
:lower_included => true,
|
2474
|
+
:upper_included => false)
|
2475
|
+
end
|
2476
|
+
}
|
2477
|
+
/ SYM_INTERVAL_DELIM lo:date_value SYM_ELLIPSIS up:date_value SYM_INTERVAL_DELIM {
|
2478
|
+
def value
|
2479
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2480
|
+
:upper => up.value,
|
2481
|
+
:lower_included => true,
|
2482
|
+
:upper_included => true)
|
2483
|
+
end
|
2484
|
+
}
|
2485
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:date_value SYM_INTERVAL_DELIM {
|
2486
|
+
def value
|
2487
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2488
|
+
:upper => up.value,
|
2489
|
+
:lower_unbounded => true,
|
2490
|
+
:upper_included => false)
|
2491
|
+
end
|
2492
|
+
}
|
2493
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:date_value SYM_INTERVAL_DELIM {
|
2494
|
+
def value
|
2495
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2496
|
+
:upper => up.value,
|
2497
|
+
:lower_unbounded => true,
|
2498
|
+
:upper_included => true)
|
2499
|
+
end
|
2500
|
+
}
|
2501
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:date_value SYM_INTERVAL_DELIM {
|
2502
|
+
def value
|
2503
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2504
|
+
:lower => lo.value,
|
2505
|
+
:uppper_unbounded => true,
|
2506
|
+
:lower_included => false)
|
2507
|
+
end
|
2508
|
+
}
|
2509
|
+
/ SYM_INTERVAL_DELIM SYM_GE val:date_value SYM_INTERVAL_DELIM {
|
2510
|
+
def value
|
2511
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2512
|
+
:lower => val.value,
|
2513
|
+
:upper_unbounded => true,
|
2514
|
+
:lower_included => true)
|
2515
|
+
end
|
2516
|
+
}
|
2517
|
+
/ SYM_INTERVAL_DELIM val:date_value SYM_INTERVAL_DELIM {
|
2518
|
+
def value
|
2519
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2520
|
+
:lower => val.value,
|
2521
|
+
:upper => val.value,
|
2522
|
+
:upper_included => true,
|
2523
|
+
:lower_included => true)
|
2524
|
+
end
|
2525
|
+
}
|
2526
|
+
end
|
2527
|
+
|
2528
|
+
rule time_value
|
2529
|
+
ti:V_ISO8601_EXTENDED_TIME '' {
|
2530
|
+
def value
|
2531
|
+
::OpenEHR::RM::DataTypes::Quantity::DateTime::DvTime.new(
|
2532
|
+
:value => ti.text_value)
|
2533
|
+
end
|
2534
|
+
}
|
2535
|
+
end
|
2536
|
+
|
2537
|
+
rule time_list_value
|
2538
|
+
time_value more_t:(',' white_space time_value)+ {
|
2539
|
+
def value
|
2540
|
+
times.map {|t| t.value}
|
2541
|
+
end
|
2542
|
+
|
2543
|
+
def times
|
2544
|
+
[time_value] + more_t.elements.map {|t| t.time_value}
|
2545
|
+
end
|
2546
|
+
}
|
2547
|
+
/ time_value ',' white_space SYM_LIST_CONTINUE {
|
2548
|
+
def value
|
2549
|
+
[time_value.value]
|
2550
|
+
end
|
2551
|
+
}
|
2552
|
+
end
|
2553
|
+
|
2554
|
+
rule time_interval_value
|
2555
|
+
SYM_INTERVAL_DELIM SYM_GT lo:time_value SYM_ELLIPSIS SYM_LT up:time_value SYM_INTERVAL_DELIM {
|
2556
|
+
def value
|
2557
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2558
|
+
:upper => up.value,
|
2559
|
+
:lower_included => false,
|
2560
|
+
:upper_included => false)
|
2561
|
+
end
|
2562
|
+
}
|
2563
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:time_value SYM_ELLIPSIS up:time_value SYM_INTERVAL_DELIM {
|
2564
|
+
def value
|
2565
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2566
|
+
:upper => up.value,
|
2567
|
+
:lower_included => false,
|
2568
|
+
:upper_included => true)
|
2569
|
+
end
|
2570
|
+
}
|
2571
|
+
/ SYM_INTERVAL_DELIM lo:time_value SYM_ELLIPSIS SYM_LT up:time_value SYM_INTERVAL_DELIM {
|
2572
|
+
def value
|
2573
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2574
|
+
:upper => up.value,
|
2575
|
+
:lower_included => true,
|
2576
|
+
:upper_included => false)
|
2577
|
+
end
|
2578
|
+
}
|
2579
|
+
/ SYM_INTERVAL_DELIM lo:time_value SYM_ELLIPSIS up:time_value SYM_INTERVAL_DELIM {
|
2580
|
+
def value
|
2581
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2582
|
+
:upper => up.value,
|
2583
|
+
:lower_included => true,
|
2584
|
+
:upper_included => true)
|
2585
|
+
end
|
2586
|
+
}
|
2587
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:time_value SYM_INTERVAL_DELIM {
|
2588
|
+
def value
|
2589
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2590
|
+
:upper => up.value,
|
2591
|
+
:lower_unbounded => true,
|
2592
|
+
:upper_included => false)
|
2593
|
+
end
|
2594
|
+
}
|
2595
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:time_value SYM_INTERVAL_DELIM {
|
2596
|
+
def value
|
2597
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2598
|
+
:upper => up.value,
|
2599
|
+
:lower_unbounded => true,
|
2600
|
+
:upper_included => true)
|
2601
|
+
end
|
2602
|
+
}
|
2603
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:time_value SYM_INTERVAL_DELIM {
|
2604
|
+
def value
|
2605
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2606
|
+
:lower => lo.value,
|
2607
|
+
:uppper_unbounded => true,
|
2608
|
+
:lower_included => false)
|
2609
|
+
end
|
2610
|
+
}
|
2611
|
+
/ SYM_INTERVAL_DELIM SYM_GE tv:time_value SYM_INTERVAL_DELIM {
|
2612
|
+
def value
|
2613
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2614
|
+
:lower => tv.value,
|
2615
|
+
:upper_unbounded => true,
|
2616
|
+
:lower_included => true)
|
2617
|
+
end
|
2618
|
+
}
|
2619
|
+
/ SYM_INTERVAL_DELIM val:time_value SYM_INTERVAL_DELIM {
|
2620
|
+
def value
|
2621
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2622
|
+
:lower => val.value,
|
2623
|
+
:upper => val.value,
|
2624
|
+
:upper_included => true,
|
2625
|
+
:lower_included => true)
|
2626
|
+
end
|
2627
|
+
}
|
2628
|
+
end
|
2629
|
+
|
2630
|
+
rule date_time_value
|
2631
|
+
dt:V_ISO8601_EXTENDED_DATE_TIME '' {
|
2632
|
+
def value
|
2633
|
+
::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDateTime.new(
|
2634
|
+
:value => dt.text_value)
|
2635
|
+
end
|
2636
|
+
}
|
2637
|
+
end
|
2638
|
+
|
2639
|
+
rule date_time_list_value
|
2640
|
+
date_time_value (',' more_dt:date_time_value)+ {
|
2641
|
+
def value
|
2642
|
+
date_times.map {|t| t.value}
|
2643
|
+
end
|
2644
|
+
|
2645
|
+
def date_times
|
2646
|
+
[date_time_value] + more_dt.elements.map {|dt| dt.date_time_value}
|
2647
|
+
end
|
2648
|
+
}
|
2649
|
+
/ date_time_value ',' SYM_LIST_CONTINUE {
|
2650
|
+
def value
|
2651
|
+
[date_time_value.value]
|
2652
|
+
end
|
2653
|
+
}
|
2654
|
+
end
|
2655
|
+
|
2656
|
+
rule date_time_interval_value
|
2657
|
+
SYM_INTERVAL_DELIM SYM_GT lo:date_time_value SYM_ELLIPSIS SYM_LT up:date_time_value SYM_INTERVAL_DELIM {
|
2658
|
+
def value
|
2659
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2660
|
+
:upper => up.value,
|
2661
|
+
:lower_included => false,
|
2662
|
+
:upper_included => false)
|
2663
|
+
end
|
2664
|
+
}
|
2665
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:date_time_value SYM_ELLIPSIS up:date_time_value SYM_INTERVAL_DELIM {
|
2666
|
+
def value
|
2667
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2668
|
+
:upper => up.value,
|
2669
|
+
:lower_included => false,
|
2670
|
+
:upper_included => true)
|
2671
|
+
end
|
2672
|
+
}
|
2673
|
+
/ SYM_INTERVAL_DELIM lo:date_time_value SYM_ELLIPSIS SYM_LT up:date_time_value SYM_INTERVAL_DELIM {
|
2674
|
+
def value
|
2675
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2676
|
+
:upper => up.value,
|
2677
|
+
:lower_included => true,
|
2678
|
+
:upper_included => false)
|
2679
|
+
end
|
2680
|
+
}
|
2681
|
+
/ SYM_INTERVAL_DELIM lo:date_time_value SYM_ELLIPSIS up:date_time_value SYM_INTERVAL_DELIM {
|
2682
|
+
def value
|
2683
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2684
|
+
:upper => up.value,
|
2685
|
+
:lower_included => true,
|
2686
|
+
:upper_included => true)
|
2687
|
+
end
|
2688
|
+
}
|
2689
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:date_time_value SYM_INTERVAL_DELIM {
|
2690
|
+
def value
|
2691
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2692
|
+
:upper => up.value,
|
2693
|
+
:lower_unbounded => true,
|
2694
|
+
:upper_included => false)
|
2695
|
+
end
|
2696
|
+
}
|
2697
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:date_time_value SYM_INTERVAL_DELIM {
|
2698
|
+
def value
|
2699
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2700
|
+
:upper => up.value,
|
2701
|
+
:lower_unbounded => true,
|
2702
|
+
:upper_included => true)
|
2703
|
+
end
|
2704
|
+
}
|
2705
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:date_time_value SYM_INTERVAL_DELIM {
|
2706
|
+
def value
|
2707
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2708
|
+
:lower => lo.value,
|
2709
|
+
:uppper_unbounded => true,
|
2710
|
+
:lower_included => false)
|
2711
|
+
end
|
2712
|
+
}
|
2713
|
+
/ SYM_INTERVAL_DELIM SYM_GE dt:date_time_value SYM_INTERVAL_DELIM {
|
2714
|
+
def value
|
2715
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2716
|
+
:lower => dt.value,
|
2717
|
+
:upper_unbounded => true,
|
2718
|
+
:lower_included => true)
|
2719
|
+
end
|
2720
|
+
}
|
2721
|
+
/ SYM_INTERVAL_DELIM val:date_time_value SYM_INTERVAL_DELIM {
|
2722
|
+
def value
|
2723
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2724
|
+
:lower => val.value,
|
2725
|
+
:upper => val.value,
|
2726
|
+
:upper_included => true,
|
2727
|
+
:lower_included => true)
|
2728
|
+
end
|
2729
|
+
}
|
2730
|
+
end
|
2731
|
+
|
2732
|
+
rule duration_value
|
2733
|
+
du:V_ISO8601_DURATION '' {
|
2734
|
+
def value
|
2735
|
+
::OpenEHR::RM::DataTypes::Quantity::DateTime::DvDuration.new(
|
2736
|
+
:value => du.text_value)
|
2737
|
+
end
|
2738
|
+
}
|
2739
|
+
end
|
2740
|
+
|
2741
|
+
rule duration_list_value
|
2742
|
+
duration_value more_d:(',' duration_value)+ {
|
2743
|
+
def value
|
2744
|
+
durations.map {|d| d.value}
|
2745
|
+
end
|
2746
|
+
|
2747
|
+
def durations
|
2748
|
+
[duration_value] + more_d.elements.map {|d| d.duration_value}
|
2749
|
+
end
|
2750
|
+
}
|
2751
|
+
/ duration_value ',' SYM_LIST_CONTINUE {
|
2752
|
+
def value
|
2753
|
+
[duration_value.value]
|
2754
|
+
end
|
2755
|
+
}
|
2756
|
+
end
|
2757
|
+
|
2758
|
+
rule duration_interval_value
|
2759
|
+
SYM_INTERVAL_DELIM SYM_GT lo:duration_value SYM_ELLIPSIS SYM_LT up:duration_value SYM_INTERVAL_DELIM {
|
2760
|
+
def value
|
2761
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2762
|
+
:upper => up.value,
|
2763
|
+
:lower_included => false,
|
2764
|
+
:upper_included => false)
|
2765
|
+
end
|
2766
|
+
}
|
2767
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:duration_value SYM_ELLIPSIS up:duration_value SYM_INTERVAL_DELIM {
|
2768
|
+
def value
|
2769
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2770
|
+
:upper => up.value,
|
2771
|
+
:lower_included => false,
|
2772
|
+
:upper_included => true)
|
2773
|
+
end
|
2774
|
+
}
|
2775
|
+
/ SYM_INTERVAL_DELIM lo:duration_value SYM_ELLIPSIS SYM_LT up:duration_value SYM_INTERVAL_DELIM {
|
2776
|
+
def value
|
2777
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2778
|
+
:upper => up.value,
|
2779
|
+
:lower_included => true,
|
2780
|
+
:upper_included => false)
|
2781
|
+
end
|
2782
|
+
}
|
2783
|
+
/ SYM_INTERVAL_DELIM lo:duration_value SYM_ELLIPSIS up:duration_value SYM_INTERVAL_DELIM {
|
2784
|
+
def value
|
2785
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value,
|
2786
|
+
:upper => up.value,
|
2787
|
+
:lower_included => true,
|
2788
|
+
:upper_included => true)
|
2789
|
+
end
|
2790
|
+
}
|
2791
|
+
/ SYM_INTERVAL_DELIM SYM_LT up:duration_value SYM_INTERVAL_DELIM {
|
2792
|
+
def value
|
2793
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2794
|
+
:upper => up.value,
|
2795
|
+
:lower_unbounded => true,
|
2796
|
+
:upper_included => false)
|
2797
|
+
end
|
2798
|
+
}
|
2799
|
+
/ SYM_INTERVAL_DELIM SYM_LE up:duration_value SYM_INTERVAL_DELIM {
|
2800
|
+
def value
|
2801
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2802
|
+
:upper => up.value,
|
2803
|
+
:lower_unbounded => true,
|
2804
|
+
:upper_included => true)
|
2805
|
+
end
|
2806
|
+
}
|
2807
|
+
/ SYM_INTERVAL_DELIM SYM_GT lo:duration_value SYM_INTERVAL_DELIM {
|
2808
|
+
def value
|
2809
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2810
|
+
:lower => lo.value,
|
2811
|
+
:uppper_unbounded => true,
|
2812
|
+
:lower_included => false)
|
2813
|
+
end
|
2814
|
+
}
|
2815
|
+
/ SYM_INTERVAL_DELIM SYM_GE val:duration_value SYM_INTERVAL_DELIM {
|
2816
|
+
def value
|
2817
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2818
|
+
:lower => val.value,
|
2819
|
+
:upper_unbounded => true,
|
2820
|
+
:lower_included => true)
|
2821
|
+
end
|
2822
|
+
}
|
2823
|
+
/ SYM_INTERVAL_DELIM val:duration_value SYM_INTERVAL_DELIM {
|
2824
|
+
def value
|
2825
|
+
OpenEHR::AssumedLibraryTypes::Interval.new(
|
2826
|
+
:upper => val.value,
|
2827
|
+
:lower => val.value,
|
2828
|
+
:upper_included => true,
|
2829
|
+
:lower_included => true)
|
2830
|
+
end
|
2831
|
+
}
|
2832
|
+
end
|
2833
|
+
|
2834
|
+
rule ALPHANUM
|
2835
|
+
[a-zA-Z0-9]
|
2836
|
+
end
|
2837
|
+
|
2838
|
+
rule IDCHAR
|
2839
|
+
[a-zA-Z0-9_]
|
2840
|
+
end
|
2841
|
+
|
2842
|
+
rule NAMECHAR
|
2843
|
+
[a-zA-Z0-9\._\-]
|
2844
|
+
end
|
2845
|
+
|
2846
|
+
rule NAMECHAR_SPACE
|
2847
|
+
[a-zA-Z0-9\._\- ]
|
2848
|
+
end
|
2849
|
+
|
2850
|
+
rule NAMECHAR_PAREN
|
2851
|
+
[a-zA-Z0-9\._\-\(\)]
|
2852
|
+
end
|
2853
|
+
|
2854
|
+
rule NAMESTR
|
2855
|
+
[a-zA-Z] [a-zA-Z0-9_]+
|
2856
|
+
end
|
2857
|
+
|
2858
|
+
rule space
|
2859
|
+
COMMENT* white_space
|
2860
|
+
end
|
2861
|
+
|
2862
|
+
rule COMMENT
|
2863
|
+
white_space '--' [^\n]* "\n"
|
2864
|
+
end
|
2865
|
+
|
2866
|
+
rule white_space
|
2867
|
+
[ \t\r\n]*
|
2868
|
+
end
|
2869
|
+
|
2870
|
+
rule Minus_code
|
2871
|
+
'-'
|
2872
|
+
end
|
2873
|
+
|
2874
|
+
rule Plus_Code
|
2875
|
+
'+'
|
2876
|
+
end
|
2877
|
+
|
2878
|
+
rule Star_code
|
2879
|
+
'*'
|
2880
|
+
end
|
2881
|
+
|
2882
|
+
rule Slash_code
|
2883
|
+
'/'
|
2884
|
+
end
|
2885
|
+
|
2886
|
+
rule Carret_code
|
2887
|
+
'^'
|
2888
|
+
end
|
2889
|
+
|
2890
|
+
rule Dot_code
|
2891
|
+
'.'
|
2892
|
+
end
|
2893
|
+
|
2894
|
+
rule Semicolon_code
|
2895
|
+
';'
|
2896
|
+
end
|
2897
|
+
|
2898
|
+
rule Colon_code
|
2899
|
+
':'
|
2900
|
+
end
|
2901
|
+
|
2902
|
+
rule Comma_code
|
2903
|
+
','
|
2904
|
+
end
|
2905
|
+
|
2906
|
+
rule Expclamation_code
|
2907
|
+
'!'
|
2908
|
+
end
|
2909
|
+
|
2910
|
+
rule Left_parenthesis_code
|
2911
|
+
'('
|
2912
|
+
end
|
2913
|
+
|
2914
|
+
rule Right_parenthesis_code
|
2915
|
+
')'
|
2916
|
+
end
|
2917
|
+
|
2918
|
+
rule Dollar_code
|
2919
|
+
'$'
|
2920
|
+
end
|
2921
|
+
|
2922
|
+
rule SYM_DT_UNKNOWN
|
2923
|
+
'??'
|
2924
|
+
end
|
2925
|
+
|
2926
|
+
rule Question_mark_code
|
2927
|
+
'?'
|
2928
|
+
end
|
2929
|
+
|
2930
|
+
rule SYM_INTERVAL_DELIM
|
2931
|
+
'|'
|
2932
|
+
end
|
2933
|
+
|
2934
|
+
rule Left_bracket_code
|
2935
|
+
'[' space
|
2936
|
+
end
|
2937
|
+
|
2938
|
+
rule Right_bracket_codde
|
2939
|
+
']'
|
2940
|
+
end
|
2941
|
+
|
2942
|
+
rule SYM_EQ
|
2943
|
+
'=' white_space
|
2944
|
+
end
|
2945
|
+
|
2946
|
+
rule SYM_GE
|
2947
|
+
('=>' / '>=') white_space
|
2948
|
+
end
|
2949
|
+
|
2950
|
+
rule SYM_LE
|
2951
|
+
('<=' / '=>') white_space
|
2952
|
+
end
|
2953
|
+
|
2954
|
+
rule SYM_LT
|
2955
|
+
'<' white_space
|
2956
|
+
end
|
2957
|
+
|
2958
|
+
rule SYM_GT
|
2959
|
+
'>' white_space
|
2960
|
+
end
|
2961
|
+
|
2962
|
+
rule SYM_START_DBLOCK
|
2963
|
+
'<' space
|
2964
|
+
end
|
2965
|
+
|
2966
|
+
rule SYM_END_DBLOCK
|
2967
|
+
'>' space
|
2968
|
+
end
|
2969
|
+
|
2970
|
+
rule SYM_START_CBLOCK
|
2971
|
+
'{' space
|
2972
|
+
end
|
2973
|
+
|
2974
|
+
rule SYM_END_CBLOCK
|
2975
|
+
'}'
|
2976
|
+
end
|
2977
|
+
|
2978
|
+
rule SYM_ELLIPSIS
|
2979
|
+
'..'
|
2980
|
+
end
|
2981
|
+
|
2982
|
+
rule SYM_LIST_CONTINUE
|
2983
|
+
'...'
|
2984
|
+
end
|
2985
|
+
|
2986
|
+
rule SYM_INFINITY
|
2987
|
+
[Ii] [Nn] [Ff] [Ii] [Nn] [Ii] [Tt] [Yy] space
|
2988
|
+
end
|
2989
|
+
|
2990
|
+
rule SYM_ARCHETYPE
|
2991
|
+
[Aa] [Rr] [Cc] [Hh] [Ee] [Tt] [Yy] [Pp] [Ee] space
|
2992
|
+
end
|
2993
|
+
|
2994
|
+
rule SYM_MATCHES
|
2995
|
+
([Mm] [Aa] [Tt] [Cc] [Hh] [Ee] [Ss] / [Ii] [Ss] '_' [Ii] [Nn]) white_space
|
2996
|
+
end
|
2997
|
+
|
2998
|
+
rule SYM_THEN
|
2999
|
+
[Tt] [Hh] [Ee] [Nn] space
|
3000
|
+
end
|
3001
|
+
|
3002
|
+
rule SYM_ELSE
|
3003
|
+
[Ee] [Ll] [Ss] [Ee] space
|
3004
|
+
end
|
3005
|
+
|
3006
|
+
rule SYM_AND
|
3007
|
+
[Aa] [Nn] [Dd] space
|
3008
|
+
end
|
3009
|
+
|
3010
|
+
rule SYM_OR
|
3011
|
+
[Oo] [Rr] space
|
3012
|
+
end
|
3013
|
+
|
3014
|
+
rule SYM_XOR
|
3015
|
+
[Xx] [Oo] [Rr] space
|
3016
|
+
end
|
3017
|
+
|
3018
|
+
rule SYM_NOT
|
3019
|
+
[Nn] [Oo] [Tt] space
|
3020
|
+
end
|
3021
|
+
|
3022
|
+
rule SYM_IMPLIES
|
3023
|
+
[Ii] [Mm] [Pp] [Ll] [Ii] [Ee] [Ss] space
|
3024
|
+
end
|
3025
|
+
|
3026
|
+
rule SYM_TRUE
|
3027
|
+
[Tt] [Rr] [Uu] [Ee] space
|
3028
|
+
end
|
3029
|
+
|
3030
|
+
rule SYM_FALSE
|
3031
|
+
[Ff] [Aa] [Ll] [Ss] [Ee] space
|
3032
|
+
end
|
3033
|
+
|
3034
|
+
rule SYM_FORALL
|
3035
|
+
[Ff] [Oo] [Rr] '_' [Aa] [Ll] [Ll] space
|
3036
|
+
end
|
3037
|
+
|
3038
|
+
rule SYM_EXISTS
|
3039
|
+
[Ee] [Xx] [Ii] [Ss] [Tt] [Ss] space
|
3040
|
+
end
|
3041
|
+
|
3042
|
+
rule SYM_EXISTENCE
|
3043
|
+
[Ee] [Xx] [Ii] [Ss] [Tt] [Ee] [Nn] [Cc] [Ee] space
|
3044
|
+
end
|
3045
|
+
|
3046
|
+
rule SYM_OCCURRENCES
|
3047
|
+
[Oo] [Cc] [Cc] [Uu] [Rr] [Rr] [Ee] [Nn] [Cc] [Ee] [Ss] white_space
|
3048
|
+
end
|
3049
|
+
|
3050
|
+
rule SYM_CARDINALITY
|
3051
|
+
[Cc] [Aa] [Rr] [Dd] [Ii] [Nn] [Aa] [Ll] [Ii] [Tt] [Yy] white_space
|
3052
|
+
end
|
3053
|
+
|
3054
|
+
rule SYM_ORDERED
|
3055
|
+
[Oo] [Rr] [Dd] [Ee] [Rr] [Ee] [Dd] white_space
|
3056
|
+
end
|
3057
|
+
|
3058
|
+
rule SYM_UNORDERD
|
3059
|
+
[Uu] [Nn] [Oo] [Rr] [Dd] [Ee] [Rr] [Ee] [Dd] white_space
|
3060
|
+
end
|
3061
|
+
|
3062
|
+
rule SYM_UNIQUE
|
3063
|
+
[Uu] [Nn] [Ii] [Qq] [Uu] [Ee] space
|
3064
|
+
end
|
3065
|
+
|
3066
|
+
rule SYM_INFINITY
|
3067
|
+
[Ii] [Nn] [Ff] [Ii] [Nn] [Ii] [Tt] [Yy] space
|
3068
|
+
end
|
3069
|
+
|
3070
|
+
rule SYM_USE_NODE
|
3071
|
+
[Uu] [Ss] [Ee] '_' [Nn] [Oo] [Dd] [Ee] space
|
3072
|
+
end
|
3073
|
+
|
3074
|
+
rule SYM_ALLOW_ARCHETYPE
|
3075
|
+
([Aa] [Ll] [Ll] [Oo] [Ww] / [Uu] [Ss] [Ee]) '_' [Aa] [Rr] [Cc] [Hh] [Ee] [Tt] [Yy] [Pp] [Ee] space
|
3076
|
+
end
|
3077
|
+
|
3078
|
+
rule SYM_INCLUDE
|
3079
|
+
[Ii] [Nn] [Cc] [Ll] [Uu] [Dd] [Ee] space
|
3080
|
+
end
|
3081
|
+
|
3082
|
+
rule SYM_EXCLUDE
|
3083
|
+
[Ee] [Xx] [Cc] [Ll] [Uu] [Dd] [Ee] space
|
3084
|
+
end
|
3085
|
+
|
3086
|
+
rule SYM_TEMPLATE_COMPONENT
|
3087
|
+
[Tt] [Ee] [Mm] [Pp] [Ll] [Aa] [Tt] [Ee] ' _' [Cc] [Oo] [Mm] [Pp] [Oo] [Nn] [Ee] [Nn] [Tt] space
|
3088
|
+
end
|
3089
|
+
|
3090
|
+
rule SYM_TEMPLATE
|
3091
|
+
[Tt] [Ee] [Mm] [Pp] [Ll] [Aa] [Tt] [Ee] space
|
3092
|
+
end
|
3093
|
+
|
3094
|
+
rule SYM_OPERATIONAL_TEMPLATE
|
3095
|
+
[Oo] [Pp] [Ee] [Rr] [Aa] [Tt] [Ii] [Oo] [Nn] [Aa] [Ll] '_' [Tt] [Ee] [Mm] [Pp] [Ll] [Aa] [Tt] [Ee] space
|
3096
|
+
end
|
3097
|
+
|
3098
|
+
rule SYM_ADL_VERSION
|
3099
|
+
[Aa] [Dd] [Ll] '_' [Vv] [Ee] [Rr] [Ss] [Ii] [Oo] [Nn] space
|
3100
|
+
end
|
3101
|
+
|
3102
|
+
rule SYM_IS_CONTROLLED
|
3103
|
+
[Cc] [Oo] [Nn] [Tt] [Rr] [Oo] [Ll] [Ll] [Ee] [Dd] space
|
3104
|
+
end
|
3105
|
+
|
3106
|
+
rule SYM_IS_GENERATED
|
3107
|
+
[Gg] [Ee] [Nn] [Ee] [Rr] [Aa] [Tt] [Ee] [Dd] space
|
3108
|
+
end
|
3109
|
+
|
3110
|
+
rule SYM_SPECIALIZE
|
3111
|
+
[Ss] [Pp] [Ee] [Cc] [Ii] [Aa] [Ll] [Ii] [SsZz] [Ee] space
|
3112
|
+
end
|
3113
|
+
|
3114
|
+
rule SYM_CONCEPT
|
3115
|
+
[Cc] [Oo] [Nn] [Cc] [Ee] [Pp] [Tt] space
|
3116
|
+
end
|
3117
|
+
|
3118
|
+
rule SYM_LANGUAGE
|
3119
|
+
[Ll] [Aa] [Nn] [Gg] [Uu] [Aa] [Gg] [Ee] space
|
3120
|
+
end
|
3121
|
+
|
3122
|
+
rule SYM_DESCRIPTION
|
3123
|
+
[Dd] [Ee] [Ss] [Cc] [Rr] [Ii] [Pp] [Tt] [Ii] [Oo] [Nn] space
|
3124
|
+
end
|
3125
|
+
|
3126
|
+
rule SYM_DEFINITION
|
3127
|
+
[Dd] [Ee] [Ff] [Ii] [Nn] [Ii] [Tt] [Ii] [Oo] [Nn] space
|
3128
|
+
end
|
3129
|
+
|
3130
|
+
rule SYM_INVARIANT
|
3131
|
+
[Ii] [Nn] [Vv] [Aa] [Rr] [Ii] [Aa] [Nn] [Tt] space
|
3132
|
+
end
|
3133
|
+
|
3134
|
+
rule SYM_ONTOLOGY
|
3135
|
+
[Oo] [Nn] [Tt] [Oo] [Ll] [Oo] [Gg] [Yy] space
|
3136
|
+
end
|
3137
|
+
|
3138
|
+
rule SYM_ANNOTATIONS
|
3139
|
+
[Aa] [Nn] [Nn] [Oo] [Tt] [Aa] [Tt] [Ii] [Oo] [Nn] [Ss] space
|
3140
|
+
end
|
3141
|
+
|
3142
|
+
rule V_VERSION_STRING
|
3143
|
+
[0-9]+ '.' [0-9]+ ('.' [0-9]+)* {
|
3144
|
+
def value
|
3145
|
+
text_value
|
3146
|
+
end
|
3147
|
+
}
|
3148
|
+
end
|
3149
|
+
|
3150
|
+
rule V_ARCHETYPE_ID
|
3151
|
+
NAMESTR ('-' NAMESTR) 2..2 '.' NAMESTR ('-' NAMESTR)* '.v' [1-9] [0-9]* {
|
3152
|
+
def value
|
3153
|
+
text_value
|
3154
|
+
end
|
3155
|
+
}
|
3156
|
+
end
|
3157
|
+
|
3158
|
+
rule V_IDENTIFIER
|
3159
|
+
[a-zA-Z] [a-zA-Z0-9_]* {
|
3160
|
+
def value
|
3161
|
+
text_value
|
3162
|
+
end
|
3163
|
+
}
|
3164
|
+
end
|
3165
|
+
|
3166
|
+
rule V_URI
|
3167
|
+
[a-z]+ '://' [^<>|\\{}^~"\[\] ]* {
|
3168
|
+
def value
|
3169
|
+
text_value
|
3170
|
+
end
|
3171
|
+
}
|
3172
|
+
end
|
3173
|
+
|
3174
|
+
rule V_QUALIFIED_TERM_CODE_REF
|
3175
|
+
'[' ti:(NAMECHAR_PAREN+) '::' cs:(NAMECHAR+) ']' {
|
3176
|
+
def value
|
3177
|
+
term_id = OpenEHR::RM::Support::Identification::TerminologyID.new(
|
3178
|
+
:value => ti.text_value)
|
3179
|
+
OpenEHR::RM::DataTypes::Text::CodePhrase.new(
|
3180
|
+
:terminology_id => term_id, :code_string => cs.text_value)
|
3181
|
+
end
|
3182
|
+
}
|
3183
|
+
end
|
3184
|
+
|
3185
|
+
rule ERR_V_QUALIFIED_TERM_CODE_REF
|
3186
|
+
'[' er:(NAMECHAR_PAREN+ '::' NAMECHAR_SPACE+) ']' {
|
3187
|
+
def value
|
3188
|
+
er.text_value
|
3189
|
+
end
|
3190
|
+
}
|
3191
|
+
end
|
3192
|
+
|
3193
|
+
rule V_LOCAL_TERM_CODE_REF
|
3194
|
+
'[' lt:(ALPHANUM NAMECHAR*) ']' {
|
3195
|
+
def value
|
3196
|
+
lt.text_value
|
3197
|
+
end
|
3198
|
+
}
|
3199
|
+
end
|
3200
|
+
|
3201
|
+
rule V_LOCAL_CODE
|
3202
|
+
'a' [ct] [0-9\.]+ {
|
3203
|
+
def value
|
3204
|
+
text_value
|
3205
|
+
end
|
3206
|
+
}
|
3207
|
+
end
|
3208
|
+
|
3209
|
+
rule V_TERM_CODE
|
3210
|
+
'[' code:([a-zA-Z0-9()._\-]+) '::' white_space {
|
3211
|
+
def value
|
3212
|
+
::OpenEHR::RM::Support::Identification::TerminologyID.new(
|
3213
|
+
:value => code.text_value)
|
3214
|
+
end
|
3215
|
+
}
|
3216
|
+
end
|
3217
|
+
|
3218
|
+
rule V_ISO8601_EXTENDED_DATE_TIME
|
3219
|
+
([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)?)
|
3220
|
+
end
|
3221
|
+
|
3222
|
+
rule V_ISO8601_EXTENDED_TIME
|
3223
|
+
[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)?
|
3224
|
+
end
|
3225
|
+
|
3226
|
+
rule V_ISO8601_EXTENDED_DATE
|
3227
|
+
[0-9] 4..4 '-' [0-1] [0-9] '-' [0-3] [0-9] / [0-9] 4..4 '-' [0-1] [0-9]
|
3228
|
+
end
|
3229
|
+
|
3230
|
+
rule V_ISO8601_DURATION
|
3231
|
+
'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])?
|
3232
|
+
/ '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])?
|
3233
|
+
/ '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])?
|
3234
|
+
/ 'P' ([0-9]+ [yY]) ([0-9]+ [mM])? ([0-9]+ [wW])? ([0-9]+ [dD])?
|
3235
|
+
/ 'P' ([0-9]+ [yY])? ([0-9]+ [mM]) ([0-9]+ [wW])? ([0-9]+ [dD])?
|
3236
|
+
/ 'P' ([0-9]+ [yY])? ([0-9]+ [mM])? ([0-9]+ [wW]) ([0-9]+ [dD])?
|
3237
|
+
/ 'P' ([0-9]+ [yY])? ([0-9]+ [mM])? ([0-9]+ [wW])? ([0-9]+ [dD])
|
3238
|
+
end
|
3239
|
+
|
3240
|
+
rule V_ISO8601_DATE_CONSTRAINT_PATTERN
|
3241
|
+
[yY] [yY] [yY] [yY] '-' [mM?X] [mM?X] '-' [dD?X] [dD?X]
|
3242
|
+
end
|
3243
|
+
|
3244
|
+
rule V_ISO8601_TIME_CONSTRAINT_PATTERN
|
3245
|
+
[hH] [hH] ':' [mM?X] [mM?X] ':' [sS?X] [sS?X]
|
3246
|
+
end
|
3247
|
+
|
3248
|
+
rule V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN
|
3249
|
+
[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]
|
3250
|
+
end
|
3251
|
+
|
3252
|
+
rule V_ISO8601_DURATION_CONSTRAINT_PATTERN
|
3253
|
+
'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH] [mM]? [sS]?
|
3254
|
+
/ 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH]? [mM] [sS]?
|
3255
|
+
/ 'P' [yY]? [mM]? [wW]? [dD]? 'T' [hH]? [mM]? [sS]
|
3256
|
+
/ 'P' [yY] [mM]? [wW]? [dD]?
|
3257
|
+
/ 'P' [yY]? [mM] [wW]? [dD]?
|
3258
|
+
/ 'P' [yY]? [mM]? [wW] [dD]?
|
3259
|
+
/ 'P' [yY]? [mM]? [wW]? [dD]
|
3260
|
+
end
|
3261
|
+
|
3262
|
+
rule V_TYPE_IDENTIFIER
|
3263
|
+
[A-Z] IDCHAR* {
|
3264
|
+
def value
|
3265
|
+
text_value
|
3266
|
+
end
|
3267
|
+
}
|
3268
|
+
end
|
3269
|
+
|
3270
|
+
rule V_GENERIC_TYPE_IDENTIFIER
|
3271
|
+
[A-Z] IDCHAR* '<' [a-zA-Z0-9,_]+ '>' { # <>
|
3272
|
+
def value
|
3273
|
+
text_value
|
3274
|
+
end
|
3275
|
+
}
|
3276
|
+
end
|
3277
|
+
|
3278
|
+
rule V_ATTRIBUTE_IDENTIFIER
|
3279
|
+
[a-z] IDCHAR* {
|
3280
|
+
def value
|
3281
|
+
text_value
|
3282
|
+
end
|
3283
|
+
}
|
3284
|
+
end
|
3285
|
+
|
3286
|
+
rule V_INTEGER
|
3287
|
+
[0-9]+ [eE] [+-]? [0-9] {
|
3288
|
+
def value
|
3289
|
+
text_value.to_i
|
3290
|
+
end
|
3291
|
+
}
|
3292
|
+
/ [1-9] [0-9]+ {
|
3293
|
+
def value
|
3294
|
+
text_value.to_i
|
3295
|
+
end
|
3296
|
+
}
|
3297
|
+
/ [0-9] {
|
3298
|
+
def value
|
3299
|
+
text_value.to_i
|
3300
|
+
end
|
3301
|
+
}
|
3302
|
+
end
|
3303
|
+
|
3304
|
+
rule V_REAL
|
3305
|
+
[0-9]+ '.' [0-9]+ [eE] [+-]? [0-9]+ / [1-9] [0-9]+ '.' [0-9]+ / [0-9] '.' [0-9]+ {
|
3306
|
+
def value
|
3307
|
+
text_value.to_f
|
3308
|
+
end
|
3309
|
+
}
|
3310
|
+
end
|
3311
|
+
|
3312
|
+
rule V_CHAR
|
3313
|
+
[^\\\n\"] {
|
3314
|
+
def value
|
3315
|
+
text_value
|
3316
|
+
end
|
3317
|
+
}
|
3318
|
+
end
|
3319
|
+
|
3320
|
+
rule V_STRING
|
3321
|
+
'"' str:(('\"' / !'"' .)*) '"' {
|
3322
|
+
def value
|
3323
|
+
str.text_value.tr_s('\\\\', '\\')
|
3324
|
+
end
|
3325
|
+
}
|
3326
|
+
end # of Shared Token section
|
243
3327
|
end # of ADLGrammar
|
244
3328
|
end # of Parser
|
245
3329
|
end # of openEHR
|