Closed 360dgries closed 1 month ago
I've since made a file with all of the readme code snippets, and compared the outputs. I ran them outside of the fhir_models repo, and compared the outputs. There is no change in behavior except the published version does not have version modules, which is to be expected. Below is the script used that contained all of the readme examples.
require 'fhir_models'
xml = File.read('patient-example.xml')
patient = FHIR.from_contents(xml)
puts patient.to_xml
json = File.read('patient-example.json')
patient = FHIR.from_contents(json)
puts patient.to_json
obs = FHIR::Observation.new(
'status' => 'final',
'code' => {
'coding' => [{ 'system' => 'http://loinc.org', 'code' => '3141-9', 'display' => 'Weight Measured' }],
'text' => 'Weight Measured'
},
'category' => {
'coding' => [{ 'system' => 'http://hl7.org/fhir/observation-category', 'code' => 'vital-signs' }]
},
'subject' => { 'reference' => 'Patient/example' },
'context' => { 'reference' => 'Encounter/example' }
)
obs.valueQuantity = FHIR::Quantity.new(
'value' => 185,
'unit' => 'lbs',
'code' => '[lb_av]',
'system' => 'http://unitsofmeasure.org'
)
patient.each_element do |value, metadata, path|
puts "Info for #{path}:"
puts "- value: #{value}"
puts "- type: #{metadata['type']}"
puts "- cardinality: #{metadata['min']}..#{metadata['max']}"
end
patient.valid? # returns true or false
patient.validate
sd = FHIR::Definitions.resource_definition('Patient')
sd.validates_resource?(patient) # passing in FHIR::Patient
# Validation failed? Get the errors and warnings...
puts sd.errors
puts sd.warnings
Let me know what other testing I should run before this is ready -- Can I force the unit tests to use the installed gem (is that even something we care about/want to do?)
@yunwwang @360dgries
I just pushed up a commit which switches to lazily loading the FHIR packages. This gets the start time back in line with what it was before the multi-version update, and then users who don't need the functionality which requires those packages will never have to load them.
CPU Time to load R4 FHIR models:
v4.3.0
- 0.32s (single version)
07db9c09
- 0.98s (current branch w/o lazy loading)
a437e97a
- 0.35s (current branch w/lazy loading
Removes the following files from the gem package:
examples
directorydefinitions/schema
directoryexpansions.json
of each versionThe built gem has gone from 52MB -> 39 MB. Still a lot, but at least it is a reduction. It also built/installed a LOT faster than it has in the past for me.
I have built the gem, installed it, and ran the unit tests in both models and client. Models unit tests uses
require
instead ofrequire_relative
, so I believe it attempts to use the installed gem before the local repo, but I'm not familiar enough with ruby to confirm this. In any case, both pass, but I'm not sure if there is more that should be done to verify this isn't a breaking change.