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

Refactor Consultation Diagnosis (M2M relation, additional verification statuses and other improvements) #6528

Merged
merged 27 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9a7661b
useSlug: support for fallbacks for graceful handling
rithviknishad Oct 29, 2023
d8aa83b
Miscellaneous changes / cleanup
rithviknishad Oct 30, 2023
8e55927
Merge branch 'develop' into consultation_diagnoses_m2m
rithviknishad Oct 30, 2023
aec3be2
Add API routes
rithviknishad Oct 30, 2023
6abdcd6
remove old diagnoses from Consultation Form
rithviknishad Oct 30, 2023
edca688
Add component: `AddICD11Diagnosis`
rithviknishad Oct 30, 2023
9b8f805
Add component: `ConditionVerificationStatusMenu`
rithviknishad Oct 30, 2023
85fba65
uncomplicate things
rithviknishad Oct 30, 2023
cb79d42
Add component `ConsultationDiangosisEntry`
rithviknishad Oct 30, 2023
a836586
Basic implementation
rithviknishad Oct 30, 2023
8c5abe2
i have no idea what these are, but lots of bugs gone
rithviknishad Oct 30, 2023
019a272
goodnight for today
rithviknishad Oct 30, 2023
03db9cf
responsiveness
rithviknishad Oct 30, 2023
6ab770a
pre-sort by verification status
rithviknishad Oct 30, 2023
a7ebd12
Adds help text
rithviknishad Oct 31, 2023
d8556b8
responsiveness
rithviknishad Oct 31, 2023
368a7cc
fix overflow
rithviknishad Oct 31, 2023
be7fe42
show diagnoses in consultation dashboard
rithviknishad Oct 31, 2023
0f1e079
fix consultation create
rithviknishad Oct 31, 2023
427875f
Show chapter of diagnosis for principal diagnosis (#6541)
rithviknishad Nov 3, 2023
8b48e9b
Merge branch 'develop' into consultation_diagnoses_m2m
rithviknishad Nov 3, 2023
a1e8493
fixes #6544; Principal Diagnosis as Dropdown
rithviknishad Nov 6, 2023
4064e32
fix cypress
rithviknishad Nov 6, 2023
700bd1c
Merge branch 'develop' into consultation_diagnoses_m2m
rithviknishad Nov 6, 2023
a5fea0c
minor fix
rithviknishad Nov 6, 2023
b696e52
Merge branch 'develop' into consultation_diagnoses_m2m
rithviknishad Nov 8, 2023
2293f40
Merge branch 'develop' into consultation_diagnoses_m2m
rithviknishad Nov 9, 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
Add component ConsultationDiangosisEntry
rithviknishad committed Oct 30, 2023
commit cb79d42ef24d513f70a115e5efceb8a0b4d149eb
Original file line number Diff line number Diff line change
@@ -34,8 +34,10 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) {

setAdding(true);
const added = await props.onAdd({
diagnosis_object: selected,
diagnosis: selected.id,
verification_status: status,
is_principal: false,
});
setAdding(false);

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { useTranslation } from "react-i18next";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import ButtonV2 from "../../Common/components/ButtonV2";
import ConditionVerificationStatusMenu from "../ConditionVerificationStatusMenu";
import {
ActiveConditionVerificationStatuses,
ConditionVerificationStatuses,
ConsultationDiagnosis,
CreateDiagnosis,
} from "../types";
import DiagnosesRoutes from "../routes";
import { useState } from "react";
import request from "../../../Utils/request/request";
import * as Notification from "../../../Utils/Notifications";

interface RemoveAction {
type: "remove";
}

interface EditAction {
type: "edit";
value: CreateDiagnosis | ConsultationDiagnosis;
}

type Action = RemoveAction | EditAction;

interface BaseProps {
className?: string;
}

interface ConsultationCreateProps extends BaseProps {
consultationId?: undefined;
value: CreateDiagnosis;
onChange: (action: Action) => void;
}

interface ConsultationEditProps extends BaseProps {
consultationId: string;
value: ConsultationDiagnosis;
}

type Props = ConsultationCreateProps | ConsultationEditProps;

export default function ConsultationCreateDignosisEntry(props: Props) {
const { t } = useTranslation();
const [data, setData] = useState<ConsultationDiagnosis>();
const [disabled, setDisabled] = useState(false);

const handleUpdate = async (value: ConsultationDiagnosis) => {
setDisabled(true);
const { res, data, error } = await request(
DiagnosesRoutes.updateConsultationDiagnosis,
{
pathParams: {
consultation: props.consultationId as string,
id: value.id,
},
}
);
setDisabled(false);

if (error) {
Notification.Error({ msg: error });
}

if (res?.ok && data) {
setData(data);
}
};

const object = data ?? props.value;

<div className={props.className}>
<div className="flex items-start gap-2">
<div className="cui-input-base">{object.diagnosis_object?.label}</div>

<ButtonV2
className="shrink-0"
variant={object.is_principal ? "primary" : "secondary"}
disabled={disabled}
ghost
border
onClick={() => {
const value = { ...object, is_principal: !object.is_principal };

if (props.consultationId === undefined) {
props.onChange({ type: "edit", value });
return;
}

handleUpdate(value as ConsultationDiagnosis);
}}
>
<CareIcon
icon={object.is_principal ? "l-check" : "l-times"}
className="text-lg"
/>

<span className="sr-only">
{object.is_principal
? t("mark_as_principal")
: t("unmark_as_principal")}
</span>
</ButtonV2>

<ConditionVerificationStatusMenu
className="shrink-0"
value={object.verification_status}
disabled={disabled}
options={
props.consultationId === undefined
? ActiveConditionVerificationStatuses
: ConditionVerificationStatuses
}
onSelect={(verification_status) => {
const value = { ...object, verification_status };

if (props.consultationId === undefined) {
props.onChange({ type: "edit", value: value as CreateDiagnosis });
return;
}

handleUpdate(value as ConsultationDiagnosis);
}}
onRemove={
props.consultationId === undefined
? () => props.onChange({ type: "remove" })
: undefined
}
/>
</div>
</div>;
}
2 changes: 1 addition & 1 deletion src/Components/Diagnosis/routes.ts
Original file line number Diff line number Diff line change
@@ -30,6 +30,6 @@ const DiagnosesRoutes = {
TBody: Type<Partial<CreateDiagnosis>>(),
TRes: Type<ConsultationDiagnosis>(),
},
};
} as const;

export default DiagnosesRoutes;
4 changes: 3 additions & 1 deletion src/Locale/en/Diagnosis.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"diagnosis_already_added": "This diagnosis was already added",
"add_diagnosis": "Add diagnosis"
"add_diagnosis": "Add diagnosis",
"mark_as_principal": "Mark as principal",
"unmark_as_principal": "Unmark as principal"
}