Modules
Copyright 2023 Bell Eapen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
BaseAgent
¶
Source code in src/dhti_elixir_base/agent.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
AgentInput
¶
Bases: BaseModel
Chat history with the bot.
Source code in src/dhti_elixir_base/agent.py
33 34 35 36 |
|
get_langgraph_agent_executor()
¶
Get the agent executor.
Source code in src/dhti_elixir_base/agent.py
158 159 160 161 162 163 164 165 166 167 168 |
|
get_langgraph_mcp_agent()
async
¶
Get the agent executor for async execution.
Source code in src/dhti_elixir_base/agent.py
204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
get_langgraph_mcp_tools(session_name='dhti')
async
¶
Get the agent executor for async execution with session.
Source code in src/dhti_elixir_base/agent.py
218 219 220 221 222 223 224 |
|
langgraph_agent()
¶
Create an agent.
Source code in src/dhti_elixir_base/agent.py
149 150 151 152 153 154 155 156 |
|
Copyright 2025 Bell Eapen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
BaseChain
¶
Source code in src/dhti_elixir_base/chain.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
ChainInput
¶
Bases: BaseModel
Input model for BaseChain.
Attributes:
Name | Type | Description |
---|---|---|
input |
str | CDSHookRequest
|
The input string or CDSHookRequest object for the chain. |
Source code in src/dhti_elixir_base/chain.py
35 36 37 38 39 40 41 42 43 44 |
|
generate_llm_config()
¶
Generate the configuration schema for the LLM function call.
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the function schema for the LLM, including name, description, and parameters. |
Source code in src/dhti_elixir_base/chain.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
get_chain_as_langchain_tool()
¶
Convert the chain to a LangChain StructuredTool.
Returns:
Name | Type | Description |
---|---|---|
StructuredTool |
An instance of LangChain StructuredTool wrapping the chain. |
Source code in src/dhti_elixir_base/chain.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
get_chain_as_mcp_tool()
¶
Convert the chain to an MCP tool using the FastMCP adapter.
Returns:
Name | Type | Description |
---|---|---|
Any |
An MCP tool instance wrapping the chain. |
Source code in src/dhti_elixir_base/chain.py
223 224 225 226 227 228 229 230 231 232 233 234 |
|
Copyright 2024 Bell Eapen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
BaseLLM
¶
Bases: LLM
Source code in src/dhti_elixir_base/llm.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
BaseMCPServer
¶
Bases: FastMCP
Base class for MCP servers, extending FastMCP for custom functionality.
Source code in src/dhti_elixir_base/mcp.py
4 5 6 7 8 9 10 11 12 13 14 |
|
name
property
¶
Return the name of this MCP server instance.
BaseDhtiModel
¶
Bases: ABC
A model class to lead the model and tokenizer
Source code in src/dhti_elixir_base/model.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
BaseServer
¶
Bases: ABC
A server class to load the model and tokenizer
Source code in src/dhti_elixir_base/server.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
get_schema()
¶
Get the request schema
Source code in src/dhti_elixir_base/server.py
48 49 50 |
|
health_check()
¶
Health check endpoint
Source code in src/dhti_elixir_base/server.py
43 44 45 46 |
|
BaseSpace
¶
Bases: Agent
Source code in src/dhti_elixir_base/space.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
say(content, current_patient_context='')
¶
Search for a patient in the FHIR database.
Source code in src/dhti_elixir_base/space.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Pydantic Model for CDS Hook Card
Example:
{ "summary": "Patient is at high risk for opioid overdose.", "detail": "According to CDC guidelines, the patient's opioid dosage should be tapered to less than 50 MME. Link to CDC Guideline", "indicator": "warning", "source": { "label": "CDC Opioid Prescribing Guidelines", "url": "https://www.cdc.gov/drugoverdose/prescribing/guidelines.html", "icon": "https://example.org/img/cdc-icon.png" }, "links": [ { "label": "View MME Conversion Table", "url": "https://www.cdc.gov/drugoverdose/prescribing/mme.html" } ] }
CDSHookCard
¶
Bases: BaseModel
CDS Hook Card Model
Source code in src/dhti_elixir_base/cds_hook/card.py
38 39 40 41 42 43 44 |
|
CDSHookCardLink
¶
Bases: BaseModel
Link associated with the CDS Hook Card
Source code in src/dhti_elixir_base/cds_hook/card.py
33 34 35 36 |
|
CDSHookCardSource
¶
Bases: BaseModel
Source of the CDS Hook Card
Source code in src/dhti_elixir_base/cds_hook/card.py
27 28 29 30 31 |
|
Copyright 2025 Bell Eapen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
add_card(output, input=[])
¶
Add a CDSHookCard to the output list.
Source code in src/dhti_elixir_base/cds_hook/generate_cards.py
20 21 22 23 24 25 26 27 28 |
|
get_card(output)
¶
Get a CDSHookCard as a dictionary.
Source code in src/dhti_elixir_base/cds_hook/generate_cards.py
30 31 32 33 34 35 36 37 |
|
Copyright 2025 Bell Eapen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
CDS Hook Request Model
Pydantic Model for CDS Hook Request
Example: { "hookInstance": "d1577c69-dfbe-44ad-ba6d-3e05e953b2ea", "fhirServer": "https://example.com/fhir", "fhirAuthorization": { ... }, "hook": "patient-view", "context": { ... }, "prefetch": { ... } }
CDSHookRequest
¶
Bases: BaseModel
CDS Hook Request Model
Source code in src/dhti_elixir_base/cds_hook/request.py
19 20 21 22 23 24 25 26 |
|
Pydantic models for CDS Hook Service
Example: { "services": [ { "hook": "patient-view", "name": "Static CDS Service Example", "description": "An example of a CDS Service that returns a card with SMART app recommendations.", "id": "static-patient-view", "prefetch": { "patientToGreet": "Patient/{{context.patientId}}" } } ] }
CDSHookService
¶
Bases: BaseModel
CDS Hook Service Model
Source code in src/dhti_elixir_base/cds_hook/service.py
23 24 25 26 27 28 29 |
|
CDSHookServicesResponse
¶
Bases: BaseModel
Response model containing a list of CDS Hook Services
Source code in src/dhti_elixir_base/cds_hook/service.py
31 32 33 |
|
DhtiFhirSearch
¶
Source code in src/dhti_elixir_base/fhir/fhir_search.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
get_allergy_intolerances_for_patient(input={}, fhirpath=None)
¶
Fetch all AllergyIntolerance resources related to a specific patient. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined AllergyIntolerance resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
get_conditions_for_patient(input={}, fhirpath=None)
¶
Fetch all Condition resources related to a specific patient. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined Condition resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
get_everything_for_patient(input={}, fhirpath=None)
¶
Fetch all resources related to a specific patient using the $everything operation. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
get_medication_requests_for_patient(input={}, fhirpath=None)
¶
Fetch all MedicationRequest resources related to a specific patient. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined MedicationRequest resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
get_observations_for_patient(input={}, fhirpath=None)
¶
Fetch all Observation resources related to a specific patient. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined Observation resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
get_procedures_for_patient(input={}, fhirpath=None)
¶
Fetch all Procedure resources related to a specific patient. Args: input (dict or str): Input containing patient ID or the patient ID itself. fhirpath (str, optional): FHIRPath expression to apply to the results. Returns: dict: Combined Procedure resources related to the patient.
Source code in src/dhti_elixir_base/fhir/fhir_search.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
search(resource_type='Patient', search_parameters={}, fhirpath=None)
¶
Search the FHIR server and return the combined results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_type
|
str
|
FHIR resource type to search (e.g., "Patient"). |
'Patient'
|
search_parameters
|
dict
|
Query parameters per FHIR spec; _count is auto-set to the configured page size if absent. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Combined search results from the FHIR server. |
Source code in src/dhti_elixir_base/fhir/fhir_search.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
SmartOnFhirSearch
¶
SMART-on-FHIR backed search helper mirroring DhtiFhirSearch API.
Uses fhirclient's resource model search pattern, e.g.:
settings = { 'app_id': 'my_web_app', 'api_base': 'https://r4.smarthealthit.org' }
smart = client.FHIRClient(settings=settings)
patient = Patient.read('<id>', smart.server)
Each method returns raw JSON like DhtiFhirSearch and optionally applies a FHIRPath expression via fhirpathpy.evaluate.
Source code in src/dhti_elixir_base/fhir/smart_on_fhir.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
get_everything_for_patient(input={}, fhirpath=None)
¶
Fetch resources related to a patient using $everything operation.
Returns JSON Bundle like DhtiFhirSearch.
Source code in src/dhti_elixir_base/fhir/smart_on_fhir.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
search(resource_type='Patient', search_parameters=None, fhirpath=None)
¶
Generic search for any resource type.
Tries to resolve the appropriate fhirclient model class and perform a model-based search; if not possible, falls back to an HTTP GET.
Source code in src/dhti_elixir_base/fhir/smart_on_fhir.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|