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.
Merge pull request medplum#4 from justinko43/opkit-bot
Opkit bot changes
- Loading branch information
Showing
2 changed files
with
265 additions
and
112 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 |
---|---|---|
@@ -1,34 +1,80 @@ | ||
import { createReference } from '@medplum/core'; | ||
import { Coverage, Organization, Patient } from '@medplum/fhirtypes'; | ||
import { Coverage, CoverageEligibilityRequest, Organization, Patient, Practitioner } from '@medplum/fhirtypes'; | ||
import { MockClient } from '@medplum/mock'; | ||
import { expect, test } from 'vitest'; | ||
import { handler } from './eligibility-check-opkit'; | ||
|
||
|
||
const contentType = 'application/fhir+json'; | ||
|
||
// To run this test only: npm t -- src/eligibility-check-opkit.test.ts | ||
test('Success', async () => { | ||
const medplum = new MockClient(); | ||
|
||
const patient = await medplum.createResource<Patient>({ | ||
resourceType: 'Patient', | ||
name:[{given:['John'],family:'Doe'}], | ||
birthDate:'1994-07-21', | ||
gender:'male' | ||
}) | ||
name: [{ given: ['Michael'], family: 'Scott' }], | ||
birthDate: '01-01-2000', | ||
gender: 'male', | ||
telecom: [ | ||
{ | ||
system: 'email', | ||
value: '[email protected]', | ||
}, | ||
], | ||
}); | ||
|
||
const org = await medplum.createResource<Organization>({ | ||
resourceType: 'Organization', | ||
name: 'DMERC - Region B (formerly MR031)' | ||
name: 'THE OFFICE INSURANCE COMPANY', | ||
identifier: [ | ||
{ | ||
system: 'https://docs.opkit.co/reference/getpayers', | ||
value: 'dcc25e45-9110-4f39-9a56-2306b5430bd0', | ||
}, | ||
], | ||
}); | ||
|
||
const practioner = await medplum.createResource<Practitioner>({ | ||
resourceType: 'Practitioner', | ||
name: [ | ||
{ | ||
given: ['Given Name'], | ||
family: 'Family Name', | ||
}, | ||
], | ||
identifier: [ | ||
{ | ||
type: { | ||
coding: [ | ||
{ | ||
system: 'https://terminology.hl7.org/CodeSystem/v2-0203', | ||
code: 'NPI', | ||
}, | ||
], | ||
}, | ||
system: 'https://hl7.org/fhir/sid/us-npi', | ||
value: '123456789', | ||
}, | ||
], | ||
}); | ||
const input: Coverage = { | ||
|
||
const coverage = await medplum.createResource<Coverage>({ | ||
resourceType: 'Coverage', | ||
beneficiary: createReference(patient), | ||
subscriber: createReference(patient), | ||
payor: [createReference(org)], | ||
subscriberId: '123456789100', | ||
subscriberId: '123', | ||
status: 'active', | ||
}); | ||
|
||
const input: CoverageEligibilityRequest = { | ||
id: '83230953-5283-48e6-ae7f-57363a142d8a', | ||
resourceType: 'CoverageEligibilityRequest', | ||
provider: createReference(practioner), | ||
patient: createReference(patient), | ||
insurer: createReference(org), | ||
insurance: [createReference(coverage)], | ||
}; | ||
|
||
const result = await handler(medplum, { input, contentType }); | ||
expect(result).toBe(true); | ||
}); |
Oops, something went wrong.