Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MHV-55400]: medications shipped tracking #28827

Merged
merged 13 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ const PrescriptionPrintOnly = props => {
</p>
<p>
<strong>Shipped on:</strong>{' '}
{entry?.trackingList?.[0]?.[1]?.completeDateTime
? dateFormat(
entry.trackingList[0][1].completeDateTime,
)
{entry?.trackingList?.[0]?.completeDateTime
? dateFormat(entry.trackingList[0].completeDateTime)
: 'None noted'}
</p>
<div className="line-break" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ const VaPrescription = prescription => {
const hasBeenDispensed =
prescription?.dispensedDate ||
prescription?.rxRfRecords.find(record => record.dispensedDate);
const shippedOn = prescription?.trackingList?.[0]?.[1];
const latestTrackingStatus = prescription?.trackingList?.[0];
const content = () => {
if (prescription) {
const dispStatus = prescription.dispStatus?.toString();
return (
<>
<div className="medication-details-div vads-u-border-top--1px vads-u-border-color--gray-lighter vads-u-margin-top--2 vads-u-margin-bottom--3">
{shippedOn?.[0] && (
{latestTrackingStatus && (
<TrackingInfo
{...shippedOn[0]}
{...latestTrackingStatus}
prescriptionName={prescription.prescriptionName}
/>
)}
Expand Down Expand Up @@ -167,7 +167,7 @@ const VaPrescription = prescription => {
className="vads-u-margin--0 vads-u-margin-bottom--1"
data-testid="shipped-on"
>
{dateFormat(shippedOn?.[i]?.completeDateTime)}
{dateFormat(latestTrackingStatus?.completeDateTime)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we supposed to be using the index here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change on line 25, const latestTrackingStatus = prescription?.trackingList?.[0]; pulls an object, the first item out of the trackingList array.

We updated the vets-api serialization to remove the unnecessary levels of nesting, so the API will serve a 1-level array.

</p>
<h4
className="vads-u-font-size--base vads-u-font-family--sans vads-u-margin-top--2 vads-u-margin--0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ const RenewablePrescriptions = ({ renewablePrescriptionsList = [] }) => {
'MMMM D, YYYY',
)}
</span>
{prescription?.trackingList?.[0]?.completeDateTime && (
<>
<br />
<span data-testid={`medications-last-shipped-${idx}`}>
<i className="fas fa-truck vads-u-margin-right--1p5" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

icon found

Last refill shipped on{' '}
{dateFormat(
prescription.trackingList[0].completeDateTime,
'MMMM D, YYYY',
)}
</span>
</>
)}
</p>
</div>
))}
Expand Down
13 changes: 7 additions & 6 deletions src/applications/mhv/medications/mocks/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const folders = require('./mhv-api/messaging/folders/index');
const vamcEhr = require('./vamc-ehr.json');
const personalInformation = require('./user/personal-information.json');
// prescriptions module generates mocks
// const prescriptions = require('./mhv-api/prescriptions/index');
const prescriptions = require('./mhv-api/prescriptions/index');
// You can user fixtures for mocks, if desired
const prescriptionsFixture = require('../../tests/e2e/fixtures/prescriptions.json');
const refillablePrescriptionsFixture = require('../../tests/e2e/fixtures/prescriptions.json');
// const prescriptionsFixture = require('../../tests/e2e/fixtures/prescriptions.json');
// const refillablePrescriptionsFixture = require('../../tests/e2e/fixtures/prescriptions.json');
const allergiesFixture = require('../../tests/e2e/fixtures/allergies.json');

const responses = {
Expand All @@ -29,9 +29,10 @@ const responses = {
// MHV Messaging - folders endpoint powers the red dot on mhv-landing-page
'GET /my_health/v1/messaging/folders': folders.allFoldersWithUnreadMessages,
// MHV Medications endpoints below
// 'GET /my_health/v1/prescriptions': prescriptions.generateMockPrescriptions(),
'GET /my_health/v1/prescriptions': prescriptionsFixture,
'GET /my_health/v1/prescriptions/list_refillable_prescriptions': refillablePrescriptionsFixture,
'GET /my_health/v1/prescriptions': prescriptions.generateMockPrescriptions(),
// 'GET /my_health/v1/prescriptions': prescriptionsFixture,
// 'GET /my_health/v1/prescriptions/list_refillable_prescriptions': refillablePrescriptionsFixture,
'GET /my_health/v1/prescriptions/list_refillable_prescriptions': prescriptions.generateMockPrescriptions(),
'GET /my_health/v1/medical_records/allergies': allergiesFixture,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { differenceInDays, formatISO, sub } = require('date-fns');

function mockPrescription(n = 0, attrs = {}) {
// Generate some refillable, some not
const isRefillable = n % 3 === 0;
const refillRemaining = isRefillable ? Math.ceil(Math.log(n + 1)) : 0;

return {
id: `fake-${n}`,
type: 'prescriptions',
Expand All @@ -11,14 +15,14 @@ function mockPrescription(n = 0, attrs = {}) {
refillStatus: 'active',
refillSubmitDate: '2024-02-21T10:30:00-05:00',
refillDate: '2024-02-28T10:30:00-05:00',
refillRemaining: 6,
refillRemaining,
facilityName: 'The Facility',
orderedDate: '2024-02-23T10:30:00-05:00',
quantity: 1,
expirationDate: '2099-01-02T10:30:00-05:00',
dispensedDate: '2024-02-25T10:30:00-05:00',
stationNumber: '001',
isRefillable: true,
isRefillable,
isTrackable: null,
sig: null,
cmopDivisionPhone: null,
Expand All @@ -41,7 +45,22 @@ function mockPrescription(n = 0, attrs = {}) {
indicationForUse: null,
indicationForUseFlag: null,
category: null,
trackingList: [],
trackingList: [
{
carrier: 'USPS',
completeDateTime: '2024-05-28T04:39:11-04:00',
dateLoaded: '2024-04-21T16:55:19-04:00',
divisionPhone: '(401)271-9804',
id: 9878,
isLocalTracking: false,
ndc: '00113002240',
othersInSamePackage: false,
rxNumber: 2719780,
stationNumber: 995,
trackingNumber: '332980271979930000002300',
viewImageDisplayed: false,
},
],
rxRfRecords: [],
tracking: null,
orderableItem: null,
Expand Down Expand Up @@ -74,7 +93,7 @@ function mockPrescriptionArray(n = 20) {
refillSubmitDate: formatISO(oneWeekAgo),
sortedDispensedDate: recentlyISOString,
dispStatus: statusString,
refillStatus: statusString.toLowerCase(),
refillStatus: statusString,
prescriptionName,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ describe('vaPrescription details container', () => {
const screen = setup();
const shippedOn = screen.getAllByText(
dateFormat(
rxDetailsResponse.data.attributes.trackingList[0][1][0]
.completeDateTime,
rxDetailsResponse.data.attributes.trackingList[0].completeDateTime,
),
{
exact: true,
Expand All @@ -61,7 +60,7 @@ describe('vaPrescription details container', () => {

expect(trackingNumber).to.exist;
expect(trackingNumber).to.have.text(
rxDetailsResponse.data.attributes.trackingList[0][1][0].trackingNumber,
rxDetailsResponse.data.attributes.trackingList[0].trackingNumber,
);
});
it('displays none noted if no phone number is provided', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ describe('Renew Prescriptions Component', () => {
);
});

it('Shows the correct "last refill shipped on" date (w/trackingList) for refill', async () => {
const screen = setup();
const lastRefillEl = await screen.findByTestId(
'medications-last-shipped-0',
);
expect(lastRefillEl).to.exist;
const rx = prescriptions.find(
({ prescriptionId }) => prescriptionId === 22217089,
);
expect(lastRefillEl).to.have.text(
`Last refill shipped on ${dateFormat(
rx.trackingList[0]?.completeDateTime,
)}`,
);
});

it('Shows the correct text for 1 prescription', async () => {
const screen = setup(initialState, [prescriptions[1]]);
const countEl = await screen.findByTestId('renew-page-list-count');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,13 @@
"prescriptionName": "BACITRACIN 500 UNT/GM OPH OINT",
"refillStatus": "refillinprocess",
"refillSubmitDate": "2023-09-26T20:10:24.000Z",
"refillDate": "2023-09-23T04:00:00.000Z",
"refillDate": "2023-08-29T04:00:00.000Z",
"refillRemaining": 1,
"facilityName": "SLC10 TEST LAB",
"orderedDate": "2023-08-27T04:00:00.000Z",
"quantity": 1,
"expirationDate": "2024-08-27T04:00:00.000Z",
"dispensedDate": "2023-08-29T04:00:00.000Z",
"dispensedDate": "September 24, 2023",
"stationNumber": "979",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reason for the format change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time does not show in the UI and I used a fixture file that has tracking info for the refill history.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually expect the API to return a date in that format? I'd expect a a consistent format from the backend APIs...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the suggested changes and pushed the updated one.

"isRefillable": false,
"isTrackable": true,
Expand All @@ -887,25 +887,20 @@
"indicationForUseFlag": null,
"category": "Rx Medication",
"trackingList": [
[
"tracking",
[
{
"id": 49049,
"stationNumber": "979",
"rxNumber": "3636889A",
"carrier": "FEDEX",
"trackingNumber": "77298036368890000006962",
"completeDateTime": "Sun, 24 Sep 2023 04:39:11 EDT",
"divisionPhone": "(410)636-6899",
"ndc": "00113002239",
"dateLoaded": "Tue, 26 Sep 2023 16:20:00 EDT",
"isLocalTracking": false,
"othersInSamePackage": false,
"viewImageDisplayed": true
}
]
]
{
"id": 49049,
"stationNumber": "979",
"rxNumber": "3636889A",
"carrier": "FEDEX",
"trackingNumber": "77298036368890000006962",
"completeDateTime": "Sun, 24 Sep 2023 04:39:11 EDT",
"divisionPhone": "(410)636-6899",
"ndc": "00113002239",
"dateLoaded": "Tue, 26 Sep 2023 16:20:00 EDT",
"isLocalTracking": false,
"othersInSamePackage": false,
"viewImageDisplayed": true
}
],
"rxRfRecords": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,66 +41,68 @@
"indicationForUseFlag": null,
"category": "Rx Medication",
"trackingList": [
[
"tracking",
[
{
"id": null,
"stationNumber": null,
"rxNumber": null,
"carrier": "UPS",
"trackingNumber": "1Z9799999993636979",
"completeDateTime": "Mon, 02 Oct 2023 00:00:00 EDT",
"divisionPhone": null,
"ndc": null,
"dateLoaded": null,
"isLocalTracking": true,
"othersInSamePackage": false,
"viewImageDisplayed": false
}
]
]
{
"id": null,
"stationNumber": null,
"rxNumber": null,
"carrier": "UPS",
"trackingNumber": "1Z9799999993636979",
"completeDateTime": "Mon, 02 Oct 2023 00:00:00 EDT",
"divisionPhone": null,
"ndc": null,
"dateLoaded": null,
"isLocalTracking": true,
"othersInSamePackage": false,
"viewImageDisplayed": false
}
],
"rxRfRecords": [
{
"refillStatus": "suspended",
"refillSubmitDate": null,
"refillDate": "Sun, 03 Sep 2023 00:00:00 EDT",
"refillRemaining": 4,
"facilityName": "SLC10 TEST LAB",
"refillStatus": "active",
"refillSubmitDate": "Wed, 20 Mar 2024 10:28:36 EDT",
"refillDate": "Mon, 19 Feb 2024 00:00:00 EST",
"refillRemaining": 2,
"facilityName": "DAYT29",
"facilityApiName": null,
"isRefillable": false,
"isTrackable": false,
"prescriptionId": 22534649,
"prescriptionId": 23298420,
"sig": null,
"orderedDate": "October 1, 2023",
"orderedDate": "Sun, 17 Mar 2024 00:00:00 EDT",
"quantity": null,
"expirationDate": null,
"prescriptionNumber": "3636979",
"prescriptionNumber": "2720848",
"prescriptionName": "ACETYLCYSTEINE 20% INHL SOLN 30ML",
"dispensedDate": "October 2, 2023",
"stationNumber": "979",
"dispensedDate": "Mon, 18 Mar 2024 00:00:00 EDT",
"stationNumber": "989",
"inCernerTransition": false,
"notRefillableDisplayMessage": null,
"cmopDivisionPhone": null,
"cmopNdcNumber": null,
"id": 22534649,
"userId": 17621060,
"cmopDivisionPhone": "(783)272-0848",
"cmopNdcNumber": "00013264681",
"id": 23298420,
"userId": 22496029,
"providerFirstName": null,
"providerLastName": null,
"remarks": null,
"divisionName": null,
"modifiedDate": null,
"institutionId": null,
"dialCmopDivisionPhone": "",
"dispStatus": "Suspended",
"ndc": null,
"dialCmopDivisionPhone": "7832720848",
"dispStatus": "Active",
"ndc": "00409-3308-03",
"reason": null,
"prescriptionNumberIndex": "RF1",
"prescriptionSource": "RF",
"disclaimer": null,
"indicationForUse": null,
"indicationForUseFlag": null,
"category": "Rx Medication",
"orderableItem": null,
"shape": null,
"color": null,
"frontImprint": null,
"backImprint": null,
"dataSourceSystem": "VISTA",
"trackingList": null,
"rxRfRecords": null,
"tracking": false
Expand Down
Loading
Loading