Skip to content

Commit

Permalink
Merge pull request medplum#4 from justinko43/opkit-bot
Browse files Browse the repository at this point in the history
Opkit bot changes
  • Loading branch information
reshmakh authored May 25, 2022
2 parents e24ec1d + 9f25fc0 commit 638ec67
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 112 deletions.
66 changes: 56 additions & 10 deletions src/eligibility-check-opkit.test.ts
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);
});
Loading

0 comments on commit 638ec67

Please sign in to comment.