Add support for concept person attributes via REST

Description

TLDR, Concept#hydrate() should use ConceptService#getConceptByReference() instead of ConceptService#getConcept().

Explanation:

With O3, OWAs and any other frontend built using the REST API as it’s primary interface with the backend, we need to be able to support storing person attributes with the type of “concept“ and being able to returned the stored values correctly via the REST API.

PersonAttributes work by storing the name of a class that implements the Attributable interface in the PersonAttributeType#format field. A value is stored in the PersonAttribute#value field that is passed to the Attributable objects hydrate() method to get the actual result.

For example, Concept-based PersonAttributes the value stores the concept’s concept_id as a string and then the Concept#hydrate() method converts id string into an integer and fetches it using ConceptService#getConcept().

The issue arises because this machinery only works on the assumption that the attribute value field stores the concept_id. However, the concept_id is (correctly) not exposed via the REST API, so clients using that API have no way of knowing the concept_id. Instead, they usually try to store the the concept UUID, which is the identifier they have, so we need to change the Concept#hydrate() method to handle UUIDs as well as concept_ids.

If we use the ConceptService#getConceptByReference(), we can support not only concept_ids and UUID, but also concept mappings, and, ultimately, it would be preferable to store concept mappings.

Activity

Show:

Wikum Weerakutti November 25, 2024 at 7:41 AM

I am closing this for the platform 2.7.0 release.

joseph ssegujja June 15, 2024 at 7:39 PM
Edited

thank you i still get a NullPointerException even when i follow your explantion. i am working with the pre-excuted data set standardTestDataset.xml in the extented BaseContextSensitiveTest class to populaate the testcase database

concept_reference_source.name=SNOMED-CT

concept_reference_term.code=7345693

 

so this should return “CD4 COUNT” if am to be correct but result.getName(); is throwing the NullPointerException meaning that the result object is null or empty

this is the dammy data below

<concept_reference_source concept_source_id="2" name="SNOMED CT" description="'Systematized Nomenclature of Medicine--Clinical Terms' is a comprehensive clinical terminology" hl7_code="SCT" unique_id="2.16.840.1.113883.6.96" creator="1" date_created="2005-02-24 00:00:00.0" uuid="j3nfjk33-639f-4cb4-961f-1e025b908433" retired="false"/>

<concept_reference_term concept_reference_term_id="4" concept_source_id="2" code="7345693" name="cd4 term2" description="A person's CD4" retired="0" creator="1" date_created="2004-08-12 00:00:00.0" uuid="SNOMED CT-7345693"/>

<concept_reference_map concept_map_id="4" concept_id="5497" concept_reference_term_id="4" concept_map_type_id="2" creator="1" date_created="2004-08-12 00:00:00.0" uuid="4b309478-49d8-11e0-8fed-18a905e044dc"/>

<concept_name concept_id="5497" name="CD4 COUNT" locale="en_GB" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="1847" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="false" uuid="6e77e374-18a1-4ec6-8ed4-4152a5a7d6a1"/>

so iam begining to wonder if the hydrate method accepts mappings, am i a bit confused

Ian Bacher June 14, 2024 at 1:14 PM

Oh! I see. Yeah this gets confusing. So “CIEL:1055“ gets split apart into the following bits:

concept_reference_source.name=CIEL

concept_reference_term.code=1055

The concept_reference_term links directly to the concept_reference_source. Then the concept_reference_term’s concept_reference_term_id property links to the concept_reference_map, which links to the concept. So there’s a few tables that need to be populated.

joseph ssegujja June 14, 2024 at 8:04 AM
Edited

it’s quit confusing for me ,i can locate the souce field that is concept_reference_source but i don’t see the MAP-Name field in the core, only concept_map_type, concept_reference_map (conceptMapId)and concept_reference_term_map now how do i then get the map-Name given the only method associated with is getConceptMappings() which returns ids. please help me understand

thank you

Ian Bacher June 13, 2024 at 6:33 PM

Mappings look like “SOURCE:MAP-NAME“, e.g., “CIEL:1055“, so still a string.

Done

Details

Assignee

Reporter

Complexity

Low

Components

Fix versions

Priority

Created May 31, 2024 at 12:47 PM
Updated November 25, 2024 at 7:41 AM
Resolved November 25, 2024 at 7:41 AM