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

Group medicine administration by 4 hours + Support for archiving medicines + Administration Activity View + migrate useDispatch to useQuery #6396

Merged
merged 47 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1f75446
fixes #6341; bin medicine administrations by 4:1 hrs
rithviknishad Oct 4, 2023
edc6bc7
fix comments
rithviknishad Oct 4, 2023
06d1a2d
fix tooltip clipping
rithviknishad Oct 4, 2023
24f1108
Merge branch 'develop' into mar-binning
rithviknishad Oct 6, 2023
1ce94cd
remove warnings
rithviknishad Oct 6, 2023
1c2944c
Merge branch 'develop' into mar-binning
rithviknishad Oct 9, 2023
741da09
improve how date seperation is shown
rithviknishad Oct 9, 2023
6cf9608
popover shows more details
rithviknishad Oct 10, 2023
2b73fad
Merge branch 'develop' into mar-binning
rithviknishad Oct 11, 2023
9e888cc
cleanup: move files to correct place
rithviknishad Oct 11, 2023
9fe202e
delete old medicine administration table
rithviknishad Oct 11, 2023
9542d2b
cleanup
rithviknishad Oct 11, 2023
32c5701
remove useDispatch in bulk administer
rithviknishad Oct 11, 2023
61c8112
fixes #6442; API calls via useQuery for Medicines
rithviknishad Oct 11, 2023
b7e8df7
cleanup
rithviknishad Oct 11, 2023
9435bf1
fix keys
rithviknishad Oct 11, 2023
2a1de90
cleanup
rithviknishad Oct 11, 2023
0324182
update seperator
rithviknishad Oct 11, 2023
82151cc
overlay
rithviknishad Oct 11, 2023
8e715ed
temp fix tooltip
rithviknishad Oct 11, 2023
34ebe7c
fix refetch logic
rithviknishad Oct 11, 2023
b9241be
fix z-index
rithviknishad Oct 12, 2023
9e56a31
consistency
rithviknishad Oct 12, 2023
60d8223
fix z-index
rithviknishad Oct 12, 2023
ed97541
fix useIsScrollable dependencies
rithviknishad Oct 12, 2023
75ff222
fix z-index
rithviknishad Oct 12, 2023
b0997f9
Merge branch 'develop' into mar-binning
rithviknishad Oct 16, 2023
c558ad9
rewrite scroll overflow behaviour
rithviknishad Oct 17, 2023
47629f5
Merge branch 'develop' into mar-binning
rithviknishad Oct 17, 2023
3183ca3
fix z-index
rithviknishad Oct 18, 2023
3d79ec8
Merge branch 'develop' into mar-binning
nihal467 Oct 20, 2023
999693c
Merge branch 'develop' into mar-binning
rithviknishad Oct 26, 2023
fb19237
cleanup API routes
rithviknishad Oct 26, 2023
ab9aa6e
support for archive and fix responsiveness issues
rithviknishad Oct 26, 2023
464ac20
fix styling
rithviknishad Oct 26, 2023
2642ff9
Merge branch 'develop' into mar-binning
rithviknishad Nov 2, 2023
dba811c
fix path missing path params
rithviknishad Nov 2, 2023
9006fba
remove tooltip
rithviknishad Nov 2, 2023
081beaf
swap positions of actions and timestamp in timeline
rithviknishad Nov 2, 2023
b8296c5
fix responsiveness
rithviknishad Nov 2, 2023
dccc00b
minor spacing
rithviknishad Nov 2, 2023
bce67f7
fix responsiveness
rithviknishad Nov 2, 2023
50cb5e0
fix spacing
rithviknishad Nov 2, 2023
7f85ec0
Merge branch 'develop' into mar-binning
nihal467 Nov 6, 2023
5bcb7c5
hide archive if discontinued
rithviknishad Nov 6, 2023
c6f8fb2
fix responsiveness
rithviknishad Nov 6, 2023
6cfd3e0
fix discontinue refetch not invoked
rithviknishad Nov 6, 2023
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
Prev Previous commit
Next Next commit
cleanup API routes
rithviknishad committed Oct 26, 2023
commit fb19237dbc388ba3b1b7d82d1d415139bbc8d262
17 changes: 4 additions & 13 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import DateFormField from "../Form/FormFields/DateFormField";
import DialogModal from "../Common/Dialog";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import { FieldLabel } from "../Form/FormFields/FormField";
import { HCXActions, PrescriptionActions } from "../../Redux/actions";
import { HCXActions } from "../../Redux/actions";
import { HCXClaimModel } from "../HCX/models";
import { SelectFormField } from "../Form/FormFields/SelectFormField";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
@@ -183,8 +183,6 @@ const DischargeModal = ({
});
};

const prescriptionActions = PrescriptionActions(consultationData.id ?? "");

const handleFacilitySelect = (selected: FacilityModel) => {
setFacility(selected);
const { id, name } = selected || {};
@@ -238,7 +236,7 @@ const DischargeModal = ({
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel)
}
selected={facility}
selected={facility ?? null}
showAll
freeText
multiple={false}
@@ -284,18 +282,11 @@ const DischargeModal = ({

<div className="mb-4">
<FieldLabel>Discharge Prescription Medications</FieldLabel>
<PrescriptionBuilder
actions={prescriptionActions}
prescription_type="DISCHARGE"
/>
<PrescriptionBuilder prescription_type="DISCHARGE" />
</div>
<div className="mb-4">
<FieldLabel>Discharge PRN Prescriptions</FieldLabel>
<PrescriptionBuilder
actions={prescriptionActions}
prescription_type="DISCHARGE"
is_prn
/>
<PrescriptionBuilder prescription_type="DISCHARGE" is_prn />
</div>
</div>
)}
6 changes: 3 additions & 3 deletions src/Components/Medicine/EditPrescriptionForm.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ import { useState } from "react";
import Form from "../Form/Form";
import { Prescription } from "./models";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import * as Notification from "../../Utils/Notifications";
import useSlug from "../../Common/hooks/useSlug";
import { RequiredFieldValidator } from "../Form/FieldValidators";
@@ -16,6 +15,7 @@ import {
import TextFormField from "../Form/FormFields/TextFormField";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import { EditPrescriptionFormValidator } from "./validators";
import MedicineRoutes from "./routes";

interface Props {
initial: Prescription;
@@ -27,7 +27,7 @@ const handleSubmit = async (
oldObj: Prescription,
{ discontinued_reason, ...newObj }: Prescription
) => {
const discontinue = await request(routes.discontinuePrescription, {
const discontinue = await request(MedicineRoutes.discontinuePrescription, {
pathParams: { consultation_external_id, external_id: oldObj.id },
body: {
discontinued_reason: discontinued_reason
@@ -43,7 +43,7 @@ const handleSubmit = async (
return;
}

const { res } = await request(routes.createPrescription, {
const { res } = await request(MedicineRoutes.createPrescription, {
pathParams: { consultation_external_id },
body: {
...newObj,
74 changes: 1 addition & 73 deletions src/Redux/actions.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { HCXClaimModel, HCXPolicyModel } from "../Components/HCX/models";
import {
MedibaseMedicine,
MedicineAdministrationRecord,
Prescription,
} from "../Components/Medicine/models";
import { MedibaseMedicine } from "../Components/Medicine/models";
import { fireRequest, fireRequestForFiles } from "./fireRequest";

export const getConfig = () => {
@@ -879,74 +875,6 @@ export const getAssetAvailability = (id: string) =>
export const listPMJYPackages = (query?: string) =>
fireRequest("listPMJYPackages", [], { query });

/** Prescription related actions */
export const PrescriptionActions = (consultation_external_id: string) => {
const pathParams = { consultation_external_id };

return {
list: (query?: Record<string, any>) => {
let altKey;
if (query?.is_prn !== undefined) {
altKey = query?.is_prn
? "listPRNPrescriptions"
: "listNormalPrescriptions";
}
return fireRequest("listPrescriptions", [], query, pathParams, altKey);
},

create: (obj: Prescription) =>
fireRequest("createPrescription", [], obj, pathParams),

listAdministrations: (query?: object) =>
fireRequest("listAdministrations", [], query, pathParams),

getAdministration: (external_id: string) =>
fireRequest("getAdministration", [], {}, { ...pathParams, external_id }),

/** Returns actions specific to a prescription */
prescription(external_id: string) {
const pathParams = { consultation_external_id, external_id };

return {
/** Read a specific prescription of a consultation */
get: () => fireRequest("getPrescription", [], {}, pathParams),

/** Administer a prescription */
administer: (obj: MedicineAdministrationRecord) =>
fireRequest(
"administerPrescription",
[],
obj,
pathParams,
`administer-medicine-${external_id}`
),

listAdministrations: (query?: {
administered_date_after?: string;
administered_date_before?: string;
}) =>
fireRequest(
"listAdministrations",
[],
{ prescription: external_id, ...query },
pathParams,
`list-administrations-${external_id}`
),

/** Discontinue a prescription */
discontinue: (discontinued_reason: string | undefined) =>
fireRequest(
"discontinuePrescription",
[],
{ discontinued_reason },
pathParams,
`discontinue-medicine-${external_id}`
),
};
},
};
};

// HCX Actions
export const HCXActions = {
checkEligibility: (policy: string) => {
43 changes: 1 addition & 42 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import {
AssetUpdate,
} from "../Components/Assets/AssetTypes";
import {
ConsultationModel,
FacilityModel,
LocationModel,
WardModel,
@@ -40,7 +41,6 @@ import {
ILocalBodyByDistrict,
IPartialUpdateExternalResult,
} from "../Components/ExternalResult/models";
import { Prescription } from "../Components/Medicine/models";
import { PatientModel } from "../Components/Patient/models";
import { UserModel } from "../Components/Users/models";
import { PaginatedResponse } from "../Utils/request/types";
@@ -1096,47 +1096,6 @@ const routes = {
method: "GET",
},

// Prescription endpoints

listPrescriptions: {
path: "/api/v1/consultation/{consultation_external_id}/prescriptions/",
method: "GET",
},

createPrescription: {
path: "/api/v1/consultation/{consultation_external_id}/prescriptions/",
method: "POST",
TBody: Type<Prescription>(),
TRes: Type<Prescription>(),
},

listAdministrations: {
path: "/api/v1/consultation/{consultation_external_id}/prescription_administration/",
method: "GET",
},

getAdministration: {
path: "/api/v1/consultation/{consultation_external_id}/prescription_administration/{external_id}/",
method: "GET",
},

getPrescription: {
path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/",
method: "GET",
},

administerPrescription: {
path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/administer/",
method: "POST",
},

discontinuePrescription: {
path: "/api/v1/consultation/{consultation_external_id}/prescriptions/{external_id}/discontinue/",
method: "POST",
TBody: Type<{ discontinued_reason: string }>(),
TRes: Type<Record<string, never>>(),
},

// HCX Endpoints

listPMJYPackages: {