felicity-lims/felicity/templates/static/assets/SamplesAdd-7bdcb1bd.js
2024-11-17 19:39:30 +02:00

1 line
8.2 KiB
JavaScript

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