Git Product home page Git Product logo

Comments (5)

nazrulworld avatar nazrulworld commented on June 8, 2024

@simonvadee thank you so much for your common interest with me! :)
I am always willing to cooperate with developing the new provider.

from fhirpath.

simonvadee avatar simonvadee commented on June 8, 2024

Great news ! I have many questions:

  • What is your tool to generate the elastic mappings from StructureDefinition ?
  • Do you have a script to PUT the mappings in elasticsearch ?
  • I don't understand how I am supposed to override the calculate_field_index_name method of the ElasticsearchEngine class, could you add a little more context ?
  • The get_index_name function of the ElasticsearchEngine class does not take a resource_name as parameter, however I think it's pretty common to have one index per FHIR resource, do I need to override the _execute method to pass the resource name as param ?
  • Why does the elasticsearch term query that is built by fhirpath contains the name of the resource ? here's an exemple:
class MyElasticSearchEngine(BaseEngine):
    def calculate_field_index_name(self, resource_type):
        #return ???
        return None
 
    def current_url(self):
        return yarl.URL("https://www.my.url.org/")

    def get_index_name(self):
        return "name_of_the_resource_index"

    def get_mapping(self, resource_type=None, index_config=None):
        return <elastic_mapping_for_my_resource>

conn = create_connexion(...)
engine = MyElasticSearchEngine(FHIR_VERSION.R4, lambda x: connection, dialect_factory)
search_context = SearchContext(engine, "Organization")
params = (
    ("active", "true"),
)
fhir_search = Search(search_context, params=params)
bundle = fhir_search()
print(bundle)

I get an elastic query that looks like this:

{
    "query": {
        "bool": {
            "filter": [
                {
                    "term": {
                        "Organization.active": true
                    }
                },
                {
                    "term": {
                        "Organization.resourceType": "Organization"
                    }
                }
            ]
        }
    },
    "_source": {
        "includes": [
            "Organization"
        ]
    }
}

But what I actually want is:

{
    "query": {
        "bool": {
            "filter": [
                {
                    "term": {
                        "active": true
                    }
                },
                {
                    "match": { // the "term" query uses the tokenizer which applies lowercase to strings so I must use "match" here
                        "resourceType": "Organization"
                    }
                }
            ]
        }
    },
    "_source": {
        "includes": [
            "*"
        ]
    }
}

Is that where the calculate_field_index_name method comes into play ?

  • Right now I had to fork the library to modify its behavior according to my needs but I'd like to communicate with you to make sure that I'm aligned with the expected design of a provider (I don't want to maintain a fork obviously)
  • Also I have an other issue but not with the code itself, I will need to use this project in an Apache2 licensed project and I can't afford changing my license to GPL3, but maybe it's not entirely up to you and we need to talk about this more. We are here to contribute :)

I know it's a lot and if you are open to discuss it in depth, our slack is open! Come @ me there

from fhirpath.

nazrulworld avatar nazrulworld commented on June 8, 2024

@simonvadee thanks for your query, I will back to you as soon as possible :)

from fhirpath.

nazrulworld avatar nazrulworld commented on June 8, 2024

My Answers are here

  1. https://github.com/nazrulworld/fhirpath_helpers is used to generate ES Mappings, but it's not from StructureDefinition instead of FHIR SearchParameter definitions and for testing purpose. You are welcome to enrich the tool.

  2. There https://github.com/nazrulworld/fhirpath/blob/master/tests/_utils.py#L128 you will find an example but don't have any script. If you if look at each provider, each framework has a mechanism to do that.

  3. https://pypi.org/project/collective.fhirpath/ and https://pypi.org/project/fhirpath-guillotina/ are coming (actually from each framework) with idea that single index is used for the whole database (on the other words, all FHIR resources are indexes under single ES index). If you think about ORM and some tables like Patient, Hospital so each table has a special field that contains fhir json resource and this field name is becoming mapping name of the es index. for Patient:: patient_resource. Using this technique, when we search for specific resource @fhir/Patient? some query, it brings correct values, also you see an auto term query for resourceType.

  4. This is a valid question, I agree with the concept of separate index names for each Resource, but in no.3 I explain the current situation. I would like you to create a separate issue for this feature.

  5. I think we already answer in no.3

  6. license issue, we can discuss later, I am fully open.

Some more example
https://github.com/nazrulworld/fhirpath_guillotina/blob/master/fhirpath_guillotina/engine.py#L92
https://github.com/nazrulworld/fhirpath_guillotina/blob/master/fhirpath_guillotina/engine.py#L153

Anyway, are you using any web framework?

from fhirpath.

simonvadee avatar simonvadee commented on June 8, 2024

Thank you for taking the time to answer :).

  1. I found the utilities provided by fhirpath_helpers and successfully used them! My team and I are already building python tooling around FHIR so we can definitely find some time to enrich this tool (since we actually need it).

  2. It makes more sense now that I see how you build the elastic index, thanks.

  3. I understand, this is the part I had to update in my fork of fhirpath. I had to do this because I have a service that listens to the logs of a mongoDB instance and propagates CRUD operations in an elasticsearch index that match de name of the mongoDB collection. For instance, when I insert a document in the Patient collection (the equivalent of a table in mongodb), my replicator service creates a new document in the index Patient in ES.
    Right nown, the changes that I had to make are not a generic and clean way to handle this kind of data modeling but I intend to improve that (and then I'll make a pull request).

  4. ok, will do!

  5. yes

  6. nice to hear! we can talk about this later

I am using a web framework indeed, I use Flask

from fhirpath.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.