1import{bb as g,g as w,F as N,d as f,j as e,e as _,B as j}from"./index-BjLsg-Ak.js";import{g as z,P as F}from"./medical-records.functions-CZX5B5WR.js";function P(t){if(!t)return"â";try{return new Date(t).toLocaleDateString("pt-BR")}catch{return"â"}}function $(t){if(!t)return"â";try{return new Date(t).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"})}catch{return"â"}}function D(t){if(!t)return null;const n=new Date(t);if(isNaN(n.getTime()))return null;const s=new Date;let i=s.getFullYear()-n.getFullYear();const o=s.getMonth()-n.getMonth();return(o<0||o===0&&s.getDate()<n.getDate())&&i--,i}function b(t){return t&&([[t.street,t.number].filter(Boolean).join(", "),t.complement,t.neighborhood,[t.city,t.state].filter(Boolean).join("/"),t.cep?`CEP ${t.cep}`:""].filter(Boolean).join(" · ")||t.address)||""}function A(){const{id:t}=g.useParams(),{doc:n,embed:s}=g.useSearch(),i=w(z),{data:o,isLoading:d,error:m}=N({queryKey:["mr-print",t],queryFn:()=>i({data:{id:t}})}),h=f.useMemo(()=>n==="receita"?"Receituário Médico":n==="anamnese"?"Ficha de Anamnese":"Prontuário Médico",[n]);if(f.useEffect(()=>{document.title=h},[h]),d)return e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsx(_,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(m||!o)return e.jsx("div",{className:"p-8 text-center text-sm text-destructive",children:"Não foi possÃvel carregar o documento."});const x=o.record,l=o.patient,a=o.clinic,c=o.doctor,u=D(l?.birth_date),y=c?`${c.full_name??"Médico(a)"}${c.specialty?` â ${c.specialty}`:""}`:"Médico(a) responsável",v=c?.crm?`CRM ${c.crm}${c.crm_uf?`/${c.crm_uf}`:""}${c.rqe?` · RQE ${c.rqe}`:""}`:"CRM â";return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:` 2 @page { size: A4; margin: 12mm 12mm; } 3 @media print { 4 .no-print { display: none !important; } 5 body { background: white !important; } 6 } 7 body { background: ${s?"#f8fafc":"#f1f5f9"}; } 8 .sheet { 9 max-width: 186mm; margin: ${s?"5mm":"10mm auto"}; background: white; color: #0f172a; 10 padding: 10mm 12mm 12mm; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; 11 font-size: 10.5pt; line-height: 1.4; box-shadow: 0 2px 10px rgba(15,23,42,.08); border-radius: 4px; 12 } 13 @media print { .sheet { box-shadow: none; margin: 0; padding: 0; max-width: none; border-radius: 0; } } 14 .hd { text-align: center; border-bottom: 2px solid #0f172a; padding-bottom: 8px; margin-bottom: 10px; } 15 .hd img { height: 52px; width: auto; object-fit: contain; margin: 0 auto 4px; display: block; } 16 .hd .cn { font-size: 15pt; font-weight: 700; color: #0f172a; letter-spacing: .02em; } 17 .hd .ci { font-size: 8.5pt; color: #475569; line-height: 1.35; margin-top: 2px; } 18 .doc-title { text-align: center; font-size: 12pt; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 4px 0 10px; color: #0f172a; } 19 .pat { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px; padding: 6px 10px; margin-bottom: 10px; font-size: 10pt; } 20 .pat .row { display: flex; flex-wrap: wrap; gap: 2px 16px; } 21 .pat strong { color: #0f172a; font-weight: 600; } 22 .sec { margin: 6px 0 10px; } 23 .sec h3 { font-size: 10pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #0f172a; border-bottom: 1px solid #cbd5e1; padding-bottom: 2px; margin-bottom: 4px; } 24 .sec p, .sec pre { white-space: pre-wrap; margin: 0 0 3px; font-size: 10pt; font-family: inherit; } 25 table.eye { width: 100%; border-collapse: collapse; margin-top: 4px; font-size: 9.5pt; } 26 table.eye th, table.eye td { border: 1px solid #cbd5e1; padding: 3px 6px; text-align: left; vertical-align: top; } 27 table.eye th { background: #f1f5f9; font-weight: 600; } 28 .rx { border: 1px solid #cbd5e1; border-radius: 4px; padding: 10px 14px; min-height: 180px; } 29 .rx ol { padding-left: 18px; margin: 0; } 30 .rx li { margin-bottom: 8px; } 31 .rx .med { font-weight: 700; font-size: 11.5pt; } 32 .rx .pos { font-size: 10pt; color: #334155; } 33 .foot { margin-top: 14mm; } 34 .sigblk { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; } 35 .sigblk .sig { flex: 1; text-align: center; border-top: 1px solid #0f172a; padding-top: 3px; font-size: 9.5pt; } 36 .sigblk .sig strong { display: block; font-size: 10pt; color: #0f172a; } 37 .sigblk .stamp { width: 46mm; height: 20mm; border: 1px dashed #94a3b8; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 8.5pt; color: #94a3b8; } 38 .clinic-foot { margin-top: 6mm; text-align: center; font-size: 8.5pt; color: #475569; border-top: 1px solid #e2e8f0; padding-top: 4px; line-height: 1.4; } 39 `}),!s&&e.jsxs("div",{className:"no-print",style:{position:"fixed",top:12,right:12,zIndex:50,display:"flex",gap:8},children:[e.jsxs(j,{size:"sm",onClick:()=>window.print(),children:[e.jsx(F,{className:"mr-2 h-4 w-4"})," Salvar em PDF"]}),e.jsx(j,{size:"sm",variant:"outline",onClick:()=>window.close(),children:"Fechar"})]}),e.jsxs("div",{className:"sheet",children:[e.jsxs("header",{className:"hd",children:[a?.logo_url?e.jsx("img",{src:a.logo_url,alt:""}):null,e.jsx("div",{className:"cn",children:a?.name||"ClÃnica"}),e.jsxs("div",{className:"ci",children:[b(a),a?.phone?e.jsxs(e.Fragment,{children:[" · Tel.: ",a.phone]}):null,a?.email?e.jsxs(e.Fragment,{children:[" · ",a.email]}):null,a?.cnpj?e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"CNPJ: ",a.cnpj]}):null]})]}),e.jsx("div",{className:"doc-title",children:h}),e.jsxs("div",{className:"pat",children:[e.jsxs("div",{className:"row",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Paciente:"})," ",l?.full_name??"â"]}),u!=null&&e.jsxs("span",{children:[e.jsx("strong",{children:"Idade:"})," ",u," anos"]}),l?.sex?e.jsxs("span",{children:[e.jsx("strong",{children:"Sexo:"})," ",l.sex]}):null]}),e.jsxs("div",{className:"row",children:[l?.cpf?e.jsxs("span",{children:[e.jsx("strong",{children:"CPF:"})," ",l.cpf]}):null,l?.birth_date?e.jsxs("span",{children:[e.jsx("strong",{children:"Nascimento:"})," ",P(l.birth_date)]}):null,l?.phone?e.jsxs("span",{children:[e.jsx("strong",{children:"Telefone:"})," ",l.phone]}
39):null]}),e.jsx("div",{className:"row",children:e.jsxs("span",{children:[e.jsx("strong",{children:"Data do atendimento:"})," ",$(x.consultation_date)]})})]}),n==="receita"&&e.jsx(B,{record:x}),n==="prontuario"&&e.jsx(R,{record:x}),n==="anamnese"&&e.jsx(C,{record:x,patient:l}),e.jsxs("div",{className:"foot",children:[e.jsxs("div",{className:"sigblk",children:[e.jsxs("div",{className:"sig",children:[e.jsx("strong",{children:y}),e.jsx("span",{children:v})]}),e.jsx("div",{className:"stamp",children:"Espaço para carimbo"})]}),e.jsxs("div",{className:"clinic-foot",children:[a?.name||""," · ",b(a),a?.phone?` · Tel. ${a.phone}`:""]})]})]})]})}function r({title:t,children:n}){return e.jsxs("section",{className:"sec",children:[e.jsx("h3",{children:t}),n]})}function p({value:t}){const n=t??"";return e.jsx("p",{children:n.trim()?n:"â"})}function B({record:t}){const n=t.prescription||[];return e.jsxs("div",{className:"rx",children:[n.length===0?e.jsx("p",{style:{color:"#94a3b8"},children:"Nenhuma prescrição registrada."}):e.jsx("ol",{children:n.map((s,i)=>e.jsxs("li",{children:[e.jsxs("div",{className:"med",children:[s.medication||"â",s.dosage?` â ${s.dosage}`:""]}),e.jsxs("div",{className:"pos",children:[s.via?`Via ${s.via}. `:"",s.frequency?`${s.frequency}. `:"",s.duration?`Por ${s.duration}. `:"",s.notes?`Obs.: ${s.notes}`:""]})]},i))}),t.conduct?e.jsxs("div",{style:{marginTop:12,fontSize:"10.5pt"},children:[e.jsx("strong",{children:"Orientações:"}),e.jsx("p",{style:{whiteSpace:"pre-wrap"},children:t.conduct})]}):null]})}function R({record:t}){const n=t.eye_exam||{od:{},oe:{}},s=n.od||{},i=n.oe||{};return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Queixa principal",children:e.jsx(p,{value:t.chief_complaint})}),e.jsx(r,{title:"História da doença atual / Anamnese",children:e.jsx(p,{value:t.anamnesis?.hda})}),e.jsx(r,{title:"Exame oftalmológico",children:e.jsxs("table",{className:"eye",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:"OD"}),e.jsx("th",{children:"OE"})]})}),e.jsx("tbody",{children:[["AV s/c","av_sc"],["AV c/c","av_cc"],["Refração","refracao"],["PIO","pio"],["Biomicroscopia","biomicroscopia"],["Fundoscopia","fundoscopia"]].map(([o,d])=>e.jsxs("tr",{children:[e.jsx("th",{style:{width:110},children:o}),e.jsx("td",{children:s[d]||"â"}),e.jsx("td",{children:i[d]||"â"})]},d))})]})}),e.jsx(r,{title:"Hipóteses diagnósticas / Diagnóstico",children:e.jsx(p,{value:t.diagnosis})}),e.jsx(r,{title:"Conduta / Plano",children:e.jsx(p,{value:t.conduct})}),t.notes?e.jsx(r,{title:"Observações",children:e.jsx(p,{value:t.notes})}):null]})}function C({record:t,patient:n}){const s=t.anamnesis||{},i=(o,d)=>{const m=d??"";return e.jsxs("div",{style:{display:"flex",gap:10,padding:"4px 0",borderBottom:"1px dotted #cbd5e1"},children:[e.jsx("strong",{style:{minWidth:170},children:o}),e.jsx("span",{style:{flex:1,whiteSpace:"pre-wrap"},children:m.trim()?m:"â"})]})};return e.jsxs(e.Fragment,{children:[e.jsxs(r,{title:"Identificação",children:[i("Profissão",s.profissao),i("Estado civil / contato",n?.email)]}),e.jsx(r,{title:"Queixa principal",children:e.jsx(p,{value:t.chief_complaint})}),e.jsx(r,{title:"História da doença atual",children:i("HDA",s.hda)}),e.jsxs(r,{title:"Antecedentes pessoais",children:[i("Doenças prévias / sistêmicas",s.antecedentes_sistemicos||s.antecedentes),i("Antecedentes oculares",s.antecedentes_oculares),i("Cirurgias oculares",s.cirurgias_oculares),i("Traumas oculares",s.traumas_oculares),i("Medicamentos em uso",s.medicamentos),i("Alergias",s.alergias)]}),e.jsxs(r,{title:"História familiar e hábitos",children:[i("Familiares",s.familiares),i("Tabagismo",s.tabagismo),i("Etilismo",s.etilismo),i("Tempo de tela (h/dia)",s.tempo_tela_horas),i("Usa correção",s.usa_correcao),i("Usa lente de contato",s.usa_lente_contato),i("Ãltima consulta oftalmológica",s.ultima_consulta)]}),e.jsxs(r,{title:"Diagnóstico / Conduta inicial",children:[i("Diagnóstico",t.diagnosis),i("Conduta",t.conduct)]})]})}export{A as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.