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
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/Common/hooks/useSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export const useSlugs = (...prefix: string[]) => {
const findSlug = (segments: string[], prefix: string, fallback?: string) => {
const index = segments.findIndex((segment) => segment === prefix);
if (index === -1) {
if (fallback) {
return fallback;
}
throw new Error(
`Prefix "${prefix}" not found in path "${segments.join("/")}"`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ interface EditDiagnosesProps {
className?: string;
value: ConsultationDiagnosis[];
suggestions?: ICD11DiagnosisModel[];
consultationId?: string;
onUpdate?: (diagnoses: ConsultationDiagnosis[]) => void;
}

export const EditDiagnosesBuilder = (props: EditDiagnosesProps) => {
const consultation = useSlug("consultation");
const consultation = useSlug("consultation", props.consultationId);
const [diagnoses, setDiagnoses] = useState(props.value);
const [prefill, setPrefill] = useState<ICD11DiagnosisModel>();

Expand Down
67 changes: 45 additions & 22 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import useQuery from "../../Utils/request/useQuery";
import { useTranslation } from "react-i18next";
import useConfirmedAction from "../../Common/hooks/useConfirmedAction";
import ConfirmDialog from "../Common/ConfirmDialog";
import careConfig from "@careConfig";
import routes from "../../Redux/api";
import { EditDiagnosesBuilder } from "../Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder";
import Loading from "../Common/Loading";
import careConfig from "@careConfig";

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

const initialDiagnoses = useQuery(routes.getConsultation, {
pathParams: { id: consultationData.id ?? "" },
prefetch: !!consultationData.id,
}).data?.diagnoses;

const discharge_reason =
new_discharge_reason ?? preDischargeForm.new_discharge_reason;

Expand Down Expand Up @@ -208,6 +215,10 @@ const DischargeModal = ({

const confirmationRequired = encounterDuration.asDays() >= 30;

if (initialDiagnoses == null) {
return <Loading />;
}

return (
<>
<ConfirmDialog
Expand Down Expand Up @@ -291,27 +302,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 @@ -354,6 +344,18 @@ const DischargeModal = ({
: errors?.discharge_date
}
/>

{discharge_reason !==
DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
<div id="diagnoses">
<FieldLabel>{t("diagnosis_at_discharge")}</FieldLabel>
<EditDiagnosesBuilder
consultationId={consultationData.id}
value={initialDiagnoses}
/>
</div>
)}

{discharge_reason ===
DISCHARGE_REASONS.find((i) => i.text == "Recovered")?.id && (
<>
Expand Down Expand Up @@ -387,6 +389,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}
/>

{careConfig.hcx.enabled && (
// TODO: if policy and approved pre-auth exists
Expand Down
1 change: 1 addition & 0 deletions src/Locale/en/Consultation.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"back_dated_encounter_date_caution": "You are creating an encounter for",
"encounter_duration_confirmation": "The duration of this encounter would be",
"consultation_notes": "General Instructions (Advice)",
"diagnosis_at_discharge": "Diagnosis at Discharge",
"procedure_suggestions": "Procedure Suggestions",
"patient_notes_thread__Doctors": "Doctor's Discussions",
"patient_notes_thread__Nurses": "Nurse's Discussions"
Expand Down
Loading