1import{r as N,N as T,Q as Hs,j as e,o as s,G as b,H as t,n as Be,M as os,B as Ps,q as nn,S as tn,T as rn,w as on,U as Us,e as Fe,s as ns,V as an,W as ln,X as dn,Y as cn,E as _n,Z as mn,u as hn,$ as Gs,P as pn,h as Os,L as un,a0 as gn,a1 as xn,a2 as jn,a3 as fn,a4 as yn,a5 as bn,a6 as Ds,a7 as vn,a8 as Cn}from"./index-BiR4tHPa.js";import{s as we}from"./editPatientHeader.module-CTIPAsEB.js";import{A as P}from"./Accordion-BluZk8dt.js";import{D as sn}from"./DeleteConfirmationModal-DM5KwsxY.js";import Sn from"./MaterialUiDatePicker-vRODdoO2.js";import{S as wn}from"./ScheduleOtRequest-CEAWCoT3.js";import{I as Rs}from"./InputGroup-BGL484mZ.js";import"./useMobilePicker-ChVQmibs.js";import"./useThemeProps-Bm86sZ3E.js";import"./AdapterDayjs-C_KT9Vl8.js";import"./dateViewRenderers-BEc2yG4Q.js";import"./index-Baj-kYYB.js";import"./InputGroupContext-CWnggAZ1.js";const kn={ot_case_id:"",request_id:"",patient_id:"",patient_name:"",ipd_admission_id:"",patient_mobile_number:"",consent:{procedure_consent:{present:!0,signed:!0,signed_by:"patient_or_relative",signed_name:"",signed_at:"",explained_by:{doctor_id:localStorage.getItem("doctorId")||localStorage.getItem("user_id")||localStorage.getItem("userId")||"",doctor_name:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||localStorage.getItem("userName")||""},witness_name:"",language:"hi",attachment_url:[]},anesthesia_consent:{present:!0,signed:!0,signed_at:"",explained_by:{doctor_id:"",doctor_name:""},attachment_url:[]}},pre_anesthesia_assessment:{assessed_by:{doctor_id:localStorage.getItem("doctorId")||localStorage.getItem("user_id")||localStorage.getItem("userId")||"",doctor_name:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||localStorage.getItem("userName")||""},assessed_at:"",allergies:[],current_medications:[],comorbidities:[],vitals:{bp:"",pulse:80,spo2:98},asa_class:"ASA_I",airway:{mallampati:"I",difficult_airway_risk:"no"},aspiration_risk:"no",npo_status:{solids_last_at:"",clear_liquids_last_at:"",confirmed:!1},investigations_reviewed:[],plan:{anesthesia_type:"general",airway_plan:"ETT",blood_loss_risk:"low",blood_prepared:!1,postop_destination:"ward"}},day_of_surgery_readiness:{identity_procedure_site_confirmed:!0,site_marked_if_applicable:!0,anesthesia_machine_check_complete:!0,medication_check_complete:!0,pulse_oximeter_ready:!0,antibiotic_plan_ready:!0,equipment_ready:!0,implants_ready:!0},gating:{preop_clearance_completed:!0,allowed_to_start_anesthesia:!0,blocked_reasons:[]},blood_arrangement:{required:!0,units:2,group:"B+",cross_matched:!0},completed_by:{user_id:"",role:"anesthetist"}},en=()=>JSON.parse(JSON.stringify(kn)),In=({show:w,handleClose:q,handleSubmit:es,patientData:m,otRequestData:a,selectedRecord:A})=>{var fe,is,de,ye;if(!w)return null;const[X,C]=N.useState([]),[j,se]=N.useState(!1),[W,ie]=N.useState(""),[d,Y]=N.useState(""),[u,je]=N.useState(null),[o,B]=N.useState(en);N.useEffect(()=>{var i,n,l,p,H,I;if(w&&(m||a)){const h=(m==null?void 0:m.data)||m||{},S=(a==null?void 0:a.data)||a||{};console.log("Patient Data:",m),console.log("OT Request Data:",a),console.log("Available fields:",Object.keys(h||{}));const ae=(S==null?void 0:S.patient_id)||(h==null?void 0:h.patient_id)||(h==null?void 0:h._id)||"",ne=((i=S==null?void 0:S.schedule_details)==null?void 0:i.ot_room_id)||((n=S==null?void 0:S.ot_location)==null?void 0:n.id)||(S==null?void 0:S.ot_room_id)||(S==null?void 0:S.request_id)||(h==null?void 0:h.request_id)||"",ge=(S==null?void 0:S.ot_case_id)||"",pe=(S==null?void 0:S.ipd_admission_id)==null?"":String(S.ipd_admission_id).trim(),re=[S==null?void 0:S.ipdAdmissionId,(l=S==null?void 0:S.ipd)==null?void 0:l.admission_id,(p=S==null?void 0:S.ipd)==null?void 0:p.admissionId,h==null?void 0:h.ipd_admission_id,h==null?void 0:h.ipdAdmissionId,h==null?void 0:h.admission_id,h==null?void 0:h.ipd_id,h==null?void 0:h.ipd_no,(H=h==null?void 0:h.ipd)==null?void 0:H.admission_id,(I=h==null?void 0:h.ipd)==null?void 0:I.admissionId].map(z=>z==null?"":String(z).trim()).filter(Boolean).filter(z=>z!==String(ae||"").trim()).filter(z=>z!==String(ne||"").trim()).filter(z=>z!==String(ge||"").trim()),J=pe||re[0]||"";B(z=>({...z,ot_case_id:a._id||"",request_id:ne,patient_id:(S==null?void 0:S.patient_id)||(h==null?void 0:h.patient_id)||(h==null?void 0:h._id)||"",patient_name:(S==null?void 0:S.patient_name)||(h==null?void 0:h.patient_name)||(h==null?void 0:h.name)||"",ipd_admission_id:J,patient_mobile_number:(S==null?void 0:S.patient_mobile_number)||(h==null?void 0:h.patient_mobile_number)||(h==null?void 0:h.phone)||(h==null?void 0:h.mobile_number)||(h==null?void 0:h.contact_number)||""}))}},[w,m,a]),N.useEffect(()=>{w&&(async()=>{var n;try{const l=await nn(),p=((n=l==null?void 0:l.data)==null?void 0:n.document)||[];C(p)}catch(l){console.error("Error fetching doctors:",l),C([])}})()},[w]);const $e=i=>{const n=String(i||"").toLowerCase().split("?")[0].split("#")[0];return n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg")||n.endsWith(".gif")||n.endsWith(".webp")},D=i=>{const n=String(i||"").trim();if(!n)return"";const l=n.toLowerCase();return l.startsWith("http://")||l.startsWith("https://")||!n.startsWith("/")?n:`${String(on).replace(/\/$/,"")}${n}`},F=(i,n)=>{B(l=>{var I,h;const H=[...Array.isArray((h=(I=l==null?void 0:l.consent)==null?void 0:I.procedure_consent)==null?void 0:h.attachment_url)?l.consent.procedure_consent.attachment_url:[]];return H[i]=D(n),{...l,consent:{...l.consent,procedure_consent:{...l.consent.procedure_consent,attachment_url:H}}}})},V=()=>{const i=D(W);
1i&&(B(n=>{var H,I;const p=[...Array.isArray((I=(H=n==null?void 0:n.consent)==null?void 0:H.procedure_consent)==null?void 0:I.attachment_url)?n.consent.procedure_consent.attachment_url:[],i];return{...n,consent:{...n.consent,procedure_consent:{...n.consent.procedure_consent,attachment_url:p}}}}),ie(""))},c=i=>{B(n=>{var H,I;const p=(Array.isArray((I=(H=n==null?void 0:n.consent)==null?void 0:H.procedure_consent)==null?void 0:I.attachment_url)?n.consent.procedure_consent.attachment_url:[]).filter((h,S)=>S!==i);return{...n,consent:{...n.consent,procedure_consent:{...n.consent.procedure_consent,attachment_url:p}}}})},r=(i,n)=>{B(l=>{var I,h;const H=[...Array.isArray((h=(I=l==null?void 0:l.consent)==null?void 0:I.anesthesia_consent)==null?void 0:h.attachment_url)?l.consent.anesthesia_consent.attachment_url:[]];return H[i]=D(n),{...l,consent:{...l.consent,anesthesia_consent:{...l.consent.anesthesia_consent,attachment_url:H}}}})},x=()=>{const i=D(d);i&&(B(n=>{var H,I;const p=[...Array.isArray((I=(H=n==null?void 0:n.consent)==null?void 0:H.anesthesia_consent)==null?void 0:I.attachment_url)?n.consent.anesthesia_consent.attachment_url:[],i];return{...n,consent:{...n.consent,anesthesia_consent:{...n.consent.anesthesia_consent,attachment_url:p}}}}),Y(""))},G=i=>{B(n=>{var H,I;const p=(Array.isArray((I=(H=n==null?void 0:n.consent)==null?void 0:H.anesthesia_consent)==null?void 0:I.attachment_url)?n.consent.anesthesia_consent.attachment_url:[]).filter((h,S)=>S!==i);return{...n,consent:{...n.consent,anesthesia_consent:{...n.consent.anesthesia_consent,attachment_url:p}}}})},K=i=>i?X.filter(n=>{var l,p,H,I,h;return((l=n.name)==null?void 0:l.toLowerCase().includes(i.toLowerCase()))||((p=n.doctor_name)==null?void 0:p.toLowerCase().includes(i.toLowerCase()))||((H=n.full_name)==null?void 0:H.toLowerCase().includes(i.toLowerCase()))||((I=n._id)==null?void 0:I.toLowerCase().includes(i.toLowerCase()))||((h=n.doctor_id)==null?void 0:h.toLowerCase().includes(i.toLowerCase()))}):X,f=i=>{const{name:n,value:l,type:p,checked:H}=i.target;if(n.includes(".")){const I=n.split(".");B(h=>{const S={...h};let ae=S;for(let ne=0;ne<I.length-1;ne++)ae[I[ne]]={...ae[I[ne]]},ae=ae[I[ne]];return ae[I[I.length-1]]=p==="checkbox"?H:l,S})}else B(I=>({...I,[n]:p==="checkbox"?H:l}))},ce=i=>{je(i)},_e=()=>{je(null)};N.useEffect(()=>{const i=n=>{n.key==="Escape"&&_e()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[]),N.useEffect(()=>{w&&(a!=null&&a.ot_case_id)&&(async()=>{var n,l,p,H,I,h,S,ae,ne,ge,pe,re,J,z,Ke,We,Ve,xe,me,ze,ke,Ie,Xe,Ne,Je,Qe,Se,Ze,qe,Ye,De,Re,Me,Ae,Le,Ee,Te,He,Oe,Pe,_,y,U,$,O,L,k,M,oe,R,le,ue,Ge,Ue,be,Q,Z,ve,te;try{const ee=await Hs(a.ot_case_id);if(((l=(n=ee==null?void 0:ee.data)==null?void 0:n.document)==null?void 0:l.length)>0){const ts=ee.data.document[0],E=ts.data||ts;B({ot_case_id:E.ot_case_id||a.ot_case_id||"",request_id:E.request_id||a._id||"",patient_id:E.patient_id||(m==null?void 0:m._id)||"",patient_name:E.patient_name||(m==null?void 0:m.patient_name)||"",ipd_admission_id:E.ipd_admission_id||"",patient_mobile_number:E.patient_mobile_number||(m==null?void 0:m.patient_mobile_number)||"",day_of_surgery_readiness:E.day_of_surgery_readiness||{identity_procedure_site_confirmed:!0,site_marked_if_applicable:!0,anesthesia_machine_check_complete:!0,medication_check_complete:!0,pulse_oximeter_ready:!0,antibiotic_plan_ready:!0,equipment_ready:!0,implants_ready:!0},gating:E.gating||{preop_clearance_completed:!0,allowed_to_start_anesthesia:!0,blocked_reasons:[]},consent:{procedure_consent:{present:((H=(p=E.consent)==null?void 0:p.procedure_consent)==null?void 0:H.present)??!0,consent_type:((h=(I=E.consent)==null?void 0:I.procedure_consent)==null?void 0:h.consent_type)||"",attachment_url:((ae=(S=E.consent)==null?void 0:S.procedure_consent)==null?void 0:ae.attachment_url)||[],signed:((ge=(ne=E.consent)==null?void 0:ne.procedure_consent)==null?void 0:ge.signed)??!0,signed_by:((re=(pe=E.consent)==null?void 0:pe.procedure_consent)==null?void 0:re.signed_by)||"patient_or_relative",signed_name:((z=(J=E.consent)==null?void 0:J.procedure_consent)==null?void 0:z.signed_name)||"",signed_at:(We=(Ke=E.consent)==null?void 0:Ke.procedure_consent)!=null&&We.signed_at?T(E.consent.procedure_consent.signed_at).format("YYYY-MM-DDTHH:mm"):"",explained_by:{doctor_id:((me=(xe=(Ve=E.consent)==null?void 0:Ve.procedure_consent)==null?void 0:xe.explained_by)==null?void 0:me.doctor_id)||"",doctor_name:((Ie=(ke=(ze=E.consent)==null?void 0:ze.procedure_consent)==null?void 0:ke.explained_by)==null?void 0:Ie.doctor_name)||""}},anesthesia_consent:{present:((Ne=(Xe=E.consent)==null?void 0:Xe.anesthesia_consent)==null?void 0:Ne.present)??!0,consent_type:((Qe=(Je=E.consent)==null?void 0:Je.anesthesia_consent)==null?void 0:Qe.consent_type)||"",attachment_url:((Ze=(Se=E.consent)==null?void 0:Se.anesthesia_consent)==null?void 0:Ze.attachment_url)||[],signed:((Ye=(qe=E.consent)==null?void 0:qe.anesthesia_consent)==null?void 0:Ye.signed)??!0,signed_by:((Re=(De=E.consent)==null?void 0:De.anesthesia_consent)==null?void 0:Re.signed_by)||"patient_or_relative",signed_name:((Ae=(Me=E.consent)==null?void 0:Me.anesthesia_consent)==null?void 0:Ae.signed_name)||"",signed_at:(Ee=(Le=E.consent)==null?void 0:Le.anesthesia_consent)!=null&&Ee.signed_at?T(E.consent.anesthesia_consent.signed_at).format("YYYY-MM-DDTHH:mm"):"",explained_by:{doctor_id:((Oe=(He=(Te=E.consent)==null?void 0:Te.anesthesia_consent)==null?void 0:He.explained_by)==null?void 0:Oe.doctor_id)||"",doctor_name:((y=(_=(Pe=E.consent)==null?void 0:Pe.ane
1sthesia_consent)==null?void 0:_.explained_by)==null?void 0:y.doctor_name)||""}}},pre_anesthesia_assessment:{assessed_by:((U=E.pre_anesthesia_assessment)==null?void 0:U.assessed_by)||{doctor_id:"",doctor_name:""},assessed_at:($=E.pre_anesthesia_assessment)!=null&&$.assessed_at?T(E.pre_anesthesia_assessment.assessed_at).format("YYYY-MM-DDTHH:mm"):"",allergies:((O=E.pre_anesthesia_assessment)==null?void 0:O.allergies)||[],current_medications:((L=E.pre_anesthesia_assessment)==null?void 0:L.current_medications)||[],comorbidities:((k=E.pre_anesthesia_assessment)==null?void 0:k.comorbidities)||[],vitals:((M=E.pre_anesthesia_assessment)==null?void 0:M.vitals)||{bp:"",pulse:0,spo2:0},asa_class:((oe=E.pre_anesthesia_assessment)==null?void 0:oe.asa_class)||"",airway:((R=E.pre_anesthesia_assessment)==null?void 0:R.airway)||{mallampati:"I",difficult_airway_risk:"no"},aspiration_risk:((le=E.pre_anesthesia_assessment)==null?void 0:le.aspiration_risk)||"",npo_status:{solids_last_at:(Ge=(ue=E.pre_anesthesia_assessment)==null?void 0:ue.npo_status)!=null&&Ge.solids_last_at?T(E.pre_anesthesia_assessment.npo_status.solids_last_at).format("YYYY-MM-DDTHH:mm"):"",clear_liquids_last_at:(be=(Ue=E.pre_anesthesia_assessment)==null?void 0:Ue.npo_status)!=null&&be.clear_liquids_last_at?T(E.pre_anesthesia_assessment.npo_status.clear_liquids_last_at).format("YYYY-MM-DDTHH:mm"):"",confirmed:((Z=(Q=E.pre_anesthesia_assessment)==null?void 0:Q.npo_status)==null?void 0:Z.confirmed)??!1},investigations_reviewed:((ve=E.pre_anesthesia_assessment)==null?void 0:ve.investigations_reviewed)||[],plan:((te=E.pre_anesthesia_assessment)==null?void 0:te.plan)||{anesthesia_type:"general",airway_plan:"ETT",blood_loss_risk:"",blood_prepared:!1,blood_arrangement:{required:!0,units:2,group:"B+",cross_matched:!0},postop_destination:"ward"}},completed_by:E.completed_by||{role:"",name:"",id:""}})}}catch(ee){console.error("Error fetching pre-op details:",ee)}})()},[w,A,a==null?void 0:a.ot_case_id,m]),N.useEffect(()=>{var i,n,l,p,H,I,h,S,ae,ne,ge,pe,re,J,z,Ke,We,Ve,xe,me,ze,ke,Ie,Xe,Ne,Je,Qe,Se,Ze,qe,Ye,De,Re,Me,Ae,Le,Ee,Te,He,Oe,Pe,_,y,U,$,O,L,k,M,oe,R,le,ue,Ge,Ue,be,Q,Z,ve,te,ee,ts,E,as,ls,ds,cs,_s,ms,hs,ps,us,gs,xs,js,fs,ys,bs,vs,Cs,Ss,ws,ks,Is,Ns,Ys,Ms,As,Ls,ss,Es,v,Bs,Fs,$s,Ks,Ws,Vs,zs,Xs,Js,Qs,Zs,qs;if(w&&A){const g=A.data||A;B({ot_case_id:g.ot_case_id||(a==null?void 0:a.ot_case_id)||"",request_id:g.request_id||(a==null?void 0:a._id)||"",patient_id:g.patient_id||(m==null?void 0:m._id)||"",patient_name:g.patient_name||(m==null?void 0:m.patient_name)||"",ipd_admission_id:g.ipd_admission_id||"",patient_mobile_number:g.patient_mobile_number||(m==null?void 0:m.patient_mobile_number)||"",blood_arrangement:{...en().blood_arrangement,...g.blood_arrangement||{}},day_of_surgery_readiness:g.day_of_surgery_readiness||{identity_procedure_site_confirmed:!0,site_marked_if_applicable:!0,anesthesia_machine_check_complete:!0,medication_check_complete:!0,pulse_oximeter_ready:!0,antibiotic_plan_ready:!0,equipment_ready:!0,implants_ready:!0},gating:g.gating||{preop_clearance_completed:!0,allowed_to_start_anesthesia:!0,blocked_reasons:[]},consent:{procedure_consent:{present:((n=(i=g.consent)==null?void 0:i.procedure_consent)==null?void 0:n.present)??!0,consent_type:((p=(l=g.consent)==null?void 0:l.procedure_consent)==null?void 0:p.consent_type)||"",attachment_url:((I=(H=g.consent)==null?void 0:H.procedure_consent)==null?void 0:I.attachment_url)||[],signed:((S=(h=g.consent)==null?void 0:h.procedure_consent)==null?void 0:S.signed)??!0,signed_by:((ne=(ae=g.consent)==null?void 0:ae.procedure_consent)==null?void 0:ne.signed_by)||"patient_or_relative",signed_name:((pe=(ge=g.consent)==null?void 0:ge.procedure_consent)==null?void 0:pe.signed_name)||"",signed_at:(J=(re=g.consent)==null?void 0:re.procedure_consent)!=null&&J.signed_at?T(g.consent.procedure_consent.signed_at).format("YYYY-MM-DDTHH:mm"):"",explained_by:{doctor_id:((We=(Ke=(z=g.consent)==null?void 0:z.procedure_consent)==null?void 0:Ke.explained_by)==null?void 0:We.doctor_id)||"",doctor_name:((me=(xe=(Ve=g.consent)==null?void 0:Ve.procedure_consent)==null?void 0:xe.explained_by)==null?void 0:me.doctor_name)||""}},anesthesia_consent:{present:((ke=(ze=g.consent)==null?void 0:ze.anesthesia_consent)==null?void 0:ke.present)??!0,consent_type:((Xe=(Ie=g.consent)==null?void 0:Ie.anesthesia_consent)==null?void 0:Xe.consent_type)||"",attachment_url:((Je=(Ne=g.consent)==null?void 0:Ne.anesthesia_consent)==null?void 0:Je.attachment_url)||[],signed:((Se=(Qe=g.consent)==null?void 0:Qe.anesthesia_consent)==null?void 0:Se.signed)??!0,signed_by:((qe=(Ze=g.consent)==null?void 0:Ze.anesthesia_consent)==null?void 0:qe.signed_by)||"patient_or_relative",signed_name:((De=(Ye=g.consent)==null?void 0:Ye.anesthesia_consent)==null?void 0:De.signed_name)||"",signed_at:(Me=(Re=g.consent)==null?void 0:Re.anesthesia_consent)!=null&&Me.signed_at?T(g.consent.anesthesia_consent.signed_at).format("YYYY-MM-DDTHH:mm"):"",explained_by:{doctor_id:((Ee=(Le
1=(Ae=g.consent)==null?void 0:Ae.anesthesia_consent)==null?void 0:Le.explained_by)==null?void 0:Ee.doctor_id)||"",doctor_name:((Oe=(He=(Te=g.consent)==null?void 0:Te.anesthesia_consent)==null?void 0:He.explained_by)==null?void 0:Oe.doctor_name)||""}}},pre_anesthesia_assessment:{assessed_by:((Pe=g.pre_anesthesia_assessment)==null?void 0:Pe.assessed_by)||{doctor_id:"",doctor_name:""},assessed_at:(_=g.pre_anesthesia_assessment)!=null&&_.assessed_at?T(g.pre_anesthesia_assessment.assessed_at).format("YYYY-MM-DDTHH:mm"):"",allergies:((y=g.pre_anesthesia_assessment)==null?void 0:y.allergies)||[],current_medications:((U=g.pre_anesthesia_assessment)==null?void 0:U.current_medications)||[],comorbidities:(($=g.pre_anesthesia_assessment)==null?void 0:$.comorbidities)||[],vitals:((O=g.pre_anesthesia_assessment)==null?void 0:O.vitals)||{bp:"",pulse:0,spo2:0},asa_class:((L=g.pre_anesthesia_assessment)==null?void 0:L.asa_class)||"",airway:((k=g.pre_anesthesia_assessment)==null?void 0:k.airway)||{mallampati:"I",difficult_airway_risk:"no"},aspiration_risk:((M=g.pre_anesthesia_assessment)==null?void 0:M.aspiration_risk)||"",npo_status:{solids_last_at:(R=(oe=g.pre_anesthesia_assessment)==null?void 0:oe.npo_status)!=null&&R.solids_last_at?T(g.pre_anesthesia_assessment.npo_status.solids_last_at).format("YYYY-MM-DDTHH:mm"):"",clear_liquids_last_at:(ue=(le=g.pre_anesthesia_assessment)==null?void 0:le.npo_status)!=null&&ue.clear_liquids_last_at?T(g.pre_anesthesia_assessment.npo_status.clear_liquids_last_at).format("YYYY-MM-DDTHH:mm"):"",confirmed:((Ue=(Ge=g.pre_anesthesia_assessment)==null?void 0:Ge.npo_status)==null?void 0:Ue.confirmed)??!1},investigations_reviewed:((be=g.pre_anesthesia_assessment)==null?void 0:be.investigations_reviewed)||[],plan:((Q=g.pre_anesthesia_assessment)==null?void 0:Q.plan)||{anesthesia_type:"general",airway_plan:"ETT",blood_loss_risk:"",blood_prepared:!1,blood_arrangement:{required:!0,units:2,group:"B+",cross_matched:!0},postop_destination:"ward"}},post_op_details:{surgery_completion_time:(Z=g.post_op_details)!=null&&Z.surgery_completion_time?T(g.post_op_details.surgery_completion_time).format("YYYY-MM-DDTHH:mm"):"",recovery_room_arrival:(ve=g.post_op_details)!=null&&ve.recovery_room_arrival?T(g.post_op_details.recovery_room_arrival).format("YYYY-MM-DDTHH:mm"):"",vitals_stable:((te=g.post_op_details)==null?void 0:te.vitals_stable)??!0,pain_score:((ee=g.post_op_details)==null?void 0:ee.pain_score)||0,pain_management:{medication:((E=(ts=g.post_op_details)==null?void 0:ts.pain_management)==null?void 0:E.medication)||"",dosage:((ls=(as=g.post_op_details)==null?void 0:as.pain_management)==null?void 0:ls.dosage)||"",frequency:((cs=(ds=g.post_op_details)==null?void 0:ds.pain_management)==null?void 0:cs.frequency)||"",route:((ms=(_s=g.post_op_details)==null?void 0:_s.pain_management)==null?void 0:ms.route)||""},consciousness_level:((hs=g.post_op_details)==null?void 0:hs.consciousness_level)||"",airway_patent:((ps=g.post_op_details)==null?void 0:ps.airway_patent)??!0,breathing_spontaneous:((us=g.post_op_details)==null?void 0:us.breathing_spontaneous)??!0,oxygen_saturation:((gs=g.post_op_details)==null?void 0:gs.oxygen_saturation)||98,blood_pressure_systolic:((xs=g.post_op_details)==null?void 0:xs.blood_pressure_systolic)||120,blood_pressure_diastolic:((js=g.post_op_details)==null?void 0:js.blood_pressure_diastolic)||80,heart_rate:((fs=g.post_op_details)==null?void 0:fs.heart_rate)||80,temperature:((ys=g.post_op_details)==null?void 0:ys.temperature)||36.5,urine_output:{amount:((vs=(bs=g.post_op_details)==null?void 0:bs.urine_output)==null?void 0:vs.amount)||0,time_period:((Ss=(Cs=g.post_op_details)==null?void 0:Cs.urine_output)==null?void 0:Ss.time_period)||"hours"},drainage_tubes:((ws=g.post_op_details)==null?void 0:ws.drainage_tubes)||[],iv_fluids:{type:((Is=(ks=g.post_op_details)==null?void 0:ks.iv_fluids)==null?void 0:Is.type)||"",rate:((Ys=(Ns=g.post_op_details)==null?void 0:Ns.iv_fluids)==null?void 0:Ys.rate)||"",volume:((As=(Ms=g.post_op_details)==null?void 0:Ms.iv_fluids)==null?void 0:As.volume)||""},complications:((Ls=g.post_op_details)==null?void 0:Ls.complications)||[],blood_arrangement:((ss=g.post_op_details)==null?void 0:ss.blood_arrangement)||{required:!0,units:2,group:"B+",cross_matched:!0},post_op_instructions:{diet:((v=(Es=g.post_op_details)==null?void 0:Es.post_op_instructions)==null?void 0:v.diet)||"",activity:((Fs=(Bs=g.post_op_details)==null?void 0:Bs.post_op_instructions)==null?void 0:Fs.activity)||"",medications:((Ks=($s=g.post_op_details)==null?void 0:$s.post_op_instructions)==null?void 0:Ks.medications)||[],follow_up:((Vs=(Ws=g.post_op_details)==null?void 0:Ws.post_op_instructions)==null?void 0:Vs.follow_up)||""},discharge_planning:{expected_discharge_date:(Xs=(zs=g.post_op_details)==null?void 0:zs.discharge_planning)!=null&&Xs.expected_discharge_date?T(g.post_op_details.discharge_planning.expected_discharge_date).format("YYYY-MM-DD"):"",discharge_criteria_met:((Qs=(Js=g.post_op_details)==null?void 0:Js.discharge_planning)==null?void 0:Qs.discharge_criteria_met)??!1,home_care_instructions:((qs=(Zs=g.post_op_details)==null?void 0:Zs.discharge_planning)==null?void 0:qs.home_care_instructions)||""}},completed_by:g.completed_by||{role:"",name:"",id:""}})}else w&&!A&&(a!=null&&a.ot_case_id)&&he()},[w,A,a==null?void 0:a.ot_case_id,m]);const he=async()=>{var i,n,l,p,H,I,h,S,ae,ne,ge,pe,re,J,z,Ke,We,Ve,xe,me,ze,ke,Ie,Xe,Ne,Je,Qe,Se,Ze,qe,Ye,De,Re,Me,Ae,Le,Ee,Te,He,Oe,Pe,_,y,U,$,O,L,k,M,oe,R,le,ue,Ge,Ue,be,Q,Z,ve,te,ee,ts,E,as,ls,ds,cs,_s,ms,hs,ps,us,gs,xs,js,fs,ys,bs,vs,Cs,Ss,ws,ks,Is,Ns,Ys,Ms,As,Ls;try{const ss=await Hs(a.ot_case_id);if(((n=(i=ss==null?void 0:ss.data)==null?void 0:i.document)==null?void 0:n.length)>0){const Es=ss.data.document[0],v=Es.data||Es;B({ot_case_id:v.ot_case_id||a.ot_case_id||"",request_id:v.request_id||a._id||"",patient_id:v.patient_id||(m==null?void 0:m._id)||"",patient_name:v.patient_name||(m==null?void 0:m.patient_name)||"",ipd_admission_id:v.ipd_admission_id||"",patient_mobile_number:v.patient_mobile_number||(m==null?void 0:m.patient_mobile_number)||"",day_of_surgery_readiness:v.day_of_surgery_readiness||{identity_procedure_site_confirmed:!0,site_marked_if_applicable:!0,anesthesia_machine_check_complete:!0,medication_check_complete:!0,pulse_oximeter_ready:!0,antibiotic_plan_ready:!0,equipment_ready:!0,implants_ready:!0}
1,gating:v.gating||{preop_clearance_completed:!0,allowed_to_start_anesthesia:!0,blocked_reasons:[]},consent:{procedure_consent:{present:((p=(l=v.consent)==null?void 0:l.procedure_consent)==null?void 0:p.present)??!0,consent_type:((I=(H=v.consent)==null?void 0:H.procedure_consent)==null?void 0:I.consent_type)||"",attachment_url:((S=(h=v.consent)==null?void 0:h.procedure_consent)==null?void 0:S.attachment_url)||[],signed:((ne=(ae=v.consent)==null?void 0:ae.procedure_consent)==null?void 0:ne.signed)??!0,signed_by:((pe=(ge=v.consent)==null?void 0:ge.procedure_consent)==null?void 0:pe.signed_by)||"patient_or_relative",signed_name:((J=(re=v.consent)==null?void 0:re.procedure_consent)==null?void 0:J.signed_name)||"",signed_at:((Ke=(z=v.consent)==null?void 0:z.procedure_consent)==null?void 0:Ke.signed_at)||"",explained_by:{doctor_id:((xe=(Ve=(We=v.consent)==null?void 0:We.procedure_consent)==null?void 0:Ve.explained_by)==null?void 0:xe.doctor_id)||"",doctor_name:((ke=(ze=(me=v.consent)==null?void 0:me.procedure_consent)==null?void 0:ze.explained_by)==null?void 0:ke.doctor_name)||""}},anesthesia_consent:{present:((Xe=(Ie=v.consent)==null?void 0:Ie.anesthesia_consent)==null?void 0:Xe.present)??!0,consent_type:((Je=(Ne=v.consent)==null?void 0:Ne.anesthesia_consent)==null?void 0:Je.consent_type)||"",attachment_url:((Se=(Qe=v.consent)==null?void 0:Qe.anesthesia_consent)==null?void 0:Se.attachment_url)||[],signed:((qe=(Ze=v.consent)==null?void 0:Ze.anesthesia_consent)==null?void 0:qe.signed)??!0,signed_by:((De=(Ye=v.consent)==null?void 0:Ye.anesthesia_consent)==null?void 0:De.signed_by)||"patient_or_relative",signed_name:((Me=(Re=v.consent)==null?void 0:Re.anesthesia_consent)==null?void 0:Me.signed_name)||"",signed_at:((Le=(Ae=v.consent)==null?void 0:Ae.anesthesia_consent)==null?void 0:Le.signed_at)||"",explained_by:{doctor_id:((He=(Te=(Ee=v.consent)==null?void 0:Ee.anesthesia_consent)==null?void 0:Te.explained_by)==null?void 0:He.doctor_id)||"",doctor_name:((_=(Pe=(Oe=v.consent)==null?void 0:Oe.anesthesia_consent)==null?void 0:Pe.explained_by)==null?void 0:_.doctor_name)||""}}},pre_anesthesia_assessment:{assessed_by:((y=v.pre_anesthesia_assessment)==null?void 0:y.assessed_by)||{doctor_id:"",doctor_name:""},vitals:((U=v.pre_anesthesia_assessment)==null?void 0:U.vitals)||{bp:"",pulse:"",spo2:""},airway:(($=v.pre_anesthesia_assessment)==null?void 0:$.airway)||{mallampati:((L=(O=v.pre_anesthesia_assessment)==null?void 0:O.airway)==null?void 0:L.mallampati)||"",difficult_airway_risk:((M=(k=v.pre_anesthesia_assessment)==null?void 0:k.airway)==null?void 0:M.difficult_airway_risk)||""},npo_status:((oe=v.pre_anesthesia_assessment)==null?void 0:oe.npo_status)||{solids_last_at:"",clear_liquids_last_at:"",confirmed:!1},airway_assessment:((R=v.pre_anesthesia_assessment)==null?void 0:R.airway)||{mallampati:((ue=(le=v.pre_anesthesia_assessment)==null?void 0:le.airway)==null?void 0:ue.mallampati)||"",neck_mobility:"",mouth_opening:""},asa_grade:((Ge=v.pre_anesthesia_assessment)==null?void 0:Ge.asa_class)||"",allergies:((Ue=v.pre_anesthesia_assessment)==null?void 0:Ue.allergies)||[],comorbidities:((be=v.pre_anesthesia_assessment)==null?void 0:be.comorbidities)||[],fasting_status:((Q=v.pre_anesthesia_assessment)==null?void 0:Q.npo_status)||{npo_status:((ve=(Z=v.pre_anesthesia_assessment)==null?void 0:Z.npo_status)==null?void 0:ve.npo_status)||"",npo_hours:((ee=(te=v.pre_anesthesia_assessment)==null?void 0:te.npo_status)==null?void 0:ee.npo_hours)||"",clear_liquids_last_at:((E=(ts=v.pre_anesthesia_assessment)==null?void 0:ts.npo_status)==null?void 0:E.clear_liquids_last_at)||"",confirmed:((ls=(as=v.pre_anesthesia_assessment)==null?void 0:as.npo_status)==null?void 0:ls.confirmed)??!1},investigations_reviewed:((ds=v.pre_anesthesia_assessment)==null?void 0:ds.investigations_reviewed)||[],plan:((cs=v.pre_anesthesia_assessment)==null?void 0:cs.plan)||{anesthesia_type:"general",airway_plan:"ETT",induction:"propofol",maintenance:"sevoflurane",analgesia:"fentanyl",antiemetic:"ondansetron",fluid_plan:"",blood_arrangement:{required:!0,units:2,group:"B+",cross_matched:!0}},risk_assessment:((_s=v.pre_anesthesia_assessment)==null?void 0:_s.risk_assessment)||"",assessed_at:(ms=v.pre_anesthesia_assessment)!=null&&ms.assessed_at?T(v.pre_anesthesia_assessment.assessed_at).format("YYYY-MM-DDTHH:mm"):""},post_op_details:{surgery_completion_time:((hs=v.post_op_details)==null?void 0:hs.surgery_completion_time)||"",recovery_room_arrival:((ps=v.post_op_details)==null?void 0:ps.recovery_room_arrival)||"",vitals_stable:((us=v.post_op_details)==null?void 0:us.vitals_stable)??!0,pain_score:((gs=v.post_op_details)==null?void 0:gs.pain_score)||0,pain_management:{medication:((js=(xs=v.post_op_details)==null?void 0:xs.pain_management)==null?void 0:js.medication)||"",dosage:((ys=(fs=v.post_op_details)==null?void 0:fs.pain_management)==null?void 0:ys.dosage)||"",frequency:((vs=(bs=v.post_op_details)==null?void 0:bs.pain_management)==null?void 0:vs.frequency)||""},complications:((Cs=v.post_op_details)==null?void 0:Cs.complications)||"",notes:((Ss=v.post_op_details)==null?void 0:Ss.notes)||"",follow_up:((ws=v.post_op_details)==null?void 0:ws.follow_up)||"",blood_arrangement:((ks=v.post_op_details)==null?void 0:ks.blood_arrangement)||{required:!0,units:2,group:"B+",cross_matched:!0},discharge_planning:{expected_discharge_date:((Ns=(Is=v.post_op_details)==null?void 0:Is.discharge_planning)==null?void 0:Ns.expected_discharge_date)||"",discharge_criteria_met:((Ms=(Ys=v.post_op_details)==null?void 0:Ys.discharge_planning)==null?void 0:Ms.discharge_criteria_met)??!1,home_care_instructions:((Ls=(As=v.post_op_details)==null?void 0:As.discharge_planning)==null?void 0:Ls.home_care_instructions)||""}},completed_by:v.completed_by||{role:"",name:"",id:""}})}else B({ot_case_id:(a==null?void 0:a.ot_case_id)||"",request_id:(a==null?void 0:a._id)||"",patient_id:(m==null?void 0:m._id)||"",patient_name:(m==null?void 0:m.patient_name)||"",ipd_admission_id:"",patient_mobile_number:(m==null?void 0:m.patient_mobile_number)||"",consent:{procedure_consent:{present:!0,consent_type:"",attachment_url:[],signed:!0,signed_by:"patient_or_relative",signed_name:"",signed_at:"",explained_by:{doctor_id:"",doctor_name:""}},anesthesia_consent:{present:!0,consent_type:"",attachment_url:[],signed:!0,signed_by:"patient_or_relative",signed_name:"",signed_at:"",explained_by:{doctor_id:"",doctor_name:""}}}
1,pre_anesthesia_assessment:{assessed_by:{doctor_id:"",doctor_name:""},airway_assessment:{mallampati:"",neck_mobility:"",mouth_opening:""},asa_grade:"",allergies:"",comorbidities:"",fasting_status:{npo_status:"",npo_hours:"",clear_liquids_last_at:"",confirmed:!1},investigations_reviewed:[],plan:{anesthesia_type:"general",airway_plan:"ETT",induction:"propofol",maintenance:"sevoflurane",analgesia:"fentanyl",antiemetic:"ondansetron",fluid_plan:""},risk_assessment:""},post_op_details:{surgery_completion_time:"",recovery_room_arrival:"",vitals_stable:!0,pain_score:0,pain_management:{medication:"",dosage:"",frequency:""},complications:"",notes:"",follow_up:"",discharge_planning:{expected_discharge_date:"",discharge_criteria_met:!1,home_care_instructions:""}},completed_by:{role:"",name:"",id:""}})}catch(ss){console.error("Failed to fetch pre-op details:",ss)}},Ce=async i=>{var l,p,H,I,h,S,ae,ne,ge,pe;if(i.preventDefault(),j)return;const n={...o,status:"Completed",completed_at:T().format("DD, MMMM YYYY HH:mm"),created_at:T().format("DD, MMMM YYYY HH:mm"),updated_at:T().format("DD, MMMM YYYY HH:mm"),consent:{...o.consent,procedure_consent:{...o.consent.procedure_consent,signed_at:o.consent.procedure_consent.signed_at?T(o.consent.procedure_consent.signed_at).format("DD, MMMM YYYY HH:mm"):""},anesthesia_consent:{...o.consent.anesthesia_consent,signed_at:o.consent.anesthesia_consent.signed_at?T(o.consent.anesthesia_consent.signed_at).format("DD, MMMM YYYY HH:mm"):""}},pre_anesthesia_assessment:{...o.pre_anesthesia_assessment,assessed_at:o.pre_anesthesia_assessment.assessed_at?T(o.pre_anesthesia_assessment.assessed_at).format("DD, MMMM YYYY HH:mm"):"",npo_status:{...o.pre_anesthesia_assessment.npo_status||{},solids_last_at:(l=o.pre_anesthesia_assessment.npo_status)!=null&&l.solids_last_at?T(o.pre_anesthesia_assessment.npo_status.solids_last_at).format("DD, MMMM YYYY HH:mm"):"",clear_liquids_last_at:(p=o.pre_anesthesia_assessment.npo_status)!=null&&p.clear_liquids_last_at?T(o.pre_anesthesia_assessment.npo_status.clear_liquids_last_at).format("DD, MMMM YYYY HH:mm"):"",confirmed:((H=o.pre_anesthesia_assessment.npo_status)==null?void 0:H.confirmed)??!1},investigations_reviewed:o.pre_anesthesia_assessment.investigations_reviewed.map(re=>({...re,date:re.date?T(re.date).format("DD, MMMM YYYY"):""}))},post_op_details:{...o.post_op_details||{},surgery_completion_time:(I=o.post_op_details)!=null&&I.surgery_completion_time?T(o.post_op_details.surgery_completion_time).format("DD, MMMM YYYY HH:mm"):"",recovery_room_arrival:(h=o.post_op_details)!=null&&h.recovery_room_arrival?T(o.post_op_details.recovery_room_arrival).format("DD, MMMM YYYY HH:mm"):"",discharge_planning:{...((S=o.post_op_details)==null?void 0:S.discharge_planning)||{},expected_discharge_date:(ne=(ae=o.post_op_details)==null?void 0:ae.discharge_planning)!=null&&ne.expected_discharge_date?T(o.post_op_details.discharge_planning.expected_discharge_date).format("DD, MMMM YYYY"):""}}};try{se(!0);let re;if(A){const J=await tn(A._id,n),z=((ge=J==null?void 0:J.data)==null?void 0:ge.document)||(J==null?void 0:J.data);re={...n,...z&&typeof z=="object"?z:{},_id:(z&&typeof z=="object"?z._id:void 0)||(A==null?void 0:A._id)}}else{const J=await rn(n),z=((pe=J==null?void 0:J.data)==null?void 0:pe.document)||(J==null?void 0:J.data);re={...n,...z&&typeof z=="object"?z:{},_id:z&&typeof z=="object"?z._id:void 0}}es(re)}catch(re){console.error("Failed to save pre_op_details:",re),window.alert("Save failed. Please try again.")}finally{se(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(s,{onSubmit:Ce,children:[e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"OT Case ID"})}),e.jsx(s.Control,{type:"text",name:"ot_case_id",value:o.ot_case_id,onChange:f,placeholder:"Enter OT Case ID",required:!0})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Request ID"})}),e.jsx(s.Control,{type:"text",name:"request_id",value:o.request_id,onChange:f,placeholder:"Enter Request ID",required:!0})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient ID"})}),e.jsx(s.Control,{type:"text",name:"patient_id",value:o.patient_id,onChange:f,required:!0})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient Name"})}),e.jsx(s.Control,{type:"text",name:"patient_name",value:o.patient_name,onChange:f,required:!0})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"IPD Admission ID"})}),e.jsx(s.Control,{type:"text",name:"ipd_admission_id",value:o.ipd_admission_id,onChange:f,placeholder:"Enter IPD Admission ID"})]})}),e.jsx(t,{md:6})]}),e.jsxs(P,{defaultActiveKey:"0",className:"mb-3",children:[e.jsxs(P.Item,{eventKey:"0",children:[e.jsx(P.Header,{children:"Consent"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"switch",label:"Procedure Consent Present",name:"consent.procedure_consent.present",checked:o.consent.procedure_consent.present,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"switch",label:"Procedure Consent Signed",name:"consent.procedure_consent.signed",checked:o.consent.procedure_consent.signed,onChange:f})})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Signed By"})}),e.jsxs(s.Select,{name:"consent.procedure_consent.signed_by",value:o.consent.procedure_consent.signed_by,onChange:f,children:[e.jsx("option",{value:"patient",children:"Patient"}),e.jsx("option",{value:"relative",children:"Relative"}),e.jsx("option",{value:"guardian",children:"Guardian"}),e.jsx("option",{value:"witness",children:"Witness"})]})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Signed Name"})}),e.jsx(s.Control,{type:"text",name:"consent.procedure_consent.signed_name",value:o.consent.procedure_consent.signed_name,onChange:f,placeholder:"Type Signed Name"})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Language"})}),e.jsxs(s.Select,{name:"consent.procedure_consent.language",value:o.consent.procedure_consent.language,onChange:f,children:[e.jsx("option",{value:"hi",children:"Hindi"}),e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"gu",children:"Gujarati"}),e.jsx("option",{value:"mr",children:"Marathi"})]})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Signed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"consent.procedure_consent.signed_at",value:o.consent.procedure_consent.signed_at,onChange:f}),e.jsxs("div",{className:"mt-2",children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Attachment URL"})}),e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[e.jsx(s.Control,{type:"text",value:W,onChange:i=>ie(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),V())},placeholder:"Paste URL and press Enter"}),e.jsx("div",{style:{width:60,height:40,flex:"0 0 auto"},children:$e(W)?e.jsx("img",{src:W,alt:"preview",style:{width:60,height:40,objectFit:"cover",borderRadius:4},onError:i=>{i.currentTarget.style.display="none"}}):null}),e.jsx(Be,{variant:"outline-primary",onClick:V,children:"Add"})]}),e.jsx("div",{className:"mt-2 d-flex flex-column gap-2",children:(o.consent.procedure_consent.attachment_url||[]).map((i,n)=>String(i||"").trim()?e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[e.jsx(s.Control,{type:"text",value:i,onChange:l=>F(n,l.target.value),style:{flex:1}}),e.jsx("div",{style:{width:60,height:40,flex:"0 0 auto"},children:e.jsx("img",{src:i,alt:"preview",style:{width:60,height:40,objectFit:"cover",borderRadius:4,cursor:"pointer"},onError:l=>{l.currentTarget.style.display="none"},onClick:()=>ce(i)})}),e.jsx(Be,{variant:"outline-danger",onClick:()=>c(n),children:"x"})]},`${i}-${n}`):null)})]})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Witness Name"})}),e.jsx(s.Control,{type:"text",name:"consent.procedure_consent.witness_name",value:o.consent.procedure_consent.witness_name,onChange:f,placeholder:"Type Witness Name"})]})})]}),e.jsx("hr",{className:"my-4"}),e.jsx("h6",{className:"mb-3",children:"Anesthesia Consent"}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"switch",label:"Anesthesia Consent Present",name:"consent.anesthesia_consent.present",checked:o.consent.anesthesia_consent.present,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"switch",label:"Anesthesia Consent Signed",name:"consent.anesthesia_consent.signed",checked:o.consent.anesthesia_consent.signed,onChange:f})})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Signed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"consent.anesthesia_consent.signed_at",value:o.consent.anesthesia_consent.signed_at,onChange:f})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Attachment URL"})}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(s.Control,{type:"text",value:d,onChange:i=>Y(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),x())},placeholder:"Paste URL and press Enter",style:{flex:1}}),e.jsx(Be,{variant:"outline-primary",onClick:x,children:"Add"})]}),e.jsx("div",{className:"mt-2 d-flex flex-column gap-2",children:(o.consent.anesthesia_consent.attachment_url||[]).map((i,n)=>String(i||"").trim()?e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[e.jsx(s.Control,{type:"text",value:i,onChange:l=>r(n,l.target.value),style:{flex:1}}),e.jsx("div",{style:{width:60,height:40,flex:"0 0 auto"},children:e.jsx("img",{src:i,alt:"preview",style:{width:60,height:40,objectFit:"cover",borderRadius:4,cursor:"pointer"},onError:l=>{l.currentTarget.style.display="none"},onClick:()=>ce(i)})}),e.jsx(Be,{variant:"outline-danger",onClick:()=>G(n),children:"x"})]},`${i}-${n}`):null)})]})})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Explained By (Doctor)"})}),e.jsxs(s.Select,{value:String(o.consent.anesthesia_consent.explained_by.doctor_id||""),onChange:i=>{const n=i.target.value,l=X.find(p=>{const H=(p==null?void 0:p._id)||(p==null?void 0:p.doctor_id);return String(H||"")===String(n||"")});if(l){const p=l.name||l.doctor_name||l.full_name,H=l._id||l.doctor_id;B(I=>({...I,consent:{...I.consent,anesthesia_consent:{...I.consent.anesthesia_consent,explained_by:{...I.consent.anesthesia_consent.explained_by,doctor_id:H,doctor_name:p}}}}))}},children:[e.jsx("option",{value:"",children:"Select Doctor..."}),K("").map((i,n)=>e.jsxs("option",{value:String(i._id||i.doctor_id||""),children:[i.name||i.doctor_name||i.full_name,"
1(",i._id||i.doctor_id,")"]},n))]}),e.jsx("small",{className:"text-muted",children:"Select doctor from dropdown"})]})})})]})]}),e.jsxs(P.Item,{eventKey:"1",children:[e.jsx(P.Header,{children:"Pre-Anesthesia Assessment"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Assessed By (Doctor)"})}),e.jsx(s.Control,{type:"text",placeholder:"Type doctor name or ID...",value:o.pre_anesthesia_assessment.assessed_by.doctor_name,onChange:i=>{const n=i.target.value,l=n.match(/^(.+)\s+\((.+)\)$/);if(l){const[,p,H]=l;B(I=>({...I,pre_anesthesia_assessment:{...I.pre_anesthesia_assessment,assessed_by:{doctor_id:H.trim(),doctor_name:p.trim()}}}))}else B(p=>({...p,pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,assessed_by:{...p.pre_anesthesia_assessment.assessed_by,doctor_name:n}}}))},list:"assessment-doctors-list"}),e.jsx("datalist",{id:"assessment-doctors-list",children:K(o.pre_anesthesia_assessment.assessed_by.doctor_name).map((i,n)=>e.jsx("option",{value:`${i.name||i.doctor_name||i.full_name} (${i._id||i.doctor_id})`},n))}),e.jsx("small",{className:"text-muted",children:"Start typing to see doctor suggestions"})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Assessed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"pre_anesthesia_assessment.assessed_at",value:o.pre_anesthesia_assessment.assessed_at,onChange:f})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Allergies"})}),e.jsx(s.Control,{type:"text",placeholder:"e.g., penicillin: rash; latex: itching",value:Array.isArray(o.pre_anesthesia_assessment.allergies)?o.pre_anesthesia_assessment.allergies.map(i=>`${i.substance.trim()}: ${i.reaction.trim()}`).join("; "):"",onChange:i=>{const l=i.target.value.split(";").map(p=>p.trim()).filter(Boolean).map(p=>{const H=p.indexOf(":");if(H===-1)return{substance:p.trim(),reaction:""};const I=p.substring(0,H).trim(),h=p.substring(H+1).trim();return{substance:I,reaction:h}}).filter(p=>p.substance);B(p=>({...p,pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,allergies:l}}))}}),e.jsx("small",{className:"text-muted",children:"Format: substance: reaction; substance2: reaction2"})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Current Medications"})}),e.jsx("div",{className:"d-flex flex-wrap gap-2 mb-2",children:o.pre_anesthesia_assessment.current_medications.map((i,n)=>e.jsxs("span",{className:"badge bg-primary d-flex align-items-center",children:[i,e.jsx("button",{type:"button",className:"btn-close btn-close-white btn-sm ms-2",style:{fontSize:"0.5rem"},onClick:()=>{const l=[...o.pre_anesthesia_assessment.current_medications];l.splice(n,1),B(p=>({...p,pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,current_medications:l}}))},"aria-label":"Remove medication"})]},n))}),e.jsx(s.Control,{type:"text",placeholder:"Type medication and press Enter or comma",value:o.medicationInput||"",onChange:i=>{B(n=>({...n,medicationInput:i.target.value}))},onKeyDown:i=>{var n;if((i.key===","||i.key==="Enter")&&((n=o.medicationInput)!=null&&n.trim())){i.preventDefault();const l=o.medicationInput.trim().replace(/,+$/,"");l&&B(p=>({...p,medicationInput:"",pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,current_medications:[...new Set([...p.pre_anesthesia_assessment.current_medications,l])]}}))}},onBlur:i=>{var n;if((n=o.medicationInput)!=null&&n.trim()){const l=o.medicationInput.trim();B(p=>({...p,medicationInput:"",pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,current_medications:[...new Set([...p.pre_anesthesia_assessment.current_medications,l])]}}))}}}),e.jsx("small",{className:"text-muted",children:"Type and press Enter or comma to add"})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Comorbidities"})}),e.jsx("div",{className:"d-flex flex-wrap gap-2 mb-2",children:o.pre_anesthesia_assessment.comorbidities.map((i,n)=>e.jsxs("span",{className:"badge bg-info text-dark d-flex align-items-center",children:[i,e.jsx("button",{type:"button",className:"btn-close btn-close-white btn-sm ms-2",style:{fontSize:"0.5rem"},onClick:()=>{const l=[...o.pre_anesthesia_assessment.comorbidities];l.splice(n,1),B(p=>({...p,pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,comorbidities:l}}))}
1,"aria-label":"Remove comorbidity"})]},n))}),e.jsx(s.Control,{type:"text",placeholder:"Type comorbidity and press Enter or comma",value:o.comorbidityInput||"",onChange:i=>{B(n=>({...n,comorbidityInput:i.target.value}))},onKeyDown:i=>{var n;if((i.key===","||i.key==="Enter")&&((n=o.comorbidityInput)!=null&&n.trim())){i.preventDefault();const l=o.comorbidityInput.trim().replace(/,+$/,"");l&&B(p=>({...p,comorbidityInput:"",pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,comorbidities:[...new Set([...p.pre_anesthesia_assessment.comorbidities,l])]}}))}},onBlur:i=>{var n;if((n=o.comorbidityInput)!=null&&n.trim()){const l=o.comorbidityInput.trim();B(p=>({...p,comorbidityInput:"",pre_anesthesia_assessment:{...p.pre_anesthesia_assessment,comorbidities:[...new Set([...p.pre_anesthesia_assessment.comorbidities,l])]}}))}}}),e.jsx("small",{className:"text-muted",children:"Type and press Enter or comma to add"})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Blood Pressure"})}),e.jsx(s.Control,{type:"text",placeholder:"130/80",name:"pre_anesthesia_assessment.vitals.bp",value:o.pre_anesthesia_assessment.vitals.bp,onChange:f})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Pulse"})}),e.jsx(s.Control,{type:"number",name:"pre_anesthesia_assessment.vitals.pulse",value:o.pre_anesthesia_assessment.vitals.pulse,onChange:f})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"SpO2 (%)"})}),e.jsx(s.Control,{type:"number",name:"pre_anesthesia_assessment.vitals.spo2",value:o.pre_anesthesia_assessment.vitals.spo2,onChange:f})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"ASA Class"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.asa_class",value:o.pre_anesthesia_assessment.asa_class,onChange:f,children:[e.jsx("option",{value:"ASA_I",children:"ASA I"}),e.jsx("option",{value:"ASA_II",children:"ASA II"}),e.jsx("option",{value:"ASA_III",children:"ASA III"}),e.jsx("option",{value:"ASA_IV",children:"ASA IV"}),e.jsx("option",{value:"ASA_V",children:"ASA V"}),e.jsx("option",{value:"ASA_VI",children:"ASA VI"})]})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Mallampati Score"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.airway.mallampati",value:o.pre_anesthesia_assessment.airway.mallampati,onChange:f,children:[e.jsx("option",{value:"I",children:"Class I"}),e.jsx("option",{value:"II",children:"Class II"}),e.jsx("option",{value:"III",children:"Class III"}),e.jsx("option",{value:"IV",children:"Class IV"})]})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Difficult Airway Risk"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.airway.difficult_airway_risk",value:o.pre_anesthesia_assessment.airway.difficult_airway_risk,onChange:f,children:[e.jsx("option",{value:"no",children:"No"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"unknown",children:"Unknown"})]})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Aspiration Risk"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.aspiration_risk",value:o.pre_anesthesia_assessment.aspiration_risk,onChange:f,children:[e.jsx("option",{value:"no",children:"No"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"unknown",children:"Unknown"})]})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Solids Last At"})}),e.jsx(s.Control,{type:"datetime-local",name:"pre_anesthesia_assessment.npo_status.solids_last_at",value:o.pre_anesthesia_assessment.npo_status.solids_last_at,onChange:f})]})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Clear Liquids Last At"})}),e.jsx(s.Control,{type:"datetime-local",name:"pre_anesthesia_assessment.npo_status.clear_liquids_last_at",value:o.pre_anesthesia_assessment.npo_status.clear_liquids_last_at,onChange:f})]})})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:12,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"NPO Status Confirmed",name:"pre_anesthesia_assessment.npo_status.confirmed",checked:o.pre_anesthesia_assessment.npo_status.confirmed,onChange:f})})})}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Anesthesia Type"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.plan.anesthesia_type",value:o.pre_anesthesia_assessment.plan.anesthesia_type,onCh
1ange:f,children:[e.jsx("option",{value:"general",children:"General"}),e.jsx("option",{value:"spinal",children:"Spinal"}),e.jsx("option",{value:"epidural",children:"Epidural"}),e.jsx("option",{value:"regional",children:"Regional"}),e.jsx("option",{value:"local",children:"Local"}),e.jsx("option",{value:"mac",children:"MAC"})]})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Airway Plan"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.plan.airway_plan",value:o.pre_anesthesia_assessment.plan.airway_plan,onChange:f,children:[e.jsx("option",{value:"ETT",children:"ETT"}),e.jsx("option",{value:"LMA",children:"LMA"}),e.jsx("option",{value:"mask",children:"Mask"}),e.jsx("option",{value:"spontaneous",children:"Spontaneous"})]})]})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Blood Loss Risk"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.plan.blood_loss_risk",value:o.pre_anesthesia_assessment.plan.blood_loss_risk,onChange:f,children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"moderate",children:"Moderate"}),e.jsx("option",{value:"high",children:"High"})]})]})}),e.jsx(t,{md:4,children:e.jsx(s.Group,{className:"mt-4",children:e.jsx(s.Check,{type:"checkbox",label:"Blood Prepared",name:"pre_anesthesia_assessment.plan.blood_prepared",checked:o.pre_anesthesia_assessment.plan.blood_prepared,onChange:f})})}),e.jsx(t,{md:4,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Pre-op Destination"})}),e.jsxs(s.Select,{name:"pre_anesthesia_assessment.plan.postop_destination",value:o.pre_anesthesia_assessment.plan.postop_destination,onChange:f,children:[e.jsx("option",{value:"ward",children:"Ward"}),e.jsx("option",{value:"icu",children:"ICU"}),e.jsx("option",{value:"recovery",children:"Recovery Room"}),e.jsx("option",{value:"home",children:"Home"})]})]})})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:12,children:e.jsx(s.Label,{className:"fw-bold",children:"Investigations Reviewed"})})}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"CBC",checked:o.pre_anesthesia_assessment.investigations_reviewed.some(i=>i.name==="CBC"),onChange:i=>{i.target.checked?B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:[...n.pre_anesthesia_assessment.investigations_reviewed,{name:"CBC",reviewed:!0,date:new Date().toISOString().split("T")[0]}]}})):B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:n.pre_anesthesia_assessment.investigations_reviewed.filter(l=>l.name!=="CBC")}}))}})})}),e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"ECG",checked:o.pre_anesthesia_assessment.investigations_reviewed.some(i=>i.name==="ECG"),onChange:i=>{i.target.checked?B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:[...n.pre_anesthesia_assessment.investigations_reviewed,{name:"ECG",reviewed:!0,date:new Date().toISOString().split("T")[0]}]}})):B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:n.pre_anesthesia_assessment.investigations_reviewed.filter(l=>l.name!=="ECG")}}))}})})}),e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"X-Ray",checked:o.pre_anesthesia_assessment.investigations_reviewed.some(i=>i.name==="X-Ray"),onChange:i=>{i.target.checked?B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:[...n.pre_anesthesia_assessment.investigations_reviewed,{name:"X-Ray",reviewed:!0,date:new Date().toISOString().split("T")[0]}]}})):B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:n.pre_anesthesia_assessment.investigations_reviewed.filter(l=>l.name!=="X-Ray")}}))}})})}),e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Blood Tests",checked:o.pre_anesthesia_assessment.investigations_reviewed.some(i=>i.name==="Blood Tests"),onChange:i=>{i.target.checked?B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:[...n.pre_anesthesia_assessment.investigations_reviewed,{name:"Blood Tests",reviewed:!0,date:new Date().toISOString().split("T")[0]}]}})):B(n=>({...n,pre_anesthesia_assessment:{...n.pre_anesthesia_assessment,investigations_reviewed:n.pre_anesthesia_assessment.investigations_reviewed.filter(l=>l.name!=="Blood Tests")}}))}})})})]})]})]}),e.jsxs(P.Item,{eventKey:"2",children:[e.jsx(P.Header,{children:"Day of Surgery Readiness"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Identity & Procedure Site Confirmed",name:"day_of_surgery_readiness.identity_procedure_site_confirmed",checked:o.day_of_surgery_readiness.identity_procedure_site_confirmed,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Site Marked (if applicable)",name:"day_of_surgery_readiness.site_marked_if_applicable",checked:o.day_of_surgery_readiness.site_marked_if_applicable,onChange:f})})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Anesthesia Machine Check Complete",name:"day_of_surgery_readiness.anesthesia_machine_check_complete",checked:o.day_of_surgery_readiness.anesthesia_machine_check_complete,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Medication Check Complete",name:"day_of_surgery_readiness.medication_check_complete",checked:o.day_of_surgery_readiness.medication_check_complete,onChange:f})})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Pulse Oximeter Ready",name:"day_of_surgery_readiness.pulse_oximeter_ready",checked:o.day_of_surgery_readiness.pulse_oximeter_ready,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Antibiotic Plan Ready",name:"day_of_surgery_readiness.antibiotic_plan_ready",checked:o.day_of_surgery_readiness.antibiotic_plan_ready,onChange:f})})})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Equipment Ready",name:"day_of_surgery_readiness.equipment_ready",checked:o.day_of_surgery_readiness.equipment_ready,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Implants Ready",name:"day_of_surgery_readiness.implants_ready",checked:o.day_of_surgery_readiness.implants_ready,onChange:f})})})]})]})]}),e.jsxs(P.Item,{eventKey:"3",children:[e.jsx(P.Header,{children:"Gating"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Pre-op Clearance Completed",name:"gating.preop_clearance_completed",checked:o.gating.preop_clearance_completed,onChange:f})})}),e.jsx(t,{md:6,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Allowed to Start Anesthesia",name:"gating.allowed_to_
1start_anesthesia",checked:o.gating.allowed_to_start_anesthesia,onChange:f})})})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:12,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Blocked Reasons (if any)"})}),e.jsx(s.Control,{as:"textarea",rows:3,placeholder:"Enter reasons for blocking, if any...",onChange:i=>{const n=i.target.value.split(` 2`).filter(l=>l.trim());B(l=>({...l,gating:{...l.gating,blocked_reasons:n}}))}}),e.jsx("small",{className:"text-muted",children:"Enter each reason on a new line"})]})})})]})]}),e.jsxs(P.Item,{eventKey:"8",children:[e.jsx(P.Header,{children:"Blood Arrangement"}),e.jsx(P.Body,{children:e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Blood Arrangement Required",name:"blood_arrangement.required",checked:((fe=o.blood_arrangement)==null?void 0:fe.required)??!0,onChange:f})})}),e.jsx(t,{md:3,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Units"})}),e.jsx(s.Control,{type:"number",name:"blood_arrangement.units",value:((is=o.blood_arrangement)==null?void 0:is.units)??2,onChange:f,min:"1"})]})}),e.jsx(t,{md:3,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Blood Group"})}),e.jsxs(s.Select,{name:"blood_arrangement.group",value:((de=o.blood_arrangement)==null?void 0:de.group)??"B+",onChange:f,children:[e.jsx("option",{value:"A+",children:"A+"}),e.jsx("option",{value:"A-",children:"A-"}),e.jsx("option",{value:"B+",children:"B+"}),e.jsx("option",{value:"B-",children:"B-"}),e.jsx("option",{value:"AB+",children:"AB+"}),e.jsx("option",{value:"AB-",children:"AB-"}),e.jsx("option",{value:"O+",children:"O+"}),e.jsx("option",{value:"O-",children:"O-"})]})]})}),e.jsx(t,{md:3,children:e.jsx(s.Group,{children:e.jsx(s.Check,{type:"checkbox",label:"Cross Matched",name:"blood_arrangement.cross_matched",checked:((ye=o.blood_arrangement)==null?void 0:ye.cross_matched)??!0,onChange:f})})})]})})]})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:12,children:e.jsxs(s.Group,{children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Role"})}),e.jsxs(s.Select,{name:"completed_by.role",value:o.completed_by.role,onChange:f,children:[e.jsx("option",{value:"anesthetist",children:"Anesthetist"}),e.jsx("option",{value:"surgeon",children:"Surgeon"}),e.jsx("option",{value:"nurse",children:"Nurse"}),e.jsx("option",{value:"resident",children:"Resident"})]})]})})}),e.jsx(os.Footer,{children:e.jsxs("div",{className:"d-flex w-10 justify-content-between",children:[e.jsx(Be,{variant:"secondary",onClick:q,children:"Close"}),e.jsx("div",{className:"ms-2",children:e.jsxs(Be,{type:"submit",variant:"primary",disabled:j,className:"d-inline-flex align-items-center gap-2",children:[j&&e.jsx(Ps,{}),"Save"]})})]})})]}),e.jsxs(os,{show:!!u,onHide:_e,size:"sm",centered:!0,children:[e.jsx(os.Header,{closeButton:!0,children:e.jsx(os.Title,{children:"Preview"})}),e.jsx(os.Body,{style:{background:"rgb(246, 245, 245)"},children:u?e.jsx("img",{src:u,alt:"preview",style:{width:"100%",height:"auto",borderRadius:8},onError:i=>{i.currentTarget.style.display="none"}}):null})]})]})};T.extend(Us);const Nn=({show:w,handleClose:q,handleSubmit:es,patientData:m,otRequestData:a,otWings:A=[],selectedRecord:X})=>{var o,B,$e,D,F,V;if(!w)return null;const[C,j]=N.useState({ot_case_id:"",patient_id:"",ipd_admission_id:"",ot_room_id:"",patient_mobile_number:"",status:"not_started",times:{patient_in_ot_at:"",anesthesia_start_at:"",incision_at:"",procedure_end_at:"",patient_out_ot_at:""},time_out:{status:"pending",performed_at:"",performed_by:{user_id:(a==null?void 0:a.requesting_doctor_id)||""},confirm_identity:"",confirm_procedure:"",confirm_site_side:{value:"",not_applicable:!1},antibiotic_given_within_60_min:{required:"",value:"",given_at:""},critical_events_discussed:!0,imaging_displayed_if_needed:{required:"",value:""}},procedure_performed:[{id:"",name:""}],anesthesia_summary:{type:"",anesthetist_id:""},estimated_blood_loss_ml:"",implants:[{name:"",qty:1,lot_no:""}],specimens:[{name:"",label_id:""}],signatures:{surgeon_signed_at:"",anesthetist_signed_at:"",nurse_signed_at:""},event_log:[]}),[se,W]=N.useState(!1);N.useEffect(()=>{var c,r,x,G;if(w&&m&&a)if(X)j({ot_case_id:X.ot_case_id||a._id||"",patient_id:X.patient_id||m._id||m.patient_id||"",ipd_admission_id:X.ipd_admission_id||"",ot_room_id:X.ot_room_id||"",patient_mobile_number:X.patient_mobile_number||m.mobile_number||"",status:X.status||"not_started",times:X.times||{patient_in_ot_at:"",anesthesia_start_at:"",incision_at:"",procedure_end_at:"",patient_out_ot_at:""},time_out:X.time_out||{status:"pending",performed_at:"",performed_by:{user_id:((r=(c=X==null?void 0:X.time_out)==null?void 0:c.performed_by)==null?void 0:r.user_id)||(a==null?void 0:a.requesting_doctor_id)||localStorage.getItem("doctorId")||localStorage.getItem("user_id")||""},confirm_identity:"",confirm_procedure:"",confirm_site_side:{value:"",not_applicable:!1},antibiotic_given_within_60_min:{required:"",value:"",given_at:""},critical_events_discussed:!0,imaging_displayed_if_needed:{required:"",value:""}},procedure_performed:X.procedure_performed||[{id:"",name:""}],anesthesia_summary:X.anesthesia_summary||{type:"",anesthetist_id:""},estimated_blood_loss_ml:X.estimated_blood_loss_ml||"",implants:X.implants||[{name:"",qty:1,lot_no:""}],specimens:X.specimens||[{name:"",label_id:""}],signatures:X.signatures||{surgeon_signed_at:"",anesthetist_signed_at:"",nurse_signed_at:""},event_log:X.event_log||[{at:"",by:"",action:"CREATED"}]});else{let K=((x=a==null?void 0:a.schedule_details)==null?void 0:x.ot_room_id)||"";if(!K&&((G=a==null?void 0:a.ot_location)!=null&&G.id)&&A.length>0){const f=A.find(ce=>ce._id===a.ot_location.id);f&&(K=f.name||f.ot_name||f._id)}j(f=>({...f,ot_case_id:a._id||"",patient_id:m._id||m.patient_id||"",ipd_admission_id:a.ipd_admission_id||"",ot_room_id:K,patient_mobile_number:m.mobile_number||m.patient_mobile_number||a.patient_mobile_number||"",status:"not_started"}))}},[w,m,a,A,X]);const ie=(c,r)=>{const x=r?T(r).utc().format("YYYY-MM-DD HH:mm:ss"):"";if(c.includes(".")){const G=c.split(".");j(K=>{const f={...K};let ce=f;for(let he=0;he<G.length-1;he++)ce=ce[G[he]]={...ce[G[he]]};const _e=G[G.length-1];return ce[_e]=x,f})}else j(G=>({...G,[c]:x}))},d=c=>{if(!c||c==="")return"";try{return c.includes("T")?c:T.utc(c).local().format("YYYY-MM-DDTHH:mm")}catch(r){return console.error("Date conversion error:",r),""}},Y=c=>{const{name:r,value:x,type:G}=c.target;if(G==="datetime-local"){console.log("DateTime change:",r,x),ie(r,x);return}if(r.includes(".")){const K=r.split(".");let f=C;for(let _e=0;_e<K.length-1;_e++)f=f[K[_e]];const ce=K[K.length-1];j(_e=>{const he={..._e};let Ce=he;for(let fe=0;fe<K.length-1;fe++)Ce=Ce[K[fe]]={...Ce[K[fe]]};return Ce[ce]=x,he})}else j(K=>({...K,[r]:x}))},u=(c,r,x)=>{j(G=>({...G,[c]:{...G[c],[r]:x}}))},je=async c=>{c.preventDefault(),W(!0);try{if(!C.ot_case_id||!C.patient_id){Fe("Please fill in all required fields"),W(!1);return}const r={...C,created_at:T().format("DD, MMMM YYYY HH:mm"),updated_at:T().format("DD, MMMM YYYY HH:mm"),time_out:{...C.time_out,performed_by:{user_id:(a==null?void 0:a.requesting_doctor_id)||localStorage.getItem("doctorId")||localStorage.getItem("user_id")||""}},event_log:[...(C.event_log||[]).filter(x=>x.action&&x.action!==""),{at:T().utc().format("YYYY-MM-DD HH:mm:ss"),by:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||"System User",action:X?"UPDATED":"CREATED"}]};await es(r),ns("Execution record saved successfully!")}catch(r){console.error("Error saving execution record:",r),Fe("Failed to save execution record")}finally{W(!1)}};return e.jsxs(s,{onSubmit:je,style:{marginTop:0,paddingTop:0},children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient ID"})}),e.jsx(s.Control,{type:"text",name:"patient_id",value:C.patient_id,readOnly:!0,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"OT Case ID"})}),e.jsx(s.Control,{type:"text",name:"ot_case_id",value:C.ot_case_id,readOnly:!0,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Status"})}),e.jsxs(s.Select,{name:"status",value:C.status,onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"not_started",children:"Not Started"}),e.jsx("option",{value:"in_progress",children:"In Progress"}),e.jsx("option",{value:"completed",children:"Completed"})]})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"IPD Admission ID"})}),e.jsx(s.Control,{type:"text",name:"ipd_admission_id",value:C.ipd_admission_id,onChange:Y,placeholder:"Enter IPD admission ID",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"OT Room ID"})}),e.jsx(s.Control,{type:"text",name:"ot_room_id",value:C.ot_room_id,onChange:Y,placeholder:"Enter OT room ID",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient Mobile Number"})}),e.jsx(s.Control,{type:"text",name:"patient_mobile_number",value:C.patient_mobile_number,onChange:Y,placeholder:"Enter mobile number",style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(P,{defaultActiveKey:"0",className:"mb-3",children:[e.jsxs(P.Item,{eventKey:"1",children:[e.jsx(P.Header,{children:"Intra-Operative Details"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient In OT At"})}),e.jsx(s.Control,{type:"datetime-local",name:"times.patient_in_ot_at",value:d(C.times.patient_in_ot_at),onChange:c=>{console.log("Direct change:",c.target.value),ie("times.patient_in_ot_at",c.target.value)},style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Anesthesia Start At"})}),e.jsx(s.Control,{type:"datetime-local",name:"times.anesthesia_start_at",value:d(C.times.anesthesia_start_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Incision At"})}),e.jsx(s.Control,{type:"datetime-local",name:"times.incision_at",value:d(C.times.incision_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Procedure End At"})}),e.jsx(s.Control,{type:"datetime-local",name:"times.procedure_end_at",value:d(C.times.procedure_end_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient Out OT At"})}),e.jsx(s.Control,{type:"datetime-local",name:"times.patient_out_ot_at",value:d(C.times.patient_out_ot_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]})]})]}),e.jsxs(P.Item,{eventKey:"2",children:[e.jsx(P.Header,{children:"Time Out (Safety Checklist)"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Time Out Status"})}),e.jsxs(s.Select,{name:"time_out.status",value:C.time_out.status,onChange:c=>{if(Y(c),c.target.value==="done"){const r=localStorage.getItem("doctorId")||localStorage.getItem("user_id")||"";j(x=>({...x,time_out:{...x.time_out,status:"done",performed_by:{user_id:r},performed_at:T().utc().format("YYYY-MM-DD HH:mm:ss")}}))}},style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"done",children:"Done"})]})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Performed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"time_out.performed_at",value:d(C.time_out.performed_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Confirm Identity"})}),e.jsx(s.Control,{type:"text",name:"time_out.confirm_identity",value:C.time_out.confirm_identity||"",onChange:Y,placeholder:"Enter patient identity confirmation",style:{backgroundColor:"#f8f9fa"}})]})}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Confirm Procedure"})}),e.jsx(s.Control,{type:"text",name:"time_out.confirm_procedure",value:C.time_out.confirm_procedure||"",onChange:Y,placeholder:"Enter procedure confirmation",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Confirm Site/Side"})}),e.jsxs(b,{children:[e.jsx(t,{md:8,children:e.jsx(s.Control,{type:"text",name:"time_out.confirm_site_side.value",value:C.time_out.confirm_site_side.value||"",onChange:Y,placeholder:"Enter site/side",style:{backgroundColor:"#f8f9fa"}})}),e.jsx(t,{md:4,children:e.jsx(s.Check,{type:"checkbox",label:"Not Applicable",name:"time_out.confirm_site_side.not_applicable",checked:C.time_out.confirm_site_side.not_applicable||!1,onChange:c=>{j(r=>({...r,time_out:{...r.time_out,confirm_site_side:{value:c.target.checked?"":r.time_out.confirm_site_side.value,not_applicable:c.target.checked}}}))}})})]})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Antibiotic Required"})}),e.jsxs(s.Select,{name:"time_out.antibiotic_given_within_60_min.required",value:C.time_out.antibiotic_given_within_60_min.required||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Antibiotic Given"})}),e.jsxs(s.Select,{name:"time_out.antibiotic_given_within_60_min.value",value:C.time_out.antibiotic_given_within_60_min.value||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Antibiotic Given At"})}),e.jsx(s.Control,{type:"datetime-local",name:"time_out.antibiotic_given_within_60_min.given_at",value:d(C.time_out.antibiotic_given_within_60_min.given_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsx(t,{md:6,children:e.jsx(s.Check,{type:"checkbox",label:"Critical Events Discussed",name:"time_out.critical_events_discussed",checked:C.time_out.critical_events_discussed||!1,onChange:c=>u("time_out","critical_events_discussed",c.target.checked)})}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Imaging Displayed (if needed)"})}),e.jsxs(b,{children:[e.jsx(t,{md:6,className:"mb-2",children:e.jsxs(s.Select,{name:"time_out.imaging_displayed_if_needed.required",value:C.time_out.imaging_displayed_if_needed.required||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Required"}),e.jsx("option",{value:"no",children:"Not Required"})]})}),e.jsx(t,{md:6,children:e.jsxs(s.Select,{name:"time_out.imaging_displayed_if_needed.value",value:C.time_out.imaging_displayed_if_needed.value||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})})]})]})]})]})]}),e.jsxs(P.Item,{eventKey:"3",children:[e.jsx(P.Header,{children:"Procedure Details & Materials"}),e.jsxs(P.Body,{children:[e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Procedure Performed"})}),e.jsx(s.Control,{type:"text",placeholder:"Enter procedure name",value:((o=C.procedure_performed[0])==null?void 0:o.name)||"",onChange:c=>{var x;const r=[...C.procedure_performed];r[0]={...r[0],name:c.target.value,id:((x=r[0])==null?void 0:x.id)||""},j(G=>({...G,procedure_performed:r}))},style:{backgroundColor:"#f8f9fa"}})]})}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.j
2sx("strong",{children:"Anesthesia Type"})}),e.jsx(s.Control,{type:"text",placeholder:"Enter anesthesia type",value:C.anesthesia_summary.type||"",onChange:c=>{j(r=>({...r,anesthesia_summary:{...r.anesthesia_summary,type:c.target.value,anesthetist_id:r.anesthesia_summary.anesthetist_id||""}}))},style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Anesthetist ID"})}),e.jsx(s.Control,{type:"text",placeholder:"Enter anesthetist ID",value:C.anesthesia_summary.anesthetist_id||"",onChange:c=>{j(r=>({...r,anesthesia_summary:{...r.anesthesia_summary,type:r.anesthesia_summary.type||"",anesthetist_id:c.target.value}}))},style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Estimated Blood Loss (ml)"})}),e.jsx(s.Control,{type:"number",placeholder:"0",value:C.estimated_blood_loss_ml||"",onChange:c=>{j(r=>({...r,estimated_blood_loss_ml:c.target.value?parseInt(c.target.value):""}))},style:{backgroundColor:"#f8f9fa"}})]})}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Implants"})}),e.jsxs(b,{className:"mb-2",children:[e.jsx(t,{md:6,className:"mb-2",children:e.jsx(s.Control,{type:"text",placeholder:"Implant name",value:((B=C.implants[0])==null?void 0:B.name)||"",onChange:c=>{var x,G;const r=[...C.implants];r[0]={...r[0],name:c.target.value,qty:((x=r[0])==null?void 0:x.qty)||1,lot_no:((G=r[0])==null?void 0:G.lot_no)||""},j(K=>({...K,implants:r}))},style:{backgroundColor:"#f8f9fa"}})}),e.jsx(t,{md:3,className:"mb-2",children:e.jsx(s.Control,{type:"number",placeholder:"Qty",value:(($e=C.implants[0])==null?void 0:$e.qty)||1,onChange:c=>{var x,G;const r=[...C.implants];r[0]={...r[0],name:((x=r[0])==null?void 0:x.name)||"",qty:parseInt(c.target.value)||1,lot_no:((G=r[0])==null?void 0:G.lot_no)||""},j(K=>({...K,implants:r}))},style:{backgroundColor:"#f8f9fa"}})}),e.jsx(t,{md:3,children:e.jsx(s.Control,{type:"text",placeholder:"Lot No",value:((D=C.implants[0])==null?void 0:D.lot_no)||"",onChange:c=>{var x,G;const r=[...C.implants];r[0]={...r[0],name:((x=r[0])==null?void 0:x.name)||"",qty:((G=r[0])==null?void 0:G.qty)||1,lot_no:c.target.value},j(K=>({...K,implants:r}))},style:{backgroundColor:"#f8f9fa"}})})]})]})}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Specimens"})}),e.jsxs(b,{className:"mb-2",children:[e.jsx(t,{md:8,className:"mb-2",children:e.jsx(s.Control,{type:"text",placeholder:"Specimen name",value:((F=C.specimens[0])==null?void 0:F.name)||"",onChange:c=>{var x;const r=[...C.specimens];r[0]={...r[0],name:c.target.value,label_id:((x=r[0])==null?void 0:x.label_id)||""},j(G=>({...G,specimens:r}))},style:{backgroundColor:"#f8f9fa"}})}),e.jsx(t,{md:4,children:e.jsx(s.Control,{type:"text",placeholder:"Label ID",value:((V=C.specimens[0])==null?void 0:V.label_id)||"",onChange:c=>{var x;const r=[...C.specimens];r[0]={...r[0],name:((x=r[0])==null?void 0:x.name)||"",label_id:c.target.value},j(G=>({...G,specimens:r}))},style:{backgroundColor:"#f8f9fa"}})})]})]})})]})]}),e.jsxs(P.Item,{eventKey:"4",children:[e.jsx(P.Header,{children:"Signatures"}),e.jsx(P.Body,{children:e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Surgeon Signed At"})}),e.jsx(s.Control,{type:"datetime-local",value:d(C.signatures.surgeon_signed_at),onChange:c=>{j(r=>({...r,signatures:{...r.signatures,surgeon_signed_at:c.target.value?T(c.target.value).utc().format("YYYY-MM-DD HH:mm:ss"):""}}))},style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Anesthetist Signed At"})}),e.jsx(s.Control,{type:"datetime-local",value:d(C.signatures.anesthetist_signed_at),onChange:c=>{j(r=>({...r,signatures:{...r.signatures,anesthetist_signed_at:c.target.value?T(c.target.value).utc().format("YYYY-MM-DD HH:mm:ss"):""}}))},style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Nurse Signed At"})}),e.jsx(s.Control,{type:"datetime-local",value:d(C.signatures.nurse_signed_at),onChange:c=>{j(r=>({...r,signatures:{...r.signatures,nurse_signed_at:c.target.value?T(c.target.value).utc().format("YYYY-MM-DD HH:mm:ss"):""}}))},style:{backgroundColor:"#f8f9fa"}})]})]})})]}),e.jsxs(P.Item,{eventKey:"5",children:[e.jsx(P.Header,{children:"Event Log"}),e.jsxs(P.Body,{children:[e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Event History"})}),e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",border:"1px solid #dee2e6",borderRadius:"4px",padding:"10px",backgroundColor:"#f8f9fa"},children:C.event_log&&C.event_log.length>0?C.event_log.map((c,r)=>e.jsxs("div",{style:{marginBottom:"8px",padding:"8px",backgroundColor:"white",borderRadius:"4px",fontSize:"14px"},children:[e.jsxs("div",{className:"d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center",children:[e.jsx("span",{className:"fw-bold text-primary",children:c.action||"UNKNOWN"}),e.jsx("span",{className:"text-muted fs-12",children:c.at?T.utc(c.at).local().format("DD, MMMM YYYY HH:mm"):"No timestamp"})]}),e.jsxs("div",{style:{fontSize:"12px",color:"#6c757d",marginTop:"4px"},children:["By: ",c.by||"Unknown user"]})]},r)):e.jsx("div",{style:{textAlign:"center",color:"#6c757d",padding:"20px"},children:"No events recorded yet"})})]})}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Add Manual Event"})}),e.jsxs(s.Select,{value:"",onChange:c=>{if(c.target.value){const r={at:T().utc().format("YYYY-MM-DD HH:mm:ss"),by:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||"System User",action:c.target.value};j(x=>({...x,event_log:[...x.event_log||[],r]}
2)),c.target.value=""}},style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select action to log"}),e.jsx("option",{value:"CREATED",children:"CREATED"}),e.jsx("option",{value:"TIMEOUT_DONE",children:"TIMEOUT_DONE"}),e.jsx("option",{value:"UPDATED",children:"UPDATED"}),e.jsx("option",{value:"SIGNED",children:"SIGNED"})]})]})})]})]})]}),e.jsx(os.Footer,{children:e.jsxs("div",{className:"d-flex w-10 justify-content-between",children:[e.jsx(Be,{variant:"secondary",onClick:q,children:"Close"}),e.jsx("div",{className:"ms-2",children:e.jsxs(Be,{type:"submit",variant:"primary",disabled:se,className:"d-inline-flex align-items-center gap-2",children:[se&&e.jsx(Ps,{}),"Save"]})})]})})]})};T.extend(Us);const rs=()=>JSON.parse(JSON.stringify({ot_case_id:"",patient_id:"",ipd_admission_id:"",ot_room_id:"",patient_mobile_number:"",status:"not_started",sign_out:{status:"pending",performed_at:"",performed_by:{user_id:""},procedure_recorded:"",counts_correct:"",specimens_labeled:"",equipment_problems:{value:"",notes:""},recovery_concerns_discussed:!0},transfer:{to:"",handover_at:"",handover_by:{user_id:""},handover_to:{user_id:""},airway:"",hemodynamically_stable:"",pain_score_0_10:""},postop_orders_summary:{analgesia_plan:"",antibiotics_plan:"",diet:"",special_instructions:""},signatures:{surgeon_signed_at:"",anesthetist_signed_at:"",nurse_signed_at:""},event_log:[],created_at:"",updated_at:""})),Ts=w=>{if(!w||w==="")return"";try{return w.includes("T")?w:T.utc(w).local().format("YYYY-MM-DDTHH:mm")}catch(q){return console.error("Date conversion error:",q),""}},Yn=w=>w?T(w).utc().format("YYYY-MM-DD HH:mm:ss"):"",Mn=({show:w,handleClose:q,handleSubmit:es,patientData:m,otRequestData:a,selectedRecord:A})=>{var o,B,$e,D;const[X,C]=N.useState(!1),[j,se]=N.useState(rs),W=(a==null?void 0:a.patient_id)||(m==null?void 0:m._id)||(m==null?void 0:m.patient_id)||(m==null?void 0:m.id)||"",ie=(a==null?void 0:a._id)||(a==null?void 0:a.ot_case_id)||"",d=(F,V,c)=>{const r=V.split("."),x={...F};let G=x;for(let K=0;K<r.length-1;K++){const f=r[K];G[f]={...G[f]||{}},G=G[f]}return G[r[r.length-1]]=c,x};N.useEffect(()=>{var F,V,c,r,x,G,K,f,ce,_e,he,Ce,fe,is;if(w){if(A){se({...rs(),...A,ot_case_id:A.ot_case_id||ie,patient_id:A.patient_id||W,ipd_admission_id:A.ipd_admission_id||(a==null?void 0:a.ipd_admission_id)||"",ot_room_id:A.ot_room_id||((F=a==null?void 0:a.schedule_details)==null?void 0:F.ot_room_id)||((V=a==null?void 0:a.ot_location)==null?void 0:V.id)||(a==null?void 0:a.ot_room_id)||"",patient_mobile_number:A.patient_mobile_number||(m==null?void 0:m.mobile_number)||(m==null?void 0:m.patient_mobile_number)||(a==null?void 0:a.patient_mobile_number)||"",sign_out:{...rs().sign_out,...A.sign_out||{},performed_by:{user_id:((r=(c=A==null?void 0:A.sign_out)==null?void 0:c.performed_by)==null?void 0:r.user_id)||""},equipment_problems:{value:((G=(x=A==null?void 0:A.sign_out)==null?void 0:x.equipment_problems)==null?void 0:G.value)||"",notes:((f=(K=A==null?void 0:A.sign_out)==null?void 0:K.equipment_problems)==null?void 0:f.notes)||""}},transfer:{...rs().transfer,...A.transfer||{},handover_by:{user_id:((_e=(ce=A==null?void 0:A.transfer)==null?void 0:ce.handover_by)==null?void 0:_e.user_id)||""},handover_to:{user_id:((Ce=(he=A==null?void 0:A.transfer)==null?void 0:he.handover_to)==null?void 0:Ce.user_id)||""}},postop_orders_summary:{...rs().postop_orders_summary,...A.postop_orders_summary||{}},signatures:{...rs().signatures,...A.signatures||{}},event_log:A.event_log&&A.event_log.length>0?A.event_log:[{at:"",by:"",action:"CREATED"}]});return}se({...rs(),ot_case_id:ie,patient_id:W,ipd_admission_id:(a==null?void 0:a.ipd_admission_id)||"",ot_room_id:((fe=a==null?void 0:a.schedule_details)==null?void 0:fe.ot_room_id)||((is=a==null?void 0:a.ot_location)==null?void 0:is.id)||(a==null?void 0:a.ot_room_id)||"",patient_mobile_number:(m==null?void 0:m.mobile_number)||(m==null?void 0:m.patient_mobile_number)||(a==null?void 0:a.patient_mobile_number)||"",status:"not_started"})}},[w,A,m,a,ie,W]);const Y=F=>{const{name:V,value:c,type:r}=F.target;if(r==="datetime-local"){se(x=>d(x,V,Yn(c)));return}if(V.includes(".")){se(x=>d(x,V,c));return}se(x=>({...x,[V]:c}))},u=(F,V)=>{se(c=>d(c,F,V))},je=async F=>{F.preventDefault(),C(!0);try{if(!j.ot_case_id||!j.patient_id){Fe("Please fill in all required fields");return}const V={...j,created_at:j.created_at||T().format("DD, MMMM YYYY HH:mm"),updated_at:T().format("DD, MMMM YYYY HH:mm"),event_log:[...(j.event_log||[]).filter(c=>c.action&&c.action!==""),{at:T().utc().format("YYYY-MM-DD HH:mm:ss"),by:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||"System User",action:A?"
2UPDATED":"CREATED"}]};await es(V)}catch(V){console.error("Error saving post-op record:",V),Fe("Failed to save post-op record")}finally{C(!1)}};return e.jsxs(s,{onSubmit:je,children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient ID"})}),e.jsx(s.Control,{type:"text",name:"patient_id",value:j.patient_id,readOnly:!0,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"OT Case ID"})}),e.jsx(s.Control,{type:"text",name:"ot_case_id",value:j.ot_case_id,readOnly:!0,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Status"})}),e.jsxs(s.Select,{name:"status",value:j.status,onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"not_started",children:"Not Started"}),e.jsx("option",{value:"in_progress",children:"In Progress"}),e.jsx("option",{value:"completed",children:"Completed"})]})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"IPD Admission ID"})}),e.jsx(s.Control,{type:"text",name:"ipd_admission_id",value:j.ipd_admission_id,onChange:Y,placeholder:"Enter IPD admission ID",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"OT Room ID"})}),e.jsx(s.Control,{type:"text",name:"ot_room_id",value:j.ot_room_id,onChange:Y,placeholder:"Enter OT room ID",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Patient Mobile Number"})}),e.jsx(s.Control,{type:"text",name:"patient_mobile_number",value:j.patient_mobile_number,onChange:Y,placeholder:"Enter mobile number",style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(P,{defaultActiveKey:"0",className:"mb-3",children:[e.jsxs(P.Item,{eventKey:"1",children:[e.jsx(P.Header,{children:"Sign Out"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Sign Out Status"})}),e.jsxs(s.Select,{name:"sign_out.status",value:j.sign_out.status,onChange:F=>{if(Y(F),F.target.value==="done"){const V=localStorage.getItem("doctorId")||localStorage.getItem("user_id")||"";se(c=>d(d(c,"sign_out.performed_by.user_id",V),"sign_out.performed_at",T().utc().format("YYYY-MM-DD HH:mm:ss")))}},style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"done",children:"Done"})]})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Performed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"sign_out.performed_at",value:Ts(j.sign_out.performed_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Procedure Recorded"})}),e.jsxs(s.Select,{name:"sign_out.procedure_recorded",value:j.sign_out.procedure_recorded||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Counts Correct"})}),e.jsxs(s.Select,{name:"sign_out.counts_correct",value:j.sign_out.counts_correct||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Specimens Labeled"})}),e.jsxs(s.Select,{name:"sign_out.specimens_labeled",value:j.sign_out.specimens_labeled||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Equipment Problems"})}),e.jsxs(s.Select,{name:"sign_out.equipment_problems.value",value:((o=j.sign_out.equipment_problems)==null?void 0:o.value)||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:8,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Equipment Problems Notes"})}),e.jsx(s.Control,{type:"text",name:"sign_out.equipment_problems.notes",value:((B=j.sign_out.equipment_problems)==null?void 0:B.notes)||"",onChange:Y,placeholder:"Enter notes",style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsx(b,{className:"mb-3",children:e.jsx(t,{md:12,children:e.jsx(s.Check,{type:"checkbox",label:"Recovery Concerns Discussed",checked:!!j.sign_out.recovery_concerns_discussed,onChange:F=>u("sign_out.recovery_concerns_discussed",F.target.checked)})})})]})]}),e.jsxs(P.Item,{eventKey:"2",children:[e.jsx(P.Header,{children:"Transfer"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"To"})}),e.jsxs(s.Select,{name:"transfer.to",value:j.transfer.to||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"PACU",children:"PACU"}),e.jsx("option",{value:"ICU",children:"ICU"}),e.jsx("option",{value:"Ward",children:"Ward"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Handover At"})}),e.jsx(s.Control,{type:"datetime-local",name:"transfer.handover_at",value:Ts(j.transfer.handover_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Airway"})}),e.jsxs(s.Select,{name:"transfer.airway",value:j.transfer.airway||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"self",children:"Self"}),e.jsx("option",{value:"ett",children:"ETT"}),e.jsx("option",{value:"lma",children:"LMA"}),e.jsx("option",{value:"other",children:"Other"})]})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Hemodynamically Stable"})}),e.jsxs(s.Select,{name:"transfer.hemodynamically_stable",value:j.transfer.hemodynamically_stable||"",onChange:Y,style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"yes",children:"Yes"}),e.jsx("option",{value:"no",children:"No"})]})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Pain Score (0-10)"})}),e.jsx(s.Control,{type:"number",min:0,max:10,name:"transfer.pain_score_0_10",value:j.transfer.pain_score_0_10||"",onChange:Y,placeholder:"0-10",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Handover By (User ID)"})}),e.jsx(s.Control,{type:"text",name:"transfer.handover_by.user_id",value:(($e=j.transfer.handover_by)==null?void 0:$e.user_id)||"",onChange:Y,placeholder:"Enter user id",style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Handover To (User ID)"})}),e.jsx(s.Control,{type:"text",name:"transfer.handover_to.user_id",value:((D=j.transfer.handover_to)==null?void 0:D.user_id
2)||"",onChange:Y,placeholder:"Enter user id",style:{backgroundColor:"#f8f9fa"}})]})})]})]}),e.jsxs(P.Item,{eventKey:"3",children:[e.jsx(P.Header,{children:"Post-Op Orders Summary"}),e.jsxs(P.Body,{children:[e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Analgesia Plan"})}),e.jsx(s.Control,{type:"text",name:"postop_orders_summary.analgesia_plan",value:j.postop_orders_summary.analgesia_plan||"",onChange:Y,placeholder:"Enter analgesia plan",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Antibiotics Plan"})}),e.jsx(s.Control,{type:"text",name:"postop_orders_summary.antibiotics_plan",value:j.postop_orders_summary.antibiotics_plan||"",onChange:Y,placeholder:"Enter antibiotics plan",style:{backgroundColor:"#f8f9fa"}})]})]}),e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Diet"})}),e.jsx(s.Control,{type:"text",name:"postop_orders_summary.diet",value:j.postop_orders_summary.diet||"",onChange:Y,placeholder:"Enter diet",style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Special Instructions"})}),e.jsx(s.Control,{type:"text",name:"postop_orders_summary.special_instructions",value:j.postop_orders_summary.special_instructions||"",onChange:Y,placeholder:"Enter special instructions",style:{backgroundColor:"#f8f9fa"}})]})]})]})]}),e.jsxs(P.Item,{eventKey:"4",children:[e.jsx(P.Header,{children:"Signatures"}),e.jsx(P.Body,{children:e.jsxs(b,{className:"mb-3",children:[e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Surgeon Signed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"signatures.surgeon_signed_at",value:Ts(j.signatures.surgeon_signed_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Anesthetist Signed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"signatures.anesthetist_signed_at",value:Ts(j.signatures.anesthetist_signed_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]}),e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Nurse Signed At"})}),e.jsx(s.Control,{type:"datetime-local",name:"signatures.nurse_signed_at",value:Ts(j.signatures.nurse_signed_at),onChange:Y,style:{backgroundColor:"#f8f9fa"}})]})]})})]}),e.jsxs(P.Item,{eventKey:"5",children:[e.jsx(P.Header,{children:"Event Log"}),e.jsxs(P.Body,{children:[e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:12,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Event History"})}),e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto",border:"1px solid #dee2e6",borderRadius:"4px",padding:"10px",backgroundColor:"#f8f9fa"},children:j.event_log&&j.event_log.length>0?j.event_log.map((F,V)=>e.jsxs("div",{style:{marginBottom:"8px",padding:"8px",backgroundColor:"white",borderRadius:"4px",fontSize:"14px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontWeight:"bold",color:"#007bff"},children:F.action||"UNKNOWN"}),e.jsx("span",{style:{fontSize:"12px",color:"#6c757d"},children:F.at&&F.at!==""?T.utc(F.at).local().format("DD, MMMM YYYY HH:mm"):"No timestamp"})]}),e.jsxs("div",{style:{fontSize:"12px",color:"#6c757d",marginTop:"4px"},children:["By: ",F.by||"Unknown user"]})]},V)):e.jsx("div",{style:{textAlign:"center",color:"#6c757d",padding:"20px"},children:"No events recorded yet"})})]})}),e.jsx(b,{className:"mb-3",children:e.jsxs(t,{md:4,children:[e.jsx(s.Label,{children:e.jsx("strong",{children:"Add Manual Event"})}),e.jsxs(s.Select,{value:"",onChange:F=>{if(!F.target.value)return;const V={at:T().utc().format("YYYY-MM-DD HH:mm:ss"),by:localStorage.getItem("doctorName")||localStorage.getItem("user_name")||"System User",action:F.target.value};se(c=>({...c,event_log:[...c.event_log||[],V]})),F.target.value=""},style:{backgroundColor:"#f8f9fa"},children:[e.jsx("option",{value:"",children:"Select action to log"}),e.jsx("option",{value:"CREATED",children:"CREATED"}),e.jsx("option",{value:"SIGNOUT_DONE",children:"SIGNOUT_DONE"}),e.jsx("option",{value:"UPDATED",children:"UPDATED"}),e.jsx("option",{value:"SIGNED",children:"SIGNED"})]})]})})]})]})]}),e.jsxs("div",{className:"d-flex justify-content-end gap-2 mt-3",children:[e.jsx(Be,{variant:"secondary",onClick:q,disabled:X,children:"Cancel"}),e.jsxs(Be,{variant:"primary",type:"submit",disabled:X,className:"d-inline-flex align-items-center gap-2",children:[X&&e.jsx(Ps,{}),"Save"]})]})]})},An=({patientData:w,otRequestData:q})=>{const[es,m]=N.useState([]),[a,A]=N.useState(!1),[X,C]=N.useState(!1),[j,se]=N.useState(null),[W,ie]=N.useState({show:!1,id:""}),[d,Y]=N.useState(!1),u=N.useMemo(()=>(q==null?void 0:q.patient_id)||(w==null?void 0:w._id)||(w==null?void 0:w.patient_id)||(w==null?void 0:w.id)||"",[q,w]),je=N.useMemo(()=>(q==null?void 0:q._id)||(q==null?void 0:q.ot_case_id)||"",[q]),o=N.useCallback(async()=>{var D;if(u){A(!0);try{const F=await an(),c=(((D=F==null?void 0:F.data)==null?void 0:D.document)||[]).filter(r=>{const x=(r==null?void 0:r.patient_id)||(r==null?void 0:r.patientId),G=(r==null?void 0:r.ot_case_id)||(r==null?void 0:r.otCaseId)||(r==null?void 0:r.ot_caseId),K=u?String(x)===String(u):!0,f=je?String(G)===String(je):!0;return K&&f});m(c),c.length>0?se(c[0]):se(null),C(!0)}catch(F){console.error("Failed to fetch post-op records:",F),m([]),se(null)}finally{A(!1)}}},[u,je]);N.useEffect(()=>{o()},[o]);const B=async D=>{var F,V;try{let c;if(j){const r=await ln(j._id||j.id,D),x=((F=r==null?void 0:r.data)==null?void 0:F.document)||(r==null?void 0:r.data);c={...D,...x&&typeof x=="object"?x:{},_id:(x&&typeof x=="object"?x._id:void 0)||(j==null?void 0:j._id)},ns("Post-op record updated successfully!")}else{const r=await dn(D),x=((V=r==null?void 0:r.data)==null?void 0:V.document)||(r==null?void 0:r.data);c={...D,...x&&typeof x=="object"?x:{},_id:x&&typeof x=="object"?x._id:void 0},ns("Post-op record created successfully!")}se(c||D),o()}catch(c){console.error("Error saving post-op record:",c),Fe("Failed to save post-op record")}},$e=async()=>
2{if(W.id){Y(!0);try{await cn(W.id),ns("Post-op record deleted successfully!"),ie({show:!1,id:""}),o()}catch(D){console.error("Failed to delete post-op record:",D),Fe("Failed to delete post-op record")}finally{Y(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsx(Mn,{show:X,handleClose:()=>{C(!1),se(null)},handleSubmit:B,patientData:w,otRequestData:q,selectedRecord:j}),e.jsx(sn,{show:W.show,handleDeleteCancel:()=>ie({show:!1,id:""}),handleDeleteConfirmation:$e,loading:d})]})};T.extend(Us);const Vn=()=>{var Me,Ae,Le,Ee,Te,He,Oe,Pe;const{id:w}=_n(),q=mn(),es=`/ot-request/${w}`,m=`/ot-request/pre-op/${w}`,a=`/ot-request/intra-op/${w}`,A=`/ot-request/post-op/${w}`,X=[{label:"General",value:"General"},{label:"Regional",value:"Regional"},{label:"Local",value:"Local"}],C=hn(),[j,se]=N.useState(!1),[W,ie]=N.useState(()=>{const _=q.pathname;return _.includes("/pre-op/")?"preop":_.includes("/intra-op/")?"intra-op":_.includes("/post-op/")?"post-op":"summary"}),[d,Y]=N.useState({}),[u,je]=N.useState({}),[o,B]=N.useState(!1),[$e,D]=N.useState([]),[F,V]=N.useState(null),[c,r]=N.useState([]),[x,G]=N.useState(null),[K,f]=N.useState({show:!1,id:""}),[ce,_e]=N.useState(!1),[he,Ce]=N.useState(!1);N.useState(!1),N.useState(!1);const[fe,is]=N.useState({}),[de,ye]=N.useState({}),[i,n]=N.useState(!1),[l,p]=N.useState(null),[H,I]=N.useState(!1),[h,S]=N.useState([]),[ae,ne]=N.useState(!1),[ge,pe]=N.useState(!1);N.useEffect(()=>{W!=="preop"&&o&&(B(!1),V(null))},[W,o]),N.useEffect(()=>{W==="preop"&&B(!0)},[W]),N.useEffect(()=>{(async()=>{var y;if(W==="preop")try{const U=await Hs(),$=((y=U==null?void 0:U.data)==null?void 0:y.document)||[],O=w||(d==null?void 0:d._id)||(d==null?void 0:d.patient_id),L=(u==null?void 0:u.ot_case_id)||(u==null?void 0:u._id),k=$.filter(M=>{const oe=(M==null?void 0:M.patient_id)||(M==null?void 0:M.patientId),R=(M==null?void 0:M.ot_case_id)||(M==null?void 0:M.otCaseId)||(M==null?void 0:M.ot_caseId),le=O?String(oe)===String(O):!0,ue=L?String(R)===String(L):!0;return le&&ue});k.length>0?V(k[0]):V(null)}catch(U){console.error("Failed to fetch pre-op details:",U)}})()},[W,u==null?void 0:u.ot_case_id,u==null?void 0:u._id,w,d==null?void 0:d._id,d==null?void 0:d.patient_id]),N.useEffect(()=>{(async()=>{var y;if(W==="intra-op")try{const U=await Gs(),$=((y=U==null?void 0:U.data)==null?void 0:y.document)||[],O=w||(d==null?void 0:d._id)||(d==null?void 0:d.patient_id),L=(u==null?void 0:u.ot_case_id)||(u==null?void 0:u._id),k=$.filter(M=>{const oe=(M==null?void 0:M.patient_id)||(M==null?void 0:M.patientId),R=(M==null?void 0:M.ot_case_id)||(M==null?void 0:M.otCaseId)||(M==null?void 0:M.ot_caseId),le=O?String(oe)===String(O):!0,ue=L?String(R)===String(L):!0;return le&&ue});k.length>0?G(k[0]):G(null)}catch(U){console.error("Failed to fetch intra-op details:",U)}})()},[W,u==null?void 0:u.ot_case_id,u==null?void 0:u._id,w,d==null?void 0:d._id,d==null?void 0:d.patient_id]),N.useEffect(()=>{(async()=>{var y;se(!0);try{const U=await gn();console.log("OT Wings loaded:",U.data),S(((y=U.data)==null?void 0:y.document)||[])}catch(U){console.error("Error fetching OT Wings:",U),S([])}finally{se(!1)}})()},[]),N.useEffect(()=>{const _=q.pathname;_.includes("/pre-op/")?ie("preop"):_.includes("/intra-op/")?ie("intra-op"):_.includes("/post-op/")?ie("post-op"):ie("summary")},[q.pathname]),N.useEffect(()=>{console.log("ActiveTab changed to:",W),W==="intra-op"&&w&&(console.log("Triggering fetchExecutionRecords"),Se())},[W,w]),N.useEffect(()=>{let _=!1;return(async()=>{var U,$,O,L,k,M,oe,R,le,ue,Ge,Ue;if(w){ne(!0);try{const be=await xn(w),Q=(($=(U=be==null?void 0:be.data)==null?void 0:U.document)==null?void 0:$[0])||{};_||(Y(Q),is({name:Q.name||Q.patient_name||"",age:Q.age||"",gender:Q.gender||"",phone:Q.phone||Q.patient_phone||Q.patient_mobile_number||Q.phone_number||"",email:Q.email||"",medicalAlert:Q.medicalAlert||""}));try{const Z=await jn("","","","","","",100,0),ve=((O=Z==null?void 0:Z.data)==null?void 0:O.document)||[],te=(Array.isArray(ve)?ve:[]).find(ee=>ee.patient_id===w||ee.patient_id===Q._id||ee.patient_id===Q.patient_id);!_&&te&&(je(te),ye({status:te.status||"",urgency:((L=te.schedule_details)==null?void 0:L.urgency)||te.urgency||"",priority:te.priority||"",anesthesia_preference:te.anesthesia_preference||"",scheduled_date:((M=(k=te.schedule_details)==null?void 0:k.schedule_preference)==null?void 0:M.scheduled_date)||"",scheduled_time:((R=(oe=te.schedule_details)==null?void 0:oe.schedule_preference)==null?void 0:R.scheduled_time)||"",total_estimated_duration_minutes:((ue=(le=te.schedule_details)==null?void 0:le.schedule_preference)==null?void 0:ue.total_estimated_duration_minutes)||0}))}catch(Z){console.log("No OT request found for patient:",Z)}try{const Z=await Hs(""),te=(((Ge=Z==null?void 0:Z.data)==null?void 0:Ge.document)||[]).filter(ee=>ee.patient_id===w||ee.patient_id===Q._id||ee.patient_id===Q.patient_id);_||D(te)}
2catch(Z){console.log("No pre-op records found for patient:",Z)}try{const Z=await Gs(),te=(((Ue=Z==null?void 0:Z.data)==null?void 0:Ue.document)||[]).filter(ee=>ee.patient_id===w||ee.patient_id===Q._id||ee.patient_id===Q.patient_id);_||r(te)}catch(Z){console.log("No execution records found for patient:",Z)}}catch{_||Y({})}finally{_||ne(!1)}}})(),()=>{_=!0}},[w]);const re=((d==null?void 0:d.name)||(d==null?void 0:d.patient_name)||"--").split(" ").filter(Boolean).map(_=>_.charAt(0).toUpperCase()+_.slice(1).toLowerCase()).join(" "),J=(d==null?void 0:d.email)||"--",z=(d==null?void 0:d.phone)||(d==null?void 0:d.patient_phone)||(d==null?void 0:d.patient_mobile_number)||(d==null?void 0:d.phone_number)||"--",Ke=d!=null&&d.gender?d.gender.charAt(0).toUpperCase()+d.gender.slice(1).toLowerCase():"--",We=(d==null?void 0:d.age)??"--",Ve=(d==null?void 0:d.medicalAlert)||"--",xe={backgroundColor:"#f8f9fa"},me={fontWeight:600},ze=de.scheduled_date??((Ae=(Me=u.schedule_details)==null?void 0:Me.schedule_preference)==null?void 0:Ae.scheduled_date),ke=de.scheduled_time??((Ee=(Le=u.schedule_details)==null?void 0:Le.schedule_preference)==null?void 0:Ee.scheduled_time),Ie=_=>{const y=String(_||"").trim();return/^\d{2}:\d{2}$/.test(y)?y:""},Xe=_=>{console.log("Post Op Data:",_),V(_),Ne()},Ne=async()=>{var _;if(w)try{const y=await Hs(),U=((_=y==null?void 0:y.data)==null?void 0:_.document)||[],$=w||(d==null?void 0:d._id)||(d==null?void 0:d.patient_id),O=(u==null?void 0:u.ot_case_id)||(u==null?void 0:u._id),L=U.filter(k=>{const M=(k==null?void 0:k.patient_id)||(k==null?void 0:k.patientId),oe=(k==null?void 0:k.ot_case_id)||(k==null?void 0:k.otCaseId)||(k==null?void 0:k.ot_caseId),R=$?String(M)===String($):!0,le=O?String(oe)===String(O):!0;return R&&le});D(L)}catch(y){console.error("Failed to fetch pre-op records:",y)}},Je=async()=>{if(K.id){_e(!0);try{K.type==="execution"?(await fn(K.id),ns("Execution record deleted successfully!"),Se()):(await yn(K.id),ns("Record deleted successfully!"),Ne()),f({show:!1,id:"",type:""})}catch(_){console.error("Failed to delete record:",_),Fe("Failed to delete record. Please try again.")}finally{_e(!1)}}},Qe=()=>{f({show:!1,id:""})},Se=async()=>{var _;if(w){console.log("Fetching execution records for patient:",w);try{const y=await Gs();console.log("Execution API response:",y);const U=((_=y==null?void 0:y.data)==null?void 0:_.document)||[],$=w||(d==null?void 0:d._id)||(d==null?void 0:d.patient_id),O=(u==null?void 0:u.ot_case_id)||(u==null?void 0:u._id),L=U.filter(k=>{const M=(k==null?void 0:k.patient_id)||(k==null?void 0:k.patientId),oe=(k==null?void 0:k.ot_case_id)||(k==null?void 0:k.otCaseId)||(k==null?void 0:k.ot_caseId),R=$?String(M)===String($):!0,le=O?String(oe)===String(O):!0;return R&&le});console.log("Filtered execution records:",L),r(L)}catch(y){console.error("Failed to fetch execution records:",y)}}},Ze=async()=>{var _,y,U,$,O,L,k;Ce(!0);try{const M=(d==null?void 0:d._id)||(d==null?void 0:d.id);M&&(await bn(M,fe),Y(R=>({...R,...fe})));const oe=(u==null?void 0:u._id)||(u==null?void 0:u.id);if(oe&&u&&Object.keys(u).length>0){const R={...u,urgency:de.urgency??u.urgency,anesthesia_preference:de.anesthesia_preference??u.anesthesia_preference,priority:de.priority??u.priority,status:de.status??u.status,schedule_details:{...u.schedule_details,schedule_preference:{...(_=u.schedule_details)==null?void 0:_.schedule_preference,scheduled_date:de.scheduled_date??((U=(y=u.schedule_details)==null?void 0:y.schedule_preference)==null?void 0:U.scheduled_date),scheduled_time:de.scheduled_time??((O=($=u.schedule_details)==null?void 0:$.schedule_preference)==null?void 0:O.scheduled_time),total_estimated_duration_minutes:de.total_estimated_duration_minutes??((k=(L=u.schedule_details)==null?void 0:L.schedule_preference)==null?void 0:k.total_estimated_duration_minutes)}}};await Ds(oe,R),je(R),ns("OT Request Updated successfully!")}}catch(M){console.error("Error saving changes:",M),Fe("Failed to save changes.")}finally{Ce(!1)}},qe=async _=>{var y,U,$,O;try{I(!0),console.log("Schedule data received:",_),console.log("Updating OT request with ID:",_._id);const L=_._id||(l==null?void 0:l._id);if(!L){Fe("Invalid request ID - Cannot update schedule"),console.error("No valid ID found. Schedule data:",_,"Selected request:",l);return}const M=((y=_.schedule_preference)==null?void 0:y.scheduled_date)&&((U=_.schedule_preference)==null?void 0:U.scheduled_time)&&_.ot_room_id?{schedule_details:_,status:"Scheduled"}:{status:"Scheduled"};await Ds(L,M),ns("OT request scheduled successfully"),Ye()}catch(L){console.error("Error scheduling OT request:",L),Fe(((O=($=L==null?void 0:L.response)==null?void 0:$.data)==null?void 0:O.message)||"Failed to schedule OT request")}finally{I(!1)}},Ye=()=>{n(!1),p(null)},De=()=>{pe(!1)},Re=async _=>{var y,U;console.log("Execution Data:",_);try{let $;if(x){const O=await vn(x._id||x.id,_),L=((y=O==null?void 0:O.data)==null?void 0:y.document)||(O==null?void 0:O.data);$={..._,...L&&typeof L=="object"?L:{}
2,_id:(L&&typeof L=="object"?L._id:void 0)||(x==null?void 0:x._id)}}else{const O=await Cn(_),L=((U=O==null?void 0:O.data)==null?void 0:U.document)||(O==null?void 0:O.data);$={..._,...L&&typeof L=="object"?L:{},_id:L&&typeof L=="object"?L._id:void 0},console.log("Creating new execution record:",_),ns("Execution record created successfully!")}G($||_),Se()}catch($){console.error("Error saving execution record:",$),Fe("Failed to save execution record")}};return e.jsxs("div",{children:[e.jsx(pn,{activeMenu:"OT Patient",motherMenu:"OT request",motherMenuPage:"/ot-request"}),e.jsxs("div",{className:`${we["header-div"]} mb-4`,children:[e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Name"}),": "]}),re]}),e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Email"}),": "]})," ",J]}),e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Phone"}),": "]}),z==="--"?"--":`+${z}`]}),e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Gender"}),": "]}),Ke]}),e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Age"}),": "]})," ",We]}),e.jsxs("p",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Medical Alert"}),": "]}),e.jsx("span",{className:we.medicalAlertValue,children:Ve})]})]}),e.jsxs("div",{style:{borderBottom:"2px solid #15516f"},className:"mb-3",children:[e.jsxs("div",{className:`d-none d-sm-flex gap-2 ${we.tabsRow}`,children:[e.jsx(Os,{to:es,children:e.jsx("h5",{className:W==="summary"?we["selected-tab"]:we.tab,onClick:()=>ie("summary"),children:"OT Request"})}),e.jsx(Os,{to:m,children:e.jsx("h5",{className:W==="preop"?we["selected-tab"]:we.tab,onClick:()=>ie("preop"),children:"Pre Op"})}),e.jsx(Os,{to:a,children:e.jsx("h5",{className:W==="intra-op"?we["selected-tab"]:we.tab,onClick:()=>ie("intra-op"),children:"Intra-Op"})}),e.jsx(Os,{to:A,children:e.jsx("h5",{className:W==="post-op"?we["selected-tab"]:we.tab,onClick:()=>ie("post-op"),children:"Post-Op"})})]}),e.jsx("div",{className:"d-block d-sm-none py-2",children:e.jsxs("select",{className:`form-select ${we.mobileSelect}`,value:W,onChange:_=>{const y=_.target.value;ie(y),C(y==="preop"?m:y==="intra-op"?a:y==="post-op"?A:es)},children:[e.jsx("option",{value:"summary",children:"OT Request"}),e.jsx("option",{value:"preop",children:"Pre Op"}),e.jsx("option",{value:"intra-op",children:"Intra-Op"}),e.jsx("option",{value:"post-op",children:"Post-Op"})]})})]}),e.jsxs("div",{children:[W==="summary"&&e.jsx("div",{className:"p-4",children:ae?e.jsx("div",{className:"d-flex justify-content-center align-items-center py-4",children:e.jsx(un,{})}):u&&Object.keys(u).length>0?e.jsxs(s,{children:[e.jsxs(b,{className:"mb-2",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{style:me,children:"Status"}),e.jsxs(s.Select,{style:xe,value:de.status||u.status||"",onChange:_=>ye(y=>({...y,status:_.target.value})),children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"Requested",children:"Requested"}),e.jsx("option",{value:"Approved",children:"Approved"}),e.jsx("option",{value:"Scheduled",children:"Scheduled"}),e.jsx("option",{value:"Completed",children:"Completed"}),e.jsx("option",{value:"Cancelled",children:"Cancelled"})]})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{style:me,children:"Urgency"}),e.jsxs(s.Select,{style:xe,value:((Te=de.schedule_details)==null?void 0:Te.urgency)||((He=u.schedule_details)==null?void 0:He.urgency)||"",onChange:_=>ye(y=>({...y,urgency:_.target.value})),children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"Elective",children:"Elective"}),e.jsx("option",{value:"Urgent",children:"Urgent"}),e.jsx("option",{value:"Emergency",children:"Emergency"})]})]})]}),e.jsxs(b,{className:"",children:[e.jsxs(t,{md:6,children:[e.jsx(s.Label,{style:me,children:"Priority"}),e.jsxs(s.Select,{style:xe,value:de.priority||u.priority||"",onChange:_=>ye(y=>({...y,priority:_.target.value})),children:[e.jsx("option",{value:"",children:"Select"}),e.jsx("option",{value:"Normal",children:"Normal"}),e.jsx("option",{value:"High",children:"High"})]})]}),e.jsx(t,{md:6,children:e.jsxs(s.Group,{className:"mb-3",children:[e.jsx(s.Label,{style:me,children:"Anesthesia"}),e.jsxs(s.Select,{className:"bg-light",value:de.anesthesia_preference||u.anesthesia_preference||"",onChange:_=>ye(y=>({...y,anesthesia_preference:_.target.value})),children:[e.jsx("option",{value:"",children:"Select"}),X.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]})]})}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{style:me,children:"Preferred Date"}),e.jsx(Sn,{style:{height:"44px"},selectedValue:ze,dateChange:_=>ye(y=>({...y,scheduled_date:_?T(_).format("DD, MMMM YYYY"):""})),dateSelect:_=>ye(y=>({...y,scheduled_date:_?T(_).format("DD, MMMM YYYY"):""}))})]}),e.jsxs(t,{md:6,children:[e.jsx(s.Label,{style:me,children:"Preferred Time"}),e.jsxs(Rs,{className:"flex-nowrap",style:{flexWrap:"nowrap"},children:[e.jsx(s.Control,{type:"time",style:xe,value:Ie((ke||"").split("-")[0]),className:"flex-grow-1",onChange:_=>{const y=_.target.value;ye(U=>
2{var L,k;const $=U.scheduled_time??((k=(L=u.schedule_details)==null?void 0:L.schedule_preference)==null?void 0:k.scheduled_time)??"",O=String($||"").includes("-")?String($).split("-")[1]:"";return{...U,scheduled_time:O?`${y}-${O}`:y}})}}),e.jsx(Rs.Text,{children:"to"}),e.jsx(s.Control,{type:"time",style:xe,value:Ie((ke||"").split("-")[1]),className:"flex-grow-1",onChange:_=>{const y=_.target.value;ye(U=>{var L,k;const $=U.scheduled_time??((k=(L=u.schedule_details)==null?void 0:L.schedule_preference)==null?void 0:k.scheduled_time)??"",O=String($||"").includes("-")?String($).split("-")[0]:String($||"");return{...U,scheduled_time:O?`${O}-${y}`:y}})}})]})]})]}),e.jsx(b,{className:"mt-2",children:e.jsxs(t,{md:6,className:"mt-1",children:[e.jsx(s.Label,{style:me,children:"Total Duration (minutes)"}),e.jsx(s.Control,{type:"number",style:{height:"42px",backgroundColor:"#f8f9fa"},value:de.total_estimated_duration_minutes??((Pe=(Oe=u.schedule_details)==null?void 0:Oe.schedule_preference)==null?void 0:Pe.total_estimated_duration_minutes)??0,onChange:_=>ye(y=>({...y,total_estimated_duration_minutes:Number(_.target.value)}))})]})}),e.jsx(b,{className:"mb-2",children:e.jsx(t,{md:6})}),e.jsx(b,{className:"mt-4",children:e.jsx(t,{xs:12,className:"text-start",children:e.jsxs(Be,{variant:"primary",onClick:Ze,disabled:he,className:"d-inline-flex align-items-center gap-2",children:[he&&e.jsx(Ps,{}),"Save"]})})})]}):e.jsx("p",{className:"text-muted",children:"No OT request found for this patient."})}),W==="preop"&&e.jsx("div",{className:"p-4"}),W==="intra-op"&&e.jsx("div",{className:"p-4",children:e.jsx(Nn,{show:!0,handleClose:De,handleSubmit:Re,patientData:d,otRequestData:u,otWings:h,selectedRecord:x})}),W==="post-op"&&e.jsx("div",{className:"p-4",children:e.jsx(An,{patientData:d,otRequestData:u})})]}),W==="preop"&&e.jsx(In,{show:o,handleClose:()=>{B(!1),V(null)},handleSubmit:Xe,patientData:d,otRequestData:u,selectedRecord:F}),e.jsx(sn,{show:K.show,handleDeleteCancel:Qe,handleDeleteConfirmation:Je,loading:ce}),e.jsx(wn,{show:i,handleHide:Ye,requestData:l,onSave:qe})]})};export{Vn as default};
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.