Hi @openmsf,
Yes you can achieve all that you describe with Data Filter. Data Filter allows to sneak in Hibernate filters based on pretty much whatever criteria you may come up with.
Your first use case is: I want certain obs to only be visible to certain roles. The headline is totally ok and that’s exactly the kind of thing that we do with Data Filter in one of our implementations. The challenge is not on the technical level of what Data Filter can or cannot do, it lies on the business analysis of your use case. Have you got a clear criterion to implement? The criterion here is about knowing why a certain obs needs to be filtered, as in which obs are the subjects to filtering.
The second use case is actually the same as the first one: you want certain obs (HIV-related ones) to only be visible to certain roles. And it will lead you to the same kind of business analysis: how do we know, looking at any obs in the system, that it is an HIV obs?
Filtering strategies can possibly be highly implementation-specific, this is why I stress all the above. Let’s take a few examples on the HIV obs that are all equally valid depending on your exact use case:
- An HIV obs can be identified as such because it was recorded during a type of encounter dedicated to HIV care.
- An HIV obs can be identified as such because it was recorded at a location dedicated to HIV care.
- An HIV obs can be identified as such because it is defined by an HIV concept. This pushes the question further: how do we know that a given concept is an HIV concept? There are multiple possible answers: because it is mapped to a specific HIV source, or because it belongs to a specific HIV set, … etc.
- …
I guess a couple of conclusions:
- I would be surprised that you find business rules that cannot be implemented through an Hibernate filter. In short: Data Filter will work.
- In depth business analysis is needed to properly define the criteria that nail your use cases.
- Data Filter is primarily used in situations where data protection is crucial. The HIV-related data use case matches this for sure.
- Data Filter will only work if the Java layer of your application uses Hibernate.
If you are a dev you’ll ask me: why do you mention the last point, of course OpenMRS uses Hibernate! My short answer to that is: yes indeed, but beware of custom modules (I’m saying that because you use Bahmni). See for instance this thread.