-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UI to not check with pharmacy for status of medication
- Loading branch information
Ariel Virgulto
committed
Feb 12, 2024
1 parent
7a78554
commit b1a856f
Showing
4 changed files
with
96 additions
and
218 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
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
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,102 +1,43 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { Patient, MedicationRequest } from 'fhir/r4'; | ||
import nock from 'nock'; | ||
import { MedicationDispense, BundleEntry } from 'fhir/r4'; | ||
|
||
import PharmacyStatus from '../PharmacyStatus'; | ||
import DoctorOrder from '../DoctorOrder'; | ||
import MetRequirements from '../../etasuStatus/MetRequirements'; | ||
|
||
const pharmacy_server_base = 'http://localhost:5051'; | ||
|
||
const testPatient: Patient = { | ||
resourceType: 'Patient', | ||
id: 'pat017', | ||
gender: 'male', | ||
birthDate: '1996-06-01', | ||
name: [ | ||
{ | ||
use: 'official', | ||
family: 'Snow', | ||
given: ['Jon', 'Stark'] | ||
} | ||
] | ||
}; | ||
|
||
const testMedicationRequest: MedicationRequest = { | ||
resourceType: 'MedicationRequest', | ||
id: 'pat017-mr-IPledge', | ||
medicationCodeableConcept: { | ||
coding: [ | ||
{ | ||
system: 'http://www.nlm.nih.gov/research/umls/rxnorm', | ||
code: '6064', | ||
display: 'Isotretinoin 20 MG Oral Capsule' | ||
}, | ||
{ | ||
system: 'http://hl7.org/fhir/sid/ndc', | ||
code: '0245-0571-01' | ||
} | ||
const testMedicationDispense: BundleEntry<MedicationDispense> = { | ||
'resource': { | ||
'resourceType': 'MedicationDispense', | ||
'id': 'pat017-mr-turalio-dispense', | ||
'meta': { | ||
'versionId': '4', | ||
'lastUpdated': '2024-02-08T16:02:57.850+00:00', | ||
'source': '#pat017-mr-turali' | ||
}, | ||
'status': 'completed', | ||
'medicationCodeableConcept': { | ||
'coding': [ | ||
{ | ||
'system': 'http://www.nlm.nih.gov/research/umls/rxnorm', | ||
'code': '2183126', | ||
'display': 'Turalio 200 MG Oral Capsule' | ||
}, | ||
{ | ||
'system': 'http://hl7.org/fhir/sid/ndc', | ||
'code': '65597-402-20' | ||
} | ||
] | ||
}, | ||
'subject': { | ||
'reference': 'Patient/pat017', | ||
'display': 'Jon Snow' | ||
}, | ||
'authorizingPrescription': [ | ||
{ | ||
'reference': 'MedicationRequest/pat017-mr-turalio' | ||
} | ||
] | ||
}, | ||
status: 'active', | ||
intent: 'order', | ||
subject: { | ||
reference: 'Patient/pat017', | ||
display: 'Jon Snow' | ||
}, | ||
authoredOn: '2020-07-11' | ||
}; | ||
|
||
const generateDoctorOrder = () => { | ||
const patientEnrollmentForm: MetRequirements = { | ||
completed: true, | ||
metRequirementId: 'asldkf23a', | ||
requirementDescription: 'Submit Patient Enrollment form to the REMS Administrator', | ||
requirementName: 'Patient Enrollment Form', | ||
stakeholderId: 'dlksk2222' | ||
}; | ||
const prescriberEnrollmentForm: MetRequirements = { | ||
completed: false, | ||
metRequirementId: 'asldkf23b', | ||
requirementDescription: 'Submit Prescriber Enrollment form to the REMS Administrator', | ||
requirementName: 'Prescriber Enrollment Form', | ||
stakeholderId: 'dlksk2222' | ||
}; | ||
const pharmacistEnrollmentForm: MetRequirements = { | ||
completed: true, | ||
metRequirementId: 'asldkf23c', | ||
requirementDescription: 'Submit Pharmacist Enrollment form to the REMS Administrator', | ||
requirementName: 'Pharmacist Enrollment Form', | ||
stakeholderId: 'dlksk2222' | ||
}; | ||
const doctorOrder: DoctorOrder = { | ||
_id: '1234', | ||
caseNumber: '2k3js', | ||
patientName: 'Jon Snow', | ||
patientFirstName: 'Jon', | ||
patientLastName: 'Snow', | ||
patientDOB: '1996-06-01', | ||
patientCity: 'Winterfell', | ||
patientStateProvince: 'Westeros', | ||
patientPostalCode: '00008', | ||
patientCountry: 'USA', | ||
doctorName: 'Dr. Jane Doe', | ||
doctorContact: '555-123-4567', | ||
doctorID: 'sdk2kd991', | ||
doctorEmail: '[email protected]', | ||
drugNames: 'Medication', | ||
simpleDrugName: 'Medication', | ||
rxDate: '2023-03-04', | ||
drugPrice: 35, | ||
drugNdcCode: '0245-0571-01', | ||
quanitities: '20', | ||
total: 1, | ||
pickupDate: '2023-04-04', | ||
dispenseStatus: 'Pending', | ||
metRequirements: [patientEnrollmentForm, prescriberEnrollmentForm, pharmacistEnrollmentForm] | ||
}; | ||
return doctorOrder; | ||
} | ||
}; | ||
describe('Test the PharmacyStatus Component', () => { | ||
function expectContains(value: string) { | ||
|
@@ -108,7 +49,7 @@ describe('Test the PharmacyStatus Component', () => { | |
const update = false; | ||
|
||
// render the module | ||
render(<PharmacyStatus update={update} callback={() => {}} pimsResponse={null} />); | ||
render(<PharmacyStatus update={update} callback={() => {}} testEhrResponse={null} />); | ||
|
||
// test the status fields and headings are present | ||
expectContains('Pharmacy Status'); | ||
|
@@ -120,11 +61,10 @@ describe('Test the PharmacyStatus Component', () => { | |
expect(refreshButton).toBeInTheDocument(); | ||
}); | ||
test('Renders order', async () => { | ||
const doctorOrder = generateDoctorOrder(); | ||
render(<PharmacyStatus update={false} callback={() => {}} pimsResponse={doctorOrder} />); | ||
render(<PharmacyStatus update={false} callback={() => {}} testEhrResponse={testMedicationDispense} />); | ||
|
||
expect(await screen.findByText(`ID: ${doctorOrder._id}`)).toBeInTheDocument(); | ||
expect(await screen.findByText(`Status: ${doctorOrder.dispenseStatus}`)).toBeInTheDocument(); | ||
expect(await screen.findByText(`ID: ${testMedicationDispense?.resource?.id}`)).toBeInTheDocument(); | ||
expect(await screen.findByText(`Status: ${testMedicationDispense?.resource?.status}`)).toBeInTheDocument(); | ||
}); | ||
|
||
test('Loads data on start', () => { | ||
|
@@ -134,7 +74,7 @@ describe('Test the PharmacyStatus Component', () => { | |
pimsResponse = true; | ||
}; | ||
// render the module | ||
render(<PharmacyStatus update={update} callback={callback} pimsResponse={null} />); | ||
render(<PharmacyStatus update={update} callback={callback} testEhrResponse={null} />); | ||
// verify that the values are updated from the call to get the Pharmacy Status | ||
expect(pimsResponse).toBeTruthy(); | ||
}); | ||
|
@@ -146,7 +86,7 @@ describe('Test the PharmacyStatus Component', () => { | |
called = true; | ||
}; | ||
// render the module | ||
render(<PharmacyStatus update={update} callback={callback} pimsResponse={null} />); | ||
render(<PharmacyStatus update={update} callback={callback} testEhrResponse={null} />); | ||
|
||
// click the refresh button | ||
const refreshButton = screen.getByTestId('refresh'); | ||
|
@@ -159,7 +99,7 @@ describe('Test the PharmacyStatus Component', () => { | |
test('Failed to load status', async () => { | ||
const update = true; | ||
// render the module | ||
render(<PharmacyStatus update={update} callback={() => {}} pimsResponse={null} />); | ||
render(<PharmacyStatus update={update} callback={() => {}} testEhrResponse={null} />); | ||
|
||
// click the refresh button | ||
const refreshButton = screen.getByTestId('refresh'); | ||
|
Oops, something went wrong.