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

Added Diagnosis at Discharge field when patient is discharged #8390

Merged
merged 23 commits into from
Oct 1, 2024
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6f2217f
diagnosis at discharge field added
JOSHIK27 Aug 22, 2024
e992525
erased console logs
JOSHIK27 Aug 22, 2024
6d3a5f9
minor fix
JOSHIK27 Aug 22, 2024
627d02e
Update src/Components/Facility/DischargeModal.tsx
JOSHIK27 Aug 22, 2024
9f2f9d6
Update src/Components/Facility/DischargeModal.tsx
JOSHIK27 Aug 22, 2024
755c4bc
Add loading state, fix lint errors and improve code quality
rithviknishad Aug 22, 2024
3af38e1
Merge branch 'develop' into fixes#8299
rithviknishad Sep 2, 2024
9262333
Update label to Diagnosis at Discharge
rithviknishad Sep 2, 2024
3ecb5c3
Merge branch 'develop' into fixes#8299
nihal467 Sep 2, 2024
0e5fe0c
fixed by keeping a check on consultatio data
JOSHIK27 Sep 7, 2024
f54ea16
Merge branch 'develop' into fixes#8299
JOSHIK27 Sep 7, 2024
eda43eb
Merge branch 'develop' into fixes#8299
nihal467 Sep 18, 2024
72f03ca
fix the merge conflict
nihal467 Sep 18, 2024
5cfccce
Merge branch 'develop' into fixes#8299
nihal467 Sep 18, 2024
511a055
Merge branch 'ohcnetwork:develop' into fixes#8299
JOSHIK27 Sep 23, 2024
1cee48e
removed duplicate imports
JOSHIK27 Sep 23, 2024
4568e85
fixed something went wrong error by setting prefetch to trigger only …
JOSHIK27 Sep 23, 2024
7de3f3c
Merge branch 'develop' into fixes#8299
JOSHIK27 Sep 25, 2024
4e99831
Merge branch 'develop' into fixes#8299
JOSHIK27 Sep 30, 2024
66d15d6
Merge branch 'develop' into fixes#8299
rithviknishad Sep 30, 2024
4a86ea1
fixes discharge modal crashing in shifting completion
rithviknishad Sep 30, 2024
dbff51c
Merge branch 'develop' into fixes#8299
JOSHIK27 Sep 30, 2024
f334814
update findSlug logic to use fallback
rithviknishad Sep 30, 2024
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
64 changes: 43 additions & 21 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import { FieldError } from "../Form/FieldValidators";
import { useTranslation } from "react-i18next";
import useConfirmedAction from "../../Common/hooks/useConfirmedAction";
import ConfirmDialog from "../Common/ConfirmDialog";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import { EditDiagnosesBuilder } from "../Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder";
import { ConsultationDiagnosis } from "../Diagnosis/types";

interface PreDischargeFormInterface {
new_discharge_reason: number | null;
Expand Down Expand Up @@ -95,6 +99,15 @@ const DischargeModal = ({
setFacility(referred_to);
}, [referred_to]);

const { data } = useQuery(routes.getConsultation, {
pathParams: {
id: consultationData.id,
},
});

const ConsultationDiagnosisList: ConsultationDiagnosis[] =
JOSHIK27 marked this conversation as resolved.
Show resolved Hide resolved
data?.diagnoses?.map((diagnosis) => diagnosis) || [];
JOSHIK27 marked this conversation as resolved.
Show resolved Hide resolved

const discharge_reason =
new_discharge_reason ?? preDischargeForm.new_discharge_reason;

Expand Down Expand Up @@ -288,27 +301,6 @@ const DischargeModal = ({
/>
</div>
)}
<TextAreaFormField
required={
discharge_reason ==
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id
}
label={
{
"3": "Cause of death",
"1": "Discharged Advice",
}[discharge_reason ?? 0] ?? "Notes"
}
name="discharge_notes"
value={preDischargeForm.discharge_notes}
onChange={(e) =>
setPreDischargeForm((prev) => ({
...prev,
discharge_notes: e.value,
}))
}
error={errors?.discharge_notes}
/>
<TextFormField
name={
discharge_reason ===
Expand Down Expand Up @@ -351,6 +343,15 @@ const DischargeModal = ({
: errors?.discharge_date
}
/>

{discharge_reason !==
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
<div id="diagnosis_at_discharge">
<FieldLabel>Diagnosis at Discharge</FieldLabel>
<EditDiagnosesBuilder value={ConsultationDiagnosisList} />
</div>
)}

{discharge_reason ===
DISCHARGE_REASONS.find((i) => i.text == "Recovered")?.id && (
<>
Expand Down Expand Up @@ -384,6 +385,27 @@ const DischargeModal = ({
/>
)}
</div>
<TextAreaFormField
required={
discharge_reason ==
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id
}
label={
{
"3": "Cause of death",
"1": "Discharged Advice",
}[discharge_reason ?? 0] ?? "Notes"
}
name="discharge_notes"
value={preDischargeForm.discharge_notes}
onChange={(e) =>
setPreDischargeForm((prev) => ({
...prev,
discharge_notes: e.value,
}))
}
error={errors?.discharge_notes}
/>

{enable_hcx && (
// TODO: if policy and approved pre-auth exists
Expand Down
Loading