test-patient-generator 1.1.2 → 1.2.0
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.
- data/Gemfile +1 -2
- data/lib/test-patient-generator.rb +0 -1
- data/lib/tpg/ext/coded.rb +3 -3
- data/lib/tpg/ext/data_criteria.rb +2 -2
- data/lib/tpg/generation/exporter.rb +10 -10
- data/lib/tpg/generation/generator.rb +18 -7
- metadata +9 -40
data/Gemfile
CHANGED
data/lib/tpg/ext/coded.rb
CHANGED
|
@@ -9,8 +9,8 @@ module HQMF
|
|
|
9
9
|
def self.select_codes(oid, value_sets)
|
|
10
10
|
value_sets = HQMF::Coded.select_value_sets(oid, value_sets)
|
|
11
11
|
code_sets = {}
|
|
12
|
-
value_sets["
|
|
13
|
-
code_sets[
|
|
12
|
+
value_sets["concepts"].each do |concept|
|
|
13
|
+
code_sets[concept["code_system_name"]] ||= [concept["code"]]
|
|
14
14
|
end
|
|
15
15
|
code_sets
|
|
16
16
|
end
|
|
@@ -23,7 +23,7 @@ module HQMF
|
|
|
23
23
|
def self.select_value_sets(oid, value_sets)
|
|
24
24
|
# Pick the value set for this DataCriteria. If it can't be found, it is an error from the value set source. We'll add the entry without codes for now.
|
|
25
25
|
index = value_sets.index{|value_set| value_set["oid"] == oid}
|
|
26
|
-
value_sets = index.nil? ? { "
|
|
26
|
+
value_sets = index.nil? ? { "concepts" => [] } : value_sets[index]
|
|
27
27
|
value_sets
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -76,7 +76,7 @@ module HQMF
|
|
|
76
76
|
entry.values ||= []
|
|
77
77
|
values.each do |value|
|
|
78
78
|
if value.type == "CD"
|
|
79
|
-
entry.values << CodedResultValue.new({codes: Coded.select_codes(value.code_list_id, value_sets), description: HQMF::Coded.select_value_sets(value.code_list_id, value_sets)["
|
|
79
|
+
entry.values << CodedResultValue.new({codes: Coded.select_codes(value.code_list_id, value_sets), description: HQMF::Coded.select_value_sets(value.code_list_id, value_sets)["display_name"]})
|
|
80
80
|
else
|
|
81
81
|
entry.values << PhysicalQuantityResultValue.new(value.format)
|
|
82
82
|
end
|
|
@@ -109,7 +109,7 @@ module HQMF
|
|
|
109
109
|
# Format the field to be stored in a Record.
|
|
110
110
|
if field.type == "CD"
|
|
111
111
|
field_value = Coded.select_code(field.code_list_id, value_sets)
|
|
112
|
-
field_value["title"] = HQMF::Coded.select_value_sets(field.code_list_id, value_sets)["
|
|
112
|
+
field_value["title"] = HQMF::Coded.select_value_sets(field.code_list_id, value_sets)["display_name"] if field_value
|
|
113
113
|
else
|
|
114
114
|
field_value = field.format
|
|
115
115
|
end
|
|
@@ -5,9 +5,9 @@ module TPG
|
|
|
5
5
|
# @param [Array] patients All of the patients that will be exported.
|
|
6
6
|
# @param [String] format The desired format for the patients to be in.
|
|
7
7
|
# @return A zip file containing all given patients in the requested format.
|
|
8
|
-
def self.zip(patients, format
|
|
8
|
+
def self.zip(patients, format)
|
|
9
9
|
file = Tempfile.new("patients-#{Time.now.to_i}")
|
|
10
|
-
|
|
10
|
+
html_exporter = HealthDataStandards::Export::HTML.new
|
|
11
11
|
Zip::ZipOutputStream.open(file.path) do |z|
|
|
12
12
|
xslt = Nokogiri::XSLT(File.read("public/cda.xsl"))
|
|
13
13
|
patients.each do |patient|
|
|
@@ -15,16 +15,16 @@ module TPG
|
|
|
15
15
|
|
|
16
16
|
if format == "c32"
|
|
17
17
|
z.put_next_entry("#{next_entry_path}.xml")
|
|
18
|
-
z << HealthDataStandards::Export::C32.export(patient)
|
|
18
|
+
z << HealthDataStandards::Export::C32.new.export(patient)
|
|
19
19
|
elsif format == "ccr"
|
|
20
20
|
z.put_next_entry("#{next_entry_path}.xml")
|
|
21
21
|
z << HealthDataStandards::Export::CCR.export(patient)
|
|
22
22
|
elsif format == "ccda"
|
|
23
23
|
z.put_next_entry("#{next_entry_path}.xml")
|
|
24
|
-
z << HealthDataStandards::Export::CCDA.export(patient)
|
|
24
|
+
z << HealthDataStandards::Export::CCDA.new.export(patient)
|
|
25
25
|
elsif format == "html"
|
|
26
26
|
z.put_next_entry("#{next_entry_path}.html")
|
|
27
|
-
z << html_contents(patient,
|
|
27
|
+
z << html_contents(patient, html_exporter)
|
|
28
28
|
elsif format == "json"
|
|
29
29
|
z.put_next_entry("#{next_entry_path}.json")
|
|
30
30
|
z << JSON.pretty_generate(JSON.parse(patient.to_json))
|
|
@@ -43,13 +43,13 @@ module TPG
|
|
|
43
43
|
# @return A zip file containing all of the QRDA Category 1 patients that were passed in.
|
|
44
44
|
def self.zip_qrda_html_patients(measure_patients)
|
|
45
45
|
file = Tempfile.new("patients-#{Time.now.to_i}")
|
|
46
|
-
|
|
46
|
+
html_exporter = HealthDataStandards::Export::HTML.new
|
|
47
47
|
Zip::ZipOutputStream.open(file.path) do |zip|
|
|
48
48
|
xslt = Nokogiri::XSLT(File.read("public/cda.xsl"))
|
|
49
49
|
measure_patients.each do |measure, patient|
|
|
50
50
|
# Create a directory for this measure and insert the HTML for this patient.
|
|
51
51
|
zip.put_next_entry(File.join(measure, "#{patient_filename(patient)}.html"))
|
|
52
|
-
zip << html_contents(patient)
|
|
52
|
+
zip << html_contents(patient, html_exporter)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -70,7 +70,7 @@ module TPG
|
|
|
70
70
|
measure_defs = measures.find {|m| m.id == nqf_id}
|
|
71
71
|
# Create a directory for this measure and insert the HTML for this patient.
|
|
72
72
|
zip.put_next_entry(File.join(measure_defs.hqmf_id, "#{patient_filename(patient)}.xml"))
|
|
73
|
-
zip <<
|
|
73
|
+
zip << HealthDataStandards::Export::Cat1.new.export(patient, [measure_defs], Time.gm(2011, 1, 1), Time.gm(2011, 12, 31))
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -82,8 +82,8 @@ module TPG
|
|
|
82
82
|
#
|
|
83
83
|
# @param [Record] patient The Record for which we're generating HTML content.
|
|
84
84
|
# @return HTML content to be exported for a Record.
|
|
85
|
-
def self.html_contents(patient,
|
|
86
|
-
|
|
85
|
+
def self.html_contents(patient, exporter = HealthDataStandards::Export::HTML.new)
|
|
86
|
+
exporter.export(patient)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Join the first and last name with an underscore and replace any other punctuation that might interfere with file names.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
module HQMF
|
|
2
2
|
class Generator
|
|
3
|
+
|
|
3
4
|
# Generate patients from lists of DataCriteria. This is originally created for QRDA Category 1 validation testing,
|
|
4
5
|
# i.e. a single patient will be generated per measure with an entry for every data criteria involved in the measure.
|
|
5
6
|
#
|
|
6
7
|
# @param [Hash] measure_needs A hash of measure IDs mapped to a list of all their data criteria in JSON.
|
|
8
|
+
# @param [Hash] Value set hash to use for looking up codes for the data criteria passed in. If null will resort to original behavior of
|
|
7
9
|
# @return [Hash] A hash of measure IDs mapped to a Record that includes all the given data criteria (values and times are arbitrary).
|
|
8
|
-
def self.generate_qrda_patients(measure_needs)
|
|
10
|
+
def self.generate_qrda_patients(measure_needs, value_sets=nil)
|
|
9
11
|
return {} if measure_needs.nil?
|
|
10
12
|
|
|
11
13
|
measure_patients = {}
|
|
@@ -13,7 +15,7 @@ module HQMF
|
|
|
13
15
|
# Define a list of unique data criteria and matching value sets to create a patient for this measure.
|
|
14
16
|
unique_data_criteria = select_unique_data_criteria(all_data_criteria)
|
|
15
17
|
oids = select_unique_oids(all_data_criteria)
|
|
16
|
-
value_sets = create_oid_dictionary(oids)
|
|
18
|
+
value_sets = create_oid_dictionary(oids) if value_sets.nil?
|
|
17
19
|
|
|
18
20
|
# Create a patient that includes an entry for every data criteria included in this measure.
|
|
19
21
|
patient = Generator.create_base_patient
|
|
@@ -81,8 +83,18 @@ module HQMF
|
|
|
81
83
|
|
|
82
84
|
unique_data_criteria = []
|
|
83
85
|
all_data_criteria.each do |data_criteria|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
|
|
87
|
+
fields1 = data_criteria.field_values || {}
|
|
88
|
+
|
|
89
|
+
index = unique_data_criteria.index {|dc| dc.code_list_id == data_criteria.code_list_id && dc.negation_code_list_id == data_criteria.negation_code_list_id && dc.status == data_criteria.status && dc.definition == data_criteria.definition}
|
|
90
|
+
|
|
91
|
+
if index
|
|
92
|
+
crit = unique_data_criteria[index]
|
|
93
|
+
crit.field_values ||= {}
|
|
94
|
+
crit.field_values.merge! data_criteria.field_values || {}
|
|
95
|
+
else
|
|
96
|
+
unique_data_criteria << data_criteria
|
|
97
|
+
end
|
|
86
98
|
end
|
|
87
99
|
|
|
88
100
|
unique_data_criteria
|
|
@@ -95,10 +107,9 @@ module HQMF
|
|
|
95
107
|
def self.create_oid_dictionary(oids)
|
|
96
108
|
value_sets = []
|
|
97
109
|
HealthDataStandards::SVS::ValueSet.any_in(oid: oids).each do |value_set|
|
|
98
|
-
code_sets = value_set.concepts
|
|
99
|
-
value_sets << {"
|
|
110
|
+
code_sets = value_set.concepts
|
|
111
|
+
value_sets << {"concepts" => code_sets, "oid" => value_set.oid}
|
|
100
112
|
end
|
|
101
|
-
|
|
102
113
|
value_sets
|
|
103
114
|
end
|
|
104
115
|
|
metadata
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: test-patient-generator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Adam Goldstein
|
|
9
|
+
- Andre Quina
|
|
9
10
|
autorequire:
|
|
10
11
|
bindir: bin
|
|
11
12
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
13
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
|
13
14
|
dependencies:
|
|
14
15
|
- !ruby/object:Gem::Dependency
|
|
15
16
|
name: health-data-standards
|
|
@@ -18,7 +19,7 @@ dependencies:
|
|
|
18
19
|
requirements:
|
|
19
20
|
- - ~>
|
|
20
21
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
22
|
+
version: 3.0.1
|
|
22
23
|
type: :runtime
|
|
23
24
|
prerelease: false
|
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -26,7 +27,7 @@ dependencies:
|
|
|
26
27
|
requirements:
|
|
27
28
|
- - ~>
|
|
28
29
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
30
|
+
version: 3.0.1
|
|
30
31
|
- !ruby/object:Gem::Dependency
|
|
31
32
|
name: hquery-patient-api
|
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -34,23 +35,7 @@ dependencies:
|
|
|
34
35
|
requirements:
|
|
35
36
|
- - ~>
|
|
36
37
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 1.0.
|
|
38
|
-
type: :runtime
|
|
39
|
-
prerelease: false
|
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
|
-
requirements:
|
|
43
|
-
- - ~>
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
version: 1.0.0
|
|
46
|
-
- !ruby/object:Gem::Dependency
|
|
47
|
-
name: hqmf-parser
|
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
|
-
requirements:
|
|
51
|
-
- - ~>
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.1.0
|
|
38
|
+
version: 1.0.1
|
|
54
39
|
type: :runtime
|
|
55
40
|
prerelease: false
|
|
56
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -58,7 +43,7 @@ dependencies:
|
|
|
58
43
|
requirements:
|
|
59
44
|
- - ~>
|
|
60
45
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.1
|
|
46
|
+
version: 1.0.1
|
|
62
47
|
- !ruby/object:Gem::Dependency
|
|
63
48
|
name: hqmf2js
|
|
64
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,7 +51,7 @@ dependencies:
|
|
|
66
51
|
requirements:
|
|
67
52
|
- - ~>
|
|
68
53
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 1.
|
|
54
|
+
version: 1.2.0
|
|
70
55
|
type: :runtime
|
|
71
56
|
prerelease: false
|
|
72
57
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -74,23 +59,7 @@ dependencies:
|
|
|
74
59
|
requirements:
|
|
75
60
|
- - ~>
|
|
76
61
|
- !ruby/object:Gem::Version
|
|
77
|
-
version: 1.
|
|
78
|
-
- !ruby/object:Gem::Dependency
|
|
79
|
-
name: qrda_generator
|
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
|
-
requirements:
|
|
83
|
-
- - ~>
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
version: 1.0.1
|
|
86
|
-
type: :runtime
|
|
87
|
-
prerelease: false
|
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
|
-
requirements:
|
|
91
|
-
- - ~>
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: 1.0.1
|
|
62
|
+
version: 1.2.0
|
|
94
63
|
description: A utility to generate patients for unit testing clinical quality measure
|
|
95
64
|
logic. The instructions for generation are guided by HQMF documents and exported
|
|
96
65
|
into various health standards, e.g. C32, CCR.
|