Skip to content

Commit

Permalink
Merge branch 'fix#6756' of https://github.com/sriharsh05/care_fe into…
Browse files Browse the repository at this point in the history
… fix#6756
  • Loading branch information
sriharsh05 committed Dec 21, 2023
2 parents 0daec4e + 7c9c3b9 commit 42dce58
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 561 deletions.
5 changes: 4 additions & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ export const CONSULTATION_SUGGESTION = [
{ id: "OP", text: "OP Consultation" },
{ id: "DC", text: "Domiciliary Care" },
{ id: "DD", text: "Declare Death" },
];
] as const;

export type ConsultationSuggestionValue =
(typeof CONSULTATION_SUGGESTION)[number]["id"];

export const ADMITTED_TO = [
{ id: "1", text: "Isolation" },
Expand Down
9 changes: 0 additions & 9 deletions src/Common/hooks/useIsInitialRender.ts

This file was deleted.

52 changes: 0 additions & 52 deletions src/Components/Common/NavTabs.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions src/Components/Common/WardAutocompleteFormField.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/Components/DeathReport/DeathReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export default function PrintDeathReport(props: { id: string }) {
date_declared_positive: res.data?.date_declared_positive
? dayjs(res.data?.date_declared_positive).toDate()
: "",
date_of_admission: res.data?.last_consultation?.admission_date
? dayjs(res.data?.last_consultation?.admission_date).toDate()
date_of_admission: res.data?.last_consultation?.encounter_date
? dayjs(res.data?.last_consultation?.encounter_date).toDate()
: "",
date_of_test: res.data?.date_of_test
? dayjs(res.data?.date_of_test).toDate()
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/ConsultationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export const ConsultationCard = (props: ConsultationProps) => {
</div>
</div>
)}
{itemData.admitted && itemData.admission_date && (
{itemData.admitted && itemData.encounter_date && (
<div className="sm:col-span-1">
<div className="sm:col-span-1">
<div className="text-sm font-semibold leading-5 text-zinc-400">
Admitted on
</div>
<div className="mt-1 overflow-x-scroll whitespace-normal break-words text-sm font-medium leading-5">
{formatDateTime(itemData.admission_date)}
{formatDateTime(itemData.encounter_date)}
{itemData.is_readmission && (
<Chip
size="small"
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export const ConsultationDetails = (props: any) => {
name:
consultationData.suggestion === "A"
? `Admitted on ${formatDateTime(
consultationData.admission_date!
consultationData.encounter_date!
)}`
: consultationData.suggestion_text,
},
Expand Down Expand Up @@ -345,19 +345,19 @@ export const ConsultationDetails = (props: any) => {
{consultationData.admitted_to}
</span>
</div>
{(consultationData.admission_date ??
consultationData.discharge_date) && (
{(consultationData.discharge_date ??
consultationData.encounter_date) && (
<div className="text-3xl font-bold">
{relativeTime(
consultationData.discharge_date
? consultationData.discharge_date
: consultationData.admission_date
: consultationData.encounter_date
)}
</div>
)}
<div className="-mt-2 text-xs">
{consultationData.admission_date &&
formatDateTime(consultationData.admission_date)}
{consultationData.encounter_date &&
formatDateTime(consultationData.encounter_date)}
{consultationData.discharge_date &&
` - ${formatDateTime(consultationData.discharge_date)}`}
</div>
Expand Down
75 changes: 38 additions & 37 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Notification from "../../Utils/Notifications.js";
import { BedModel, FacilityModel } from "./models";
import {
CONSULTATION_SUGGESTION,
ConsultationSuggestionValue,
PATIENT_CATEGORIES,
REVIEW_AT_CHOICES,
TELEMEDICINE_ACTIONS,
Expand Down Expand Up @@ -82,14 +83,14 @@ type FormDetails = {
symptoms: number[];
other_symptoms: string;
symptoms_onset_date?: Date;
suggestion: string;
suggestion: ConsultationSuggestionValue;
route_to_facility?: RouteToFacility;
patient: string;
facility: string;
admitted: BooleanStrings;
admitted_to: string;
category: string;
admission_date?: Date;
encounter_date?: Date;
icu_admission_date?: Date;
discharge_date: null;
referred_to?: string;
Expand Down Expand Up @@ -139,7 +140,7 @@ const initForm: FormDetails = {
admitted: "false",
admitted_to: "",
category: "",
admission_date: new Date(),
encounter_date: new Date(),
icu_admission_date: undefined,
discharge_date: null,
referred_to: "",
Expand Down Expand Up @@ -375,7 +376,7 @@ export const ConsultationForm = (props: any) => {
const formData = {
...res.data,
symptoms_onset_date: isoStringToDate(res.data.symptoms_onset_date),
admission_date: isoStringToDate(res.data.admission_date),
encounter_date: isoStringToDate(res.data.encounter_date),
icu_admission_date: isoStringToDate(res.data.icu_admission_date),
admitted: res.data.admitted ? String(res.data.admitted) : "false",
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
Expand Down Expand Up @@ -485,15 +486,12 @@ export const ConsultationForm = (props: any) => {
invalidForm = true;
}
return;
case "admission_date":
if (
["A", "DC"].includes(state.form.suggestion) &&
!state.form[field]
) {
case "encounter_date":
if (!state.form[field]) {
errors[field] = "Field is required";
invalidForm = true;
}
if (dayjs(state.form.admission_date).isBefore(dayjs("2000-01-01"))) {
if (dayjs(state.form.encounter_date).isBefore(dayjs("2000-01-01"))) {
errors[field] = "Admission date cannot be before 01/01/2000";
invalidForm = true;
}
Expand Down Expand Up @@ -685,9 +683,7 @@ export const ConsultationForm = (props: any) => {
suggestion: state.form.suggestion,
route_to_facility: state.form.route_to_facility,
admitted: state.form.suggestion === "A",
admission_date: ["A", "DC"].includes(state.form.suggestion)
? state.form.admission_date
: undefined,
encounter_date: state.form.encounter_date,
category: state.form.category,
is_kasp: state.form.is_kasp,
kasp_enabled_date: JSON.parse(state.form.is_kasp) ? new Date() : null,
Expand Down Expand Up @@ -1134,7 +1130,7 @@ export const ConsultationForm = (props: any) => {
label="Decision after consultation"
{...selectField("suggestion")}
options={CONSULTATION_SUGGESTION.filter(
({ deprecated }) => !deprecated
(option) => !("deprecated" in option)
)}
/>
</div>
Expand Down Expand Up @@ -1200,30 +1196,35 @@ export const ConsultationForm = (props: any) => {
</>
)}

{["A", "DC"].includes(state.form.suggestion) && (
<div
className={classNames(
"col-span-6",
state.form.route_to_facility === 30 && "xl:col-span-3"
<div
className={classNames(
"col-span-6",
state.form.route_to_facility === 30 && "xl:col-span-3"
)}
ref={fieldRef["encounter_date"]}
>
<TextFormField
{...field("encounter_date")}
required={["A", "DC", "OP"].includes(
state.form.suggestion
)}
ref={fieldRef["admission_date"]}
>
<TextFormField
{...field("admission_date")}
required
label={
state.form.suggestion === "DC"
? "Date & Time of Domiciliary Care commencement"
: "Date & Time of Admission to the Facility"
}
type="datetime-local"
value={dayjs(state.form.admission_date).format(
"YYYY-MM-DDTHH:mm"
)}
max={dayjs().format("YYYY-MM-DDTHH:mm")}
/>
</div>
)}
label={
{
A: "Date & Time of Admission to the Facility",
DC: "Date & Time of Domiciliary Care commencement",
OP: "Date & Time of Out-patient visit",
DD: "Date & Time of Encounter",
HI: "Date & Time of Encounter",
R: "Date & Time of Encounter",
}[state.form.suggestion]
}
type="datetime-local"
value={dayjs(state.form.encounter_date).format(
"YYYY-MM-DDTHH:mm"
)}
max={dayjs().format("YYYY-MM-DDTHH:mm")}
/>
</div>

{state.form.route_to_facility === 30 && (
<div
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ const DischargeModal = ({
setPreDischargeForm((form) => ({ ...form, ...updates }));
}}
required
min={dayjs(
consultationData?.admission_date ?? consultationData?.created_date
).format("YYYY-MM-DDTHH:mm")}
min={dayjs(consultationData?.encounter_date).format(
"YYYY-MM-DDTHH:mm"
)}
max={dayjs().format("YYYY-MM-DDTHH:mm")}
error={
preDischargeForm.discharge_reason === "EXP"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/TreatmentSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const TreatmentSummary = (props: any) => {
<b>Date of admission :</b>
<span>
{consultationData.admitted
? formatDateTime(consultationData.admission_date)
? formatDateTime(consultationData.encounter_date)
: " --/--/----"}
</span>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AssetData, AssetLocationType } from "../Assets/AssetTypes";
import { UserBareMinimum } from "../Users/models";
import { RouteToFacility } from "../Common/RouteToFacilitySelect";
import { ConsultationDiagnosis, CreateDiagnosis } from "../Diagnosis/types";
import { ConsultationSuggestionValue } from "../../Common/constants";

export interface LocalBodyModel {
id: number;
Expand Down Expand Up @@ -93,7 +94,7 @@ export type PatientCategory =
| "Critical";

export interface ConsultationModel {
admission_date?: string;
encounter_date: string;
icu_admission_date?: string;
admitted?: boolean;
test_id?: string;
Expand Down Expand Up @@ -123,7 +124,7 @@ export interface ConsultationModel {
referred_by_external?: string;
transferred_from_location?: LocationModel["id"];
transferred_from_location_object?: LocationModel;
suggestion?: string;
suggestion?: ConsultationSuggestionValue;
patient_no?: string;
route_to_facility?: RouteToFacility;
is_kasp?: boolean;
Expand Down
Loading

0 comments on commit 42dce58

Please sign in to comment.