rtp-connect 1.7 → 1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/rtp-connect/constants.rb +1 -1
- data/lib/rtp-connect/control_point.rb +5 -3
- data/lib/rtp-connect/dose_tracking.rb +5 -3
- data/lib/rtp-connect/extended_field.rb +5 -3
- data/lib/rtp-connect/extended_plan.rb +5 -3
- data/lib/rtp-connect/field.rb +5 -3
- data/lib/rtp-connect/plan.rb +13 -7
- data/lib/rtp-connect/prescription.rb +5 -3
- data/lib/rtp-connect/record.rb +27 -2
- data/lib/rtp-connect/simulation_field.rb +5 -3
- data/lib/rtp-connect/site_setup.rb +5 -3
- data/lib/rtp-connect/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODZiNzJlZGMxY2M5OTk4OTZhOWRjOGVlMzFlZDQxOTY3NjUwNjQ1Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmU2ZDc0N2NiMTFmYTIwYmEwZWExZGM3ZTQ1MTY2NDA0YTM5OWZkNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjY5ODBmNWNhZGJhZGJlM2Y1YmJmZTgzNWY1NjU4ZDBlMjE4YjgyZmYxNWI1
|
10
|
+
Y2VkMTc1NDcxMmQzNzZkZDcyODA4NTU0M2RkZDQzYjc2YTM1ZDYwNjE2NWE3
|
11
|
+
YjZhODU4ZGQ2ODY4NzY4ZTZjMWM1NDFlNzdhYjhlNGNkYmM4NjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDE5NjI3ZGIwMzY4NTVkZWJiYjRkMDAxN2UwNDQ5M2VkZjFmMGJhYzAyN2Nl
|
14
|
+
ZmNjM2Q3MDMxY2Q5NDFhNjc4Yzk2NmM1NWY5M2IxMThlZTk2MTA0MDUxZTA5
|
15
|
+
ZWQ5NzM3OGViYmJkMTA4NWQ0NTMxYTk3MzFiODQyNGZmMGQ4NTI=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 1.8
|
2
|
+
|
3
|
+
## 19th February 2015
|
4
|
+
|
5
|
+
* Fixed an issue with misinterpretation of crc in RTP files from older Mosaiq versions.
|
6
|
+
* Added support for versioning in RTP file output (supporting versions 2.4, 2.5 & 2.6).
|
7
|
+
* Fixed an issue where you couldn't access the ExtendedPlan record from its parent Plan record.
|
8
|
+
|
9
|
+
|
1
10
|
# 1.7
|
2
11
|
|
3
12
|
## 17th September 2014
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.11752.png)](http://dx.doi.org/10.5281/zenodo.11752)
|
2
|
+
|
1
3
|
# RTPConnect
|
2
4
|
|
3
5
|
The RTPConnect library allows you to read, edit and write RTPConnect files in Ruby.
|
@@ -123,7 +125,7 @@ If you encounter an RTP file with an unsupported record type, please contact me.
|
|
123
125
|
|
124
126
|
## COPYRIGHT
|
125
127
|
|
126
|
-
Copyright 2011-
|
128
|
+
Copyright 2011-2015 Christoffer Lervåg
|
127
129
|
|
128
130
|
This program is free software: you can redistribute it and/or modify
|
129
131
|
it under the terms of the GNU General Public License as published by
|
@@ -42,7 +42,7 @@ module RTP
|
|
42
42
|
# Pairs of RTPConnect keywords and parse method names.
|
43
43
|
PARSE_METHOD = {
|
44
44
|
"PLAN_DEF" => :plan_definition,
|
45
|
-
"EXTENDED_PLAN_DEF" => :
|
45
|
+
"EXTENDED_PLAN_DEF" => :extended_plan_def,
|
46
46
|
"RX_DEF" => :prescription_site,
|
47
47
|
"SITE_SETUP_DEF" => :site_setup,
|
48
48
|
"SIM_DEF" => :simulation_field,
|
@@ -279,13 +279,15 @@ module RTP
|
|
279
279
|
# Encodes the ControlPoint object + any hiearchy of child objects,
|
280
280
|
# to a properly formatted RTPConnect ascii string.
|
281
281
|
#
|
282
|
+
# @param [Hash] options an optional hash parameter
|
283
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
282
284
|
# @return [String] an RTP string with a single or multiple lines/records
|
283
285
|
#
|
284
|
-
def to_s
|
285
|
-
str = encode
|
286
|
+
def to_s(options={})
|
287
|
+
str = encode(options)
|
286
288
|
if children
|
287
289
|
children.each do |child|
|
288
|
-
str += child.to_s
|
290
|
+
str += child.to_s(options)
|
289
291
|
end
|
290
292
|
end
|
291
293
|
return str
|
@@ -123,13 +123,15 @@ module RTP
|
|
123
123
|
# Encodes the DoseTracking object + any hiearchy of child objects,
|
124
124
|
# to a properly formatted RTPConnect ascii string.
|
125
125
|
#
|
126
|
+
# @param [Hash] options an optional hash parameter
|
127
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
126
128
|
# @return [String] an RTP string with a single or multiple lines/records
|
127
129
|
#
|
128
|
-
def to_s
|
129
|
-
str = encode
|
130
|
+
def to_s(options={})
|
131
|
+
str = encode(options)
|
130
132
|
if children
|
131
133
|
children.each do |child|
|
132
|
-
str += child.to_s
|
134
|
+
str += child.to_s(options)
|
133
135
|
end
|
134
136
|
end
|
135
137
|
return str
|
@@ -100,13 +100,15 @@ module RTP
|
|
100
100
|
# Encodes the ExtendedField object + any hiearchy of child objects,
|
101
101
|
# to a properly formatted RTPConnect ascii string.
|
102
102
|
#
|
103
|
+
# @param [Hash] options an optional hash parameter
|
104
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
103
105
|
# @return [String] an RTP string with a single or multiple lines/records
|
104
106
|
#
|
105
|
-
def to_s
|
106
|
-
str = encode
|
107
|
+
def to_s(options={})
|
108
|
+
str = encode(options)
|
107
109
|
if children
|
108
110
|
children.each do |child|
|
109
|
-
str += child.to_s
|
111
|
+
str += child.to_s(options)
|
110
112
|
end
|
111
113
|
end
|
112
114
|
return str
|
@@ -87,13 +87,15 @@ module RTP
|
|
87
87
|
# Encodes the ExtendedPlan object + any hiearchy of child objects,
|
88
88
|
# to a properly formatted RTPConnect ascii string.
|
89
89
|
#
|
90
|
+
# @param [Hash] options an optional hash parameter
|
91
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
90
92
|
# @return [String] an RTP string with a single or multiple lines/records
|
91
93
|
#
|
92
|
-
def to_s
|
93
|
-
str = encode
|
94
|
+
def to_s(options={})
|
95
|
+
str = encode(options)
|
94
96
|
if children
|
95
97
|
children.each do |child|
|
96
|
-
str += child.to_s
|
98
|
+
str += child.to_s(options)
|
97
99
|
end
|
98
100
|
end
|
99
101
|
return str
|
data/lib/rtp-connect/field.rb
CHANGED
@@ -233,13 +233,15 @@ module RTP
|
|
233
233
|
# Encodes the Field object + any hiearchy of child objects,
|
234
234
|
# to a properly formatted RTPConnect ascii string.
|
235
235
|
#
|
236
|
+
# @param [Hash] options an optional hash parameter
|
237
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
236
238
|
# @return [String] an RTP string with a single or multiple lines/records
|
237
239
|
#
|
238
|
-
def to_s
|
239
|
-
str = encode
|
240
|
+
def to_s(options={})
|
241
|
+
str = encode(options)
|
240
242
|
if children
|
241
243
|
children.each do |child|
|
242
|
-
str += child.to_s
|
244
|
+
str += child.to_s(options)
|
243
245
|
end
|
244
246
|
end
|
245
247
|
return str
|
data/lib/rtp-connect/plan.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright 2011-
|
1
|
+
# Copyright 2011-2015 Christoffer Lervag
|
2
2
|
#
|
3
3
|
# This program is free software: you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -29,6 +29,8 @@ module RTP
|
|
29
29
|
attr_reader :parent
|
30
30
|
# An array of Prescription records (if any) that belongs to this Plan.
|
31
31
|
attr_reader :prescriptions
|
32
|
+
# The ExtendedPlan record (if any) that belongs to this Plan.
|
33
|
+
attr_reader :extended_plan
|
32
34
|
# An array of DoseTracking records (if any) that belongs to this Plan.
|
33
35
|
attr_reader :dose_trackings
|
34
36
|
attr_reader :patient_id
|
@@ -270,12 +272,14 @@ module RTP
|
|
270
272
|
# Encodes the Plan object + any hiearchy of child objects,
|
271
273
|
# to a properly formatted RTPConnect ascii string.
|
272
274
|
#
|
275
|
+
# @param [Hash] options an optional hash parameter
|
276
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
273
277
|
# @return [String] an RTP string with a single or multiple lines/records
|
274
278
|
#
|
275
|
-
def to_s
|
276
|
-
str = encode
|
279
|
+
def to_s(options={})
|
280
|
+
str = encode(options)
|
277
281
|
children.each do |child|
|
278
|
-
str += child.to_s
|
282
|
+
str += child.to_s(options) unless child.class == ExtendedPlan && options[:version].to_f < 2.5
|
279
283
|
end
|
280
284
|
return str
|
281
285
|
end
|
@@ -286,10 +290,12 @@ module RTP
|
|
286
290
|
# to a properly formatted RTPConnect ascii file.
|
287
291
|
#
|
288
292
|
# @param [String] file a path/file string
|
293
|
+
# @param [Hash] options an optional hash parameter
|
294
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
289
295
|
#
|
290
|
-
def write(file)
|
296
|
+
def write(file, options={})
|
291
297
|
f = open_file(file)
|
292
|
-
f.write(to_s)
|
298
|
+
f.write(to_s(options))
|
293
299
|
f.close
|
294
300
|
end
|
295
301
|
|
@@ -525,7 +531,7 @@ module RTP
|
|
525
531
|
#
|
526
532
|
# @param [String] string a string line containing an extended plan definition
|
527
533
|
#
|
528
|
-
def
|
534
|
+
def extended_plan_def(string)
|
529
535
|
ep = ExtendedPlan.load(string, @current_parent)
|
530
536
|
@current_parent = ep
|
531
537
|
end
|
@@ -140,13 +140,15 @@ module RTP
|
|
140
140
|
# Encodes the Prescription object + any hiearchy of child objects,
|
141
141
|
# to a properly formatted RTPConnect ascii string.
|
142
142
|
#
|
143
|
+
# @param [Hash] options an optional hash parameter
|
144
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
143
145
|
# @return [String] an RTP string with a single or multiple lines/records
|
144
146
|
#
|
145
|
-
def to_s
|
146
|
-
str = encode
|
147
|
+
def to_s(options={})
|
148
|
+
str = encode(options)
|
147
149
|
if children
|
148
150
|
children.each do |child|
|
149
|
-
str += child.to_s
|
151
|
+
str += child.to_s(options)
|
150
152
|
end
|
151
153
|
end
|
152
154
|
return str
|
data/lib/rtp-connect/record.rb
CHANGED
@@ -35,10 +35,13 @@ module RTP
|
|
35
35
|
#
|
36
36
|
# This produces the full record string line, including a computed CRC checksum.
|
37
37
|
#
|
38
|
+
# @param [Hash] options an optional hash parameter
|
39
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
38
40
|
# @return [String] a proper RTPConnect type CSV string
|
39
41
|
#
|
40
|
-
def encode
|
42
|
+
def encode(options={})
|
41
43
|
encoded_values = values.collect {|v| v && v.encode('ISO8859-1')}
|
44
|
+
encoded_values = discard_unsupported_attributes(encoded_values, options) if options[:version]
|
42
45
|
content = CSV.generate_line(encoded_values, force_quotes: true, row_sep: '') + ","
|
43
46
|
checksum = content.checksum
|
44
47
|
# Complete string is content + checksum (in double quotes) + carriage return + line feed
|
@@ -110,10 +113,32 @@ module RTP
|
|
110
113
|
# @param [Array<String>] values the record attributes (as parsed from a record string)
|
111
114
|
#
|
112
115
|
def set_attributes(values)
|
113
|
-
|
116
|
+
([values.length - 1, @max_elements - 1].min).times do |i|
|
117
|
+
self.send("#{@attributes[i]}=", values[i])
|
118
|
+
end
|
114
119
|
@crc = values[-1]
|
115
120
|
end
|
116
121
|
|
122
|
+
# Removes any attributes that are newer than the given compatibility target version.
|
123
|
+
# E.g. if a compatibility version of Mosaiq 2.4 is specified, attributes that were
|
124
|
+
# introduced in Mosaiq 2.5 or later is removed before the RTP string is created.
|
125
|
+
#
|
126
|
+
# @param [Array<String>] values the complete set of values of this record
|
127
|
+
# @param [Hash] options an optional hash parameter
|
128
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
129
|
+
# @return [Array<String>] an array of attributes where some of the recent attributes may have been removed
|
130
|
+
#
|
131
|
+
def discard_unsupported_attributes(values, options={})
|
132
|
+
case self
|
133
|
+
when SiteSetup
|
134
|
+
options[:version].to_f >= 2.6 ? values : values[0..-4]
|
135
|
+
when ExtendedField
|
136
|
+
options[:version].to_f >= 2.4 ? values : values[0..-5]
|
137
|
+
else
|
138
|
+
values
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
117
142
|
end
|
118
143
|
|
119
144
|
end
|
@@ -186,13 +186,15 @@ module RTP
|
|
186
186
|
# Encodes the SimulationField object + any hiearchy of child objects,
|
187
187
|
# to a properly formatted RTPConnect ascii string.
|
188
188
|
#
|
189
|
+
# @param [Hash] options an optional hash parameter
|
190
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
189
191
|
# @return [String] an RTP string with a single or multiple lines/records
|
190
192
|
#
|
191
|
-
def to_s
|
192
|
-
str = encode
|
193
|
+
def to_s(options={})
|
194
|
+
str = encode(options)
|
193
195
|
if children
|
194
196
|
children.each do |child|
|
195
|
-
str += child.to_s
|
197
|
+
str += child.to_s(options)
|
196
198
|
end
|
197
199
|
end
|
198
200
|
return str
|
@@ -110,13 +110,15 @@ module RTP
|
|
110
110
|
# Encodes the SiteSetup object + any hiearchy of child objects,
|
111
111
|
# to a properly formatted RTPConnect ascii string.
|
112
112
|
#
|
113
|
+
# @param [Hash] options an optional hash parameter
|
114
|
+
# @option options [Float] :version the Mosaiq compatibility version number (e.g. 2.4) used for the output
|
113
115
|
# @return [String] an RTP string with a single or multiple lines/records
|
114
116
|
#
|
115
|
-
def to_s
|
116
|
-
str = encode
|
117
|
+
def to_s(options={})
|
118
|
+
str = encode(options)
|
117
119
|
if children
|
118
120
|
children.each do |child|
|
119
|
-
str += child.to_s
|
121
|
+
str += child.to_s(options)
|
120
122
|
end
|
121
123
|
end
|
122
124
|
return str
|
data/lib/rtp-connect/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtp-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoffer Lervag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.4.5
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Library for handling RTPConnect files.
|