forked from medplum/medplum-demo-bots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
174558b
commit 13c23ea
Showing
5 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"bots": [ | ||
{ | ||
"name": "hello-world", | ||
"id": "488fe72d-b5cf-4a8a-81df-908647c19e02", | ||
"source": "src/hello-world.ts", | ||
"dist": "dist/hello-world.js" | ||
}, | ||
{ | ||
"name": "patient-intake", | ||
"id": "add1bd8d-0901-46a3-87ec-222ef88abccd", | ||
"source": "src/patient-intake.ts", | ||
"dist": "dist/patient-intake.js" | ||
}, | ||
{ | ||
"name": "create-pdf", | ||
"id": "daae7b6b-3481-4a60-a4b1-31f8fbff4468", | ||
"source": "src/create-pdf.ts", | ||
"dist": "dist/create-pdf.js" | ||
} | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,10 @@ | |
"author": "Medplum <[email protected]>", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@medplum/cli": "0.9.6", | ||
"@medplum/core": "0.9.6", | ||
"@medplum/fhirtypes": "0.9.6", | ||
"@medplum/mock": "0.9.6", | ||
"@medplum/cli": "0.9.10", | ||
"@medplum/core": "0.9.10", | ||
"@medplum/fhirtypes": "0.9.10", | ||
"@medplum/mock": "0.9.10", | ||
"@types/node": "17.0.33", | ||
"c8": "7.11.2", | ||
"eslint": "8.15.0", | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MockClient } from '@medplum/mock'; | ||
import { expect, test } from 'vitest'; | ||
import { handler } from './create-pdf'; | ||
|
||
const medplum = new MockClient(); | ||
|
||
test('Create PDF', async () => { | ||
const input = 'Hello'; | ||
const contentType = 'text/plain'; | ||
|
||
const media = await handler(medplum, { input, contentType }); | ||
expect(media).toBeDefined(); | ||
expect(media.resourceType).toEqual('Media'); | ||
expect(media.content.contentType).toEqual('application/pdf'); | ||
expect(media.content.url).toMatch('Binary'); | ||
|
||
const binary = await medplum.readReference({ reference: media.content.url }); | ||
expect(binary).toBeDefined(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BotEvent, MedplumClient } from '@medplum/core'; | ||
|
||
export async function handler(medplum: MedplumClient, event: BotEvent): Promise<any> { | ||
console.log(event); | ||
|
||
// Generate the PDF | ||
const binary = await medplum.createPdf({ | ||
content: [ | ||
'First paragraph', | ||
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines', | ||
], | ||
}); | ||
|
||
// Create a Media, representing an attachment | ||
const media = await medplum.createResource({ | ||
resourceType: 'Media', | ||
content: { | ||
contentType: 'application/pdf', | ||
url: 'Binary/' + binary.id, | ||
title: 'report.pdf', | ||
}, | ||
}); | ||
|
||
return media; | ||
} |
This file contains 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