fhir_client 1.6.3 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +34 -0
- data/.csslintrc +2 -0
- data/.eslintignore +1 -0
- data/.eslintrc +213 -0
- data/.rubocop.yml +1159 -0
- data/.travis.yml +8 -0
- data/Gemfile +5 -5
- data/Rakefile +14 -13
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fhir_client.gemspec +34 -21
- data/lib/fhir_client.rb +13 -18
- data/lib/fhir_client/client.rb +533 -0
- data/lib/{client_exception.rb → fhir_client/client_exception.rb} +1 -3
- data/lib/{ext → fhir_client/ext}/bundle.rb +5 -7
- data/lib/{ext → fhir_client/ext}/model.rb +10 -2
- data/lib/fhir_client/ext/reference.rb +28 -0
- data/lib/{fhir_api_validation.json → fhir_client/fhir_api_validation.json} +0 -0
- data/lib/{model → fhir_client/model}/client_reply.rb +47 -51
- data/lib/{model → fhir_client/model}/tag.rb +6 -7
- data/lib/fhir_client/patch_format.rb +8 -0
- data/lib/{resource_address.rb → fhir_client/resource_address.rb} +135 -139
- data/lib/fhir_client/resource_format.rb +11 -0
- data/lib/{sections → fhir_client/sections}/crud.rb +28 -30
- data/lib/{sections → fhir_client/sections}/feed.rb +1 -4
- data/lib/{sections → fhir_client/sections}/history.rb +14 -15
- data/lib/{sections → fhir_client/sections}/operations.rb +22 -28
- data/lib/fhir_client/sections/search.rb +52 -0
- data/lib/{sections → fhir_client/sections}/tags.rb +12 -12
- data/lib/{sections → fhir_client/sections}/transactions.rb +17 -20
- data/lib/{sections → fhir_client/sections}/validate.rb +12 -15
- data/lib/{tasks → fhir_client/tasks}/tasks.rake +19 -18
- data/lib/fhir_client/version.rb +5 -0
- metadata +127 -83
- data/lib/client_interface.rb +0 -533
- data/lib/ext/reference.rb +0 -11
- data/lib/patch_format.rb +0 -10
- data/lib/resource_format.rb +0 -13
- data/lib/sections/search.rb +0 -53
- data/test/fixtures/bundle-example.xml +0 -79
- data/test/fixtures/parameters-example.json +0 -18
- data/test/fixtures/parameters-example.xml +0 -17
- data/test/test_helper.rb +0 -8
- data/test/unit/basic_test.rb +0 -17
- data/test/unit/bundle_test.rb +0 -21
- data/test/unit/parameters_test.rb +0 -44
data/lib/ext/reference.rb
DELETED
data/lib/patch_format.rb
DELETED
data/lib/resource_format.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module FHIR
|
2
|
-
module Formats
|
3
|
-
class ResourceFormat
|
4
|
-
|
5
|
-
RESOURCE_XML = "application/fhir+xml"
|
6
|
-
RESOURCE_JSON = "application/fhir+json"
|
7
|
-
|
8
|
-
RESOURCE_XML_DSTU2 = "application/xml+fhir"
|
9
|
-
RESOURCE_JSON_DSTU2 = "application/json+fhir"
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/sections/search.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module FHIR
|
2
|
-
module Sections
|
3
|
-
module Search
|
4
|
-
|
5
|
-
#
|
6
|
-
# Search a set of resources of a given type.
|
7
|
-
#
|
8
|
-
# @param klass The type of resource to be searched.
|
9
|
-
# @param options A hash of options used to construct the search query.
|
10
|
-
# @return FHIR::ClientReply
|
11
|
-
#
|
12
|
-
def search(klass, options={}, format=@default_format)
|
13
|
-
options.merge!({ resource: klass, format: format })
|
14
|
-
|
15
|
-
if options[:search] && options[:search][:flag]
|
16
|
-
reply = post resource_url(options), nil, fhir_headers(options)
|
17
|
-
else
|
18
|
-
reply = get resource_url(options), fhir_headers(options)
|
19
|
-
end
|
20
|
-
# reply = get resource_url(options), fhir_headers(options)
|
21
|
-
reply.resource = parse_reply(klass, format, reply)
|
22
|
-
reply.resource_class = klass
|
23
|
-
reply
|
24
|
-
end
|
25
|
-
|
26
|
-
def search_existing(klass, id, options={}, format=@default_format)
|
27
|
-
options.merge!({ resource: klass, id: id, format: format })
|
28
|
-
#if options[:search][:flag]
|
29
|
-
if options[:search] && options[:search][:flag]
|
30
|
-
reply = post resource_url(options), nil, fhir_headers(options)
|
31
|
-
else
|
32
|
-
reply = get resource_url(options), fhir_headers(options)
|
33
|
-
end
|
34
|
-
reply.resource = parse_reply(klass, format, reply)
|
35
|
-
reply.resource_class = klass
|
36
|
-
reply
|
37
|
-
end
|
38
|
-
|
39
|
-
def search_all(options={}, format=@default_format)
|
40
|
-
options.merge!({ format: format })
|
41
|
-
if options[:search] && options[:search][:flag]
|
42
|
-
reply = post resource_url(options), nil, fhir_headers(options)
|
43
|
-
else
|
44
|
-
reply = get resource_url(options), fhir_headers(options)
|
45
|
-
end
|
46
|
-
reply.resource = parse_reply(nil, format, reply)
|
47
|
-
reply.resource_class = nil
|
48
|
-
reply
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
<Bundle xmlns="http://hl7.org/fhir">
|
2
|
-
<id value="example"/>
|
3
|
-
<meta>
|
4
|
-
<versionId value="1"/>
|
5
|
-
<lastUpdated value="2014-08-18T01:43:30Z"/>
|
6
|
-
</meta>
|
7
|
-
<type value="transaction"/>
|
8
|
-
<base value="http://example.com/base"/>
|
9
|
-
<total value="3"/>
|
10
|
-
<link>
|
11
|
-
<relation value="next"/>
|
12
|
-
<url value="https://example.com/base/MedicationOrder?patient=347&searchId=ff15fd40-ff71-4b48-b366-09c
|
13
|
-
706bed9d0&page=2"/>
|
14
|
-
</link>
|
15
|
-
<link>
|
16
|
-
<relation value="self"/>
|
17
|
-
<url value="https://example.com/base/MedicationOrder?patient=347"/>
|
18
|
-
</link>
|
19
|
-
<entry>
|
20
|
-
<status value="update"/>
|
21
|
-
<resource>
|
22
|
-
<MedicationOrder>
|
23
|
-
<id value="3123"/>
|
24
|
-
<meta>
|
25
|
-
<versionId value="1"/>
|
26
|
-
<lastUpdated value="2014-08-16T05:31:17Z"/>
|
27
|
-
</meta>
|
28
|
-
<text>
|
29
|
-
<status value="generated"/>
|
30
|
-
<div xmlns="http://www.w3.org/1999/xhtml"><!-- Snipped for brevity --></div>
|
31
|
-
</text>
|
32
|
-
<status value="active"/>
|
33
|
-
<patient>
|
34
|
-
<reference value="Patient/example"/>
|
35
|
-
</patient>
|
36
|
-
<prescriber>
|
37
|
-
<reference value="Practitioner/example"/>
|
38
|
-
</prescriber>
|
39
|
-
|
40
|
-
<medicationReference>
|
41
|
-
<reference value="Medication/example"/>
|
42
|
-
</medicationReference>
|
43
|
-
|
44
|
-
<dosageInstruction>
|
45
|
-
<timing>
|
46
|
-
<repeat>
|
47
|
-
<frequency value="3"/>
|
48
|
-
<duration value="1"/>
|
49
|
-
<units value="d"/>
|
50
|
-
</repeat>
|
51
|
-
</timing>
|
52
|
-
<route>
|
53
|
-
<coding>
|
54
|
-
<system value="http://snomed.info/sct"/>
|
55
|
-
<code value="394899003"/>
|
56
|
-
<display value="oral administration of treatment"/>
|
57
|
-
</coding>
|
58
|
-
</route>
|
59
|
-
<doseQuantity>
|
60
|
-
<value value="5"/>
|
61
|
-
<units value="ml"/>
|
62
|
-
<system value="http://unitsofmeasure.org"/>
|
63
|
-
<code value="ml"/>
|
64
|
-
</doseQuantity>
|
65
|
-
</dosageInstruction>
|
66
|
-
|
67
|
-
<dispenseRequest>
|
68
|
-
<quantity>
|
69
|
-
<value value="100"/>
|
70
|
-
<units value="ml"/>
|
71
|
-
<system value="http://unitsofmeasure.org"/>
|
72
|
-
<code value="ml"/>
|
73
|
-
</quantity>
|
74
|
-
</dispenseRequest>
|
75
|
-
|
76
|
-
</MedicationOrder>
|
77
|
-
</resource>
|
78
|
-
</entry>
|
79
|
-
</Bundle>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"resourceType": "Parameters",
|
3
|
-
"id": "example",
|
4
|
-
"parameter": [
|
5
|
-
{
|
6
|
-
"name": "start",
|
7
|
-
"valueDate": "2010-01-01"
|
8
|
-
},
|
9
|
-
{
|
10
|
-
"name": "end",
|
11
|
-
"resource": {
|
12
|
-
"resourceType": "Binary",
|
13
|
-
"contentType": "text/plain",
|
14
|
-
"content": "VGhpcyBpcyBhIHRlc3QgZXhhbXBsZQ=="
|
15
|
-
}
|
16
|
-
}
|
17
|
-
]
|
18
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Parameters xmlns="http://hl7.org/fhir">
|
3
|
-
<id value="example"/>
|
4
|
-
<parameter>
|
5
|
-
<name value="start"/>
|
6
|
-
<valueDate value="2010-01-01"/>
|
7
|
-
</parameter>
|
8
|
-
<parameter>
|
9
|
-
<name value="end"/>
|
10
|
-
<resource>
|
11
|
-
<Binary>
|
12
|
-
<contentType value="text/plain"/>
|
13
|
-
<content value="VGhpcyBpcyBhIHRlc3QgZXhhbXBsZQ=="/>
|
14
|
-
</Binary>
|
15
|
-
</resource>
|
16
|
-
</parameter>
|
17
|
-
</Parameters>
|
data/test/test_helper.rb
DELETED
data/test/unit/basic_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class BasicTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
TESTING_ENDPOINT = 'http://fhirtest.uhn.ca/baseDstu3'
|
6
|
-
|
7
|
-
def test_client_initialization
|
8
|
-
client = FHIR::Client.new(TESTING_ENDPOINT)
|
9
|
-
assert !client.use_format_param, "Using _format instead of [Accept] headers."
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_conformance
|
13
|
-
client = FHIR::Client.new(TESTING_ENDPOINT)
|
14
|
-
assert !client.conformanceStatement.nil?, "Unable to retrieve conformance statement."
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/test/unit/bundle_test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class BundleTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_example_bundle
|
6
|
-
client = FHIR::Client.new("feed-test")
|
7
|
-
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
|
8
|
-
bundle_xml = File.read(File.join(root, 'fixtures', 'bundle-example.xml'))
|
9
|
-
response = {
|
10
|
-
:code => '200',
|
11
|
-
:headers => {},
|
12
|
-
:body => bundle_xml
|
13
|
-
}
|
14
|
-
clientReply = FHIR::ClientReply.new('feed-test', response)
|
15
|
-
|
16
|
-
bundle = client.parse_reply(FHIR::Bundle, FHIR::Formats::ResourceFormat::RESOURCE_XML, clientReply)
|
17
|
-
|
18
|
-
assert !bundle.nil?, "Failed to parse example Bundle."
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class ParametersTest < Test::Unit::TestCase
|
4
|
-
# <?xml version="1.0" encoding="UTF-8"?>
|
5
|
-
# <Parameters xmlns="http://hl7.org/fhir">
|
6
|
-
# <id value="example"/>
|
7
|
-
# <parameter>
|
8
|
-
# <name value="start"/>
|
9
|
-
# <valueDate value="2010-01-01"/>
|
10
|
-
# </parameter>
|
11
|
-
# <parameter>
|
12
|
-
# <name value="end"/>
|
13
|
-
# <resource>
|
14
|
-
# <Binary>
|
15
|
-
# <contentType value="text/plain"/>
|
16
|
-
# <content value="VGhpcyBpcyBhIHRlc3QgZXhhbXBsZQ=="/>
|
17
|
-
# </Binary>
|
18
|
-
# </resource>
|
19
|
-
# </parameter>
|
20
|
-
# </Parameters>
|
21
|
-
def test_example_parameters_xml
|
22
|
-
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
|
23
|
-
xml = File.read(File.join(root, 'fixtures', 'parameters-example.xml'))
|
24
|
-
parameters = FHIR::Xml.from_xml(xml)
|
25
|
-
check_params(parameters)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_example_parameters_json
|
29
|
-
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
|
30
|
-
json = File.read(File.join(root, 'fixtures', 'parameters-example.json'))
|
31
|
-
parameters = FHIR::Json.from_json(json)
|
32
|
-
check_params(parameters)
|
33
|
-
end
|
34
|
-
|
35
|
-
def check_params(parameters)
|
36
|
-
message = "Failed to parse example Parameters."
|
37
|
-
assert parameters.parameter.length==2, message
|
38
|
-
assert parameters.parameter[0].name=='start', message
|
39
|
-
assert parameters.parameter[0].valueDate=='2010-01-01', message
|
40
|
-
assert parameters.parameter[1].name=='end', message
|
41
|
-
assert !parameters.parameter[1].resource.nil? && parameters.parameter[1].resource.class==FHIR::Binary, message
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|