-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from vadi2/add-r4-support
Add R4 support
- Loading branch information
Showing
33 changed files
with
60,877 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug Lua Interpreter", | ||
"type": "lua-local", | ||
"request": "launch", | ||
"program": { | ||
"lua": "lua", | ||
"file": "${file}" | ||
} | ||
}, | ||
{ | ||
"name": "Debug Custom Lua Environment", | ||
"type": "lua-local", | ||
"request": "launch", | ||
"program": { | ||
"command": "command" | ||
}, | ||
"args": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--[[ | ||
FHIR Formats | ||
Copyright (C) 2016 Vadim Peretokin | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
]] | ||
|
||
package.path = "src/?.lua;"..package.path | ||
local in_fhir_json = require("fhirformats").to_json | ||
local in_fhir_xml = require("fhirformats").to_xml | ||
local cjson = require("cjson") | ||
local xml = require("xml") | ||
local inspect = require("inspect") | ||
|
||
describe("auto-version xml to json", function() | ||
local positive_example, negative_example, immunization_example, | ||
positive_example_data, immunization_example_data | ||
|
||
setup(function() | ||
io.input("spec/R4/stu3-immunization.json") | ||
positive_example_data = io.read("*a") | ||
immunization_example_data = in_fhir_json("spec/R4/stu3-immunization.xml", {file = true, fhirversion = "auto"}) | ||
|
||
-- for same div data test | ||
assert:set_parameter("TableFormatLevel", -1) | ||
end) | ||
|
||
before_each(function() | ||
positive_example = cjson.decode(positive_example_data) | ||
immunization_example = cjson.decode(immunization_example_data) | ||
end) | ||
|
||
it("should have the same non-div data", function() | ||
assert.same(positive_example, immunization_example) | ||
end) | ||
end) | ||
|
||
describe("auto-version json to xml", function() | ||
local positive_example, negative_example, immunization_example, | ||
positive_example_data, immunization_example_data | ||
|
||
setup(function() | ||
io.input("spec/R4/stu3-immunization.xml") | ||
positive_example_data = io.read("*a") | ||
immunization_example_data = in_fhir_xml("spec/R4/stu3-immunization.json", {file = true, fhirversion = "auto"}) | ||
|
||
-- for same div data test | ||
assert:set_parameter("TableFormatLevel", -1) | ||
end) | ||
|
||
it("should have the same data, order included", function() | ||
assert.same(positive_example_data, immunization_example_data) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"resourceType": "DeviceUseStatement", | ||
"id": "example", | ||
"text": { | ||
"status": "generated", | ||
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: example</p><p><b>identifier</b>: 51ebb7a9-4e3a-4360-9a05-0cc2d869086f</p><p><b>status</b>: active</p><p><b>subject</b>: <a>Patient/example</a></p><p><b>device</b>: <a>Device/example</a></p><p><b>reasonReference</b>: <a>Appendectomy (surgery)</a></p></div>" | ||
}, | ||
"identifier": [ | ||
{ | ||
"system": "http:goodhealth.org/identifiers", | ||
"value": "51ebb7a9-4e3a-4360-9a05-0cc2d869086f" | ||
} | ||
], | ||
"status": "active", | ||
"subject": { | ||
"reference": "Patient/example" | ||
}, | ||
"device": { | ||
"reference": "Device/example" | ||
}, | ||
"reasonReference": [ | ||
{ | ||
"reference": "Procedure/example", | ||
"display": "Appendectomy (surgery)" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><DeviceUseStatement xmlns="http://hl7.org/fhir"> | ||
<id value="example"/> | ||
<text><status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: example</p><p><b>identifier</b>: 51ebb7a9-4e3a-4360-9a05-0cc2d869086f</p><p><b>status</b>: active</p><p><b>subject</b>: <a>Patient/example</a></p><p><b>device</b>: <a>Device/example</a></p><p><b>reasonReference</b>: <a>Appendectomy (surgery)</a></p></div></text><identifier> | ||
<system value="http:goodhealth.org/identifiers"/> | ||
<value value="51ebb7a9-4e3a-4360-9a05-0cc2d869086f"/> | ||
</identifier> | ||
<status value="active"/> | ||
<subject> | ||
<reference value="Patient/example"/> | ||
</subject> | ||
<device> | ||
<reference value="Device/example"/> | ||
</device> | ||
<reasonReference> | ||
<reference value="Procedure/example"/> | ||
<display value="Appendectomy (surgery)"/> | ||
</reasonReference> | ||
</DeviceUseStatement> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--[[ | ||
FHIR Formats | ||
Copyright (C) 2022 Vadim Peretokin | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
]] | ||
|
||
package.path = "src/?.lua;"..package.path | ||
local in_fhir_json = require("fhirformats").to_json | ||
local in_fhir_xml = require("fhirformats").to_xml | ||
local cjson = require("cjson") | ||
local xml = require("xml") | ||
local inspect = require("inspect") | ||
|
||
describe("xml to json", function() | ||
local positive_example, negative_example, deviceusestatement_example, | ||
positive_example_data, deviceusestatement_example_data | ||
|
||
setup(function() | ||
io.input("spec/R4/deviceusestatement-example.json") | ||
positive_example_data = io.read("*a") | ||
deviceusestatement_example_data = in_fhir_json("spec/R4/deviceusestatement-example.xml", | ||
{file = true, fhirversion = "R4"}) | ||
|
||
-- for same div data test | ||
assert:set_parameter("TableFormatLevel", -1) | ||
end) | ||
|
||
before_each(function() | ||
positive_example = cjson.decode(positive_example_data) | ||
deviceusestatement_example = cjson.decode(deviceusestatement_example_data) | ||
end) | ||
|
||
it("should have the same non-div data", function() | ||
-- cut out the div's, since the whitespace doesn't matter as much in xml | ||
positive_example.text.div = nil | ||
deviceusestatement_example.text.div = nil | ||
assert.same(positive_example, deviceusestatement_example) | ||
end) | ||
|
||
it("should have xml-comparable div data", function() | ||
local positive_example_div = xml.load(positive_example.text.div) | ||
local deviceusestatement_example_div = xml.load(deviceusestatement_example.text.div) | ||
--print(inspect(positive_example_div)) | ||
--print(inspect(deviceusestatement_example_div)) | ||
assert.same(positive_example_div, deviceusestatement_example_div) | ||
end) | ||
end) | ||
|
||
describe("json to xml", function() | ||
local positive_example, negative_example, deviceusestatement_example, | ||
positive_example_data, deviceusestatement_example_data | ||
|
||
setup(function() | ||
io.input("spec/R4/deviceusestatement-example.xml") | ||
positive_example_data = io.read("*a") | ||
deviceusestatement_example_data = in_fhir_xml("spec/R4/deviceusestatement-example.json", | ||
{file = true, fhirversion = "R4"}) | ||
|
||
-- for same div data test | ||
assert:set_parameter("TableFormatLevel", -1) | ||
end) | ||
|
||
it("should have the same data", function() | ||
-- convert it down to JSON since order of elements doesn't matter in JSON, while it does in XML | ||
assert.same( | ||
cjson.decode(in_fhir_json(positive_example_data, {fhirversion = "R4"})), | ||
cjson.decode(in_fhir_json(deviceusestatement_example_data, {fhirversion = "R4"}))) | ||
end) | ||
end) |
Oops, something went wrong.