-
Notifications
You must be signed in to change notification settings - Fork 213
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
Basic custom helper functions in the Resource classes #14
Comments
Yes, this is definitely desired and should live in the Python client (of course, nothing stops you from creating your own one ;) ). Thing is, all model classes are auto-generated from the spec using fhir-parser, hence it's a problem to create these methods on the resource classes themselves. In the Swift library we use class extensions for this purpose, Python doesn't have those, though. How do you think this could be solved? |
Yeah, I'm aware of the relationship between the fhir-parser and the client-py. I believe it would be nice to have what I'm suggesting live outside the fhir-parser process -- what do you think? Can you show me an example the class extensions in Swift? I'm not familiar with the language but I could probably get a gist of it if I see it. Does that live outside the fhir-parser process? How Airflow does itLast week I used Airflow's plugin framework. The user specifies a plugin directory, and the code from the folder is dynamically imported and plugged into the proper places. For example, I can make an extra Flask Admin View (a pretty standard Flask thing to do) and plug it to Airflow's Flask Admin framework, which provides menu links to the View and means to render it with a custom URL. Here's a rough sketch:
Note: I'm not saying we should do it the Airflow way, just adding it as an example in. It depends on what kind of behavior to evoke. Possible behaviors:
Regardless of the behaviors, it sounds to me like the auto-generated model classes may need some dynamic loading aspect to decouple the process of regenerating the FHIR classes from the process of developing non-fhir-schema functionality. |
Swift allows to extend classes, adding methods to classes that are globally available without the need to create a subclass. Here's an example of how our Swift client adds reference resolving to the generated I haven't used Airflow, but have used Yapsy which seems to function similarly. What I'm missing is how these plugins would enable to extend the classes, how would I be able to add the method/property |
I suppose once the standard becomes mostly non-volatile, this issue becomes less complex. From what I gather, you are asking about monkey patching. EDIT: An example.
Sounds like monkey patching a property gets into somewhat uncomfortable territory. Still possible, I think:
|
I see that the way of getting the human name of a patient is handled in the FHIRClient class.
To me, this could naturally be a method of the Patient object, like this:
I'm interested in creating more functions like this, say what is the base title of on Observation object, which has no natural FHIR top-level field to represent it. For example, to me, the "title" of this resource is "Respiratory Rate" in the
observation.code.text
field (which is actually different for this resource, where I would say the "title" is "Weight Measured" in theobservation.code.coding.display
field).Is this need very particular to how I'm applying it? How should I proceed?
The text was updated successfully, but these errors were encountered: