felicity-lims/felicity/templates/static/assets/PatientForm-e5abf0f3.js
2023-11-10 18:48:39 +02:00

1 line
14 KiB
JavaScript

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