Created
December 22, 2025 15:01
-
-
Save gavinsharp/74f52a39abd48fbe3399c6d4e9fb986f to your computer and use it in GitHub Desktop.
lang2fhir and create TS helper example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { PhenoMLClient, phenoml } from "phenoml"; | |
| const client = new PhenoMLClient({ | |
| username: process.env.PHENOML_USERNAME || "your_username", | |
| password: process.env.PHENOML_PASSWORD || "your_password", | |
| baseUrl: process.env.PHENOML_BASE_URL || "https://api.phenoml.com", | |
| }); | |
| type Resource = phenoml.tools.Lang2FhirAndCreateRequest["resource"]; | |
| async function createFhirResource( | |
| text: string, | |
| resource: Resource = "auto", // must be one of the supported resource types; no exported values to use here | |
| provider?: string | |
| ): Promise<phenoml.tools.Lang2FhirAndCreateResponse> { | |
| return client.tools.createFhirResource({ | |
| text, | |
| resource, | |
| provider, | |
| }); | |
| } | |
| // Example usage | |
| async function main(): Promise<void> { | |
| const result = await createFhirResource( | |
| "Patient John Doe, male, born 1985-03-15", | |
| "patient", // no exported values to use here | |
| "550e8400-e29b-41d4-a716-446655440000" | |
| ); | |
| console.log(JSON.stringify(result, null, 2)); | |
| } | |
| main().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment