-
Notifications
You must be signed in to change notification settings - Fork 3
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
Convert FSH to FHIR and back using right click context menu in the explorer view #97
Conversation
@hvamstel - Thank you for the very cool PR. I am reviewing it now and will provide more feedback later. Regarding the broken CI check -- if you run |
@cmoesel Thanks for looking into it. I did run Your suggestion of |
Hi @hvamstel. Thanks again for this contribution. It's a cool idea and I can see its usefulness. In my review of it, I did find a few limitations/questions I'd like to discuss:
I'm interested in your thoughts about these. |
Hi Chris, My main goal was to quickly convert a single file locally. Specifically, I wanted to convert a FHIR resource to FSH to understand how FHIR is represented in FSH and to create a good starting point for our FSH-based resource. Another goal was to convert from FSH to FHIR to demonstrate the equivalence between the two, proving that moving from FHIR to FSH doesn't result in any semantic changes. This ensures that existing FHIR projects can be safely converted to FSH. 1+2) The method(s) that I found in the gofsh and sushi packages allowed only the conversion of a single stand-alone file as far as I could see. If there are other methods, then it would be nice to have the conversion in the context of the sushi project.
5,6,7) Are good ideas and should be in currently :) |
Hi Hans, Thanks for the response and the updates! The implementation of 5, 6, and 7 came out very nicely. I really like the way that works now. I hope you do too! As for 1, the SUSHI API takes in a string that can have any number of FSH definitions in it. So, in theory, you could concatenate all of the FSH files in the project into one big FSH string and send it through. But... you will get an array of all the JSONs back -- and the tricky bit would be figuring out which ones pertain to the original file you invoked "FSH to FHIR" on. Maybe we should update the return object in the API to also include something similar to the I'm also realizing now that by adding all the files, the process could take a good bit longer to run - so that's a tradeoff to consider. I wonder if we could extend the SUSHI API to also add a mode where you specify a primary FSH file and have it only compile the things needed to complete that file. That could speed things up -- but... I'm not sure where that would fit in our priorities. As for 2, the GoFSH API takes an array of JSONs as input -- so you could pass in all the JSONs found in the project. Similar to above, however, the tricky bit would be displaying only the FSH that is relevant to the JSON file originally selected. You might be able to figure it out using the Regarding 3, here is the code we currently have for finding a sushi-config and grabbing its fhirVersion and dependencies. It just grabs the first one it finds, but you could look at the list of all the ones it finds in the workspace and figure out which one is the closest to the FSH file and use that. Current code starts here (click through to get to all the code): vscode-fsh/src/FshCompletionProvider.ts Line 358 in 9f17be9
Regarding 4, I was hoping it might work if you made fsh-sushi and gofsh |
… in one FSH file + update to latest sushi..
Hi Chris I noticed indeed that you can have multiple resources in one FSH file. Currently I open multiple previews with Json resource in each. This seems to work quite nicely with the caveat that it can be quite a lot of preview tabs when there are a lot of resources described in one FSH file. I also rewrote the configuration part and now it will read from the sushi config. It will search for the sushi-config that is part of the same sushi project by matching the directory path. As there can be more than one sushi projects in the workspace as is in our situation. For this I reused some of the code that you mentioned and there are some refactoring opportunities. Having the conversion in the context of the complete sushi project would be nice. The issue I see there is that concatenating all the resources together and retrieving the needed resources from the result can be complex and therefore error prone. Adopting the API of sushi and gofsh as you mentioned would help here. Concatenating the FSH files will increase the time of the conversion having some kind of progress of activity indication could help. I was thinking of a panel in the status bar informing the user of a conversion in progress. Happy to know your thoughts and ideas on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to review this but noticed that some of the changes you referred to (regarding opening multiple tabs, extracting information from sushi-config, etc) are not pushed up to this PR. Did you mean to push them up? Or were you waiting for further discussion?
I agree that supporting FSH to FHIR JSON and FHIR to FSH w/ full context would be easiest with the API changes I described -- but I'm not sure if/when we will be able to implement those API changes. Perhaps we should ask the FSH community (on Zulip) if they would support us releasing this feature with the single-file-only limitation for now. What do you think?
…tput information from conversion.
Hi Chris, Indeed, I forget to push to origin sorry for that. I also managed to implement running the FSH to JSON conversion in the project context and only show the converted resources that where requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, Hans. This is fantastic! I love it! I think people will really like this new feature!
I've provided some additional comments and suggestions, but they are mostly small and easy to do. Please let me know if you disagree with any of the suggestions I have made.
The one last thing I would like to ask you about is unit tests. As a general rule, we like to include unit tests for any new features that we introduce. This helps to ensure that as the extension evolves, we do not accidentally break anything. I know you have already invested a lot of time in this, but would you have a little more time to create a few basic unit tests to validate the core functionality? If not, then I will check to see if anyone here is able to add unit tests for you.
Thank you again for contributing this excellent feature!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvamstel This is looking very good! It looks like there are a few merge conflicts that need to be resolved, but we're getting very close! Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again, @hvamstel. I took this for one more round of testing and made a final request. I felt bad about asking for another change, so I basically implemented it for you (although I'm sure you could have done it just as well, if not better). If you like it, please integrate it and then I'll approve and ask one more team member to review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvamstel - Thank you again for this fantastic contribution! It looks great to me!
@mint-thompson - Could you provide a 2nd review before we merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all of your work on this extension! The FSH to FHIR mostly worked fine for me, but I encountered a problem with FSH to FHIR. I've provided details in some additional comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks good to me!
@mint-thompson - thank you for your review and feedback. I think this is ready for your re-review.
Can this pr be merged? I do not have the rights for that :) |
Yes! I apologize. I meant to do it yesterday and somehow forgot. I will merge it now. Thank you, @hvamstel, for this excellent PR. It's a really cool feature and I think people will love it! |
@hvamstel - We've just published a new release of VS Code with your new feature! Thank you again! |
Description:
Convert a JSON file to FSH by right click on the file in the explorer view and select the convert option.
Convert a FSH file to JSON by right click on the file in the explorer view and select the convert option.
Testing Instructions:
Right click on a file and convert and then inspect the result.
Related Issue:
Convert FSH to FHIR and back using right click context menu in the explorer view #96