felicity-lims/static/assets/SamplesAdd-c24c69a2.js
2023-04-10 17:21:30 +02:00

1 line
7.4 KiB
JavaScript

import{d as te,a8 as se,a3 as le,P as ae,ac as ne,u as oe,U as d,A as T,r as ie,c as I,a as N,ae as E,am as ce,b as re,e as u,b8 as de,o,g as i,h as e,i as r,v as R,j as l,k as m,t as c,l as B,aj as ue,R as b,F as _,z as h,w as V,y as pe,L as me,ak as _e,b5 as he,b9 as fe,_ as ye}from"./index-596c477d.js";/* empty css */const ve={class:"w-3/6 mt-4 py-4"},we=e("h5",{class:"mb-4"},"Add Analysis Request",-1),be={class:""},xe={class:"flex whitespace-nowrap mb-2 w-full"},Se=e("span",{class:"text-gray-700 w-4/12"},"Client Request ID",-1),ge={class:"w-full"},Ce={class:"text-orange-600 w-4/12"},ke={class:"flex whitespace-nowrap mb-2 w-full"},Ae=e("span",{class:"text-gray-700 w-4/12"},"Clinical Data",-1),Ue={class:"w-full"},Re={class:"text-orange-600 w-4/12"},Ve={class:"flex whitespace-nowrap mb-2 w-full"},qe=e("span",{class:"text-gray-700 w-4/12"},"Client",-1),De={class:"w-full"},Pe={class:"flex whitespace-nowrap mb-2 w-full"},Te=e("span",{class:"text-gray-700 w-4/12"},"Client Contacts",-1),Ie={class:"w-full"},Ne=e("option",{value:""},null,-1),Ee=["value"],Be={class:"text-orange-600 w-4/12"},Fe={class:"flex whitespace-nowrap mb-2 w-full"},Me=e("span",{class:"text-gray-700 w-4/12"},"Priority",-1),$e={class:"w-full"},je={class:"text-orange-600 w-4/12"},Le={id:"samples"},ze=e("hr",null,null,-1),Qe={class:"flex justify-between items-center py-2"},Ye=e("h5",null,"Samples",-1),Ge={class:"text-orange-600"},He=e("hr",{class:"mb-4"},null,-1),Je={class:"flex items-center justify-between"},Ke={class:"flex items-top gap-x-4"},Oe={class:"flex flex-col whitespace-nowrap mb-2"},We=e("span",{class:"text-gray-700"},"Sample Type",-1),Xe=["onUpdate:modelValue"],Ze=e("option",{value:""},null,-1),et=["value"],tt={class:"flex flex-col whitespace-nowrap mb-2"},st=e("span",{class:"text-gray-700"},"Analysis Profiles",-1),lt=["onUpdate:modelValue"],at=e("option",{value:""},null,-1),nt=["value"],ot={class:"flex flex-col whitespace-nowrap mb-2"},it=e("span",{class:"text-gray-700"},"Analysis Services",-1),ct=["onUpdate:modelValue"],rt=e("option",{value:""},null,-1),dt=["value"],ut={class:""},pt=["onClick"],mt=e("hr",null,null,-1),_t=e("hr",null,null,-1),ht={key:0,type:"submit",class:"-mb-4 w-full 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"},ft={key:1,class:"py-4 text-center"},yt=te({__name:"SamplesAdd",setup(vt){const x=se(),F=le(),f=ae(),y=ne(),M=oe(),{withClientMutation:$}=_e(),{swalError:q}=he();let D=d(()=>F.getPatient),j=T({first:void 0,after:"",text:"",sortBy:["name"]});y.fetchClients(j);const L=d(()=>y.getClients);function z(n){fe(n)&&y.fetchClientContacts(n?.uid)}const Q=d(()=>y.getClientContacts);x.fetchSampleTypes();const Y=d(()=>x.getSampleTypes);let G=T({first:void 0,after:"",text:"",sortBy:["name"]});f.fetchAnalysesServices(G);const H=d(()=>{const n=f.getAnalysesServicesSimple;let s=new Set;return n.forEach((t,U)=>{t.profiles?.length===0&&s.add(t)}),[...s]});f.fetchAnalysesProfiles();const J=d(()=>f.getAnalysesProfiles),S=ie(!1),K=I({clientRequestId:N().required("Client Request ID is Required"),clinicalData:N().nullable(),client:I().required("Client is Required"),clientContactUid:E().required("Client Contact is Required"),samples:ce().required().min(1,"Add at least 1 sample"),priority:E()}),{handleSubmit:O,errors:p}=re({validationSchema:K,initialValues:{priority:0,samples:[]}}),{value:g}=u("clientRequestId"),{value:C}=u("clinicalData"),{value:v}=u("client"),{value:k}=u("clientContactUid"),{value:A}=u("priority"),{value:w}=u("samples"),P=O(n=>{S.value=!0;for(let s of n.samples||[]){if(typeof s?.sampleType!="string"){q("Samples must have sample types");return}if(s?.analyses?.length<=0&&s?.profiles?.length<=0){q("Samples must have either profiles/analyses or both");return}}W(n)});function W(n){const s={patientUid:D.value?.uid,clientRequestId:n.clientRequestId,clinicalData:n.clinicalData,clientUid:v?.value?.uid,clientContactUid:n.clientContactUid,samples:n.samples};$(de,{payload:s},"createAnalysisRequest").then(t=>{x.addAnalysisRequest(t),M.push({name:"patient-detail",params:{patientUid:D.value?.uid}})}).finally(()=>{S.value=!1})}function X(){const n={sampleType:{},profiles:[],analyses:[]};w.value.push(n)}function Z(n){w.value.splice(n,1)}return(n,s)=>(o(),i("div",ve,[we,e("form",{action:"post",class:"p-4 mb-8 bg-white",onSubmit:s[6]||(s[6]=V((...t)=>l(P)&&l(P)(...t),["prevent"]))},[e("div",be,[e("label",xe,[Se,e("div",ge,[r(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":s[0]||(s[0]=t=>m(g)?g.value=t:null),placeholder:"CRID ..."},null,512),[[R,l(g)]]),e("div",Ce,c(l(p).clientRequestId),1)])]),e("label",ke,[Ae,e("div",Ue,[r(e("textarea",{cols:"2",class:"form-input mt-1 w-full","onUpdate:modelValue":s[1]||(s[1]=t=>m(C)?C.value=t:null),placeholder:"Clinical Data ..."},null,512),[[R,l(C)]]),e("div",Re,c(l(p).clinicalData),1)])]),e("label",Ve,[qe,e("div",De,[B(l(ue),{placeholder:"Select a Client",modelValue:l(v),"onUpdate:modelValue":s[2]||(s[2]=t=>m(v)?v.value=t:null),options:l(L),searchable:!0,label:"name","track-by":"uid",onSelect:z},null,8,["modelValue","options"])])]),e("label",Pe,[Te,e("div",Ie,[r(e("select",{name:"clientContacts",id:"clientContacts","onUpdate:modelValue":s[3]||(s[3]=t=>m(k)?k.value=t:null),class:"form-input mt-1 block w-full"},[Ne,(o(!0),i(_,null,h(l(Q),t=>(o(),i("option",{key:t.uid,value:t.uid},c(t.firstName)+" "+c(t.lastName),9,Ee))),128))],512),[[b,l(k)]]),e("div",Be,c(l(p).clientContactUid),1)])]),e("label",Fe,[Me,e("div",$e,[r(e("input",{type:"number",min:"0",max:"2",class:"form-input mt-1 block w-full","onUpdate:modelValue":s[4]||(s[4]=t=>m(A)?A.value=t:null)},null,512),[[R,l(A)]]),e("div",je,c(l(p).priority),1)])])]),e("section",Le,[ze,e("div",Qe,[Ye,e("span",Ge,c(l(p).samples),1),l(w)?.length!==20?(o(),i("button",{key:0,onClick:s[5]||(s[5]=V(t=>X(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800rounded-smtransition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Add Sample ")):pe("v-if",!0)]),He,(o(!0),i(_,null,h(l(w),(t,U)=>(o(),i("div",{key:U},[e("div",Je,[e("div",Ke,[e("label",Oe,[We,r(e("select",{name:"sampleTypes",id:"sampleTypes","onUpdate:modelValue":a=>t.sampleType=a,class:"form-input mt-1"},[Ze,(o(!0),i(_,null,h(l(Y),a=>(o(),i("option",{key:a.uid,value:a.uid},c(a.name),9,et))),128))],8,Xe),[[b,t.sampleType]])]),e("label",tt,[st,r(e("select",{name:"analysisProfiles",id:"analysisProfiles","onUpdate:modelValue":a=>t.profiles=a,class:"form-input mt-1",multiple:""},[at,(o(!0),i(_,null,h(l(J),(a,ee)=>(o(),i("option",{key:a.uid,value:a.uid},c(a.name),9,nt))),128))],8,lt),[[b,t.profiles]])]),e("label",ot,[it,r(e("select",{name:"analysesServices",id:"analysesServices","onUpdate:modelValue":a=>t.analyses=a,class:"form-input mt-1",multiple:""},[rt,(o(!0),i(_,null,h(l(H),(a,ee)=>(o(),i("option",{key:a.uid,value:a.uid},c(a.name),9,dt))),128))],8,ct),[[b,t.analyses]])])]),e("div",ut,[e("button",{onClick:V(a=>Z(U),["prevent"]),class:"px-2 py-1 mr-2 border-orange-600 border text-orange-600rounded-smtransition duration-300 hover:bg-orange-600 hover:text-white focus:outline-none"}," Remove ",8,pt)])]),mt]))),128))]),_t,S.value?(o(),i("div",ft,[B(me,{message:"Adding Samples ..."})])):(o(),i("button",ht," Add Sample(s) "))],32)]))}}),xt=ye(yt,[["__file","/home/aurthur/Development/Python/felicity/felicity-lims/webapp/views/sample/SamplesAdd.vue"]]);export{xt as default};