us_core_test_kit 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5065cd644a0b1a71df633c16670902c3f652888ba813dc89791c9f2812530a68
4
- data.tar.gz: '04139c5a765c360de1e4a8eef004265fc1efb6695f9f175284773b3fcb188166'
3
+ metadata.gz: cf7aef28c22652157e161c0577936f83368ed966e95d313d43a96c3aae618a3f
4
+ data.tar.gz: d44b31b58c97c38e9d80462a47dbc2baa50e2e6cdc2e98ed4cb244a375c381bf
5
5
  SHA512:
6
- metadata.gz: 5f6df18ebaa802e0237f0eb0980a82618ec49714e36b6148abf82a619969ed4b92cc1191e5c7907d5551f1f2c9f24d2ab17d1586a20f478adb01db1ee5a31e6f
7
- data.tar.gz: 727a50e4891774a0e0d9773e698d8aa26db367de651465ac4562812c0e10a11540a3325b19cdd1d20fee4aab47a357607115676cb596ac64a50778643287d16b
6
+ metadata.gz: 6b87c6b6d5be087b6d28837ea02581ec2fc53bef7301e858db3b7e9e7538e8db93a54416a916ec8e8077c9cdcc5313880a63353d633d5e0039306e7c93c28758
7
+ data.tar.gz: 348461765954b1564b1e44bbac4c149de5740c18c13edb920a79cc1ddf00a5a6279fab8f0ee01732b9caf1bd1a4a54bb7a17f471a2abc3325ac96410e6691cf5
@@ -36,7 +36,7 @@ module USCoreTestKit
36
36
  range
37
37
  end
38
38
 
39
- def fhir_date_comparer(search_range, target_range, comparator)
39
+ def fhir_date_comparer(search_range, target_range, comparator, extend_start = false, extend_end = false)
40
40
  # Implicitly, a missing lower boundary is "less than" any actual date. A missing upper boundary is "greater than" any actual date.
41
41
  case comparator
42
42
  when 'eq' # the range of the search value fully contains the range of the target value
@@ -44,13 +44,13 @@ module USCoreTestKit
44
44
  when 'ne' # the range of the search value does not fully contain the range of the target value
45
45
  target_range[:start].nil? || target_range[:end].nil? || search_range[:start] > target_range[:start] || search_range[:end] < target_range[:end]
46
46
  when 'gt' # the range above the search value intersects (i.e. overlaps) with the range of the target value
47
- target_range[:end].nil? || search_range[:end] < target_range[:end]
47
+ target_range[:end].nil? || search_range[:end] < target_range[:end] || (search_range[:end] < (target_range[:end] + 1) && extend_end)
48
48
  when 'lt' # the range below the search value intersects (i.e. overlaps) with the range of the target value
49
- target_range[:start].nil? || search_range[:start] > target_range[:start]
49
+ target_range[:start].nil? || search_range[:start] > target_range[:start] || (search_range[:start] > (target_range[:start] - 1) && extend_start)
50
50
  when 'ge'
51
- fhir_date_comparer(search_range, target_range, 'gt') || fhir_date_comparer(search_range, target_range, 'eq')
51
+ fhir_date_comparer(search_range, target_range, 'gt', extend_start, extend_end) || fhir_date_comparer(search_range, target_range, 'eq')
52
52
  when 'le'
53
- fhir_date_comparer(search_range, target_range, 'lt') || fhir_date_comparer(search_range, target_range, 'eq')
53
+ fhir_date_comparer(search_range, target_range, 'lt', extend_start, extend_end) || fhir_date_comparer(search_range, target_range, 'eq')
54
54
  when 'sa' # the range above the search value contains the range of the target value
55
55
  !target_range[:start].nil? && search_range[:end] < target_range[:start]
56
56
  when 'eb' # the range below the search value contains the range of the target value
@@ -81,9 +81,11 @@ module USCoreTestKit
81
81
  else
82
82
  comparator = 'eq'
83
83
  end
84
+ search_is_date = is_date?(search_value)
85
+ target_is_date = is_date?(target_value)
84
86
  search_range = get_fhir_datetime_range(search_value)
85
87
  target_range = get_fhir_datetime_range(target_value)
86
- fhir_date_comparer(search_range, target_range, comparator)
88
+ fhir_date_comparer(search_range, target_range, comparator, !search_is_date && target_is_date, !search_is_date && target_is_date)
87
89
  end
88
90
 
89
91
  def validate_period_search(search_value, target_value)
@@ -93,9 +95,14 @@ module USCoreTestKit
93
95
  else
94
96
  comparator = 'eq'
95
97
  end
98
+ search_is_date = is_date?(search_value)
96
99
  search_range = get_fhir_datetime_range(search_value)
97
100
  target_range = get_fhir_period_range(target_value)
98
- fhir_date_comparer(search_range, target_range, comparator)
101
+ fhir_date_comparer(search_range, target_range, comparator, !search_is_date && is_date?(target_value.start), !search_is_date && is_date?(target_value.end))
102
+ end
103
+
104
+ def is_date?(value)
105
+ /^\d{4}(-\d{2})?(-\d{2})?$/.match?(value) # YYYY or YYYY-MM or YYYY-MM-DD
99
106
  end
100
107
  end
101
108
  end
@@ -11880,20 +11880,12 @@
11880
11880
  :uscdi_only: true
11881
11881
  - :path: name.suffix
11882
11882
  :uscdi_only: true
11883
- - :path: name.use
11884
- :fixed_value: old
11885
- :uscdi_only: true
11886
11883
  - :path: name.period.end
11887
11884
  :uscdi_only: true
11888
11885
  - :path: telecom
11889
11886
  :uscdi_only: true
11890
11887
  - :path: communication
11891
11888
  :uscdi_only: true
11892
- :choices:
11893
- - :paths:
11894
- - name.period.end
11895
- - name.use
11896
- :uscdi_only: true
11897
11889
  :mandatory_elements:
11898
11890
  - Patient.identifier
11899
11891
  - Patient.identifier.system
@@ -185,20 +185,12 @@
185
185
  :uscdi_only: true
186
186
  - :path: name.suffix
187
187
  :uscdi_only: true
188
- - :path: name.use
189
- :fixed_value: old
190
- :uscdi_only: true
191
188
  - :path: name.period.end
192
189
  :uscdi_only: true
193
190
  - :path: telecom
194
191
  :uscdi_only: true
195
192
  - :path: communication
196
193
  :uscdi_only: true
197
- :choices:
198
- - :paths:
199
- - name.period.end
200
- - name.use
201
- :uscdi_only: true
202
194
  :mandatory_elements:
203
195
  - Patient.identifier
204
196
  - Patient.identifier.system
@@ -34,7 +34,7 @@ module USCoreTestKit
34
34
  * Patient.extension:birthsex
35
35
  * Patient.extension:ethnicity
36
36
  * Patient.extension:race
37
- * Patient.name.period.end or Patient.name.use
37
+ * Patient.name.period.end
38
38
  * Patient.name.suffix
39
39
  * Patient.telecom
40
40
  * Patient.telecom.system
@@ -17444,9 +17444,6 @@
17444
17444
  :uscdi_only: true
17445
17445
  - :path: name.suffix
17446
17446
  :uscdi_only: true
17447
- - :path: name.use
17448
- :fixed_value: old
17449
- :uscdi_only: true
17450
17447
  - :path: name.period.end
17451
17448
  :uscdi_only: true
17452
17449
  - :path: telecom
@@ -17456,10 +17453,8 @@
17456
17453
  - :path: address.use
17457
17454
  :fixed_value: old
17458
17455
  :uscdi_only: true
17459
- :choices:
17460
- - :paths:
17461
- - name.period.end
17462
- - name.use
17456
+ - :path: name.use
17457
+ :fixed_value: old
17463
17458
  :uscdi_only: true
17464
17459
  :mandatory_elements:
17465
17460
  - Patient.identifier
@@ -188,9 +188,6 @@
188
188
  :uscdi_only: true
189
189
  - :path: name.suffix
190
190
  :uscdi_only: true
191
- - :path: name.use
192
- :fixed_value: old
193
- :uscdi_only: true
194
191
  - :path: name.period.end
195
192
  :uscdi_only: true
196
193
  - :path: telecom
@@ -200,10 +197,8 @@
200
197
  - :path: address.use
201
198
  :fixed_value: old
202
199
  :uscdi_only: true
203
- :choices:
204
- - :paths:
205
- - name.period.end
206
- - name.use
200
+ - :path: name.use
201
+ :fixed_value: old
207
202
  :uscdi_only: true
208
203
  :mandatory_elements:
209
204
  - Patient.identifier
@@ -36,8 +36,9 @@ module USCoreTestKit
36
36
  * Patient.extension:ethnicity
37
37
  * Patient.extension:genderIdentity
38
38
  * Patient.extension:race
39
- * Patient.name.period.end or Patient.name.use
39
+ * Patient.name.period.end
40
40
  * Patient.name.suffix
41
+ * Patient.name.use
41
42
  * Patient.telecom
42
43
  * Patient.telecom.system
43
44
  * Patient.telecom.use
@@ -375,11 +375,6 @@ module USCoreTestKit
375
375
  choices << { paths: ['location.location', 'serviceProvider'] }
376
376
  when 'MedicationRequest'
377
377
  choices << { paths: ['reportedBoolean', 'reportedReference'] }
378
- when 'Patient'
379
- choices << {
380
- paths: ['name.period.end', 'name.use'],
381
- uscdi_only: true
382
- }
383
378
  end
384
379
  when '5.0.1'
385
380
  case profile.type
@@ -400,13 +395,7 @@ module USCoreTestKit
400
395
  choices << { paths: ['location.location', 'serviceProvider'] }
401
396
  when 'MedicationRequest'
402
397
  choices << { paths: ['reportedBoolean', 'reportedReference'] }
403
- when 'Patient'
404
- choices << {
405
- paths: ['name.period.end', 'name.use'],
406
- uscdi_only: true
407
- }
408
398
  end
409
-
410
399
  end
411
400
 
412
401
  @must_supports[:choices] = choices if choices.present?
@@ -445,11 +434,6 @@ module USCoreTestKit
445
434
  path: 'name.suffix',
446
435
  uscdi_only: true
447
436
  }
448
- @must_supports[:elements] << {
449
- path: 'name.use',
450
- fixed_value: 'old',
451
- uscdi_only: true
452
- }
453
437
  @must_supports[:elements] << {
454
438
  path: 'name.period.end',
455
439
  uscdi_only: true
@@ -483,6 +467,11 @@ module USCoreTestKit
483
467
  fixed_value: 'old',
484
468
  uscdi_only: true
485
469
  }
470
+ @must_supports[:elements] << {
471
+ path: 'name.use',
472
+ fixed_value: 'old',
473
+ uscdi_only: true
474
+ }
486
475
  end
487
476
  end
488
477
 
@@ -609,9 +609,8 @@ module USCoreTestKit
609
609
  # Patient.birthDate does not mandate comparators so cannot be converted
610
610
  # Goal.target-date has day precision
611
611
  # All others have second + time offset precision
612
- if /^\d{4}$/.match?(element) || # YYYY
613
- /^\d{4}-\d{2}$/.match?(element) || # YYYY-MM
614
- (/^\d{4}-\d{2}-\d{2}$/.match?(element) && resource_type != "Goal") # YYYY-MM-DD AND Resource is NOT Goal
612
+ if /^\d{4}(-\d{2})?$/.match?(element) || # YYYY or YYYY-MM
613
+ (/^\d{4}-\d{2}-\d{2}$/.match?(element) && resource_type != "Goal") # YYY-MM-DD AND Resource is NOT Goal
615
614
  "gt#{(DateTime.xmlschema(element)-1).xmlschema}"
616
615
  else
617
616
  element
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module USCoreTestKit
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: us_core_test_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen MacVicar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inferno_core