Преглед на файлове

fix reports classification

Matthew Trejo преди 1 месец
родител
ревизия
ad0d900171

+ 2 - 0
src/components/chatbot/ChatInterface.tsx

@@ -204,6 +204,7 @@ export const ChatInterface = ({ chatType }: ChatInterfaceProps) => {
             {showCompletedBanner && (
               <CompletedBanner
                 isGeneratingReport={isGeneratingReport}
+                chatType={chatType}
                 onDismiss={dismissCompletedBanner}
               />
             )}
@@ -266,6 +267,7 @@ export const ChatInterface = ({ chatType }: ChatInterfaceProps) => {
         isOpen={showReportModal}
         onClose={() => setShowReportModal(false)}
         generatedReport={generatedReport}
+        chatType={chatType}
       />
 
       {/* Reset Confirmation Modal */}

+ 7 - 4
src/components/chatbot/CompletedBanner.tsx

@@ -3,10 +3,13 @@ import { Button } from "@/components/ui/button";
 
 interface CompletedBannerProps {
   isGeneratingReport: boolean;
+  chatType?: "medical" | "psychological";
   onDismiss: () => void;
 }
 
-export const CompletedBanner = ({ isGeneratingReport, onDismiss }: CompletedBannerProps) => {
+export const CompletedBanner = ({ isGeneratingReport, chatType = "medical", onDismiss }: CompletedBannerProps) => {
+  const reportType = chatType === "psychological" ? "Reporte Psicológico" : "Reporte Médico";
+  
   return (
     <div className="bg-success/10 border border-success/20 rounded-lg p-4 mb-4 relative">
       <Button
@@ -30,13 +33,13 @@ export const CompletedBanner = ({ isGeneratingReport, onDismiss }: CompletedBann
         <div className="flex-1">
           <h3 className="font-semibold text-foreground text-sm">
             {isGeneratingReport
-              ? "Generando Reporte Médico"
+              ? `Generando ${reportType}`
               : "Consulta Completada"}
           </h3>
           <p className="text-muted-foreground text-xs mt-1">
             {isGeneratingReport
-              ? "Estamos procesando tu consulta y generando un reporte médico personalizado."
-              : "Tu consulta ha sido completada. El reporte médico ha sido generado y guardado. Puedes revisar la conversación abajo."}
+              ? `Estamos procesando tu consulta y generando un ${reportType.toLowerCase()} personalizado.`
+              : `Tu consulta ha sido completada. El ${reportType.toLowerCase()} ha sido generado y guardado. Puedes revisar la conversación abajo.`}
           </p>
         </div>
       </div>

+ 7 - 4
src/components/chatbot/CompletedState.tsx

@@ -2,9 +2,12 @@ import { FileText } from "lucide-react";
 
 interface CompletedStateProps {
   isGeneratingReport: boolean;
+  chatType?: "medical" | "psychological";
 }
 
-export const CompletedState = ({ isGeneratingReport }: CompletedStateProps) => {
+export const CompletedState = ({ isGeneratingReport, chatType = "medical" }: CompletedStateProps) => {
+  const reportType = chatType === "psychological" ? "Reporte Psicológico" : "Reporte Médico";
+  
   return (
     <div className="text-center py-12">
       <div className="w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-4">
@@ -16,13 +19,13 @@ export const CompletedState = ({ isGeneratingReport }: CompletedStateProps) => {
       </div>
       <h3 className="text-xl font-semibold text-foreground mb-2">
         {isGeneratingReport
-          ? "Generando Reporte Médico"
+          ? `Generando ${reportType}`
           : "Consulta Completada"}
       </h3>
       <p className="text-muted-foreground">
         {isGeneratingReport
-          ? "Estamos procesando tu consulta y generando un reporte médico personalizado."
-          : "Tu consulta ha sido completada. El reporte médico ha sido generado y guardado."}
+          ? `Estamos procesando tu consulta y generando un ${reportType.toLowerCase()} personalizado.`
+          : `Tu consulta ha sido completada. El ${reportType.toLowerCase()} ha sido generado y guardado.`}
       </p>
     </div>
   );

+ 7 - 2
src/components/chatbot/ReportModal.tsx

@@ -12,13 +12,18 @@ interface ReportModalProps {
   isOpen: boolean;
   onClose: () => void;
   generatedReport: string;
+  chatType?: "medical" | "psychological";
 }
 
 export const ReportModal = ({
   isOpen,
   onClose,
   generatedReport,
+  chatType = "medical",
 }: ReportModalProps) => {
+  const reportType = chatType === "psychological" ? "psicologico" : "medico";
+  const reportLabel = chatType === "psychological" ? "Reporte Psicológico" : "Reporte Médico";
+  
   const copyReport = () => {
     navigator.clipboard.writeText(generatedReport);
     notifications.records.copied();
@@ -29,7 +34,7 @@ export const ReportModal = ({
     const url = URL.createObjectURL(blob);
     const a = document.createElement("a");
     a.href = url;
-    a.download = `reporte-medico-${new Date().toISOString().split("T")[0]}.txt`;
+    a.download = `reporte-${reportType}-${new Date().toISOString().split("T")[0]}.txt`;
     document.body.appendChild(a);
     a.click();
     document.body.removeChild(a);
@@ -43,7 +48,7 @@ export const ReportModal = ({
         <DialogHeader>
           <DialogTitle className="flex items-center">
             <FileText className="w-5 h-5 mr-2" />
-            Reporte Médico Generado
+            {reportLabel} Generado
           </DialogTitle>
         </DialogHeader>
         <div className="mt-4">

+ 21 - 6
src/components/records/RecordsCard.tsx

@@ -49,6 +49,16 @@ export default function RecordsCard({
     return formatDate(dateString)
   }
 
+  const getReportTypeLabel = () => {
+    return record.chatType === "PSYCHOLOGICAL" ? "Reporte Psicológico" : "Reporte Médico"
+  }
+
+  const getReportTypeColor = () => {
+    return record.chatType === "PSYCHOLOGICAL" 
+      ? "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300" 
+      : "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"
+  }
+
   return (
     <Card className="group hover:shadow-lg transition-all duration-300 border overflow-hidden">
       <CardHeader className="pb-4">
@@ -61,12 +71,17 @@ export default function RecordsCard({
               <CardTitle className="text-xl font-bold text-foreground">
                 {userRole === "PATIENT" ? "Mi Reporte" : `Reporte #${record.id.slice(-8)}`}
               </CardTitle>
-              {userRole !== "PATIENT" && (
-                <div className="flex items-center text-xs text-muted-foreground mt-1">
-                  <Tag className="w-3 h-3 mr-1" />
-                  {record.id.slice(0, 8)}...
-                </div>
-              )}
+              <div className="flex items-center gap-2 mt-1">
+                {userRole !== "PATIENT" && (
+                  <div className="flex items-center text-xs text-muted-foreground">
+                    <Tag className="w-3 h-3 mr-1" />
+                    {record.id.slice(0, 8)}...
+                  </div>
+                )}
+                <span className={`text-xs font-medium px-2 py-1 rounded-full ${getReportTypeColor()}`}>
+                  {getReportTypeLabel()}
+                </span>
+              </div>
             </div>
           </div>
           <div className="flex space-x-1">

+ 7 - 1
src/components/records/RecordsModal.tsx

@@ -55,6 +55,10 @@ function RecordsModal({
     });
   };
 
+  const getReportTypeLabel = (chatType: string) => {
+    return chatType === "PSYCHOLOGICAL" ? "Reporte Psicológico" : "Reporte Médico"
+  }
+
   if (!record) return null;
 
   return (
@@ -67,7 +71,9 @@ function RecordsModal({
           <div className="px-4 py-3 border-b border-border bg-card sticky top-0 z-10 flex items-center justify-between">
             <DialogTitle className="flex items-center text-lg font-semibold">
               <FileText className="w-5 h-5 mr-2 text-primary flex-shrink-0" />
-              {userRole === "PATIENT" ? "Mi Reporte Médico" : `Reporte Médico - ${record.id.slice(-8)}`}
+              {userRole === "PATIENT" 
+                ? getReportTypeLabel(record.chatType)
+                : `${getReportTypeLabel(record.chatType)} - ${record.id.slice(-8)}`}
             </DialogTitle>
             <Button
               variant="ghost"

+ 1 - 0
src/components/records/types.ts

@@ -2,6 +2,7 @@ export interface Record {
   id: string
   content: string
   messages: unknown
+  chatType: 'MEDICAL' | 'PSYCHOLOGICAL'
   createdAt: string
   user: {
     id: string

+ 2 - 0
src/hooks/useChat.ts

@@ -517,6 +517,7 @@ export const useChat = ({ chatType }: UseChatProps) => {
         body: JSON.stringify({
           content: currentReport,
           messages: messages,
+          chatType: chatType.toUpperCase(), // Pasar el tipo de chat
         }),
       });
 
@@ -565,6 +566,7 @@ export const useChat = ({ chatType }: UseChatProps) => {
         body: JSON.stringify({
           content: currentReport,
           messages: messages,
+          chatType: chatType.toUpperCase(), // Pasar el tipo de chat
         }),
       });