responses

These classes are Pydantic models for the response format for the suggestions API. The main class is ConceptSuggestionResponse, composed of a list of Suggestions, and SuggestionsMetaData describing the pipeline.

Suggestion

class Suggestion(BaseModel):
    concept_name: str
    concept_id: int
    domain_id: str
    vocabulary_id: str
    concept_class_id: str
    standard_concept: Optional[str]
    invalid_reason: Optional[str]
    ranks: Optional[Dict[str, int]]
    scores: Optional[Dict[str, float]]

A model describing a single suggestion from a lettuce search. Most of the fields are OMOP concept table fields, but ranks and scores describe how well the suggestions match the request.

Attributes

FieldsTypeDescription
concept_namestrThe concept_name field from the OMOP concept table
concept_idintThe concept_id field from the OMOP concept table
domain_idstrThe domain_id field from the OMOP concept table
vocabulary_idstrThe vocabulary_id field from the OMOP concept table
concept_class_idstrThe concept_class_id field from the OMOP concept table
standard_conceptOptional[str]The standard_concept field from the OMOP concept table. The field is nullable, so is Optional
invalid_reasonOptional[str]The invalid_reason field from the OMOP concept table. The field is nullable, so is Optional
ranksOptional[Dict[str, int]]The ranks of the suggestion, as determined by some algorithm used. The keys of the dict describe the algorithms, the values are the rank.
scoreOptional[Dict[str, int]]The scores of the suggestion, as determined by some algorithm used. The keys of the dict describe the algorithms, the values are the score.

SuggestionsMetaData

class SuggestionsMetaData(BaseModel):
    assistant: str = "Lettuce"
    version: str = "0.1.0"
    pipeline: Optional[str] = None

A model describing the process used to get suggestions from a lettuce search. The fields are general so that if applications use lettuce and other assistants, the provenance can be tracked.

Attributes

FieldsTypeDescription
assistantstrA description of the assistant used to make the suggestions. Defaults to “Lettuce” for obvious reasons
versionstrThe version of the application used to make the suggestions. There’s probably a clever way of reading the version at run time
pipelineOptional[str]A description of the pipeline within the application used to suggest concepts

ConceptSuggestionResponse

class ConceptSuggestionResponse(BaseModel):
    recommendations: List[Suggestion]
    metadata: SuggestionsMetaData = Field(default_factory=SuggestionsMetaData)

A model to bundle Suggestions and their associated SuggestionsMetaData into a single response.

Attributes

FieldsTypeDescription
recommendationsList[Suggestion]A list of Suggestions made by lettuce
metadataSuggestionsMetaDataA description of the process used to generate suggestions