felicity-lims/felicity/templates/static/assets/PatientForm-b033aef6.js
2024-11-17 19:39:30 +02:00

1 line
14 KiB
JavaScript

import{d as be,aA as ge,p as xe,n as Ue,u as ye,N as Ne,q as W,x as B,y as De,aa as Pe,r as C,aR as Me,aB as ke,m as Ve,o as c,c as m,b as e,e as o,v as p,f as n,i as r,t as a,at as X,P as Se,g as J,as as D,F as b,E as g,w as Q,M as Be,b7 as Ce,k as Ie}from"./index-e62f5c21.js";import Ee from"./vue-multiselect.esm-b4ea8090.js";import{A as Oe,U as $e}from"./patient.mutations-8b20d6de.js";import{c as Z,d as P,a as _,f as qe,g as ee,u as Ae,b as d}from"./array-4296cccc.js";/* empty css */const Fe={class:"flex whitespace-nowrap w-full"},Ye=e("span",{class:"text-gray-700 w-4/12"},"Patient Unique Identifier",-1),Re={class:"w-full"},Te={class:"text-orange-600 w-4/12"},je={class:"flex whitespace-nowrap w-full"},He=e("span",{class:"text-gray-700 w-4/12"},"First Name",-1),Le={class:"w-full"},Ge={class:"text-orange-600 w-4/12"},Ke={class:"flex whitespace-nowrap mb-2 w-full"},ze=e("span",{class:"text-gray-700 w-4/12"},"Middle Name",-1),We={class:"w-full"},Xe={class:"text-orange-600 w-4/12"},Je={class:"flex whitespace-nowrap w-full"},Qe=e("span",{class:"text-gray-700 w-4/12"},"Last Name",-1),Ze={class:"w-full"},et={class:"text-orange-600 w-4/12"},tt={class:"flex whitespace-nowrap my-2 w-full"},st=e("span",{class:"text-gray-700 w-4/12"},"Age/DOB Estimated?",-1),lt={class:"w-full flex justify-between items-center"},nt={class:"flex justify-start items-center gap-x-2 ml-4"},it={for:"estimateYears"},at=e("span",{class:"mr-1"},"Years",-1),ot={for:"estimateMonths"},dt=e("span",{class:"mr-1"},"Months",-1),ut={for:"estimateDays"},rt=e("span",{class:"mr-1"},"Days",-1),ct={class:"text-orange-600 w-4/12"},mt={class:"flex whitespace-nowrap mb-2 w-full"},pt=e("span",{class:"text-gray-700 w-4/12"},"Date of Birth",-1),vt={class:"w-full"},ft={class:"text-orange-600 w-4/12"},_t={class:"flex whitespace-nowrap mb-2 w-full"},wt=e("span",{class:"text-gray-700 w-4/12"},"Age",-1),ht={class:"w-full"},bt={class:"text-orange-600 w-4/12"},gt={class:"flex whitespace-nowrap mb-2 w-full"},xt=e("span",{class:"text-gray-700 w-4/12"},"Gender",-1),Ut={class:"w-full"},yt=e("option",null,null,-1),Nt=["value"],Dt={class:"text-orange-600 w-4/12"},Pt={class:"flex whitespace-nowrap mb-2 w-full"},Mt=e("span",{class:"text-gray-700 w-4/12"},"Mobile Number",-1),kt={class:"w-full"},Vt={class:"text-orange-600 w-4/12"},St={class:"flex whitespace-nowrap mb-2 w-full"},Bt=e("span",{class:"text-gray-700 w-4/12"},"Consent to SMS",-1),Ct={class:"w-full"},It={class:"text-orange-600 w-4/12"},Et={class:"flex whitespace-nowrap mb-2 w-full"},Ot=e("span",{class:"text-gray-700 w-4/12"},"Primary Referrer",-1),$t={class:"w-full"},qt={class:"text-orange-600 w-4/12"},At={class:"flex whitespace-nowrap mb-2 w-full"},Ft={class:"text-gray-700 w-4/12 flex justify-between items-center"},Yt=e("span",{class:"mr-4"},"Extra Ids:",-1),Rt={class:"w-full border-gray-200"},Tt={class:"flex justify-around items-center w-full"},jt=e("span",null,"Identification",-1),Ht=["onUpdate:modelValue"],Lt=e("option",null,null,-1),Gt=["value"],Kt=e("span",null,"Value",-1),zt=["onUpdate:modelValue"],Wt=["onClick"],Xt=e("hr",{class:"my-2"},null,-1),Jt={class:"grid grid-cols-3 gap-x-4 mb-4"},Qt={class:"col-span-1"},Zt={class:"flex gap-x-2 items-center whitespace-nowrap w-full"},es=e("span",{class:"text-gray-700 w-4/12"},"Country",-1),ts=e("option",{value:null},null,-1),ss=["value"],ls={class:"text-orange-600 w-4/12"},ns={class:"col-span-1"},is={class:"flex gap-x-2 items-center whitespace-nowrap col-span-1 w-full"},as=e("span",{class:"text-gray-700 w-4/12"},"Province",-1),os=e("option",{value:null},null,-1),ds=["value"],us={class:"text-orange-600 w-4/12"},rs={class:"col-span-1"},cs={class:"flex gap-x-2 items-center whitespace-nowrap col-span-1 w-full"},ms=e("span",{class:"text-gray-700 w-4/12"},"District",-1),ps=e("option",{value:null},null,-1),vs=["value"],fs={class:"text-orange-600 w-4/12"},_s=e("hr",null,null,-1),ws=e("button",{type:"submit",class:"-mb-4 w-1/5 border border-sky-800 bg-sky-800 text-white rounded-sm px-4 py-2 m-2 transition-colors duration-500 ease select-none hover:bg-sky-800 focus:outline-none focus:shadow-outline"}," Save Patient ",-1),hs=be({__name:"PatientForm",props:{patient:Object,navigate:{type:Boolean,default:!1}},emits:["close"],setup(te,{emit:se}){const x=te,L=se;let G=ge(),v=xe(),M=Ue();const{withClientMutation:K}=Be();let le=ye(),ne=Ne();const U=W({genders:["Male","Female","Missing","Trans Gender"],createAction:!0,countries:B(()=>v.getCountries),provinces:B(()=>v.getProvinces),districts:B(()=>v.getDistricts),clients:B(()=>G.getClients)});let ie=W({first:void 0,after:"",text:"",sortBy:["name"],filterAction:!1});De(async()=>{await v.fetchCountries(),await G.fetchClients(ie),x.patient?.countryUid&&await v.filterProvincesByCountry(x.patient?.countryUid),x.patient?.provinceUid&&await v.filterDistrictsByProvince(x.patient?.provinceUid),await M.fetchIdentifications()});const{patient:i,navigate:ae}=Pe(x),oe=C(new Date),k=C(0),I=C(0),E=C(0),w=()=>{const l=Ce().subtract(k.value,"year").subtract(I.value,"month").subtract(E.value,"day");h.value=l.format("YYYY-MM-DD"),y.value=k.value},de=()=>{var l=new Date().getFullYear();if(h.value){const t=new Date(h.value).getFullYear();y.value=l-t}},ue=Z({uid:P(),clientPatientId:_().required("Client Patient ID is Required"),patientId:_().nullable(),firstName:_().required("First Name is Required"),middleName:_().nullable(),lastName:_().required("Last Name is Required"),client:Z().required("Client is Required"),gender:_().required("Gender is Required"),age:P().nullable(),dateOfBirth:qe().nullable(),ageDobEstimated:ee().nullable(),phoneHome:_().nullable(),phoneMobile:_().nullable(),consentSms:ee().nullable(),districtUid:P().nullable(),provinceUid:P().nullable(),countryUid:P().nullable()}),{handleSubmit:re,errors:u}=Ae({validationSchema:ue,initialValues:{uid:i?.value?.uid,clientPatientId:i?.value?.clientPatientId||ne?.query?.cpid,patientId:i?.value?.patientId,firstName:i?.value?.firstName,middleName:i?.value?.middleName,lastName:i?.value?.lastName,client:i?.value?.client,gender:i?.value?.gender,age:i?.value?.age,dateOfBirth:Me(i?.value?.dateOfBirth)?void 0:new Date(i?.value?.dateOfBirth).toISOString().split("T")[0],ageDobEstimated:i?.value?.ageDobEstimated,phoneHome:i?.value?.phoneHome,phoneMobile:i?.value?.phoneMobile,consentSms:i?.value?.consentSms,districtUid:i?.value?.districtUid,provinceUid:i?.value?.provinceUid,countryUid:i?.value?.countryUid,identifications:i?.value?.identifications??[]}}),{value:O}=d("clientPatientId"),{value:$}=d("firstName"),{value:q}=d("middleName"),{value:A}=d("lastName"),{value:F}=d("client"),{value:Y}=d("gender"),{value:y}=d("age"),{value:h}=d("dateOfBirth"),{value:N}=d("ageDobEstimated"),{value:R}=d("phoneMobile"),{value:T}=d("consentSms"),{value:j}=d("districtUid"),{value:V}=d("provinceUid"),{value:S}=d("countryUid"),{value:H}=d("identifications"),z=re(l=>{l.uid||ce(l),l.uid&&me(l)});function ce(l){K(Oe,{payload:{clientPatientId:l.clientPatientId,firstName:l.firstName,middleName:l.middleName,lastName:l.lastName,age:l.age,gender:l.gender,dateOfBirth:ke(l.dateOfBirth,"YYYY-MM-DD HH:mm"),ageDobEstimated:l.ageDobEstimated,clientUid:l.client.uid,phoneMobile:l.phoneMobile,consentSms:l.consentSms,countryUid:l.countryUid,provinceUid:l.provinceUid,districtUid:l.districtUid,identifications:l.identifications}},"createPatient").then(t=>{M.addPatient(t),L("close",t),ae.value===!0&&le.push({name:"patient-detail",params:{patientUid:t.uid}})})}function me(l){K($e,{uid:l.uid,payload:{clientPatientId:l.clientPatientId,firstName:l.firstName,middleName:l.middleName,lastName:l.lastName,age:l.age,gender:l.gender,dateOfBirth:l.dateOfBirth,ageDobEstimated:l.ageDobEstimated,clientUid:l.client.uid,phoneMobile:l.phoneMobile,consentSms:l.consentSms,countryUid:l.countryUid,provinceUid:l.provinceUid,districtUid:l.districtUid,identifications:l.identifications?.map(t=>({identificationUid:t.identificationUid,value:t.value}))}},"updatePatient").then(t=>{M.updatePatient(t),L("close",t)})}function pe(l){v.filterProvincesByCountry(S.value)}function ve(l){v.filterDistrictsByProvince(V.value)}const fe=()=>{H.value.push({identificationUid:"12122",value:""})},_e=l=>{H.value.splice(l,1)};return(l,t)=>{const we=Ve("VueDatePicker");return c(),m("form",{onSubmit:t[27]||(t[27]=Q((...s)=>n(z)&&n(z)(...s),["prevent"])),class:"border-2 border-gray-900 border-dotted rounded-sm px-4 py-8",autocomplete:"off"},[e("label",Fe,[Ye,e("div",Re,[o(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":t[0]||(t[0]=s=>r(O)?O.value=s:null),placeholder:"Patient Unique Identifier"},null,512),[[p,n(O)]]),e("div",Te,a(n(u).clientPatientId),1)])]),e("label",je,[He,e("div",Le,[o(e("input",{class:"form-input mt-1 w-full","onUpdate:modelValue":t[1]||(t[1]=s=>r($)?$.value=s:null),placeholder:"First Name"},null,512),[[p,n($)]]),e("div",Ge,a(n(u).firstName),1)])]),e("label",Ke,[ze,e("div",We,[o(e("input",{class:"form-input mt-1 w-full","onUpdate:modelValue":t[2]||(t[2]=s=>r(q)?q.value=s:null),placeholder:"Middle Name"},null,512),[[p,n(q)]]),e("div",Xe,a(n(u).middleName),1)])]),e("label",Je,[Qe,e("div",Ze,[o(e("input",{class:"form-input mt-1 w-full","onUpdate:modelValue":t[3]||(t[3]=s=>r(A)?A.value=s:null),placeholder:"Last Name"},null,512),[[p,n(A)]]),e("div",et,a(n(u).lastName),1)])]),e("label",tt,[st,e("div",lt,[o(e("input",{type:"checkbox",class:"form-checkbox text-sky-800","onUpdate:modelValue":t[4]||(t[4]=s=>r(N)?N.value=s:null)},null,512),[[X,n(N)]]),o(e("div",nt,[e("label",it,[at,o(e("input",{name:"estimateYears",type:"number",min:"0",class:"form-input w-24 py-0 text-sky-800","onUpdate:modelValue":t[5]||(t[5]=s=>k.value=s),onChange:t[6]||(t[6]=s=>w()),onKeyup:t[7]||(t[7]=s=>w())},null,544),[[p,k.value]])]),e("label",ot,[dt,o(e("input",{name:"estimateMonths",type:"number",min:"0",max:"12",class:"form-input w-24 py-0 text-sky-800","onUpdate:modelValue":t[8]||(t[8]=s=>I.value=s),onChange:t[9]||(t[9]=s=>w()),onKeyup:t[10]||(t[10]=s=>w())},null,544),[[p,I.value]])]),e("label",ut,[rt,o(e("input",{name:"estimateDays",type:"number",min:"0",max:"365",class:"form-input w-24 py-0 text-sky-800","onUpdate:modelValue":t[11]||(t[11]=s=>E.value=s),onChange:t[12]||(t[12]=s=>w()),onKeyup:t[13]||(t[13]=s=>w())},null,544),[[p,E.value]])])],512),[[Se,n(N)]]),e("div",ct,a(n(u).ageDobEstimated),1)])]),e("label",mt,[pt,e("div",vt,[J(we,{class:"z-60 disabled:bg-slate-200",modelValue:n(h),"onUpdate:modelValue":t[14]||(t[14]=s=>r(h)?h.value=s:null),disabled:n(N),onClosed:t[15]||(t[15]=s=>de()),"max-date":oe.value},null,8,["modelValue","disabled","max-date"]),e("div",ft,a(n(u).dateOfBirth),1)])]),e("label",_t,[wt,e("div",ht,[o(e("input",{class:"form-input mt-1 w-full disabled:bg-slate-200",type:"number","onUpdate:modelValue":t[16]||(t[16]=s=>r(y)?y.value=s:null),placeholder:"Age",disabled:""},null,512),[[p,n(y)]]),e("div",bt,a(n(u).age),1)])]),e("label",gt,[xt,e("div",Ut,[o(e("select",{class:"form-select mt-1 w-full","onUpdate:modelValue":t[17]||(t[17]=s=>r(Y)?Y.value=s:null)},[yt,(c(!0),m(b,null,g(U.genders,s=>(c(),m("option",{key:s,value:s},a(s),9,Nt))),128))],512),[[D,n(Y)]]),e("div",Dt,a(n(u).gender),1)])]),e("label",Pt,[Mt,e("div",kt,[o(e("input",{class:"form-input mt-1 w-full","onUpdate:modelValue":t[18]||(t[18]=s=>r(R)?R.value=s:null),placeholder:"Mobile Number"},null,512),[[p,n(R)]]),e("div",Vt,a(n(u).phoneMobile),1)])]),e("label",St,[Bt,e("div",Ct,[o(e("input",{type:"checkbox",class:"form-checkbox text-sky-800","onUpdate:modelValue":t[19]||(t[19]=s=>r(T)?T.value=s:null)},null,512),[[X,n(T)]]),e("div",It,a(n(u).consentSms),1)])]),e("label",Et,[Ot,e("div",$t,[J(n(Ee),{placeholder:"Select a Primary Referrer",modelValue:n(F),"onUpdate:modelValue":t[20]||(t[20]=s=>r(F)?F.value=s:null),options:U.clients,searchable:!0,label:"name","track-by":"uid"},null,8,["modelValue","options"]),e("div",qt,a(n(u).client),1)])]),e("label",At,[e("span",Ft,[Yt,e("div",null,[e("span",{class:"relative px-1 mr-2 mt-4 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none",onClick:t[21]||(t[21]=s=>fe())}," Add ")])]),e("div",Rt,[(c(!0),m(b,null,g(n(H),(s,he)=>(c(),m("div",Tt,[jt,o(e("select",{class:"form-select mt-1","onUpdate:modelValue":f=>s.identificationUid=f},[Lt,(c(!0),m(b,null,g(n(M).identifications,f=>(c(),m("option",{key:f.uid,value:f.uid},a(f.name),9,Gt))),128))],8,Ht),[[D,s.identificationUid]]),Kt,o(e("input",{type:"text",class:"form-input text-sky-800","onUpdate:modelValue":f=>s.value=f},null,8,zt),[[p,s.value]]),e("span",{class:"p-2 text-red-800",onClick:Q(f=>_e(he),["prevent"])},"X",8,Wt)]))),256))])]),Xt,e("div",Jt,[e("div",Qt,[e("label",Zt,[es,o(e("select",{class:"form-select mt-1 w-full","onUpdate:modelValue":t[22]||(t[22]=s=>r(S)?S.value=s:null),onChange:t[23]||(t[23]=s=>pe())},[ts,(c(!0),m(b,null,g(U.countries,s=>(c(),m("option",{key:s.uid,value:s.uid},a(s.name),9,ss))),128))],544),[[D,n(S)]])]),e("div",ls,a(n(u).countryUid),1)]),e("div",ns,[e("label",is,[as,o(e("select",{class:"form-select mt-1 w-full","onUpdate:modelValue":t[24]||(t[24]=s=>r(V)?V.value=s:null),onChange:t[25]||(t[25]=s=>ve())},[os,(c(!0),m(b,null,g(U.provinces,s=>(c(),m("option",{key:s.uid,value:s.uid},a(s.name),9,ds))),128))],544),[[D,n(V)]])]),e("div",us,a(n(u).provinceUid),1)]),e("div",rs,[e("label",cs,[ms,o(e("select",{class:"form-select mt-1 w-full","onUpdate:modelValue":t[26]||(t[26]=s=>r(j)?j.value=s:null)},[ps,(c(!0),m(b,null,g(U.districts,s=>(c(),m("option",{key:s.uid,value:s.uid},a(s.name),9,vs))),128))],512),[[D,n(j)]])])]),e("div",fs,a(n(u).districtUid),1)]),_s,ws],32)}}}),Ns=Ie(hs,[["__file","/home/aurthurm/Documents/Development/felicity/felicity-lims/webapp/components/person/PatientForm.vue"]]);export{Ns as default};