From 7d55fed90f8012e07e5c87395999cd662caff3aa Mon Sep 17 00:00:00 2001 From: Rob Scanlon Date: Fri, 1 Feb 2019 16:28:49 -0500 Subject: [PATCH 1/3] Follow basebone elements for base resource validation. --- lib/fhir_dstu2_models/bootstrap/model.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fhir_dstu2_models/bootstrap/model.rb b/lib/fhir_dstu2_models/bootstrap/model.rb index b471dda..e47a99c 100644 --- a/lib/fhir_dstu2_models/bootstrap/model.rb +++ b/lib/fhir_dstu2_models/bootstrap/model.rb @@ -209,8 +209,8 @@ def validate_field(field, value, contained_here, meta, errors) else errors[field] << "#{meta['path']}: expected Reference, found #{klassname}" end - # if the data type is a particular resource or complex type - elsif FHIR::DSTU2::RESOURCES.include?(datatype) || FHIR::DSTU2::TYPES.include?(datatype) + # if the data type is a particular resource or complex type or BackBone element within this resource + elsif FHIR::DSTU2::RESOURCES.include?(datatype) || FHIR::DSTU2::TYPES.include?(datatype) || v.class.name.start_with?(self.class.name) if datatype == klassname validation = v.validate(contained_here) errors[field] << validation unless validation.empty? From d86bd859ad6daca237b9348ac0fc28cbaa3c687f Mon Sep 17 00:00:00 2001 From: Rob Scanlon Date: Fri, 1 Feb 2019 16:45:56 -0500 Subject: [PATCH 2/3] Add more information to test failures. --- test/unit/json_validation_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/json_validation_test.rb b/test/unit/json_validation_test.rb index 6ef6fb0..24f0090 100644 --- a/test/unit/json_validation_test.rb +++ b/test/unit/json_validation_test.rb @@ -27,7 +27,7 @@ def run_json_validation_test(example_file, example_name) File.open("#{ERROR_DIR}/#{example_name}.err", 'w:UTF-8') { |file| file.write(JSON.pretty_unparse(errors)) } File.open("#{ERROR_DIR}/#{example_name}.json", 'w:UTF-8') { |file| file.write(input_json) } end - assert errors.empty?, 'Resource failed to validate.' + assert errors.empty?, "Resource failed to validate: #{errors}." # check memory before = check_memory resource = nil From 0aeba93d98485fd260648ac6b97cd88bf7ef2d9f Mon Sep 17 00:00:00 2001 From: Rob Scanlon Date: Sat, 9 Feb 2019 22:06:08 -0500 Subject: [PATCH 3/3] Fix codes in examples. --- .../examples/json/appointment-example-request.json | 2 +- .../examples/json/appointment-example.json | 2 +- .../examples/json/claim-example-institutional.json | 2 +- .../examples/json/claim-example-oral-average.json | 10 +++++----- .../examples/json/claim-example-oral-contained.json | 2 +- .../examples/json/claim-example-oral-orthoplan.json | 8 ++++---- .../examples/json/claim-example-pharmacy.json | 2 +- .../examples/json/claim-example-professional.json | 2 +- .../examples/json/claim-example-vision-glasses.json | 8 ++++---- .../examples/json/claim-example-vision.json | 2 +- lib/fhir_dstu2_models/examples/json/claim-example.json | 2 +- .../examples/xml/appointment-example(example).xml | 2 +- .../xml/appointment-example-request(examplereq).xml | 2 +- .../examples/xml/claim-example(100150).xml | 2 +- .../xml/claim-example-institutional(960150).xml | 2 +- .../xml/claim-example-oral-average(100151).xml | 10 +++++----- .../xml/claim-example-oral-contained(100152).xml | 2 +- .../xml/claim-example-oral-orthoplan(100153).xml | 8 ++++---- .../examples/xml/claim-example-pharmacy(760150).xml | 2 +- .../xml/claim-example-professional(860150).xml | 2 +- .../examples/xml/claim-example-vision(660150).xml | 2 +- .../xml/claim-example-vision-glasses(660151).xml | 8 ++++---- ...rofile-example(dataelement-sdc-profile-example).xml | 1 - 23 files changed, 42 insertions(+), 43 deletions(-) diff --git a/lib/fhir_dstu2_models/examples/json/appointment-example-request.json b/lib/fhir_dstu2_models/examples/json/appointment-example-request.json index c0fd23d..9b011ec 100755 --- a/lib/fhir_dstu2_models/examples/json/appointment-example-request.json +++ b/lib/fhir_dstu2_models/examples/json/appointment-example-request.json @@ -43,7 +43,7 @@ { "coding": [ { - "code": "attending" + "code": "ATND" } ] } diff --git a/lib/fhir_dstu2_models/examples/json/appointment-example.json b/lib/fhir_dstu2_models/examples/json/appointment-example.json index 1af47d8..4cea690 100755 --- a/lib/fhir_dstu2_models/examples/json/appointment-example.json +++ b/lib/fhir_dstu2_models/examples/json/appointment-example.json @@ -33,7 +33,7 @@ { "coding": [ { - "code": "attending" + "code": "ATND" } ] } diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-institutional.json b/lib/fhir_dstu2_models/examples/json/claim-example-institutional.json index 5ce21de..5197e1e 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-institutional.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-institutional.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-oral-average.json b/lib/fhir_dstu2_models/examples/json/claim-example-oral-average.json index 10c0e6a..c15d81b 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-oral-average.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-oral-average.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" @@ -79,7 +79,7 @@ { "sequence": 2, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" @@ -113,7 +113,7 @@ { "sequence": 3, "type": { - "code": "group" + "code": "CPNDDRGING" }, "provider": { "reference": "Practitioner/example" @@ -141,7 +141,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "service": { "system": "http://hl7.org/fhir/oralservicecodes", @@ -161,7 +161,7 @@ { "sequence": 2, "type": { - "code": "service" + "code": "CSINV" }, "service": { "system": "http://hl7.org/fhir/oralservicecodes", diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-oral-contained.json b/lib/fhir_dstu2_models/examples/json/claim-example-oral-contained.json index 2a07aa0..a8dbac2 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-oral-contained.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-oral-contained.json @@ -139,7 +139,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "#practitioner-1" diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-oral-orthoplan.json b/lib/fhir_dstu2_models/examples/json/claim-example-oral-orthoplan.json index 34ca76d..656d12e 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-oral-orthoplan.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-oral-orthoplan.json @@ -213,7 +213,7 @@ { "sequence": 2, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" @@ -247,7 +247,7 @@ { "sequence": 3, "type": { - "code": "group" + "code": "CPNDDRGING" }, "provider": { "reference": "Practitioner/example" @@ -275,7 +275,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "service": { "system": "http://hl7.org/fhir/oralservicecodes", @@ -295,7 +295,7 @@ { "sequence": 2, "type": { - "code": "service" + "code": "CSINV" }, "service": { "system": "http://hl7.org/fhir/oralservicecodes", diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-pharmacy.json b/lib/fhir_dstu2_models/examples/json/claim-example-pharmacy.json index f9833b6..a12c541 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-pharmacy.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-pharmacy.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-professional.json b/lib/fhir_dstu2_models/examples/json/claim-example-professional.json index 7c4cb66..91a1a4e 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-professional.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-professional.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-vision-glasses.json b/lib/fhir_dstu2_models/examples/json/claim-example-vision-glasses.json index 17c6ae7..d47468a 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-vision-glasses.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-vision-glasses.json @@ -58,7 +58,7 @@ { "sequence": 1, "type": { - "code": "group" + "code": "CPNDDRGING" }, "provider": { "reference": "Practitioner/example" @@ -82,7 +82,7 @@ { "sequence": 1, "type": { - "code": "product" + "code": "CPINV" }, "service": { "system": "http://hl7.org/fhir/ex-visionservice", @@ -102,7 +102,7 @@ { "sequence": 2, "type": { - "code": "product" + "code": "CPINV" }, "service": { "system": "http://hl7.org/fhir/ex-visionservice", @@ -125,7 +125,7 @@ { "sequence": 3, "type": { - "code": "tax" + "code": "VRXINV" }, "service": { "system": "http://hl7.org/fhir/ex-visionservice", diff --git a/lib/fhir_dstu2_models/examples/json/claim-example-vision.json b/lib/fhir_dstu2_models/examples/json/claim-example-vision.json index 28d2c57..f0f9bb5 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example-vision.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example-vision.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" diff --git a/lib/fhir_dstu2_models/examples/json/claim-example.json b/lib/fhir_dstu2_models/examples/json/claim-example.json index 1bd8054..4c3e1b0 100755 --- a/lib/fhir_dstu2_models/examples/json/claim-example.json +++ b/lib/fhir_dstu2_models/examples/json/claim-example.json @@ -55,7 +55,7 @@ { "sequence": 1, "type": { - "code": "service" + "code": "CSINV" }, "provider": { "reference": "Practitioner/example" diff --git a/lib/fhir_dstu2_models/examples/xml/appointment-example(example).xml b/lib/fhir_dstu2_models/examples/xml/appointment-example(example).xml index 2459bed..924d380 100755 --- a/lib/fhir_dstu2_models/examples/xml/appointment-example(example).xml +++ b/lib/fhir_dstu2_models/examples/xml/appointment-example(example).xml @@ -27,7 +27,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/appointment-example-request(examplereq).xml b/lib/fhir_dstu2_models/examples/xml/appointment-example-request(examplereq).xml index 4275708..c7fbec0 100755 --- a/lib/fhir_dstu2_models/examples/xml/appointment-example-request(examplereq).xml +++ b/lib/fhir_dstu2_models/examples/xml/appointment-example-request(examplereq).xml @@ -33,7 +33,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example(100150).xml b/lib/fhir_dstu2_models/examples/xml/claim-example(100150).xml index ef3041f..a5902e4 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example(100150).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example(100150).xml @@ -61,7 +61,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-institutional(960150).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-institutional(960150).xml index 76587b2..511452d 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-institutional(960150).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-institutional(960150).xml @@ -60,7 +60,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-average(100151).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-average(100151).xml index d0b55d0..97419d9 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-average(100151).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-average(100151).xml @@ -60,7 +60,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -145,7 +145,7 @@ - + @@ -165,7 +165,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-contained(100152).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-contained(100152).xml index c63c11a..294db52 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-contained(100152).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-contained(100152).xml @@ -116,7 +116,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-orthoplan(100153).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-orthoplan(100153).xml index ccdc7b4..e560d93 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-oral-orthoplan(100153).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-oral-orthoplan(100153).xml @@ -189,7 +189,7 @@ - + @@ -222,7 +222,7 @@ - + @@ -249,7 +249,7 @@ - + @@ -269,7 +269,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-pharmacy(760150).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-pharmacy(760150).xml index c5c17a1..78f6b78 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-pharmacy(760150).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-pharmacy(760150).xml @@ -60,7 +60,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-professional(860150).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-professional(860150).xml index 268071d..766eab6 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-professional(860150).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-professional(860150).xml @@ -60,7 +60,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-vision(660150).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-vision(660150).xml index d8bcb4f..3b2ed56 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-vision(660150).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-vision(660150).xml @@ -60,7 +60,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/claim-example-vision-glasses(660151).xml b/lib/fhir_dstu2_models/examples/xml/claim-example-vision-glasses(660151).xml index a545034..c6b6204 100755 --- a/lib/fhir_dstu2_models/examples/xml/claim-example-vision-glasses(660151).xml +++ b/lib/fhir_dstu2_models/examples/xml/claim-example-vision-glasses(660151).xml @@ -64,7 +64,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/lib/fhir_dstu2_models/examples/xml/dataelement-sdc-profile-example(dataelement-sdc-profile-example).xml b/lib/fhir_dstu2_models/examples/xml/dataelement-sdc-profile-example(dataelement-sdc-profile-example).xml index f96a985..c157e17 100755 --- a/lib/fhir_dstu2_models/examples/xml/dataelement-sdc-profile-example(dataelement-sdc-profile-example).xml +++ b/lib/fhir_dstu2_models/examples/xml/dataelement-sdc-profile-example(dataelement-sdc-profile-example).xml @@ -37,7 +37,6 @@ -