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

U4X-358 : Barcode and referal / shipping inclusion #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const configSchema = {
},
laboratorySpecimenTypeConcept: {
_type: Type.ConceptUuid,
_default: "159959AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
_default: "162476AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
_description: "Concept UUID for laboratory specimen types",
},
laboratoryEncounterTypeUuid: {
Expand All @@ -26,6 +26,11 @@ export const configSchema = {
_default: "52a447d3-a64a-11e3-9aeb-50e549534c5e",
_description: "Uuid for orderType",
},
laboratoryReferalDestinationUuid: {
_type: Type.String,
_default: "b1f8b6c8-c255-4518-89f5-4236ab76025b",
_description: "Concept uuid for laboratory referals destinations",
},
};

export type Config = {
Expand Down
147 changes: 90 additions & 57 deletions src/queue-list/lab-dialogs/add-to-worklist-dialog.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,82 +32,41 @@ import {
GetOrderByUuid,
UpdateOrder,
useQueueRoomLocations,
useReferralLocations,
useSpecimenTypes,
} from "./add-to-worklist-dialog.resource";
import { Encounter, Order } from "../../types/patient-queues";

interface AddToWorklistDialogProps {
queueId;
encounter: Encounter;
order: Order;
closeModal: () => void;
}

const AddToWorklistDialog: React.FC<AddToWorklistDialogProps> = ({
queueId,
encounter,
order,
closeModal,
}) => {
const { t } = useTranslation();

const locations = useLocations();

const sessionUser = useSession();

const [selectedLocation, setSelectedLocation] = useState("");

const [preferred, setPreferred] = useState(false);

const [specimenID, setSpecimenID] = useState();
const [specimenID, setSpecimenID] = useState("");

const { specimenTypes } = useSpecimenTypes();

const [orderer, setOrderer] = useState("");

const [concept, setConcept] = useState("");

const [patient, setPatient] = useState("");

const [encounterUuid, setEncounterUuid] = useState("");

const { queueRoomLocations } = useQueueRoomLocations(
sessionUser?.sessionLocation?.uuid
);
const { referrals } = useReferralLocations();

const [specimenType, setSpecimenType] = useState();

const [selectedNextQueueLocation, setSelectedNextQueueLocation] = useState(
queueRoomLocations[0]?.uuid
);
const [selectedReferral, setSelectedReferral] = useState("");

const filteredlocations = queueRoomLocations?.filter(
(location) => location.uuid != selectedLocation
);
const [barcode, setBarcode] = useState("");

useEffect(() => {
if (locations?.length && sessionUser) {
setSelectedLocation(sessionUser?.sessionLocation?.uuid);
}
}, [locations, sessionUser]);
const [confirmBarcode, setConfirmBarcode] = useState("");

// GetOrderByUuid
GetOrderByUuid(order.uuid).then(
(resp) => {
setOrderer(resp.data?.orderer?.uuid);
setConcept(resp.data?.concept?.uuid);
setPatient(resp.data?.patient?.uuid);
setEncounterUuid(resp.data?.encounter.uuid);
},
(err) => {
showNotification({
title: t(`errorGettingOrder', 'Error Getting Order Id`),
kind: "error",
critical: true,
description: err?.message,
});
}
);
const [externalReferralName, setExternalReferralName] = useState("");

const pickLabRequestQueue = async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -174,6 +133,12 @@ const AddToWorklistDialog: React.FC<AddToWorklistDialogProps> = ({
);
};

useEffect(() => {
if (barcode !== "" && confirmBarcode !== "" && barcode == confirmBarcode) {
setSpecimenID(barcode);
}
}, [barcode, confirmBarcode]);

return (
<div>
<Form onSubmit={pickLabRequestQueue}>
Expand All @@ -193,7 +158,9 @@ const AddToWorklistDialog: React.FC<AddToWorklistDialogProps> = ({
}}
>
<div className={styles.sectionTitle}>
{t("specimenID", "Specimen ID")}
{preferred
? t("barcode", "Barcode")
: t("specimenID", "Specimen ID")}
</div>

<div
Expand All @@ -209,13 +176,16 @@ const AddToWorklistDialog: React.FC<AddToWorklistDialogProps> = ({
type="text"
id="specimentID"
value={specimenID}
readOnly={preferred}
hideReadOnly={preferred}
/>
</div>
<div style={{ width: "50px" }}>
<Button
hasIconOnly
onClick={(e) => generateId(e)}
renderIcon={(props) => <Renew size={16} {...props} />}
disabled={preferred}
/>
</div>
</div>
Expand Down Expand Up @@ -282,26 +252,89 @@ const AddToWorklistDialog: React.FC<AddToWorklistDialogProps> = ({
<div style={{ width: "500px" }}>
<section className={styles.section}>
<Select
labelText={t("location", "Location ")}
labelText={t("locationReferral", "Referral Location ")}
id="nextQueueLocation"
name="nextQueueLocation"
invalidText="Required"
value={selectedNextQueueLocation}
value={selectedReferral}
onChange={(event) =>
setSelectedNextQueueLocation(event.target.value)
setSelectedReferral(event.target.value)
}
>
{filteredlocations.map((location) => (
{referrals.map((referral) => (
<SelectItem
key={location.uuid}
text={location.display}
value={location.uuid}
key={referral.uuid}
text={referral.display}
value={referral.uuid}
>
{location.display}
{referral.display}
</SelectItem>
))}
</Select>
</section>

<section className={styles.section}>
{selectedReferral ===
"3476fd97-71da-4e9c-bf57-2b6318dc0c9f" && (
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<div style={{ width: "500px" }}>
<TextInput
type="text"
id="locationName"
labelText={"Enter Name"}
value={externalReferralName}
required={true}
onChange={(e) =>
setExternalReferralName(e.target.value)
}
/>
</div>
</div>
)}
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<div style={{ width: "500px" }}>
<TextInput
type="text"
id="enterBarcode"
labelText={"Enter Barcode"}
value={barcode}
required={true}
onChange={(e) => {
setBarcode(e.target.value);
}}
/>
</div>
</div>
<div
style={{
display: "flex",
alignItems: "center",
}}
>
<div style={{ width: "500px" }}>
<TextInput
type="text"
id="confirmBarcode"
labelText={"Confirm Barcode"}
value={confirmBarcode}
required={true}
onChange={(e) => {
setConfirmBarcode(e.target.value);
}}
/>
</div>
</div>
</section>
</div>
)}
</section>
Expand Down
18 changes: 17 additions & 1 deletion src/queue-list/lab-dialogs/add-to-worklist-dialog.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ export function useQueueRoomLocations(currentQueueLocation: string) {
};
}

// get referral locations
export function useReferralLocations() {
const config = useConfig();
const { laboratoryReferalDestinationUuid } = config;
const apiUrl = `/ws/rest/v1/concept/${laboratoryReferalDestinationUuid}`;
const { data, error, isLoading } = useSWRImmutable<FetchResponse>(
apiUrl,
openmrsFetch
);

return {
referrals: data ? data?.data?.answers : [],
isLoading,
};
}

// get specimen types
export function useSpecimenTypes() {
const config = useConfig();
Expand All @@ -114,7 +130,7 @@ export function useSpecimenTypes() {
);

return {
specimenTypes: data ? data?.data?.answers : [],
specimenTypes: data ? data?.data?.setMembers : [],
isLoading,
};
}
Expand Down
Loading