Skip to content

Instantly share code, notes, and snippets.

@gavinsharp
Created December 22, 2025 15:01
Show Gist options
  • Select an option

  • Save gavinsharp/74f52a39abd48fbe3399c6d4e9fb986f to your computer and use it in GitHub Desktop.

Select an option

Save gavinsharp/74f52a39abd48fbe3399c6d4e9fb986f to your computer and use it in GitHub Desktop.
lang2fhir and create TS helper example
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