wardle / hermes

A library and microservice implementing the health and care terminology SNOMED CT with support for cross-maps, inference, fast full-text search, autocompletion, compositional grammar and the expression constraint language.
Eclipse Public License 2.0
177 stars 21 forks source link

Excluding Codes #36

Closed ce-cox closed 2 years ago

ce-cox commented 2 years ago

Hi Mark I have been told that I need to exclude 3 codes and their children, eg 410663007 <- 246061005 from entering the patient record. Ideally this would be done when loading from TRUD, but alternatively is there a way to delete a conceptID and all children? If not could you exclude codes in a config file for the server or least preferable when searching ?

wardle commented 2 years ago

That's easy. Just constrain your search with an ECL expression. For this case, you'd add a MINUS clause and the concept. You can use << to specify a concept AND its children.

wardle commented 2 years ago

To be clear, not importing certain items from the distribution(s) would be a mistake. You are much better simply excluding those from your search. I've just checked what those concepts refer to, and given that they reflect concepts reflecting the SNOMED metadata model itself, I suspect that you aren't using search correctly. I NEVER use search without some kind of constraint. For example, I might autocomplete on a type of problem or diagnosis, or on a type of country of birth, or on a medication, or on a procedure, etc. You almost always want to specify a search constraint. So don't remove what you don't need, simply specify what you do need!

ce-cox commented 2 years ago

Hi Mark My best effort so far is constraint=900000000000441003 MINUS (<< 408739003 AND << 900000000000441003 AND << 410663007) but it returns a match? as does 246061005 MINUS (<< 408739003 AND << 900000000000441003 AND << 410663007) I tried the not = operator but it doesn't parse 246061005 != (<< 408739003 AND << 900000000000441003 AND << 410663007)

wardle commented 2 years ago

Those don't look right. What are you trying to do?

It is very unlikely you will want to search the whole hierarchy.

wardle commented 2 years ago

See the ECL documentation and see the examples.

ce-cox commented 2 years ago

It would be good to exclude by module as they share the same one but sadly this fails as well 410663007 {{C moduleId != 900000000000012004}}

wardle commented 2 years ago

The implementation of concept filters is on the to-do list, but is trivial. I'm still not quite sure what you're trying to achieve however, as it sounds like you're making it more complicated than you need it to be. What are you searching for?

ce-cox commented 2 years ago

I have been told that the following codes must not be returned ( or their children ) when a search is run 410663007 | Concept history attribute (attribute) | 408739003 | Unapproved attribute (attribute) | 900000000000441003 | SNOMED CT Model Component (metadata) |

wardle commented 2 years ago

A search for what?

ce-cox commented 2 years ago

any code (conceptID) or description

wardle commented 2 years ago

As I said, we don't search for any code or description! You'll end up with a mess!

But if you insist,

<<138875005 gives you all concepts

<< 138875005 MINUS << 900000000000441003 will constrain a search to all concepts except those descending from the metadata code.

Again, you do not want to search the whole hierarchy.

wardle commented 2 years ago

SNOMED CT is a complex hierarchical terminology. If you let users search across the whole index in a user interface, you'll end up with a mess. You constrain your searches so that the search makes sense in context. e.g. an anatomical structure, a pharmaceutical product, a diagnosis, an ethnicity, a country of birth, an occupation.

ce-cox commented 2 years ago

We currently let a user search for a code which returns the description ( not preferred ) eg ../api/ct/266920004 returns {"ctActive":true,"ctCode":"266920004","ctDescription":"Occasional smoker"} However ../api/ct/410663007 ( or any of the children ) returns nothing With your system I will be adding the 'MINUS << 900000000000441003' part on the end so that the 3 codes can not be found or used. Many thanks for the assistance