coronasafe/care_fe

View on GitHub
src/pages/Encounters/PrintPrescription.tsx

Summary

Maintainability
F
6 days
Test Coverage

Showing 10 of 10 total issues

Function PrintPrescription has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const PrintPrescription = (props: {
facilityId: string;
encounterId: string;
patientId: string;
}) => {
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx - About 6 hrs to fix

Function PrintPrescription has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const PrintPrescription = (props: {
facilityId: string;
encounterId: string;
patientId: string;
}) => {
Severity: Minor
Found in src/pages/Encounters/PrintPrescription.tsx - About 35 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

rows={activeMedications?.results.map((medication) => {
const instruction = medication.dosage_instruction[0];
const frequency = getFrequencyDisplay(instruction?.timing);
const dosage = formatDosage(instruction);
const duration = instruction?.timing?.repeat?.bounds_duration;
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 1 day to fix
src/components/Patient/TreatmentSummary.tsx on lines 472..495

Identical blocks of code found in 2 locations. Consider refactoring.
Open

<div className="grid grid-cols-1 md:grid-cols-2 gap-x-12 gap-y-6 mb-8">
<div className="space-y-3">
<DetailRow
label={t("patient")}
value={encounter?.patient.name}
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 1 day to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 203..238

Similar blocks of code found in 3 locations. Consider refactoring.
Open

const DetailRow = ({
label,
value,
isStrong = false,
}: {
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 2 other locations - About 6 hrs to fix
src/components/Facility/ConsultationDetails/PrintQuestionnaireQuestionnaireResponses.tsx on lines 130..148
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 320..338

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<div className="flex flex-col sm:flex-row justify-between items-center sm:items-start mb-4 pb-2 border-b border-gray-200">
<img
src={careConfig.mainLogo?.dark}
alt="Care Logo"
className="h-10 w-auto object-contain mb-2 sm:mb-0 sm:order-2"
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 4 hrs to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 187..201

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const medicationsByPrescriber = activeMedications.results.reduce<
Record<string, MedicationRequestRead[]>
>((acc, med) => {
const prescriberId = med.created_by.id.toString();
if (!acc[prescriberId]) {
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 2 hrs to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 64..73

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const { data: encounter } = useQuery<Encounter>({
queryKey: ["encounter", encounterId],
queryFn: query(api.encounter.get, {
pathParams: { id: encounterId },
queryParams: { facility: facilityId },
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 1 hr to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 42..48

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<div className="mt-8 pt-2 text-[10px] text-gray-500 flex justify-between flex-wrap">
<p>
{t("generated_on")} {format(new Date(), "PPP 'at' p")}
</p>
<p>{t("computer_generated_prescription")}</p>
Severity: Major
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 1 hr to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 308..313

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<PrintPreview
title={`${t("prescriptions")} - ${encounter?.patient.name}`}
disabled={!activeMedications?.results?.length}
>
<div className="min-h-screen md:p-2 max-w-4xl mx-auto">
Severity: Minor
Found in src/pages/Encounters/PrintPrescription.tsx and 1 other location - About 55 mins to fix
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx on lines 181..316

There are no issues that match your filters.

Category
Status