-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
213 additions
and
95 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
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
70 changes: 35 additions & 35 deletions
70
packages/esm-ward-app/src/ward-view/materal-ward/maternal-ward-beds.component.tsx
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,60 +1,60 @@ | ||
import { useAppContext } from '@openmrs/esm-framework'; | ||
import React from 'react'; | ||
import WardBed from '../../beds/ward-bed.component'; | ||
import { MotherAndChild, type WardPatient, type WardViewContext } from '../../types'; | ||
import { type MotherAndChild, type WardPatient, type WardViewContext } from '../../types'; | ||
import { bedLayoutToBed } from '../ward-view.resource'; | ||
import MaternalWardPatientCard from './maternal-ward-patient-card.component'; | ||
|
||
interface MaternalWardBedsProps { | ||
motherChildrenRelationshipsByPatient: Map<string, MotherAndChild[]>; | ||
} | ||
|
||
const MaternalWardBeds : React.FC<MaternalWardBedsProps> = ({motherChildrenRelationshipsByPatient}) => { | ||
const {wardPatientGroupDetails} = useAppContext<WardViewContext>('ward-view-context') ?? {}; | ||
const MaternalWardBeds: React.FC<MaternalWardBedsProps> = ({ motherChildrenRelationshipsByPatient }) => { | ||
const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {}; | ||
const { bedLayouts, wardAdmittedPatientsWithBed } = wardPatientGroupDetails ?? {}; | ||
|
||
const wardBeds = bedLayouts?.map((bedLayout) => { | ||
const { patients: patientsInCurrentBed } = bedLayout; | ||
const bed = bedLayoutToBed(bedLayout); | ||
const wardPatients: WardPatient[] = patientsInCurrentBed.map((patient): WardPatient => { | ||
const inpatientAdmission = wardAdmittedPatientsWithBed?.get(patient.uuid); | ||
if (inpatientAdmission) { | ||
const { patient, visit, currentInpatientRequest } = inpatientAdmission; | ||
return { patient, visit, bed, inpatientAdmission, inpatientRequest: currentInpatientRequest || null }; | ||
} else { | ||
// for some reason this patient is in a bed but not in the list of admitted patients, | ||
// so we need to use the patient data from the bed endpoint | ||
return { | ||
patient: patient, | ||
visit: null, | ||
bed, | ||
inpatientAdmission: null, | ||
inpatientRequest: null, | ||
}; | ||
} | ||
}).filter((wardPatient) => { | ||
// filter out any child patient whose mother is also assigned to the same bed | ||
// (the child patient will instead have a sub-card rendered in the mother's patient card) | ||
const patientUuid = wardPatient.patient.uuid; | ||
for(const relationship of motherChildrenRelationshipsByPatient?.get(patientUuid) ?? []) { | ||
if(relationship.child.uuid == patientUuid) { | ||
if(patientsInCurrentBed.some((patient) => patient.uuid == relationship.mother.uuid)) { | ||
return false; | ||
const wardPatients: WardPatient[] = patientsInCurrentBed | ||
.map((patient): WardPatient => { | ||
const inpatientAdmission = wardAdmittedPatientsWithBed?.get(patient.uuid); | ||
if (inpatientAdmission) { | ||
const { patient, visit, currentInpatientRequest } = inpatientAdmission; | ||
return { patient, visit, bed, inpatientAdmission, inpatientRequest: currentInpatientRequest || null }; | ||
} else { | ||
// for some reason this patient is in a bed but not in the list of admitted patients, | ||
// so we need to use the patient data from the bed endpoint | ||
return { | ||
patient: patient, | ||
visit: null, | ||
bed, | ||
inpatientAdmission: null, | ||
inpatientRequest: null, | ||
}; | ||
} | ||
}) | ||
.filter((wardPatient) => { | ||
// filter out any child patient whose mother is also assigned to the same bed | ||
// (the child patient will instead have a sub-card rendered in the mother's patient card) | ||
const patientUuid = wardPatient.patient.uuid; | ||
for (const relationship of motherChildrenRelationshipsByPatient?.get(patientUuid) ?? []) { | ||
if (relationship.child.uuid == patientUuid) { | ||
if (patientsInCurrentBed.some((patient) => patient.uuid == relationship.mother.uuid)) { | ||
return false; | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
}); | ||
const patientCards = wardPatients.map(wardPatient => ( | ||
<MaternalWardPatientCard | ||
key={wardPatient.patient.uuid} | ||
{...wardPatient} /> | ||
return true; | ||
}); | ||
const patientCards = wardPatients.map((wardPatient) => ( | ||
<MaternalWardPatientCard key={wardPatient.patient.uuid} {...wardPatient} /> | ||
)); | ||
|
||
return <WardBed key={bed.uuid} bed={bed} patientCards={patientCards} />; | ||
}); | ||
|
||
return <>{wardBeds}</>; | ||
} | ||
}; | ||
|
||
export default MaternalWardBeds; |
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
48 changes: 48 additions & 0 deletions
48
...ages/esm-ward-app/src/ward-view/materal-ward/maternal-ward-pending-patients.component.tsx
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,48 @@ | ||
import { ErrorState, useAppContext } from '@openmrs/esm-framework'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { type InpatientRequest, type WardViewContext } from '../../types'; | ||
import AdmissionRequestNoteRow from '../../ward-patient-card/card-rows/admission-request-note-row.component'; | ||
import CodedObsTagsRow from '../../ward-patient-card/card-rows/coded-obs-tags-row.component'; | ||
import MotherChildRowExtension from '../../ward-patient-card/card-rows/mother-child-row.component'; | ||
import WardPatientSkeletonText from '../../ward-patient-card/row-elements/ward-patient-skeleton-text'; | ||
import AdmissionRequestCard from '../../ward-workspace/admission-request-card/admission-request-card.component'; | ||
|
||
function MaternalWardPendingPatients() { | ||
const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {}; | ||
const { t } = useTranslation(); | ||
const { inpatientRequestResponse } = wardPatientGroupDetails ?? {}; | ||
const { | ||
inpatientRequests, | ||
isLoading: isLoadingInpatientRequests, | ||
error: errorFetchingInpatientRequests, | ||
} = inpatientRequestResponse ?? {}; | ||
|
||
return isLoadingInpatientRequests ? ( | ||
<WardPatientSkeletonText /> | ||
) : errorFetchingInpatientRequests ? ( | ||
<ErrorState headerTitle={t('admissionRequests', 'Admission requests')} error={errorFetchingInpatientRequests} /> | ||
) : ( | ||
<> | ||
{inpatientRequests?.map((request: InpatientRequest, i) => { | ||
const wardPatient = { | ||
patient: request.patient, | ||
visit: request.visit, | ||
bed: null, | ||
inpatientRequest: request, | ||
inpatientAdmission: null, | ||
}; | ||
|
||
return ( | ||
<AdmissionRequestCard key={`admission-request-card-${i}`} wardPatient={wardPatient}> | ||
<CodedObsTagsRow id="pregnancy-complications" {...wardPatient} /> | ||
<MotherChildRowExtension {...wardPatient} /> | ||
<AdmissionRequestNoteRow id={'admission-request-note'} wardPatient={wardPatient} /> | ||
</AdmissionRequestCard> | ||
); | ||
})} | ||
</> | ||
); | ||
} | ||
|
||
export default MaternalWardPendingPatients; |
Oops, something went wrong.