-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) - O3-3216 - Ward App - show admitted newborn baby / mother in …
…ward patient card (#1303) * feat-metrics * (fix) O3-3709 - ward app - handle pagination * update metrics * mother child stash * what a mess * stash * good to go * (fix) O3-3709 - ward app - handle pagination * remove orig files * (fix) O3-3709 - ward app - handle pagination * fix tests --------- Co-authored-by: Bhargav Kodali <kodalibhargav019@gmail.com>
- Loading branch information
Showing
33 changed files
with
983 additions
and
125 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
Binary file not shown.
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 |
---|---|---|
|
@@ -22,7 +22,3 @@ | |
@include type.type-style('heading-compact-01'); | ||
color: $text-02; | ||
} | ||
|
||
.skeletonText { | ||
width: 6.25rem; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/esm-ward-app/src/config-schema-mother-child-row.ts
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Type } from '@openmrs/esm-framework'; | ||
|
||
export const motherChildRowConfigSchema = { | ||
maternalLocations: { | ||
_type: Type.Array, | ||
_description: 'Defines obs display elements that can be included in the card header or footer.', | ||
_default: [], | ||
_elements: { | ||
id: { | ||
_type: Type.UUID, | ||
_description: 'The unique identifier for this ward location', | ||
}, | ||
} | ||
}, | ||
childLocations: { | ||
_type: Type.Array, | ||
_description: 'Defines obs display elements that can be included in the card header or footer.', | ||
_default: [], | ||
_elements: { | ||
id: { | ||
_type: Type.UUID, | ||
_description: 'The unique identifier for this ward location', | ||
}, | ||
} | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { | ||
makeUrl, | ||
restBaseUrl, | ||
useOpenmrsFetchAll, | ||
useOpenmrsInfinite, | ||
useOpenmrsPagination, | ||
} from '@openmrs/esm-framework'; | ||
import { type MotherAndChildren } from '../types'; | ||
|
||
export interface MothersAndChildrenSearchCriteria { | ||
mothers?: Array<string>; | ||
children?: Array<string>; | ||
requireMotherHasActiveVisit?: boolean; | ||
requireChildHasActiveVisit?: boolean; | ||
requireChildBornDuringMothersActiveVisit?: boolean; | ||
} | ||
|
||
export function useMotherAndChildren( | ||
criteria: MothersAndChildrenSearchCriteria, | ||
fetch: boolean = true, | ||
rep: string = null, | ||
) { | ||
const url = makeUrlUrl(`${restBaseUrl}/emrapi/maternal/mothersAndChildren`); | ||
const { | ||
mothers, | ||
children, | ||
requireChildBornDuringMothersActiveVisit, | ||
requireChildHasActiveVisit, | ||
requireMotherHasActiveVisit, | ||
} = criteria; | ||
|
||
for (const m of mothers ?? []) { | ||
url.searchParams.append('mother', m); | ||
} | ||
|
||
for (const c of children ?? []) { | ||
url.searchParams.append('child', c); | ||
} | ||
|
||
url.searchParams.append('requireMotherHasActiveVisit', requireMotherHasActiveVisit?.toString() ?? 'false'); | ||
url.searchParams.append('requireChildHasActiveVisit', requireChildHasActiveVisit?.toString() ?? 'false'); | ||
url.searchParams.append( | ||
'requireChildBornDuringMothersActiveVisit', | ||
requireChildBornDuringMothersActiveVisit?.toString() ?? 'false', | ||
); | ||
rep && url.searchParams.append('v', rep); | ||
return useOpenmrsPagination<MotherAndChildren>(fetch ? url : null, 50); | ||
} | ||
|
||
function makeUrlUrl(path: string) { | ||
return new URL(makeUrl(path), window.location.toString()); | ||
} |
31 changes: 13 additions & 18 deletions
31
packages/esm-ward-app/src/hooks/useWardPatientGrouping.ts
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,35 +1,30 @@ | ||
import { useMemo } from 'react'; | ||
import { createAndGetWardPatientGrouping, getInpatientAdmissionsUuidMap } from '../ward-view/ward-view.resource'; | ||
import { createAndGetWardPatientGrouping } from '../ward-view/ward-view.resource'; | ||
import { useAdmissionLocation } from './useAdmissionLocation'; | ||
import { useInpatientAdmission } from './useInpatientAdmission'; | ||
import { useInpatientRequest } from './useInpatientRequest'; | ||
|
||
export function useWardPatientGrouping() { | ||
const admissionLocationResponse = useAdmissionLocation(); | ||
const inpatientAdmissionResponse = useInpatientAdmission(); | ||
const inpatientRequestResponse = useInpatientRequest(); | ||
|
||
const { data: inpatientAdmissions } = inpatientAdmissionResponse; | ||
const { admissionLocation } = admissionLocationResponse; | ||
const inpatientAdmissionsByPatientUuid = useMemo(() => { | ||
return getInpatientAdmissionsUuidMap(inpatientAdmissions); | ||
}, [inpatientAdmissions]); | ||
const { inpatientRequests } = inpatientRequestResponse; | ||
|
||
const { | ||
wardAdmittedPatientsWithBed, | ||
wardUnadmittedPatientsWithBed, | ||
wardPatientPendingCount, | ||
bedLayouts, | ||
wardUnassignedPatientsList, | ||
} = useMemo(() => { | ||
return createAndGetWardPatientGrouping(inpatientAdmissions, admissionLocation, inpatientAdmissionsByPatientUuid); | ||
}, [inpatientAdmissionsByPatientUuid, admissionLocation, inpatientAdmissions]); | ||
const groupings = useMemo(() => { | ||
if(!admissionLocationResponse.isLoading && !inpatientAdmissionResponse.isLoading && !inpatientRequestResponse.isLoading) { | ||
return createAndGetWardPatientGrouping(inpatientAdmissions, admissionLocation, inpatientRequests); | ||
} else { | ||
return {}; | ||
} | ||
}, [admissionLocation, inpatientAdmissions]) as ReturnType<typeof createAndGetWardPatientGrouping>; | ||
|
||
return { | ||
wardAdmittedPatientsWithBed, | ||
wardUnadmittedPatientsWithBed, | ||
wardUnassignedPatientsList, | ||
wardPatientPendingCount, | ||
...groupings, | ||
admissionLocationResponse, | ||
inpatientAdmissionResponse, | ||
bedLayouts, | ||
inpatientRequestResponse, | ||
}; | ||
} |
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
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
Oops, something went wrong.