IHTSDO / snomed-scg-parser

An Open Source Java library for parsing SNOMED Post-Coordinated expressions written in SNOMED Compositional Grammar.
Other
7 stars 5 forks source link

Feature request: get the term or description #6

Open tvinke opened 4 years ago

tvinke commented 4 years ago

Hi! Thank you for a great library, which helps me parse some complex queries.

For my use case I also would like to retrieve any available terms from the expression.

E.g. a random example from the unit tests shows how to get the codes from the concept and the attributes (like 83152002, 405815000, 122456005) but how can I access the terms/descriptions such as "oophorectomy", "procedure device" and "laser device"? I don't see any getter for this on any of the resulting structure.

Example:

    @Test
    public void testExpressionWithAttribute() {
    String scg = "83152002 |oophorectomy|: 405815000|procedure device| = 122456005 |laser device|";
    Expression expression = builder.createQuery(scg);
    ...
    assertTrue(expression.getFocusConcepts().contains("83152002"));
    ...
    Attribute attribute = expression.getAttributes().get(0);
    assertEquals("405815000", attribute.getAttributeId());
    assertEquals("122456005", attribute.getAttributeValueId());
    }

If this is not yet implemented, I think it would be very valuable to have access to any of these descriptions i.e. for every focus concept and any refinement.

Would it be possible to add this as a new feature?

kaicode commented 4 years ago

Hi @tvinke thanks for getting in touch and sorry to not have responded until now.

The term between the pipe characters is just to make these expressions more human readable and is not intended to be parsed, validated to or used in any way by machines. This is why getters for the terms have not been implemented.

Regrettably I've not aware of anyone else who would find this useful so we are not able to invest time developing this enhancement. I've labeled the issue as "good first issue" to encourage anyone in the community to contribute this feature. I hope you can understand my position and good luck in your project.

Kind regards, Kai Kewley