Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-2832 Add multi-version support #113

Merged
merged 85 commits into from
Sep 25, 2024
Merged

FI-2832 Add multi-version support #113

merged 85 commits into from
Sep 25, 2024

Conversation

yunwwang
Copy link
Contributor

@yunwwang yunwwang commented Jul 3, 2024

Summary

This PR add support to generate FHIR models for mulitple FHIR versions.

There is no update for fhir_client at this time. As we discussed, we will redeign fhir_client later.

Change Log

  • Move several generator files to generator folder
  • Move generated files to generated folder
  • Add ig folder for NPM package
  • Change task.rake to use the new generator class in generator folder.

@yunwwang yunwwang requested a review from Jammjammjamm August 30, 2024 13:22
Rakefile Outdated Show resolved Hide resolved
lib/fhir_models/bootstrap/hashable.rb Outdated Show resolved Hide resolved
end

def self.module_version
FHIR.module_version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand these methods. They don't look like they will return the correct version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was trying to accomplish here was deferring the version to the FHIR module whenever methods are called through FHIR instead of through a model. i.e., when making a new resource from a json/xml, we can call FHIR::Account.new(*payload*) and the version will be inferred from the Account class. But if you run FHIR::Json.from_json (as we do, at least in our unit tests), it has no class to find the version from. The FHIR module defaults to R4 and these just retrieve that.

That being said, I'm sure there is a cleaner way to model this behavior. If there is a cleaner inheritance structure that is preferred, I can make that change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this means FHIR.from_json will always create an R4 resource and we don't have a way to do something like FHIR::R4B.from_json to create an R4B resource.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I've made the changes to allow what you are proposing, but the inheritance looks a little funky. I would appreciate a closer look at r4/fhir_ext/json.rb to make sure that seems alright, especially the set up of FHIR::Json to default to r4.

elsif FHIR::PRIMITIVES.include?(datatype)
primitive_meta = FHIR::PRIMITIVES[datatype]
elsif module_version::PRIMITIVES.include?(datatype)
primitive_meta = module_version::PRIMITIVES[datatype]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 219 needs updating also, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently primitive? is not versioned and just under the FHIR module. I think it makes sense to make it a versioned method in case primitives change from version to version.

So, it doesn't currently need an update, but we can change primitive to be versioned, and then it would need to be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance, I don't think primitive? supports all of the types in PRIMITIVES.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it was missing canonical, uuid, and url. each case has been added now. I'm still wondering if maybe we want this to be a versioned method because that might change from version to version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth spending time on now. If it's an issue it can be addressed later.

lib/fhir_models/bootstrap/xml.rb Outdated Show resolved Hide resolved
lib/fhir_models/r4/fhir_ext/element_definition.rb Outdated Show resolved Hide resolved
lib/fhir_models/r4/fhir_ext/structure_definition.rb Outdated Show resolved Hide resolved
lib/fhir_models/tasks/tasks.rake Outdated Show resolved Hide resolved
new_file.txt Outdated Show resolved Hide resolved
test/test_helper.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@Jammjammjamm Jammjammjamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments were collapsed, and I don't think they were addressed.

@Jammjammjamm
Copy link
Contributor

There are still some comments that were collapsed and not addressed.

Screenshot 2024-09-24 at 10 02 07 AM

@360dgries 360dgries merged commit 00acb83 into master Sep 25, 2024
3 checks passed
@360dgries 360dgries deleted the FI-2832-version-support branch September 25, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants