Skip to content

Commit f162b20

Browse files
author
alex-omophub
committed
Update documentation and enhance functionality
- Added semantic search examples to the README for better user guidance. - Modified user agent in request.R to dynamically reflect package version. - Enhanced SearchResource class to include `concept_class_id` parameter for filtering. - Updated documentation for `SearchResource` to reflect new parameter.
1 parent a21e87e commit f162b20

6 files changed

Lines changed: 32 additions & 5 deletions

File tree

.github/FUNDING.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.Ruserdata
77
*.Rcheck/
88
*.tar.gz
9+
dump.rdb
910

1011
# Build artifacts
1112
docs/

R/request.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ build_request <- function(base_url, api_key, timeout = 30, max_retries = 3,
2020
"Content-Type" = "application/json",
2121
"Accept" = "application/json"
2222
) |>
23-
httr2::req_user_agent("OMOPHub-SDK-R/1.0.0") |>
23+
httr2::req_user_agent(paste0("OMOPHub-SDK-R/", utils::packageVersion("omophub"))) |>
2424
httr2::req_timeout(timeout) |>
2525
httr2::req_throttle(
2626
rate = .omophub_env$rate_limit_capacity / .omophub_env$rate_limit_fill_time

R/search.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ SearchResource <- R6::R6Class(
280280
#' @param vocabulary_ids Filter by vocabulary IDs.
281281
#' @param domain_ids Filter by domain IDs.
282282
#' @param standard_concept Filter by standard concept ('S' or 'C').
283+
#' @param concept_class_id Filter by concept class ID.
283284
#' @param threshold Minimum similarity threshold (0.0-1.0).
284285
#' @param page_size Results per page. Default 100.
285286
#' @param max_pages Maximum pages to fetch. Default Inf.
@@ -290,6 +291,7 @@ SearchResource <- R6::R6Class(
290291
vocabulary_ids = NULL,
291292
domain_ids = NULL,
292293
standard_concept = NULL,
294+
concept_class_id = NULL,
293295
threshold = NULL,
294296
page_size = 100,
295297
max_pages = Inf,
@@ -300,6 +302,7 @@ SearchResource <- R6::R6Class(
300302
vocabulary_ids = vocabulary_ids,
301303
domain_ids = domain_ids,
302304
standard_concept = standard_concept,
305+
concept_class_id = concept_class_id,
303306
threshold = threshold,
304307
page = page,
305308
page_size = size

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,29 @@ mappings <- client$mappings$get(201826, target_vocabulary = "ICD10CM")
8282
ancestors <- client$hierarchy$ancestors(201826, max_levels = 3)
8383
```
8484

85+
## Semantic Search
86+
87+
Use natural language queries to find concepts using neural embeddings:
88+
89+
```r
90+
# Natural language search - understands clinical intent
91+
results <- client$search$semantic("high blood sugar levels")
92+
for (r in results$data$results) {
93+
cat(sprintf("%s (similarity: %.2f)\n", r$concept_name, r$similarity_score))
94+
}
95+
96+
# Filter by vocabulary and set minimum similarity threshold
97+
results <- client$search$semantic(
98+
"heart attack",
99+
vocabulary_ids = "SNOMED",
100+
domain_ids = "Condition",
101+
threshold = 0.5
102+
)
103+
104+
# Fetch all results with auto-pagination
105+
all_results <- client$search$semantic_all("chronic kidney disease", page_size = 50)
106+
```
107+
85108
## Use Cases
86109

87110
### ETL & Data Pipelines
@@ -169,7 +192,7 @@ concepts_df %>%
169192
| Resource | Description | Key Methods |
170193
|----------|-------------|-------------|
171194
| `concepts` | Concept lookup and batch operations | `get()`, `get_by_code()`, `batch()`, `suggest()` |
172-
| `search` | Full-text and semantic search | `basic()`, `advanced()`, `basic_all()` |
195+
| `search` | Full-text and semantic search | `basic()`, `advanced()`, `semantic()`, `semantic_all()`, `basic_all()` |
173196
| `hierarchy` | Navigate concept relationships | `ancestors()`, `descendants()` |
174197
| `mappings` | Cross-vocabulary mappings | `get()`, `map()` |
175198
| `vocabularies` | Vocabulary metadata | `list()`, `get()`, `stats()` |

man/SearchResource.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)