Skip to content

Commit

Permalink
Merge from main repo: Release Version 3.2.12 (#5251)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 17, 2024
1 parent fae78f4 commit 3bcf729
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 19 deletions.
46 changes: 46 additions & 0 deletions data/core/patient-intake-questionnaire.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,52 @@
}
]
},
{
"linkId": "vaccination-history",
"text": "Vaccination History",
"type": "group",
"repeats": true,
"item": [
{
"linkId": "immunization-vaccine",
"text": "Vaccine",
"type": "choice",
"answerValueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1010.6"
},
{
"linkId": "immunization-date",
"text": "Administration Date",
"type": "dateTime"
}
]
},
{
"linkId": "preferred-pharmacy",
"text": "Preferred Pharmacy",
"type": "group",
"item": [
{
"linkId": "preferred-pharmacy-reference",
"text": "Pharmacy",
"type": "reference",
"extension": [
{
"id": "reference-pharmacy",
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/fhir-types",
"display": "Organizations",
"code": "Organization"
}
]
}
}
]
}
]
},
{
"linkId": "coverage-information",
"text": "Coverage Information",
Expand Down
60 changes: 59 additions & 1 deletion data/example/example-organization-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:b884050a-bc99-472c-ad66-4f903fe84aa8",
"fullUrl": "urn:uuid:38bcbdea-1b0c-4e9d-9548-4711a999acf4",
"request": {
"method": "PUT",
"url": "Organization?identifier=blue-cross"
Expand Down Expand Up @@ -59,6 +59,64 @@
}
]
}
},
{
"fullUrl": "urn:uuid:56867ac2-9c23-415f-a9e8-0bc95a87e986",
"request": {
"method": "PUT",
"url": "Organization?identifier=cvs-pharmacy"
},
"resource": {
"resourceType": "Organization",
"name": "CVS Pharmacy",
"active": true,
"identifier": [
{
"system": "http://example.com/pharmacy-orgs",
"value": "cvs-pharmacy"
}
],
"type": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/organization-type",
"code": "prov",
"display": "Healthcare Provider"
}
]
}
]
}
},
{
"fullUrl": "urn:uuid:d8cc4839-3abf-4a58-8895-190b06551b66",
"request": {
"method": "PUT",
"url": "Organization?identifier=medplum-pharmacy"
},
"resource": {
"resourceType": "Organization",
"name": "Medplum Pharmacy",
"active": true,
"identifier": [
{
"system": "http://example.com/pharmacy-orgs",
"value": "medplum-pharmacy"
}
],
"type": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/organization-type",
"code": "prov",
"display": "Healthcare Provider"
}
]
}
]
}
}
]
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medplum-patient-intake-demo",
"version": "3.2.11",
"version": "3.2.12",
"private": true,
"type": "module",
"scripts": {
Expand Down Expand Up @@ -28,29 +28,29 @@
"@mantine/core": "7.12.2",
"@mantine/hooks": "7.12.2",
"@mantine/notifications": "7.12.2",
"@medplum/bot-layer": "3.2.11",
"@medplum/core": "3.2.11",
"@medplum/definitions": "3.2.11",
"@medplum/eslint-config": "3.2.11",
"@medplum/fhirtypes": "3.2.11",
"@medplum/mock": "3.2.11",
"@medplum/react": "3.2.11",
"@tabler/icons-react": "3.16.0",
"@types/node": "22.5.4",
"@types/react": "18.3.5",
"@medplum/bot-layer": "3.2.12",
"@medplum/core": "3.2.12",
"@medplum/definitions": "3.2.12",
"@medplum/eslint-config": "3.2.12",
"@medplum/fhirtypes": "3.2.12",
"@medplum/mock": "3.2.12",
"@medplum/react": "3.2.12",
"@tabler/icons-react": "3.17.0",
"@types/node": "22.5.5",
"@types/react": "18.3.6",
"@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.1",
"chart.js": "4.4.4",
"esbuild": "0.23.1",
"postcss": "8.4.45",
"postcss": "8.4.47",
"postcss-preset-mantine": "1.17.0",
"react": "18.2.0",
"react-chartjs-2": "5.2.0",
"react-dom": "18.2.0",
"react-router-dom": "6.26.2",
"ts-node": "10.9.2",
"typescript": "5.6.2",
"vite": "5.4.3",
"vitest": "2.0.5"
"vite": "5.4.5",
"vitest": "2.1.1"
}
}
55 changes: 52 additions & 3 deletions src/bots/core/intake-form.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
intakeResponse,
payorOrganization1,
payorOrganization2,
pharmacyOrganization,
} from './test-data/intake-form-test-data';
import {
Bundle,
Expand Down Expand Up @@ -35,7 +36,8 @@ describe('Intake form', async () => {
response: QuestionnaireResponse,
patient: Patient | undefined,
payor1: Organization,
payor2: Organization;
payor2: Organization,
pharmacy: Organization;
const bot = { reference: 'Bot/123' };
const contentType = 'application/fhir+json';
const ssn = '518225060';
Expand All @@ -53,6 +55,7 @@ describe('Intake form', async () => {
medplum = new MockClient();
payor1 = await medplum.createResource(payorOrganization1);
payor2 = await medplum.createResource(payorOrganization2);
pharmacy = await medplum.createResource(pharmacyOrganization);
await medplum.createResource(intakeQuestionnaire);
response = await medplum.createResource(intakeResponse);
});
Expand Down Expand Up @@ -252,6 +255,32 @@ describe('Intake form', async () => {
});
});

describe('Immunization', async () => {
test('add immunizations', async () => {
await handler(medplum, { bot, input: response, contentType, secrets: {} });

patient = (await medplum.searchOne('Patient', `identifier=${ssn}`)) as Patient;

expect(patient).toBeDefined();

const immunizations = await medplum.searchResources('Immunization', {
patient: getReferenceString(patient),
});

expect(immunizations.length).toEqual(2);

expect(immunizations[0].vaccineCode?.coding?.[0].system).toEqual('http://hl7.org/fhir/sid/cvx');
expect(immunizations[0].vaccineCode?.coding?.[0].code).toEqual('197');
expect(immunizations[0].status).toEqual('completed');
expect(immunizations[0].occurrenceDateTime).toEqual('2024-02-01T14:00:00-07:00');

expect(immunizations[1].vaccineCode?.coding?.[0].system).toEqual('http://hl7.org/fhir/sid/cvx');
expect(immunizations[1].vaccineCode?.coding?.[0].code).toEqual('115');
expect(immunizations[1].status).toEqual('completed');
expect(immunizations[1].occurrenceDateTime).toEqual('2015-08-01T15:00:00-07:00');
});
});

describe('Language information', async () => {
test('add languages', async () => {
await handler(medplum, { bot, input: response, contentType, secrets: {} });
Expand Down Expand Up @@ -369,6 +398,26 @@ describe('Intake form', async () => {
});
});

describe('CareTeam', async () => {
test('Preferred Pharmacy', async () => {
await handler(medplum, { bot, input: response, contentType, secrets: {} });

patient = (await medplum.searchOne('Patient', `identifier=${ssn}`)) as Patient;

expect(patient).toBeDefined();

const careTeam = await medplum.searchResources('CareTeam', {
subject: getReferenceString(patient),
});

expect(careTeam.length).toEqual(1);
expect(careTeam[0].status).toEqual('proposed');
expect(careTeam[0].name).toEqual('Patient Preferred Pharmacy');
expect(careTeam[0].participant?.length).toEqual(1);
expect(careTeam[0].participant?.[0].member?.reference).toEqual(getReferenceString(pharmacy));
});
});

describe('Coverage', async () => {
test('adds coverage resources', async () => {
await handler(medplum, { bot, input: response, contentType, secrets: {} });
Expand All @@ -382,12 +431,12 @@ describe('Intake form', async () => {
expect(coverages[0].beneficiary).toEqual(createReference(patient));
expect(coverages[0].subscriberId).toEqual('first-provider-id');
expect(coverages[0].relationship?.coding?.[0]?.code).toEqual('self');
expect(coverages[0].payor?.[0].reference).toEqual(createReference(payor1).reference);
expect(coverages[0].payor?.[0].reference).toEqual(getReferenceString(payor1));

expect(coverages[1].beneficiary).toEqual(createReference(patient));
expect(coverages[1].subscriberId).toEqual('second-provider-id');
expect(coverages[1].relationship?.coding?.[0]?.code).toEqual('child');
expect(coverages[1].payor?.[0].reference).toEqual(createReference(payor2).reference);
expect(coverages[1].payor?.[0].reference).toEqual(getReferenceString(payor2));
});

test('upsert coverage resources to ensure there is only one coverage resource per payor', async () => {
Expand Down
19 changes: 18 additions & 1 deletion src/bots/core/intake-form.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { BotEvent, createReference, getQuestionnaireAnswers, MedplumClient } from '@medplum/core';
import { Patient, Questionnaire, QuestionnaireResponse } from '@medplum/fhirtypes';
import { Organization, Patient, Questionnaire, QuestionnaireResponse, Reference } from '@medplum/fhirtypes';
import {
addAllergy,
addCondition,
addConsent,
addCoverage,
addFamilyMemberHistory,
addImmunization,
addLanguage,
addMedication,
addPharmacy,
consentCategoryMapping,
consentPolicyRuleMapping,
consentScopeMapping,
Expand Down Expand Up @@ -180,6 +182,7 @@ export async function handler(medplum: MedplumClient, event: BotEvent<Questionna
}

// Handle medications

const medications = getGroupRepeatedAnswers(questionnaire, response, 'medications');
for (const medication of medications) {
await addMedication(medplum, patient, medication);
Expand All @@ -197,13 +200,27 @@ export async function handler(medplum: MedplumClient, event: BotEvent<Questionna
await addFamilyMemberHistory(medplum, patient, history);
}

// Handle vaccination history (immunizations)

const vaccinationHistory = getGroupRepeatedAnswers(questionnaire, response, 'vaccination-history');
for (const vaccine of vaccinationHistory) {
await addImmunization(medplum, patient, vaccine);
}

// Handle coverage

const insuranceProviders = getGroupRepeatedAnswers(questionnaire, response, 'coverage-information');
for (const provider of insuranceProviders) {
await addCoverage(medplum, patient, provider);
}

// Handle preferred pharmacy

const preferredPharmacyReference = answers['preferred-pharmacy-reference']?.valueReference;
if (preferredPharmacyReference) {
await addPharmacy(medplum, patient, preferredPharmacyReference as Reference<Organization>);
}

// Handle consents

await addConsent(
Expand Down
Loading

0 comments on commit 3bcf729

Please sign in to comment.