@photonhealth/elements 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1093,7 +1093,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a
|
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
|
-
`,ub=e=>k(h6,{get children(){const t=Iq.cloneNode(!0),n=t.firstChild;return z(n,()=>e.LeftChildren),z(t,k(X,{get when(){return e?.RightChildren},get children(){const r=Aq.cloneNode(!0);return z(r,()=>e.RightChildren),r}}),null),t}});function Rq(e){const t=ct({draftPrescriptions:[],templateIds:[],prescriptionIds:[]},e),[n,r]=M(!0),i=mf();async function o(){r(!0);const a=[];if(t.templateIds.length>0){const{data:s}=await i.apollo.query({query:Dq});if(s?.catalogs){const c=s.catalogs.reduce((l,u)=>[...l,...u.templates],[]);t.templateIds.forEach(l=>{const u=c.find(d=>d.id===l);if(!u)return console.error(`Invalid template id ${l}`)
|
|
1096
|
+
`,ub=e=>k(h6,{get children(){const t=Iq.cloneNode(!0),n=t.firstChild;return z(n,()=>e.LeftChildren),z(t,k(X,{get when(){return e?.RightChildren},get children(){const r=Aq.cloneNode(!0);return z(r,()=>e.RightChildren),r}}),null),t}});function Rq(e){const t=ct({draftPrescriptions:[],templateIds:[],templateOverrides:{},prescriptionIds:[]},e),[n,r]=M(!0),i=mf();async function o(){r(!0);const a=[];if(t.templateIds.length>0){const{data:s}=await i.apollo.query({query:Dq});if(s?.catalogs){const c=s.catalogs.reduce((l,u)=>[...l,...u.templates],[]);t.templateIds.forEach(l=>{const u=c.find(d=>d.id===l);if(!u)return console.error(`Invalid template id ${l}`);if(!u?.treatment||!u?.dispenseQuantity||!u?.dispenseUnit||!u?.fillsAllowed||!u?.instructions)console.error(`Template is missing required prescription details ${l}`);else{const d=t?.templateOverrides?.[u.id],f=d?{...u,...d}:u;a.push(lb(f))}})}}t.prescriptionIds.length>0&&await Promise.allSettled(t.prescriptionIds.map(async s=>{const{data:c}=await i.apollo.query({query:Lq,variables:{id:s}}),l=c?.prescription;if(!l)return console.error(`Invalid prescription id ${s}`);a.push(lb(l))})),a.length>0&&e.setDraftPrescriptions(a),r(!1)}return Ve(()=>{t.templateIds.length>0||t.prescriptionIds.length>0?o():r(!1)}),(()=>{const a=Mq.cloneNode(!0);return z(a,k(X,{get when(){return n()},get children(){return k(mn,{get each(){return[...t.templateIds,...t.prescriptionIds]},children:()=>k(ub,{get LeftChildren(){return[k(gn,{size:"lg",sampleLoadingText:"Medication 100mg",loading:!0}),k(gn,{size:"sm",sampleLoadingText:"Loading notes about the medication",loading:!0})]}})})}}),null),z(a,k(X,{get when(){return!n()&&t.draftPrescriptions.length===0},get children(){return k(gn,{get color(){return t.error?"red":"gray"},class:"italic",children:"No prescriptions pending"})}}),null),z(a,k(X,{get when(){return!n()&&t.draftPrescriptions.length>0},get children(){return k(mn,{get each(){return t.draftPrescriptions},children:s=>k(ub,{get LeftChildren(){return[k(gn,{get children(){return s.treatment.name}}),k(gn,{color:"gray",size:"sm",get children(){return[Q(()=>s.dispenseQuantity)," ",Q(()=>s.dispenseUnit),", ",Q(()=>s.refillsInput)," refills -"," ",Q(()=>s.instructions)]}})]},get RightChildren(){return[(()=>{const c=cb.cloneNode(!0);return c.$$click=()=>t.handleEdit&&t.handleEdit(s.id),z(c,k(Ut,{name:"pencilSquare",size:"sm",class:"text-gray-500 hover:text-amber-500"})),c})(),(()=>{const c=cb.cloneNode(!0);return c.$$click=()=>t.handleDelete&&t.handleDelete(s.id),z(c,k(Ut,{name:"trash",size:"sm",class:"text-gray-500 hover:text-red-500"})),c})()]}})})}}),null),a})()}uo(["click"]);const U1=Symbol("store-raw"),Vs=Symbol("store-node"),Fq=Symbol("store-name");function M8(e,t){let n=e[Dt];if(!n&&(Object.defineProperty(e,Dt,{value:n=new Proxy(e,Vq)}),!Array.isArray(e))){const r=Object.keys(e),i=Object.getOwnPropertyDescriptors(e);for(let o=0,a=r.length;o<a;o++){const s=r[o];i[s].get&&Object.defineProperty(e,s,{enumerable:i[s].enumerable,get:i[s].get.bind(n)})}}return n}function mi(e){let t;return e!=null&&typeof e=="object"&&(e[Dt]||!(t=Object.getPrototypeOf(e))||t===Object.prototype||Array.isArray(e))}function ca(e,t=new Set){let n,r,i,o;if(n=e!=null&&e[U1])return n;if(!mi(e)||t.has(e))return e;if(Array.isArray(e)){Object.isFrozen(e)?e=e.slice(0):t.add(e);for(let a=0,s=e.length;a<s;a++)i=e[a],(r=ca(i,t))!==i&&(e[a]=r)}else{Object.isFrozen(e)?e=Object.assign({},e):t.add(e);const a=Object.keys(e),s=Object.getOwnPropertyDescriptors(e);for(let c=0,l=a.length;c<l;c++)o=a[c],!s[o].get&&(i=e[o],(r=ca(i,t))!==i&&(e[o]=r))}return e}function Rm(e){let t=e[Vs];return t||Object.defineProperty(e,Vs,{value:t={}}),t}function B1(e,t,n){return e[t]||(e[t]=L8(n))}function jq(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.get||!n.configurable||t===Dt||t===Vs||t===Fq||(delete n.value,delete n.writable,n.get=()=>e[Dt][t]),n}function D8(e){if(Rd()){const t=Rm(e);(t._||(t._=L8()))()}}function zq(e){return D8(e),Reflect.ownKeys(e)}function L8(e){const[t,n]=M(e,{equals:!1,internal:!0});return t.$=n,t}const Vq={get(e,t,n){if(t===U1)return e;if(t===Dt)return n;if(t===ks)return D8(e),n;const r=Rm(e),i=r.hasOwnProperty(t);let o=i?r[t]():e[t];if(t===Vs||t==="__proto__")return o;if(!i){const a=Object.getOwnPropertyDescriptor(e,t);Rd()&&(typeof o!="function"||e.hasOwnProperty(t))&&!(a&&a.get)&&(o=B1(r,t,o)())}return mi(o)?M8(o):o},has(e,t){return t===U1||t===Dt||t===ks||t===Vs||t==="__proto__"?!0:(this.get(e,t,e),t in e)},set(){return!0},deleteProperty(){return!0},ownKeys:zq,getOwnPropertyDescriptor:jq};function kn(e,t,n,r=!1){if(!r&&e[t]===n)return;const i=e[t],o=e.length;n===void 0?delete e[t]:e[t]=n;let a=Rm(e),s;(s=B1(a,t,i))&&s.$(()=>n),Array.isArray(e)&&e.length!==o&&(s=B1(a,"length",o))&&s.$(e.length),(s=a._)&&s.$()}function R8(e,t){const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const i=n[r];kn(e,i,t[i])}}function Uq(e,t){if(typeof t=="function"&&(t=t(e)),t=ca(t),Array.isArray(t)){if(e===t)return;let n=0,r=t.length;for(;n<r;n++){const i=t[n];e[n]!==i&&kn(e,n,i)}kn(e,"length",r)}else R8(e,t)}function ms(e,t,n=[]){let r,i=e;if(t.length>1){r=t.shift();const a=typeof r,s=Array.isArray(e);if(Array.isArray(r)){for(let c=0;c<r.length;c++)ms(e,[r[c]].concat(t),n);return}else if(s&&a==="function"){for(let c=0;c<e.length;c++)r(e[c],c)&&ms(e,[c].concat(t),n);return}else if(s&&a==="object"){const{from:c=0,to:l=e.length-1,by:u=1}=r;for(let d=c;d<=l;d+=u)ms(e,[d].concat(t),n);return}else if(t.length>1){ms(e[r],t,[r].concat(n));return}i=e[r],n=[r].concat(n)}let o=t[0];typeof o=="function"&&(o=o(i,n),o===i)||r===void 0&&o==null||(o=ca(o),r===void 0||mi(i)&&mi(o)&&!Array.isArray(o)?R8(i,o):kn(e,r,o))}function _i(...[e,t]){const n=ca(e||{}),r=Array.isArray(n),i=M8(n);function o(...a){su(()=>{r&&a.length===1?Uq(n,a[0]):ms(n,a)})}return[i,o]}const H1=Symbol("store-root");function No(e,t,n,r,i){const o=t[n];if(e===o)return;if(!mi(e)||!mi(o)||i&&e[i]!==o[i]){if(e!==o){if(n===H1)return e;kn(t,n,e)}return}if(Array.isArray(e)){if(e.length&&o.length&&(!r||i&&e[0]&&e[0][i]!=null)){let c,l,u,d,f,h,p,v;for(u=0,d=Math.min(o.length,e.length);u<d&&(o[u]===e[u]||i&&o[u]&&e[u]&&o[u][i]===e[u][i]);u++)No(e[u],o,u,r,i);const g=new Array(e.length),y=new Map;for(d=o.length-1,f=e.length-1;d>=u&&f>=u&&(o[d]===e[f]||i&&o[u]&&e[u]&&o[d][i]===e[f][i]);d--,f--)g[f]=o[d];if(u>f||u>d){for(l=u;l<=f;l++)kn(o,l,e[l]);for(;l<e.length;l++)kn(o,l,g[l]),No(e[l],o,l,r,i);o.length>e.length&&kn(o,"length",e.length);return}for(p=new Array(f+1),l=f;l>=u;l--)h=e[l],v=i&&h?h[i]:h,c=y.get(v),p[l]=c===void 0?-1:c,y.set(v,l);for(c=u;c<=d;c++)h=o[c],v=i&&h?h[i]:h,l=y.get(v),l!==void 0&&l!==-1&&(g[l]=o[c],l=p[l],y.set(v,l));for(l=u;l<e.length;l++)l in g?(kn(o,l,g[l]),No(e[l],o,l,r,i)):kn(o,l,e[l])}else for(let c=0,l=e.length;c<l;c++)No(e[c],o,c,r,i);o.length>e.length&&kn(o,"length",e.length);return}const a=Object.keys(e);for(let c=0,l=a.length;c<l;c++)No(e[a[c]],o,a[c],r,i);const s=Object.keys(o);for(let c=0,l=s.length;c<l;c++)e[s[c]]===void 0&&kn(o,s[c],void 0)}function Bq(e,t={}){const{merge:n,key:r="id"}=t,i=ca(e);return o=>{if(!mi(o)||!mi(i))return i;const a=No(i,{[H1]:o},H1,n,r);return a===void 0?o:a}}function W1(e){this.message=e}W1.prototype=new Error,W1.prototype.name="InvalidCharacterError";var db=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new W1("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,r,i=0,o=0,a="";r=t.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return a};function Hq(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(n){return decodeURIComponent(db(n).replace(/(.)/g,function(r,i){var o=i.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(t)}catch{return db(t)}}function Hu(e){this.message=e}function F8(e,t){if(typeof e!="string")throw new Hu("Invalid token specified");var n=(t=t||{}).header===!0?0:1;try{return JSON.parse(Hq(e.split(".")[n]))}catch(r){throw new Hu("Invalid token specified: "+r.message)}}Hu.prototype=new Error,Hu.prototype.name="InvalidTokenError";const Wq=e=>{window.location.replace(e?.returnTo||window.location.pathname)},qq=nf`
|
|
1097
1097
|
fragment CatalogTreatmentsFields on Catalog {
|
|
1098
1098
|
treatments {
|
|
1099
1099
|
id
|
|
@@ -3240,7 +3240,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
3240
3240
|
${this.caret?bc` <sl-icon part="caret" class="button__caret" library="system" name="caret"></sl-icon> `:""}
|
|
3241
3241
|
${this.loading?bc`<sl-spinner></sl-spinner>`:""}
|
|
3242
3242
|
</${t}>
|
|
3243
|
-
`}};Fe.styles=jee;x([vt(".button")],Fe.prototype,"button",2);x([gr()],Fe.prototype,"hasFocus",2);x([gr()],Fe.prototype,"invalid",2);x([C()],Fe.prototype,"title",2);x([C({reflect:!0})],Fe.prototype,"variant",2);x([C({reflect:!0})],Fe.prototype,"size",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"caret",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"disabled",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"loading",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"outline",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"pill",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"circle",2);x([C()],Fe.prototype,"type",2);x([C()],Fe.prototype,"name",2);x([C()],Fe.prototype,"value",2);x([C()],Fe.prototype,"href",2);x([C()],Fe.prototype,"target",2);x([C()],Fe.prototype,"rel",2);x([C()],Fe.prototype,"download",2);x([C()],Fe.prototype,"form",2);x([C({attribute:"formaction"})],Fe.prototype,"formAction",2);x([C({attribute:"formenctype"})],Fe.prototype,"formEnctype",2);x([C({attribute:"formmethod"})],Fe.prototype,"formMethod",2);x([C({attribute:"formnovalidate",type:Boolean})],Fe.prototype,"formNoValidate",2);x([C({attribute:"formtarget"})],Fe.prototype,"formTarget",2);x([Ke("disabled",{waitUntilFirstUpdate:!0})],Fe.prototype,"handleDisabledChange",1);Fe=x([Yt("sl-button")],Fe);const N$=(e,t)=>{e.updateFormValue({key:"treatment",value:t.treatment}),t.dispenseAsWritten&&e.updateFormValue({key:"dispenseAsWritten",value:t.dispenseAsWritten}),t.dispenseQuantity&&e.updateFormValue({key:"dispenseQuantity",value:Number(t.dispenseQuantity)}),t.dispenseUnit&&e.updateFormValue({key:"dispenseUnit",value:t.dispenseUnit}),t.daysSupply&&e.updateFormValue({key:"daysSupply",value:Number(t.daysSupply)}),t.fillsAllowed&&e.updateFormValue({key:"refillsInput",value:Number(t.fillsAllowed)-1}),t.instructions&&e.updateFormValue({key:"instructions",value:t.instructions}),t.notes&&e.updateFormValue({key:"notes",value:t.notes})},zee=e=>{e.updateFormValue({key:"treatment",value:void 0}),e.updateFormValue({key:"dispenseAsWritten",value:!1}),e.updateFormValue({key:"dispenseQuantity",value:null}),e.updateFormValue({key:"dispenseUnit",value:"Each"}),e.updateFormValue({key:"daysSupply",value:null}),e.updateFormValue({key:"refillsInput",value:0}),e.updateFormValue({key:"instructions",value:""}),e.updateFormValue({key:"notes",value:""})},Vee=N('<photon-checkbox label="Add To Templates" form-name="daw"></photon-checkbox>'),Uee=N('<photon-card title="Add Prescription"><style></style><div class="flex flex-col sm:gap-3"><photon-treatment-select label="Search Treatment Catalog"></photon-treatment-select><div class="flex flex-col sm:flex-none sm:grid sm:grid-cols-2 sm:gap-4"><div class="order-last sm:order-first"><photon-checkbox label="Dispense as written" tip="This prescription will be filled generically unless this box is checked" form-name="daw" class="flex-grow"></photon-checkbox><photon-med-search-dialog></photon-med-search-dialog></div><div class="pb-4 md:py-2 text-left sm:text-right"><a class="font-sans text-gray-500 text-sm hover:text-black hover:cursor-pointer">Advanced Search \u2192</a></div></div><div class="mt-2 sm:mt-0 md:max-w-[50%] md:pr-2"><photon-datepicker label="Effective Date" required="true"></photon-datepicker></div><div class="mt-2 sm:mt-0 sm:grid sm:grid-cols-2 sm:gap-4"><div class="flex items-end gap-1"><photon-number-input class="flex-grow flex-1 w-2/5 sm:w-auto" label="Quantity" required="true" min="1"></photon-number-input><div><photon-button variant="outline" class="w-fit"><button><sl-icon name="calculator"></sl-icon></button></photon-button><div class="pt-1"></div></div></div><photon-dispense-units label="Dispense Unit" required="true" force-label-size="true"></photon-dispense-units></div><div class="sm:grid sm:grid-cols-2 sm:gap-4"><photon-number-input class="flex-grow flex-shrink flex-1" label="Days Supply" required="true" min="0"></photon-number-input><photon-number-input class="flex-grow flex-shrink flex-1" label="Refills" required="true" min="0"></photon-number-input></div><photon-textarea label="Patient Instructions (SIG)" form-name="patient_instructions" required="true" placeholder="Enter patient instructions"></photon-textarea><photon-textarea label="Pharmacy Note" placeholder="Enter pharmacy note"></photon-textarea><div class="flex flex-col xs:flex-row gap-2"><div class="flex flex-grow justify-end"><photon-button class="w-full xs:w-fit">Add Prescription</photon-button></div></div></div></photon-card>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");const Bee={treatment:xt(qm(Pn(),hl()),"Please select a treatment..."),dispenseQuantity:xt(q0(H0(),1),"Quantity must be positive"),daysSupply:xt(q0(H0(),0),"Days Supply must be at least 0"),refillsInput:xt(q0(H0(),0),"Refills must be at least 0"),instructions:xt(ai(Pn(),1,1/0),"Please enter instructions for the patient..."),effectiveDate:xt(Lee(new Date),"Please choose a date that isn't in the past")},Hee=e=>{let t;const[n,r]=M(void 0),[i]=M(void 0),[o,a]=M(!1);let s;for(const[c,l]of Object.entries(Bee))e.actions.registerValidator({key:c,validator:l});return(()=>{const c=J(()=>document.importNode(Uee,!0)),l=c.firstChild,u=l.nextSibling,d=u.firstChild,f=d.nextSibling,h=f.firstChild,p=h.firstChild,v=p.nextSibling,g=h.nextSibling,y=g.firstChild,m=f.nextSibling,b=m.firstChild,$=m.nextSibling,_=$.firstChild,E=_.firstChild,O=E.nextSibling,T=O.firstChild,V=T.firstChild,q=V.firstChild,ee=T.nextSibling,U=_.nextSibling,j=$.nextSibling,D=j.firstChild,A=D.nextSibling,W=j.nextSibling,G=W.nextSibling,Y=G.nextSibling,K=Y.firstChild,se=K.firstChild,re=s;typeof re=="function"?ge(re,c):s=c,c._$owner=F(),S(l,Zm),u.addEventListener("photon-medication-selected",B=>{r(B.detail.medication),e.actions.updateFormValue({key:"treatment",value:B.detail.medication})}),d.addEventListener("photon-treatment-selected",B=>{B.detail.data.__typename==="PrescriptionTemplate"?N$(e.actions,B.detail.data):e.actions.updateFormValue({key:"treatment",value:B.detail.data}),e.actions.updateFormValue({key:"catalogId",value:B.detail.catalogId})}),d._$owner=F(),p.addEventListener("photon-checkbox-toggled",B=>e.actions.updateFormValue({key:"dispenseAsWritten",value:B.detail.checked})),p._$owner=F();const I=t;return typeof I=="function"?ge(I,v):t=v,v._$owner=F(),y.$$click=()=>t.open=!0,b.addEventListener("photon-datepicker-selected",B=>e.actions.updateFormValue({key:"effectiveDate",value:B.detail.date})),b._$owner=F(),E.addEventListener("photon-input-changed",B=>{const ye=Number(B.detail.input);!isNaN(ye)&&B.detail.input!==""&&e.actions.updateFormValue({key:"dispenseQuantity",value:ye})}),E.style.setProperty("width","100px"),E._$owner=F(),S(_,k(tV,{get open(){return o()},onClose:()=>a(!1),get medicationName(){return e.store.treatment?.value?.name},setAutocompleteValues:({liquidDose:B,totalLiquid:ye,unit:te,days:pe})=>{e.actions.updateFormValue({key:"daysSupply",value:Number(pe)}),e.actions.updateFormValue({key:"dispenseQuantity",value:Number(ye)}),e.actions.updateFormValue({key:"instructions",value:`${B} ${te} ${e.store.instructions?.value}`}),te==="mL"&&e.actions.updateFormValue({key:"dispenseUnit",value:"Milliliter"})}}),O),T.addEventListener("photon-clicked",()=>a(!0)),T._$owner=F(),V.$$click=()=>a(!0),q._$owner=F(),ee.style.setProperty("height","23px"),U.addEventListener("photon-dispense-unit-selected",B=>e.actions.updateFormValue({key:"dispenseUnit",value:B.detail.dispenseUnit.name})),U._$owner=F(),D.addEventListener("photon-input-changed",B=>{e.actions.updateFormValue({key:"daysSupply",value:Number(B.detail.input)})}),D._$owner=F(),A.addEventListener("photon-input-changed",B=>e.actions.updateFormValue({key:"refillsInput",value:Number(B.detail.input)})),A._$owner=F(),W.addEventListener("photon-textarea-changed",B=>e.actions.updateFormValue({key:"instructions",value:B.detail.value})),W._$owner=F(),G.addEventListener("photon-textarea-changed",B=>e.actions.updateFormValue({key:"notes",value:B.detail.value})),G._$owner=F(),S(Y,k(X,{get when(){return!e.hideAddToTemplates},get children(){const B=J(()=>document.importNode(Vee,!0));return B.addEventListener("photon-checkbox-toggled",ye=>e.actions.updateFormValue({key:"addToTemplates",value:ye.detail.checked})),B._$owner=F(),H(()=>B.checked=e.store.addToTemplates?.value||!1),B}}),K),se.addEventListener("photon-clicked",()=>{const B=["treatment","effectiveDate","dispenseQuantity","daysSupply","refillsInput","instructions"];e.actions.validate(B),e.actions.hasErrors(B)||(e.actions.updateFormValue({key:"draftPrescriptions",value:[...e.store.draftPrescriptions?.value||[],{id:String(Math.random()),effectiveDate:e.store.effectiveDate.value,treatment:e.store.treatment.value,dispenseAsWritten:e.store.dispenseAsWritten.value,dispenseQuantity:e.store.dispenseQuantity.value,dispenseUnit:e.store.dispenseUnit.value,daysSupply:e.store.daysSupply.value,refillsInput:e.store.refillsInput.value,instructions:e.store.instructions.value,notes:e.store.notes.value,fillsAllowed:e.store.refillsInput.value+1,addToTemplates:e.store.addToTemplates?.value??!1,catalogId:e.store.catalogId.value??void 0}]}),e.actions.updateFormValue({key:"effectiveDate",value:Ym(new Date,"yyyy-MM-dd").toString()}),e.actions.clearKeys(["treatment","dispenseAsWritten","dispenseQuantity","dispenseUnit","daysSupply","refillsInput","instructions","notes"]),r(void 0),zee(e.actions))}),se._$owner=F(),H(B=>{const ye=e.store.treatment?.value??void 0,te=e.store.treatment?.error??!1,pe=e.store.treatment?.error,Ae=n(),fe=e.store.effectiveDate?.error??!1,ae=e.store.effectiveDate?.error,ue=e.store.dispenseQuantity?.error??!1,Ee=e.store.dispenseQuantity?.error,gt=e.store.dispenseUnit?.value??i()?.name,Ft=e.store.daysSupply?.error??!1,Ot=e.store.daysSupply?.error,sn=e.store.refillsInput?.error??!1,Rr=e.store.refillsInput?.error,La=e.store.instructions?.error??!1,Ra=e.store.instructions?.error;return ye!==B._v$&&(d.selected=B._v$=ye),te!==B._v$2&&(d.invalid=B._v$2=te),pe!==B._v$3&&(d.helpText=B._v$3=pe),Ae!==B._v$4&&(d.offCatalogOption=B._v$4=Ae),fe!==B._v$5&&(b.invalid=B._v$5=fe),ae!==B._v$6&&(b.helpText=B._v$6=ae),ue!==B._v$7&&(E.invalid=B._v$7=ue),Ee!==B._v$8&&(E.helpText=B._v$8=Ee),gt!==B._v$9&&(U.selected=B._v$9=gt),Ft!==B._v$10&&(D.invalid=B._v$10=Ft),Ot!==B._v$11&&(D.helpText=B._v$11=Ot),sn!==B._v$12&&(A.invalid=B._v$12=sn),Rr!==B._v$13&&(A.helpText=B._v$13=Rr),La!==B._v$14&&(W.invalid=B._v$14=La),Ra!==B._v$15&&(W.helpText=B._v$15=Ra),B},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0,_v$5:void 0,_v$6:void 0,_v$7:void 0,_v$8:void 0,_v$9:void 0,_v$10:void 0,_v$11:void 0,_v$12:void 0,_v$13:void 0,_v$14:void 0,_v$15:void 0}),H(()=>p.checked=e.store.dispenseAsWritten?.value||!1),H(()=>E.value=e.store.dispenseQuantity?.value??null),H(()=>D.value=e.store.daysSupply?.value??null),H(()=>A.value=e.store.refillsInput?.value??0),H(()=>W.value=e.store.instructions?.value),H(()=>G.value=e.store.notes?.value),c})()};Ks(["click"]);const Wee=N("<photon-patient-select></photon-patient-select>"),qee=N('<p class="font-sans text-gray-700">, </p>'),Gee=N("<photon-patient-dialog></photon-patient-dialog>"),Yee=N('<p class="font-sans text-sm font-medium">Patient Address</p>'),Qee=N('<div class="flex flex-col font-sans text-gray-700"><p></p><div class="flex flex-row gap-1"><div class="flex flex-row"><p>,</p><p></p></div><p></p></div></div>'),Kee=N('<p class="italic font-sans text-gray-500">Please edit patient and add address</p>'),Xee=N('<p class="font-sans text-red-500 text-sm"></p>'),Jee=N('<photon-button class="self-end" variant="outline">Edit Patient</photon-button>'),Zee=N('<photon-card><div class="flex flex-col gap-3"><p class="font-sans text-l font-medium"></p></div></photon-card>'),ete=N("<sl-spinner></sl-spinner>"),tte=N("<p></p>"),nte=xt(qm(Pn(),hl()),"Please select a patient..."),rte=xt(qm(Pn(),hl()),"Please enter an address for patient..."),ite=e=>{const[t,n]=M(!1),{actions:r,store:i}=_f;e.actions.registerValidator({key:"patient",validator:nte}),e.enableOrder&&e.actions.registerValidator({key:"address",validator:rte});const o=a=>{e.actions.updateFormValue({key:"patient",value:a.detail.patient}),e.enableOrder&&!e.hideAddress&&e.actions.updateFormValue({key:"address",value:a.detail.patient.address})};return Ve(()=>{e?.patientId&&r.getSelectedPatient(e.client.getSDK(),e.patientId)}),me(()=>{i?.selectedPatient?.data&&e?.patientId&&o({detail:{patient:i?.selectedPatient?.data}})}),(()=>{const a=J(()=>document.importNode(Zee,!0)),s=a.firstChild,c=s.firstChild;return a._$owner=F(),S(c,()=>e?.patientId?"Patient":"Select Patient"),S(s,k(X,{get when(){return!e?.patientId},get children(){const l=J(()=>document.importNode(Wee,!0));return l.addEventListener("photon-patient-selected",o),l._$owner=F(),H(u=>{const d=e.store.patient?.error??!1,f=e.store.patient?.error,h=e.store.patient?.value?.id??e.patientId,p=e.client.getSDK();return d!==u._v$&&(l.invalid=u._v$=d),f!==u._v$2&&(l.helpText=u._v$2=f),h!==u._v$3&&(l.selected=u._v$3=h),p!==u._v$4&&(l.sdk=u._v$4=p),u},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),l}}),null),S(s,k(X,{get when(){return e?.patientId},get children(){return k(X,{get when(){return i?.selectedPatient?.data?.id},get fallback(){return(()=>{const l=J(()=>document.importNode(ete,!0));return l.style.setProperty("font-size","1rem"),l._$owner=F(),l})()},get children(){const l=qee.cloneNode(!0),u=l.firstChild;return S(l,()=>i?.selectedPatient?.data?.name?.full,u),S(l,()=>R9(i?.selectedPatient?.data?.dateOfBirth||""),null),l}})}}),null),S(s,k(X,{get when(){return e.store.patient?.value?.id&&e.enableOrder&&!e.hideAddress},get children(){return[(()=>{const l=J(()=>document.importNode(Gee,!0));return l.addEventListener("photon-patient-updated",()=>{r.getSelectedPatient(e.client.getSDK(),e.store.patient?.value?.id)}),l._$owner=F(),H(u=>{const d=t(),f=e.store.patient.value.id;return d!==u._v$5&&(l.open=u._v$5=d),f!==u._v$6&&(l.patientId=u._v$6=f),u},{_v$5:void 0,_v$6:void 0}),l})(),k(X,{get when(){return e.store.patient?.value},get children(){return[Yee.cloneNode(!0),k(X,{get when(){return e.store.patient.value.address},get children(){const l=Qee.cloneNode(!0),u=l.firstChild,d=u.nextSibling,f=d.firstChild,h=f.firstChild,p=h.firstChild,v=h.nextSibling,g=f.nextSibling;return S(u,()=>e.store.patient.value.address.street1),S(l,(()=>{const y=Q(()=>!!e.store.patient.value.address.street2);return()=>y()?(()=>{const m=tte.cloneNode(!0);return S(m,()=>e.store.patient.value.address.street2),m})():null})(),d),S(h,()=>e.store.patient.value.address.city,p),S(v,()=>e.store.patient.value.address.state),S(g,()=>e.store.patient.value.address.postalCode),l}}),k(X,{get when(){return!e.store.patient.value.address},get children(){return[(()=>{const l=Kee.cloneNode(!0);return H(u=>{const d=!!e.store.address.error,f=!!e.store.address.error,h=!!e.store.address.error,p=!!e.store.address.error;return d!==u._v$7&&l.classList.toggle("p-2",u._v$7=d),f!==u._v$8&&l.classList.toggle("border-red-500",u._v$8=f),h!==u._v$9&&l.classList.toggle("border-2",u._v$9=h),p!==u._v$10&&l.classList.toggle("rounded",u._v$10=p),u},{_v$7:void 0,_v$8:void 0,_v$9:void 0,_v$10:void 0}),l})(),k(X,{get when(){return e.store.address.error},get children(){const l=Xee.cloneNode(!0);return S(l,()=>e.store.address.error),l}})]}})]}}),(()=>{const l=J(()=>document.importNode(Jee,!0));return l.addEventListener("photon-clicked",()=>{n(!1),n(!0)}),l._$owner=F(),l})()]}}),null),a})()},ote=N('<photon-card><style></style><photon-dialog label="Overwrite in progress prescription?" confirm-text="Yes, Overwrite" cancel-text="No, Cancel"><p class="font-sans text-lg xs:text-base">You are editing a prescription that has not been added. This will be overwritten if you edit another prescription.</p></photon-dialog><photon-dialog label="Delete pending prescription?" confirm-text="Yes, Delete" cancel-text="No, Cancel"><p class="font-sans text-lg xs:text-base">Deleting this prescription will remove it from your pending prescriptions. This action cannot be undone.</p></photon-dialog><div class="flex flex-col gap-3"><p class="font-sans text-l font-medium">Pending Prescriptions</p></div></photon-card>'),ate=xt(ai(YY(hl()),1,1/0),"You must add at least 1 Prescription"),ste=e=>{const[t,n]=M(!1),[r,i]=M(!1),[o,a]=M(void 0),[s,c]=M();e.actions.registerValidator({key:"draftPrescriptions",validator:ate});const l=()=>{o().treatment&&(N$(e.actions,o()),e.actions.updateFormValue({key:"catalogId",value:o().catalogId}),e.actions.updateFormValue({key:"draftPrescriptions",value:e.store.draftPrescriptions.value.filter(v=>v.id!==o().id)}),window.scrollTo({behavior:"smooth",top:(e.prescriptionRef?.getBoundingClientRect().top||0)-document.body.getBoundingClientRect().top-70}))},u=v=>{const g=e.store.draftPrescriptions.value.find(y=>y.id===v);a(g),e.store.treatment.value?i(!0):(e.setIsEditing(!0),l())},d=()=>{l(),i(!1),a(void 0)},f=()=>{i(!1),a(void 0)},h=()=>{e.actions.updateFormValue({key:"draftPrescriptions",value:e.store.draftPrescriptions.value.filter(v=>v.id!==s())}),n(!1),c(void 0),e.store.draftPrescriptions?.value?.length===0&&e.setIsEditing(!0)},p=()=>{n(!1),c(void 0)};return(()=>{const v=J(()=>document.importNode(ote,!0)),g=v.firstChild,y=g.nextSibling,m=y.nextSibling,b=m.nextSibling;return b.firstChild,v._$owner=F(),S(g,Zm),y.addEventListener("photon-dialog-confirmed",d),y.addEventListener("photon-dialog-canceled",f),y.addEventListener("photon-dialog-alt",f),y._$owner=F(),m.addEventListener("photon-dialog-confirmed",h),m.addEventListener("photon-dialog-canceled",p),m.addEventListener("photon-dialog-alt",p),m._$owner=F(),S(b,k(Rq,{get draftPrescriptions(){return e.store.draftPrescriptions?.value??[]},handleDelete:$=>{n(!0),c($)},handleEdit:$=>{u($)},get templateIds(){return e.templateIds},get prescriptionIds(){return e.prescriptionIds},setDraftPrescriptions:$=>{e.actions.updateFormValue({key:"draftPrescriptions",value:$})},get error(){return e.store.draftPrescriptions?.error}}),null),H($=>{const _=r(),E=t();return _!==$._v$&&(y.open=$._v$=_),E!==$._v$2&&(m.open=$._v$2=E),$},{_v$:void 0,_v$2:void 0}),v})()},lte=N('<photon-card><style></style><div class="flex flex-row"><p class="font-sans text-l font-medium flex-grow">Select Pharmacy</p></div></photon-card>'),cte=e=>{const t=Q(()=>e.store.patient?.value?[e.store.patient?.value?.id]:[]),n=Q(()=>{const r=e.store.patient?.value?.address;return r?`${r.street1} ${r.street2||""} ${r.city}, ${r.state} ${r.postalCode}`:""});return(()=>{const r=J(()=>document.importNode(lte,!0)),i=r.firstChild;return i.nextSibling,r._$owner=F(),S(i,Zm),S(r,k(mW,{get enableSendToPatient(){return e.enableSendToPatient},get enableLocalPickup(){return e.enableLocalPickup||!e?.enableSendToPatient&&!e?.mailOrderIds},get mailOrderPharmacyIds(){return Q(()=>!!e.mailOrderIds)()?e.mailOrderIds.split(","):void 0},get patientIds(){return t()},get address(){return n()},setFufillmentType:o=>{e.actions.updateFormValue({key:"fulfillmentType",value:o||""})},setPreferredPharmacy:(o=!1)=>{e.actions.updateFormValue({key:"updatePreferredPharmacy",value:o})},setPharmacyId:o=>{e.actions.updateFormValue({key:"pharmacy",value:o})}}),null),r})()},ute=N("<span>, </span>"),dte=N('<div class="flex flex-col items-start"></div>'),fte=N('<photon-card><div class="flex flex-col gap-3"><div class="flex flex-row"><p class="font-sans text-l font-medium flex-grow">Selected Pharmacy</p></div></div></photon-card>'),hte=e=>{const t=Et(),[n,r]=M(null);return me(async()=>{if(e.pharmacyId&&t){const{data:i}=await t.getSDK().clinical.pharmacy.getPharmacy({id:e.pharmacyId});r(i.pharmacy)}}),(()=>{const i=J(()=>document.importNode(fte,!0)),o=i.firstChild;return o.firstChild,i._$owner=F(),S(o,k(X,{get when(){return n()},get children(){return k(Fi,{label:"Pharmacies",get initSelected(){return e?.pharmacyId||""},get children(){return k(Fi.Option,{get value(){return e?.pharmacyId||""},get children(){const a=dte.cloneNode(!0);return S(a,k(gn,{get loading(){return!n()},sampleLoadingText:"Loading Name",get children(){return n()?.name}}),null),S(a,k(gn,{get loading(){return!n()},color:"gray",size:"sm",sampleLoadingText:"Cityville, ST",get children(){const s=ute.cloneNode(!0),c=s.firstChild;return S(s,()=>n()?.address?.city,c),S(s,()=>n()?.address?.state,null),s}}),null),a}})}})}}),null),i})()},pte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>You are not signed in</strong><br></sl-alert>'),mte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>Something went wrong, please contact support at Photon Health <a href="mailto:support@photon.health">support@photon.health</a></strong><br></sl-alert>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");function i4(e,t){for(let n=0;n<e.length;n++)if(t.indexOf(e[n])===-1)return!1;return!0}const A$=e=>{const t=ct({permissions:[]},e),n=Et(),[r,i]=M(n?.authentication.state.isLoading||!1),[o,a]=M(n?.authentication.state.isAuthenticated||!1),[s,c]=M(n?.authentication.state.isInOrg||!1),[l,u]=M(i4(t.permissions,n?.authentication.state.permissions||[]));return me(()=>{i(n?.authentication.state.isLoading||!1)}),me(()=>{a(n?.authentication.state.isAuthenticated||!1)}),me(()=>{c(n?.authentication.state.isInOrg||!1)}),me(()=>{u(i4(t.permissions,n?.authentication.state.permissions||[]))}),k(X,{get when(){return n&&!r()},get children(){return[k(X,{get when(){return!o()},get children(){const d=J(()=>document.importNode(pte,!0)),f=d.firstChild;return d._$owner=F(),f._$owner=F(),d}}),k(X,{get when(){return Q(()=>!!o())()&&(!s()||!l())},get children(){const d=J(()=>document.importNode(mte,!0)),f=d.firstChild,h=f.nextSibling,p=h.firstChild,v=p.nextSibling;return d._$owner=F(),f._$owner=F(),v.style.setProperty("text-decoration","underline"),d}}),k(X,{get when(){return Q(()=>!!s())()&&l()},get children(){return t.children}})]}})},vte=N('<div class="w-full flex justify-center"><sl-spinner></sl-spinner></div>'),gte=N("<div></div>"),yte=N('<div class="m-3"></div>'),bte=N('<photon-button class="min-w-min" variant="outline">Add Prescription</photon-button>'),wte=N('<div class="flex flex-row justify-end gap-2"><photon-button class="min-w-min"></photon-button></div>'),$te=N('<div><style></style><style></style><style></style><style></style><div><div class="flex flex-col gap-8"></div></div></div>'),_te=N("<div>No errors...</div>"),xte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>Error with <!>: </strong><br><br></sl-alert>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");je("photon-prescribe-workflow",{patientId:void 0,templateIds:void 0,prescriptionIds:void 0,hideSubmit:!1,hideTemplates:!0,enableOrder:!1,enableLocalPickup:!1,enableSendToPatient:!1,mailOrderIds:void 0,pharmacyId:void 0,loading:!1,address:void 0},(e,t)=>{let n;const{store:r,actions:i}=p$({dispenseAsWritten:!1,patient:void 0,treatment:void 0,draftPrescriptions:[],pharmacy:void 0,errors:[],address:void 0}),o=Et(),[a,s]=M(!e.templateIds&&!e.prescriptionIds),[c,l]=M([]),[u,d]=M(!0),[f,h]=M(!1),[p,v]=M(o?.authentication.state.isAuthenticated||!1);Ve(()=>{e.address&&i.updateFormValue({key:"address",value:e.address})}),me(()=>{!o?.authentication.state.isAuthenticated&&!o?.authentication.state.isLoading&&!o?.authentication.state.error&&o?.authentication.login({appState:{returnTo:window.location.pathname}})}),me(()=>{d(o?.authentication.state.isLoading||!1)}),me(()=>{v(o?.authentication.state.isAuthenticated||!1)});const g=O=>{const T=new CustomEvent("photon-prescriptions-created",{composed:!0,bubbles:!0,detail:{prescriptions:O}});n?.dispatchEvent(T)},y=O=>{const T=new CustomEvent("photon-order-created",{composed:!0,bubbles:!0,detail:{order:O}});n?.dispatchEvent(T)},m=O=>{const T=new CustomEvent("photon-prescriptions-error",{composed:!0,bubbles:!0,detail:{errors:O}});n?.dispatchEvent(T)},b=O=>{const T=new CustomEvent("photon-order-error",{composed:!0,bubbles:!0,detail:{errors:O}});n?.dispatchEvent(T)},$=O=>{const T=new CustomEvent("photon-form-validate",{composed:!0,bubbles:!0,detail:{canSubmit:O,form:r,actions:i}});n?.dispatchEvent(T)},_=async O=>{l([]);const T=O?["patient","draftPrescriptions","pharmacy","address"]:["patient","draftPrescriptions"];i.validate(T);const V=i.getErrors(T);if(V.length===0){d(!0),i.updateFormValue({key:"errors",value:[]});const q=o.getSDK().clinical.order.createOrder({}),ee=o.getSDK().clinical.patient.removePatientPreferredPharmacy({}),U=o.getSDK().clinical.patient.updatePatient({}),j=o.getSDK().clinical.prescription.createPrescriptions({}),D=[];for(const G of r.draftPrescriptions.value){const Y={daysSupply:G.daysSupply,dispenseAsWritten:G.dispenseAsWritten,dispenseQuantity:G.dispenseQuantity,dispenseUnit:G.dispenseUnit,effectiveDate:G.effectiveDate,instructions:G.instructions,notes:G.notes,patientId:r.patient?.value.id,fillsAllowed:G.refillsInput?G.refillsInput+1:1,treatmentId:G.treatment.id};D.push(Y)}const{data:A,errors:W}=await j({variables:{prescriptions:D},refetchQueries:[],awaitRefetchQueries:!1});if(e.enableOrder||d(!1),W){m(W);return}if(g(A.createPrescriptions),e.enableOrder){const G=r?.address?.value??r?.patient?.value?.address??{},{__typename:Y,name:K,...se}=G,re={street2:"",country:"US",...se};if(r.updatePreferredPharmacy?.value&&r.pharmacy?.value&&r.fulfillmentType?.value==="PICK_UP"){const ye=r.patient?.value;ye?.preferredPharmacies&&ye?.preferredPharmacies?.length>0&&ee({variables:{patientId:ye.id,pharmacyId:ye?.preferredPharmacies?.[0]?.id},awaitRefetchQueries:!1}),U({variables:{id:ye.id,preferredPharmacies:[r.pharmacy?.value]},awaitRefetchQueries:!1})}const{data:I,errors:B}=await q({variables:{patientId:r.patient?.value.id,pharmacyId:e?.pharmacyId||r.pharmacy?.value||"",fulfillmentType:r.fulfillmentType?.value||"",address:re,fills:A?.createPrescriptions.map(ye=>({prescriptionId:ye.id}))},refetchQueries:[],awaitRefetchQueries:!1});if(e.enableOrder&&d(!1),B){b(B);return}y(I.createOrder)}}else l(V)};t.element.submitForm=_,me(()=>{$(Boolean(r.draftPrescriptions?.value?.length>0&&r.patient?.value))});let E;return(()=>{const O=$te.cloneNode(!0),T=O.firstChild,V=T.nextSibling,q=V.nextSibling,ee=q.nextSibling,U=ee.nextSibling,j=U.firstChild,D=n;return typeof D=="function"?ge(D,O):n=O,S(T,dt),S(V,$n),S(q,wn),S(ee,VY),S(j,k(X,{get when(){return Q(()=>!!(!o||u()))()&&!p()},get children(){const A=J(()=>document.importNode(vte,!0)),W=A.firstChild;return W.style.setProperty("font-size","3rem"),W._$owner=F(),A}}),null),S(j,k(A$,{permissions:["write:prescription"],get children(){return[k(ite,{actions:i,store:r,get patientId(){return e.patientId},client:o,get enableOrder(){return e.enableOrder},get hideAddress(){return!!e.address}}),k(X,{get when(){return a()||f()},get children(){const A=gte.cloneNode(!0),W=E;return typeof W=="function"?ge(W,A):E=A,S(A,k(Hee,{get hideAddToTemplates(){return e.hideTemplates},actions:i,store:r})),A}}),k(ste,{get templateIds(){return e.templateIds?.split(",")||[]},get prescriptionIds(){return e.prescriptionIds?.split(",")||[]},prescriptionRef:E,actions:i,store:r,setIsEditing:h}),k(X,{get when(){return e.enableOrder&&!e.pharmacyId},get children(){return k(cte,{store:r,actions:i,get enableLocalPickup(){return e.enableLocalPickup},get enableSendToPatient(){return e.enableSendToPatient},get mailOrderIds(){return e.mailOrderIds}})}}),k(X,{get when(){return e.enableOrder&&e.pharmacyId},get children(){return k(hte,{get pharmacyId(){return e.pharmacyId}})}}),k(X,{get when(){return!e.hideSubmit},get children(){return[k(X,{get when(){return c().length>0&&e.enableOrder},get children(){const A=yte.cloneNode(!0);return S(A,k(mn,{get each(){return c()},get fallback(){return _te.cloneNode(!0)},children:({key:W,error:G})=>(()=>{const Y=J(()=>document.importNode(xte,!0)),K=Y.firstChild,se=K.nextSibling,re=se.firstChild,I=re.nextSibling;I.nextSibling;const B=se.nextSibling,ye=B.nextSibling;return Y._$owner=F(),K._$owner=F(),S(se,W,I),S(Y,G,ye),S(Y,()=>JSON.stringify(r?.[W]?.value||{}),null),Y})()})),A}}),(()=>{const A=J(()=>document.importNode(wte,!0)),W=A.firstChild;return S(A,k(X,{get when(){return!a()},get children(){const G=J(()=>document.importNode(bte,!0));return G.addEventListener("photon-clicked",async()=>s(!0)),G._$owner=F(),G}}),W),W.addEventListener("photon-clicked",async()=>await _(e.enableOrder)),W._$owner=F(),S(W,()=>e.enableOrder?"Send Order":"Save Prescriptions"),H(()=>W.loading=u()),A})()]}})]}}),null),O})()});const kte=N('<p class="font-sans text-l font-medium mb-2"></p>'),Ste=N('<sl-icon-button class="self-start"></sl-icon-button>'),Ete=N("<style></style>"),Ote=N('<div class="rounded-lg bg-white p-4 shadow-card border border-gray-200"></div>'),Cte=N('<div class="flex flex-row justify-between"></div>'),Tte=N("<slot></slot>");je("photon-card",{invalid:!1,title:null,collapsable:!1},e=>{const[t,n]=M(!0);let r=null,i=null;return e.title&&(r=(()=>{const o=kte.cloneNode(!0);return S(o,()=>e.title),o})()),e.collapsable&&(i=(()=>{const o=J(()=>document.importNode(Ste,!0));return o.addEventListener("click",()=>{n(!t())}),o._$owner=F(),H(()=>o.name=t()?"chevron-right":"chevron-down"),o})()),[(()=>{const o=Ete.cloneNode(!0);return S(o,dt),o})(),(()=>{const o=Ote.cloneNode(!0);return S(o,r||i?(()=>{const a=Cte.cloneNode(!0);return S(a,r,null),S(a,i,null),a})():null,null),S(o,(()=>{const a=Q(()=>!!(e.collapsable&&t()));return()=>a()?null:(()=>{const s=Tte.cloneNode(!0);return s._$owner=F(),s})()})(),null),H(a=>{const s=!!e.invalid,c=!!e.invalid;return s!==a._v$&&o.classList.toggle("border-red-500",a._v$=s),c!==a._v$2&&o.classList.toggle("border-2",a._v$2=c),a},{_v$:void 0,_v$2:void 0}),o})()]});const Pte=nf`
|
|
3243
|
+
`}};Fe.styles=jee;x([vt(".button")],Fe.prototype,"button",2);x([gr()],Fe.prototype,"hasFocus",2);x([gr()],Fe.prototype,"invalid",2);x([C()],Fe.prototype,"title",2);x([C({reflect:!0})],Fe.prototype,"variant",2);x([C({reflect:!0})],Fe.prototype,"size",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"caret",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"disabled",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"loading",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"outline",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"pill",2);x([C({type:Boolean,reflect:!0})],Fe.prototype,"circle",2);x([C()],Fe.prototype,"type",2);x([C()],Fe.prototype,"name",2);x([C()],Fe.prototype,"value",2);x([C()],Fe.prototype,"href",2);x([C()],Fe.prototype,"target",2);x([C()],Fe.prototype,"rel",2);x([C()],Fe.prototype,"download",2);x([C()],Fe.prototype,"form",2);x([C({attribute:"formaction"})],Fe.prototype,"formAction",2);x([C({attribute:"formenctype"})],Fe.prototype,"formEnctype",2);x([C({attribute:"formmethod"})],Fe.prototype,"formMethod",2);x([C({attribute:"formnovalidate",type:Boolean})],Fe.prototype,"formNoValidate",2);x([C({attribute:"formtarget"})],Fe.prototype,"formTarget",2);x([Ke("disabled",{waitUntilFirstUpdate:!0})],Fe.prototype,"handleDisabledChange",1);Fe=x([Yt("sl-button")],Fe);const N$=(e,t)=>{e.updateFormValue({key:"treatment",value:t.treatment}),t.dispenseAsWritten&&e.updateFormValue({key:"dispenseAsWritten",value:t.dispenseAsWritten}),t.dispenseQuantity&&e.updateFormValue({key:"dispenseQuantity",value:Number(t.dispenseQuantity)}),t.dispenseUnit&&e.updateFormValue({key:"dispenseUnit",value:t.dispenseUnit}),t.daysSupply&&e.updateFormValue({key:"daysSupply",value:Number(t.daysSupply)}),t.fillsAllowed&&e.updateFormValue({key:"refillsInput",value:Number(t.fillsAllowed)-1}),t.instructions&&e.updateFormValue({key:"instructions",value:t.instructions}),t.notes&&e.updateFormValue({key:"notes",value:t.notes})},zee=e=>{e.updateFormValue({key:"treatment",value:void 0}),e.updateFormValue({key:"dispenseAsWritten",value:!1}),e.updateFormValue({key:"dispenseQuantity",value:null}),e.updateFormValue({key:"dispenseUnit",value:"Each"}),e.updateFormValue({key:"daysSupply",value:null}),e.updateFormValue({key:"refillsInput",value:0}),e.updateFormValue({key:"instructions",value:""}),e.updateFormValue({key:"notes",value:""})},Vee=N('<photon-checkbox label="Add To Templates" form-name="daw"></photon-checkbox>'),Uee=N('<photon-card title="Add Prescription"><style></style><div class="flex flex-col sm:gap-3"><photon-treatment-select label="Search Treatment Catalog"></photon-treatment-select><div class="flex flex-col sm:flex-none sm:grid sm:grid-cols-2 sm:gap-4"><div class="order-last sm:order-first"><photon-checkbox label="Dispense as written" tip="This prescription will be filled generically unless this box is checked" form-name="daw" class="flex-grow"></photon-checkbox><photon-med-search-dialog></photon-med-search-dialog></div><div class="pb-4 md:py-2 text-left sm:text-right"><a class="font-sans text-gray-500 text-sm hover:text-black hover:cursor-pointer">Advanced Search \u2192</a></div></div><div class="mt-2 sm:mt-0 md:max-w-[50%] md:pr-2"><photon-datepicker label="Effective Date" required="true"></photon-datepicker></div><div class="mt-2 sm:mt-0 sm:grid sm:grid-cols-2 sm:gap-4"><div class="flex items-end gap-1"><photon-number-input class="flex-grow flex-1 w-2/5 sm:w-auto" label="Quantity" required="true" min="1"></photon-number-input><div><photon-button variant="outline" class="w-fit"><button><sl-icon name="calculator"></sl-icon></button></photon-button><div class="pt-1"></div></div></div><photon-dispense-units label="Dispense Unit" required="true" force-label-size="true"></photon-dispense-units></div><div class="sm:grid sm:grid-cols-2 sm:gap-4"><photon-number-input class="flex-grow flex-shrink flex-1" label="Days Supply" required="true" min="0"></photon-number-input><photon-number-input class="flex-grow flex-shrink flex-1" label="Refills" required="true" min="0"></photon-number-input></div><photon-textarea label="Patient Instructions (SIG)" form-name="patient_instructions" required="true" placeholder="Enter patient instructions"></photon-textarea><photon-textarea label="Pharmacy Note" placeholder="Enter pharmacy note"></photon-textarea><div class="flex flex-col xs:flex-row gap-2"><div class="flex flex-grow justify-end"><photon-button class="w-full xs:w-fit">Add Prescription</photon-button></div></div></div></photon-card>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");const Bee={treatment:xt(qm(Pn(),hl()),"Please select a treatment..."),dispenseQuantity:xt(q0(H0(),1),"Quantity must be positive"),daysSupply:xt(q0(H0(),0),"Days Supply must be at least 0"),refillsInput:xt(q0(H0(),0),"Refills must be at least 0"),instructions:xt(ai(Pn(),1,1/0),"Please enter instructions for the patient..."),effectiveDate:xt(Lee(new Date),"Please choose a date that isn't in the past")},Hee=e=>{let t;const[n,r]=M(void 0),[i]=M(void 0),[o,a]=M(!1);let s;for(const[c,l]of Object.entries(Bee))e.actions.registerValidator({key:c,validator:l});return(()=>{const c=J(()=>document.importNode(Uee,!0)),l=c.firstChild,u=l.nextSibling,d=u.firstChild,f=d.nextSibling,h=f.firstChild,p=h.firstChild,v=p.nextSibling,g=h.nextSibling,y=g.firstChild,m=f.nextSibling,b=m.firstChild,$=m.nextSibling,_=$.firstChild,E=_.firstChild,O=E.nextSibling,T=O.firstChild,V=T.firstChild,q=V.firstChild,ee=T.nextSibling,U=_.nextSibling,j=$.nextSibling,D=j.firstChild,A=D.nextSibling,W=j.nextSibling,G=W.nextSibling,Y=G.nextSibling,K=Y.firstChild,se=K.firstChild,re=s;typeof re=="function"?ge(re,c):s=c,c._$owner=F(),S(l,Zm),u.addEventListener("photon-medication-selected",B=>{r(B.detail.medication),e.actions.updateFormValue({key:"treatment",value:B.detail.medication})}),d.addEventListener("photon-treatment-selected",B=>{B.detail.data.__typename==="PrescriptionTemplate"?N$(e.actions,B.detail.data):e.actions.updateFormValue({key:"treatment",value:B.detail.data}),e.actions.updateFormValue({key:"catalogId",value:B.detail.catalogId})}),d._$owner=F(),p.addEventListener("photon-checkbox-toggled",B=>e.actions.updateFormValue({key:"dispenseAsWritten",value:B.detail.checked})),p._$owner=F();const I=t;return typeof I=="function"?ge(I,v):t=v,v._$owner=F(),y.$$click=()=>t.open=!0,b.addEventListener("photon-datepicker-selected",B=>e.actions.updateFormValue({key:"effectiveDate",value:B.detail.date})),b._$owner=F(),E.addEventListener("photon-input-changed",B=>{const ye=Number(B.detail.input);!isNaN(ye)&&B.detail.input!==""&&e.actions.updateFormValue({key:"dispenseQuantity",value:ye})}),E.style.setProperty("width","100px"),E._$owner=F(),S(_,k(tV,{get open(){return o()},onClose:()=>a(!1),get medicationName(){return e.store.treatment?.value?.name},setAutocompleteValues:({liquidDose:B,totalLiquid:ye,unit:te,days:pe})=>{e.actions.updateFormValue({key:"daysSupply",value:Number(pe)}),e.actions.updateFormValue({key:"dispenseQuantity",value:Number(ye)}),e.actions.updateFormValue({key:"instructions",value:`${B} ${te} ${e.store.instructions?.value}`}),te==="mL"&&e.actions.updateFormValue({key:"dispenseUnit",value:"Milliliter"})}}),O),T.addEventListener("photon-clicked",()=>a(!0)),T._$owner=F(),V.$$click=()=>a(!0),q._$owner=F(),ee.style.setProperty("height","23px"),U.addEventListener("photon-dispense-unit-selected",B=>e.actions.updateFormValue({key:"dispenseUnit",value:B.detail.dispenseUnit.name})),U._$owner=F(),D.addEventListener("photon-input-changed",B=>{e.actions.updateFormValue({key:"daysSupply",value:Number(B.detail.input)})}),D._$owner=F(),A.addEventListener("photon-input-changed",B=>e.actions.updateFormValue({key:"refillsInput",value:Number(B.detail.input)})),A._$owner=F(),W.addEventListener("photon-textarea-changed",B=>e.actions.updateFormValue({key:"instructions",value:B.detail.value})),W._$owner=F(),G.addEventListener("photon-textarea-changed",B=>e.actions.updateFormValue({key:"notes",value:B.detail.value})),G._$owner=F(),S(Y,k(X,{get when(){return!e.hideAddToTemplates},get children(){const B=J(()=>document.importNode(Vee,!0));return B.addEventListener("photon-checkbox-toggled",ye=>e.actions.updateFormValue({key:"addToTemplates",value:ye.detail.checked})),B._$owner=F(),H(()=>B.checked=e.store.addToTemplates?.value||!1),B}}),K),se.addEventListener("photon-clicked",()=>{const B=["treatment","effectiveDate","dispenseQuantity","daysSupply","refillsInput","instructions"];e.actions.validate(B),e.actions.hasErrors(B)||(e.actions.updateFormValue({key:"draftPrescriptions",value:[...e.store.draftPrescriptions?.value||[],{id:String(Math.random()),effectiveDate:e.store.effectiveDate.value,treatment:e.store.treatment.value,dispenseAsWritten:e.store.dispenseAsWritten.value,dispenseQuantity:e.store.dispenseQuantity.value,dispenseUnit:e.store.dispenseUnit.value,daysSupply:e.store.daysSupply.value,refillsInput:e.store.refillsInput.value,instructions:e.store.instructions.value,notes:e.store.notes.value,fillsAllowed:e.store.refillsInput.value+1,addToTemplates:e.store.addToTemplates?.value??!1,catalogId:e.store.catalogId.value??void 0}]}),e.actions.updateFormValue({key:"effectiveDate",value:Ym(new Date,"yyyy-MM-dd").toString()}),e.actions.clearKeys(["treatment","dispenseAsWritten","dispenseQuantity","dispenseUnit","daysSupply","refillsInput","instructions","notes"]),r(void 0),zee(e.actions))}),se._$owner=F(),H(B=>{const ye=e.store.treatment?.value??void 0,te=e.store.treatment?.error??!1,pe=e.store.treatment?.error,Ae=n(),fe=e.store.effectiveDate?.error??!1,ae=e.store.effectiveDate?.error,ue=e.store.dispenseQuantity?.error??!1,Ee=e.store.dispenseQuantity?.error,gt=e.store.dispenseUnit?.value??i()?.name,Ft=e.store.daysSupply?.error??!1,Ot=e.store.daysSupply?.error,sn=e.store.refillsInput?.error??!1,Rr=e.store.refillsInput?.error,La=e.store.instructions?.error??!1,Ra=e.store.instructions?.error;return ye!==B._v$&&(d.selected=B._v$=ye),te!==B._v$2&&(d.invalid=B._v$2=te),pe!==B._v$3&&(d.helpText=B._v$3=pe),Ae!==B._v$4&&(d.offCatalogOption=B._v$4=Ae),fe!==B._v$5&&(b.invalid=B._v$5=fe),ae!==B._v$6&&(b.helpText=B._v$6=ae),ue!==B._v$7&&(E.invalid=B._v$7=ue),Ee!==B._v$8&&(E.helpText=B._v$8=Ee),gt!==B._v$9&&(U.selected=B._v$9=gt),Ft!==B._v$10&&(D.invalid=B._v$10=Ft),Ot!==B._v$11&&(D.helpText=B._v$11=Ot),sn!==B._v$12&&(A.invalid=B._v$12=sn),Rr!==B._v$13&&(A.helpText=B._v$13=Rr),La!==B._v$14&&(W.invalid=B._v$14=La),Ra!==B._v$15&&(W.helpText=B._v$15=Ra),B},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0,_v$5:void 0,_v$6:void 0,_v$7:void 0,_v$8:void 0,_v$9:void 0,_v$10:void 0,_v$11:void 0,_v$12:void 0,_v$13:void 0,_v$14:void 0,_v$15:void 0}),H(()=>p.checked=e.store.dispenseAsWritten?.value||!1),H(()=>E.value=e.store.dispenseQuantity?.value??null),H(()=>D.value=e.store.daysSupply?.value??null),H(()=>A.value=e.store.refillsInput?.value??0),H(()=>W.value=e.store.instructions?.value),H(()=>G.value=e.store.notes?.value),c})()};Ks(["click"]);const Wee=N("<photon-patient-select></photon-patient-select>"),qee=N('<p class="font-sans text-gray-700">, </p>'),Gee=N("<photon-patient-dialog></photon-patient-dialog>"),Yee=N('<p class="font-sans text-sm font-medium">Patient Address</p>'),Qee=N('<div class="flex flex-col font-sans text-gray-700"><p></p><div class="flex flex-row gap-1"><div class="flex flex-row"><p>,</p><p></p></div><p></p></div></div>'),Kee=N('<p class="italic font-sans text-gray-500">Please edit patient and add address</p>'),Xee=N('<p class="font-sans text-red-500 text-sm"></p>'),Jee=N('<photon-button class="self-end" variant="outline">Edit Patient</photon-button>'),Zee=N('<photon-card><div class="flex flex-col gap-3"><p class="font-sans text-l font-medium"></p></div></photon-card>'),ete=N("<sl-spinner></sl-spinner>"),tte=N("<p></p>"),nte=xt(qm(Pn(),hl()),"Please select a patient..."),rte=xt(qm(Pn(),hl()),"Please enter an address for patient..."),ite=e=>{const[t,n]=M(!1),{actions:r,store:i}=_f;e.actions.registerValidator({key:"patient",validator:nte}),e.enableOrder&&e.actions.registerValidator({key:"address",validator:rte});const o=a=>{e.actions.updateFormValue({key:"patient",value:a.detail.patient}),e.enableOrder&&!e.hideAddress&&e.actions.updateFormValue({key:"address",value:a.detail.patient.address})};return Ve(()=>{e?.patientId&&r.getSelectedPatient(e.client.getSDK(),e.patientId)}),me(()=>{i?.selectedPatient?.data&&e?.patientId&&o({detail:{patient:i?.selectedPatient?.data}})}),(()=>{const a=J(()=>document.importNode(Zee,!0)),s=a.firstChild,c=s.firstChild;return a._$owner=F(),S(c,()=>e?.patientId?"Patient":"Select Patient"),S(s,k(X,{get when(){return!e?.patientId},get children(){const l=J(()=>document.importNode(Wee,!0));return l.addEventListener("photon-patient-selected",o),l._$owner=F(),H(u=>{const d=e.store.patient?.error??!1,f=e.store.patient?.error,h=e.store.patient?.value?.id??e.patientId,p=e.client.getSDK();return d!==u._v$&&(l.invalid=u._v$=d),f!==u._v$2&&(l.helpText=u._v$2=f),h!==u._v$3&&(l.selected=u._v$3=h),p!==u._v$4&&(l.sdk=u._v$4=p),u},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),l}}),null),S(s,k(X,{get when(){return e?.patientId},get children(){return k(X,{get when(){return i?.selectedPatient?.data?.id},get fallback(){return(()=>{const l=J(()=>document.importNode(ete,!0));return l.style.setProperty("font-size","1rem"),l._$owner=F(),l})()},get children(){const l=qee.cloneNode(!0),u=l.firstChild;return S(l,()=>i?.selectedPatient?.data?.name?.full,u),S(l,()=>R9(i?.selectedPatient?.data?.dateOfBirth||""),null),l}})}}),null),S(s,k(X,{get when(){return e.store.patient?.value?.id&&e.enableOrder&&!e.hideAddress},get children(){return[(()=>{const l=J(()=>document.importNode(Gee,!0));return l.addEventListener("photon-patient-updated",()=>{r.getSelectedPatient(e.client.getSDK(),e.store.patient?.value?.id)}),l._$owner=F(),H(u=>{const d=t(),f=e.store.patient.value.id;return d!==u._v$5&&(l.open=u._v$5=d),f!==u._v$6&&(l.patientId=u._v$6=f),u},{_v$5:void 0,_v$6:void 0}),l})(),k(X,{get when(){return e.store.patient?.value},get children(){return[Yee.cloneNode(!0),k(X,{get when(){return e.store.patient.value.address},get children(){const l=Qee.cloneNode(!0),u=l.firstChild,d=u.nextSibling,f=d.firstChild,h=f.firstChild,p=h.firstChild,v=h.nextSibling,g=f.nextSibling;return S(u,()=>e.store.patient.value.address.street1),S(l,(()=>{const y=Q(()=>!!e.store.patient.value.address.street2);return()=>y()?(()=>{const m=tte.cloneNode(!0);return S(m,()=>e.store.patient.value.address.street2),m})():null})(),d),S(h,()=>e.store.patient.value.address.city,p),S(v,()=>e.store.patient.value.address.state),S(g,()=>e.store.patient.value.address.postalCode),l}}),k(X,{get when(){return!e.store.patient.value.address},get children(){return[(()=>{const l=Kee.cloneNode(!0);return H(u=>{const d=!!e.store.address.error,f=!!e.store.address.error,h=!!e.store.address.error,p=!!e.store.address.error;return d!==u._v$7&&l.classList.toggle("p-2",u._v$7=d),f!==u._v$8&&l.classList.toggle("border-red-500",u._v$8=f),h!==u._v$9&&l.classList.toggle("border-2",u._v$9=h),p!==u._v$10&&l.classList.toggle("rounded",u._v$10=p),u},{_v$7:void 0,_v$8:void 0,_v$9:void 0,_v$10:void 0}),l})(),k(X,{get when(){return e.store.address.error},get children(){const l=Xee.cloneNode(!0);return S(l,()=>e.store.address.error),l}})]}})]}}),(()=>{const l=J(()=>document.importNode(Jee,!0));return l.addEventListener("photon-clicked",()=>{n(!1),n(!0)}),l._$owner=F(),l})()]}}),null),a})()},ote=N('<photon-card><style></style><photon-dialog label="Overwrite in progress prescription?" confirm-text="Yes, Overwrite" cancel-text="No, Cancel"><p class="font-sans text-lg xs:text-base">You are editing a prescription that has not been added. This will be overwritten if you edit another prescription.</p></photon-dialog><photon-dialog label="Delete pending prescription?" confirm-text="Yes, Delete" cancel-text="No, Cancel"><p class="font-sans text-lg xs:text-base">Deleting this prescription will remove it from your pending prescriptions. This action cannot be undone.</p></photon-dialog><div class="flex flex-col gap-3"><p class="font-sans text-l font-medium">Pending Prescriptions</p></div></photon-card>'),ate=xt(ai(YY(hl()),1,1/0),"You must add at least 1 Prescription"),ste=e=>{const[t,n]=M(!1),[r,i]=M(!1),[o,a]=M(void 0),[s,c]=M();e.actions.registerValidator({key:"draftPrescriptions",validator:ate});const l=()=>{o().treatment&&(N$(e.actions,o()),e.actions.updateFormValue({key:"catalogId",value:o().catalogId}),e.actions.updateFormValue({key:"draftPrescriptions",value:e.store.draftPrescriptions.value.filter(v=>v.id!==o().id)}),window.scrollTo({behavior:"smooth",top:(e.prescriptionRef?.getBoundingClientRect().top||0)-document.body.getBoundingClientRect().top-70}))},u=v=>{const g=e.store.draftPrescriptions.value.find(y=>y.id===v);a(g),e.store.treatment.value?i(!0):(e.setIsEditing(!0),l())},d=()=>{l(),i(!1),a(void 0)},f=()=>{i(!1),a(void 0)},h=()=>{e.actions.updateFormValue({key:"draftPrescriptions",value:e.store.draftPrescriptions.value.filter(v=>v.id!==s())}),n(!1),c(void 0),e.store.draftPrescriptions?.value?.length===0&&e.setIsEditing(!0)},p=()=>{n(!1),c(void 0)};return(()=>{const v=J(()=>document.importNode(ote,!0)),g=v.firstChild,y=g.nextSibling,m=y.nextSibling,b=m.nextSibling;return b.firstChild,v._$owner=F(),S(g,Zm),y.addEventListener("photon-dialog-confirmed",d),y.addEventListener("photon-dialog-canceled",f),y.addEventListener("photon-dialog-alt",f),y._$owner=F(),m.addEventListener("photon-dialog-confirmed",h),m.addEventListener("photon-dialog-canceled",p),m.addEventListener("photon-dialog-alt",p),m._$owner=F(),S(b,k(Rq,{get draftPrescriptions(){return e.store.draftPrescriptions?.value??[]},handleDelete:$=>{n(!0),c($)},handleEdit:$=>{u($)},get templateIds(){return e.templateIds},get templateOverrides(){return e.templateOverrides},get prescriptionIds(){return e.prescriptionIds},setDraftPrescriptions:$=>{e.actions.updateFormValue({key:"draftPrescriptions",value:$})},get error(){return e.store.draftPrescriptions?.error}}),null),H($=>{const _=r(),E=t();return _!==$._v$&&(y.open=$._v$=_),E!==$._v$2&&(m.open=$._v$2=E),$},{_v$:void 0,_v$2:void 0}),v})()},lte=N('<photon-card><style></style><div class="flex flex-row"><p class="font-sans text-l font-medium flex-grow">Select Pharmacy</p></div></photon-card>'),cte=e=>{const t=Q(()=>e.store.patient?.value?[e.store.patient?.value?.id]:[]),n=Q(()=>{const r=e.store.patient?.value?.address;return r?`${r.street1} ${r.street2||""} ${r.city}, ${r.state} ${r.postalCode}`:""});return(()=>{const r=J(()=>document.importNode(lte,!0)),i=r.firstChild;return i.nextSibling,r._$owner=F(),S(i,Zm),S(r,k(mW,{get enableSendToPatient(){return e.enableSendToPatient},get enableLocalPickup(){return e.enableLocalPickup||!e?.enableSendToPatient&&!e?.mailOrderIds},get mailOrderPharmacyIds(){return Q(()=>!!e.mailOrderIds)()?e.mailOrderIds.split(","):void 0},get patientIds(){return t()},get address(){return n()},setFufillmentType:o=>{e.actions.updateFormValue({key:"fulfillmentType",value:o||""})},setPreferredPharmacy:(o=!1)=>{e.actions.updateFormValue({key:"updatePreferredPharmacy",value:o})},setPharmacyId:o=>{e.actions.updateFormValue({key:"pharmacy",value:o})}}),null),r})()},ute=N("<span>, </span>"),dte=N('<div class="flex flex-col items-start"></div>'),fte=N('<photon-card><div class="flex flex-col gap-3"><div class="flex flex-row"><p class="font-sans text-l font-medium flex-grow">Selected Pharmacy</p></div></div></photon-card>'),hte=e=>{const t=Et(),[n,r]=M(null);return me(async()=>{if(e.pharmacyId&&t){const{data:i}=await t.getSDK().clinical.pharmacy.getPharmacy({id:e.pharmacyId});r(i.pharmacy)}}),(()=>{const i=J(()=>document.importNode(fte,!0)),o=i.firstChild;return o.firstChild,i._$owner=F(),S(o,k(X,{get when(){return n()},get children(){return k(Fi,{label:"Pharmacies",get initSelected(){return e?.pharmacyId||""},get children(){return k(Fi.Option,{get value(){return e?.pharmacyId||""},get children(){const a=dte.cloneNode(!0);return S(a,k(gn,{get loading(){return!n()},sampleLoadingText:"Loading Name",get children(){return n()?.name}}),null),S(a,k(gn,{get loading(){return!n()},color:"gray",size:"sm",sampleLoadingText:"Cityville, ST",get children(){const s=ute.cloneNode(!0),c=s.firstChild;return S(s,()=>n()?.address?.city,c),S(s,()=>n()?.address?.state,null),s}}),null),a}})}})}}),null),i})()},pte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>You are not signed in</strong><br></sl-alert>'),mte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>Something went wrong, please contact support at Photon Health <a href="mailto:support@photon.health">support@photon.health</a></strong><br></sl-alert>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");function i4(e,t){for(let n=0;n<e.length;n++)if(t.indexOf(e[n])===-1)return!1;return!0}const A$=e=>{const t=ct({permissions:[]},e),n=Et(),[r,i]=M(n?.authentication.state.isLoading||!1),[o,a]=M(n?.authentication.state.isAuthenticated||!1),[s,c]=M(n?.authentication.state.isInOrg||!1),[l,u]=M(i4(t.permissions,n?.authentication.state.permissions||[]));return me(()=>{i(n?.authentication.state.isLoading||!1)}),me(()=>{a(n?.authentication.state.isAuthenticated||!1)}),me(()=>{c(n?.authentication.state.isInOrg||!1)}),me(()=>{u(i4(t.permissions,n?.authentication.state.permissions||[]))}),k(X,{get when(){return n&&!r()},get children(){return[k(X,{get when(){return!o()},get children(){const d=J(()=>document.importNode(pte,!0)),f=d.firstChild;return d._$owner=F(),f._$owner=F(),d}}),k(X,{get when(){return Q(()=>!!o())()&&(!s()||!l())},get children(){const d=J(()=>document.importNode(mte,!0)),f=d.firstChild,h=f.nextSibling,p=h.firstChild,v=p.nextSibling;return d._$owner=F(),f._$owner=F(),v.style.setProperty("text-decoration","underline"),d}}),k(X,{get when(){return Q(()=>!!s())()&&l()},get children(){return t.children}})]}})},vte=N('<div class="w-full flex justify-center"><sl-spinner></sl-spinner></div>'),gte=N("<div></div>"),yte=N('<div class="m-3"></div>'),bte=N('<photon-button class="min-w-min" variant="outline">Add Prescription</photon-button>'),wte=N('<div class="flex flex-row justify-end gap-2"><photon-button class="min-w-min"></photon-button></div>'),$te=N('<div><style></style><style></style><style></style><style></style><div><div class="flex flex-col gap-8"></div></div></div>'),_te=N("<div>No errors...</div>"),xte=N('<sl-alert variant="warning" open><sl-icon slot="icon" name="exclamation-triangle"></sl-icon><strong>Error with <!>: </strong><br><br></sl-alert>');$t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");je("photon-prescribe-workflow",{patientId:void 0,templateIds:void 0,templateOverrides:void 0,prescriptionIds:void 0,hideSubmit:!1,hideTemplates:!0,enableOrder:!1,enableLocalPickup:!1,enableSendToPatient:!1,mailOrderIds:void 0,pharmacyId:void 0,loading:!1,address:void 0},(e,t)=>{let n;const{store:r,actions:i}=p$({dispenseAsWritten:!1,patient:void 0,treatment:void 0,draftPrescriptions:[],pharmacy:void 0,errors:[],address:void 0}),o=Et(),[a,s]=M(!e.templateIds&&!e.prescriptionIds),[c,l]=M([]),[u,d]=M(!0),[f,h]=M(!1),[p,v]=M(o?.authentication.state.isAuthenticated||!1);Ve(()=>{e.address&&i.updateFormValue({key:"address",value:e.address})}),me(()=>{!o?.authentication.state.isAuthenticated&&!o?.authentication.state.isLoading&&!o?.authentication.state.error&&o?.authentication.login({appState:{returnTo:window.location.pathname}})}),me(()=>{d(o?.authentication.state.isLoading||!1)}),me(()=>{v(o?.authentication.state.isAuthenticated||!1)});const g=O=>{const T=new CustomEvent("photon-prescriptions-created",{composed:!0,bubbles:!0,detail:{prescriptions:O}});n?.dispatchEvent(T)},y=O=>{const T=new CustomEvent("photon-order-created",{composed:!0,bubbles:!0,detail:{order:O}});n?.dispatchEvent(T)},m=O=>{const T=new CustomEvent("photon-prescriptions-error",{composed:!0,bubbles:!0,detail:{errors:O}});n?.dispatchEvent(T)},b=O=>{const T=new CustomEvent("photon-order-error",{composed:!0,bubbles:!0,detail:{errors:O}});n?.dispatchEvent(T)},$=O=>{const T=new CustomEvent("photon-form-validate",{composed:!0,bubbles:!0,detail:{canSubmit:O,form:r,actions:i}});n?.dispatchEvent(T)},_=async O=>{l([]);const T=O?["patient","draftPrescriptions","pharmacy","address"]:["patient","draftPrescriptions"];i.validate(T);const V=i.getErrors(T);if(V.length===0){d(!0),i.updateFormValue({key:"errors",value:[]});const q=o.getSDK().clinical.order.createOrder({}),ee=o.getSDK().clinical.patient.removePatientPreferredPharmacy({}),U=o.getSDK().clinical.patient.updatePatient({}),j=o.getSDK().clinical.prescription.createPrescriptions({}),D=[];for(const G of r.draftPrescriptions.value){const Y={daysSupply:G.daysSupply,dispenseAsWritten:G.dispenseAsWritten,dispenseQuantity:G.dispenseQuantity,dispenseUnit:G.dispenseUnit,effectiveDate:G.effectiveDate,instructions:G.instructions,notes:G.notes,patientId:r.patient?.value.id,fillsAllowed:G.refillsInput?G.refillsInput+1:1,treatmentId:G.treatment.id};D.push(Y)}const{data:A,errors:W}=await j({variables:{prescriptions:D},refetchQueries:[],awaitRefetchQueries:!1});if(e.enableOrder||d(!1),W){m(W);return}if(g(A.createPrescriptions),e.enableOrder){const G=r?.address?.value??r?.patient?.value?.address??{},{__typename:Y,name:K,...se}=G,re={street2:"",country:"US",...se};if(r.updatePreferredPharmacy?.value&&r.pharmacy?.value&&r.fulfillmentType?.value==="PICK_UP"){const ye=r.patient?.value;ye?.preferredPharmacies&&ye?.preferredPharmacies?.length>0&&ee({variables:{patientId:ye.id,pharmacyId:ye?.preferredPharmacies?.[0]?.id},awaitRefetchQueries:!1}),U({variables:{id:ye.id,preferredPharmacies:[r.pharmacy?.value]},awaitRefetchQueries:!1})}const{data:I,errors:B}=await q({variables:{patientId:r.patient?.value.id,pharmacyId:e?.pharmacyId||r.pharmacy?.value||"",fulfillmentType:r.fulfillmentType?.value||"",address:re,fills:A?.createPrescriptions.map(ye=>({prescriptionId:ye.id}))},refetchQueries:[],awaitRefetchQueries:!1});if(e.enableOrder&&d(!1),B){b(B);return}y(I.createOrder)}}else l(V)};t.element.submitForm=_,me(()=>{$(Boolean(r.draftPrescriptions?.value?.length>0&&r.patient?.value))});let E;return(()=>{const O=$te.cloneNode(!0),T=O.firstChild,V=T.nextSibling,q=V.nextSibling,ee=q.nextSibling,U=ee.nextSibling,j=U.firstChild,D=n;return typeof D=="function"?ge(D,O):n=O,S(T,dt),S(V,$n),S(q,wn),S(ee,VY),S(j,k(X,{get when(){return Q(()=>!!(!o||u()))()&&!p()},get children(){const A=J(()=>document.importNode(vte,!0)),W=A.firstChild;return W.style.setProperty("font-size","3rem"),W._$owner=F(),A}}),null),S(j,k(A$,{permissions:["write:prescription"],get children(){return[k(ite,{actions:i,store:r,get patientId(){return e.patientId},client:o,get enableOrder(){return e.enableOrder},get hideAddress(){return!!e.address}}),k(X,{get when(){return a()||f()},get children(){const A=gte.cloneNode(!0),W=E;return typeof W=="function"?ge(W,A):E=A,S(A,k(Hee,{get hideAddToTemplates(){return e.hideTemplates},actions:i,store:r})),A}}),k(ste,{get templateIds(){return e.templateIds?.split(",")||[]},get templateOverrides(){return e.templateOverrides||{}},get prescriptionIds(){return e.prescriptionIds?.split(",")||[]},prescriptionRef:E,actions:i,store:r,setIsEditing:h}),k(X,{get when(){return e.enableOrder&&!e.pharmacyId},get children(){return k(cte,{store:r,actions:i,get enableLocalPickup(){return e.enableLocalPickup},get enableSendToPatient(){return e.enableSendToPatient},get mailOrderIds(){return e.mailOrderIds}})}}),k(X,{get when(){return e.enableOrder&&e.pharmacyId},get children(){return k(hte,{get pharmacyId(){return e.pharmacyId}})}}),k(X,{get when(){return!e.hideSubmit},get children(){return[k(X,{get when(){return c().length>0&&e.enableOrder},get children(){const A=yte.cloneNode(!0);return S(A,k(mn,{get each(){return c()},get fallback(){return _te.cloneNode(!0)},children:({key:W,error:G})=>(()=>{const Y=J(()=>document.importNode(xte,!0)),K=Y.firstChild,se=K.nextSibling,re=se.firstChild,I=re.nextSibling;I.nextSibling;const B=se.nextSibling,ye=B.nextSibling;return Y._$owner=F(),K._$owner=F(),S(se,W,I),S(Y,G,ye),S(Y,()=>JSON.stringify(r?.[W]?.value||{}),null),Y})()})),A}}),(()=>{const A=J(()=>document.importNode(wte,!0)),W=A.firstChild;return S(A,k(X,{get when(){return!a()},get children(){const G=J(()=>document.importNode(bte,!0));return G.addEventListener("photon-clicked",async()=>s(!0)),G._$owner=F(),G}}),W),W.addEventListener("photon-clicked",async()=>await _(e.enableOrder)),W._$owner=F(),S(W,()=>e.enableOrder?"Send Order":"Save Prescriptions"),H(()=>W.loading=u()),A})()]}})]}}),null),O})()});const kte=N('<p class="font-sans text-l font-medium mb-2"></p>'),Ste=N('<sl-icon-button class="self-start"></sl-icon-button>'),Ete=N("<style></style>"),Ote=N('<div class="rounded-lg bg-white p-4 shadow-card border border-gray-200"></div>'),Cte=N('<div class="flex flex-row justify-between"></div>'),Tte=N("<slot></slot>");je("photon-card",{invalid:!1,title:null,collapsable:!1},e=>{const[t,n]=M(!0);let r=null,i=null;return e.title&&(r=(()=>{const o=kte.cloneNode(!0);return S(o,()=>e.title),o})()),e.collapsable&&(i=(()=>{const o=J(()=>document.importNode(Ste,!0));return o.addEventListener("click",()=>{n(!t())}),o._$owner=F(),H(()=>o.name=t()?"chevron-right":"chevron-down"),o})()),[(()=>{const o=Ete.cloneNode(!0);return S(o,dt),o})(),(()=>{const o=Ote.cloneNode(!0);return S(o,r||i?(()=>{const a=Cte.cloneNode(!0);return S(a,r,null),S(a,i,null),a})():null,null),S(o,(()=>{const a=Q(()=>!!(e.collapsable&&t()));return()=>a()?null:(()=>{const s=Tte.cloneNode(!0);return s._$owner=F(),s})()})(),null),H(a=>{const s=!!e.invalid,c=!!e.invalid;return s!==a._v$&&o.classList.toggle("border-red-500",a._v$=s),c!==a._v$2&&o.classList.toggle("border-2",a._v$2=c),a},{_v$:void 0,_v$2:void 0}),o})()]});const Pte=nf`
|
|
3244
3244
|
fragment CatalogTreatmentsFields on Catalog {
|
|
3245
3245
|
id
|
|
3246
3246
|
treatments {
|
package/dist/index.mjs
CHANGED
|
@@ -21067,6 +21067,7 @@ function Rq(e) {
|
|
|
21067
21067
|
const t = ct({
|
|
21068
21068
|
draftPrescriptions: [],
|
|
21069
21069
|
templateIds: [],
|
|
21070
|
+
templateOverrides: {},
|
|
21070
21071
|
prescriptionIds: []
|
|
21071
21072
|
}, e), [n, r] = M(!0), i = mf();
|
|
21072
21073
|
async function o() {
|
|
@@ -21084,7 +21085,15 @@ function Rq(e) {
|
|
|
21084
21085
|
const u = c.find((d) => d.id === l);
|
|
21085
21086
|
if (!u)
|
|
21086
21087
|
return console.error(`Invalid template id ${l}`);
|
|
21087
|
-
!u?.treatment || !u?.dispenseQuantity || !u?.dispenseUnit || !u?.fillsAllowed || !u?.instructions
|
|
21088
|
+
if (!u?.treatment || !u?.dispenseQuantity || !u?.dispenseUnit || !u?.fillsAllowed || !u?.instructions)
|
|
21089
|
+
console.error(`Template is missing required prescription details ${l}`);
|
|
21090
|
+
else {
|
|
21091
|
+
const d = t?.templateOverrides?.[u.id], f = d ? {
|
|
21092
|
+
...u,
|
|
21093
|
+
...d
|
|
21094
|
+
} : u;
|
|
21095
|
+
a.push(lb(f));
|
|
21096
|
+
}
|
|
21088
21097
|
});
|
|
21089
21098
|
}
|
|
21090
21099
|
}
|
|
@@ -33744,6 +33753,9 @@ const Wee = /* @__PURE__ */ N("<photon-patient-select></photon-patient-select>")
|
|
|
33744
33753
|
get templateIds() {
|
|
33745
33754
|
return e.templateIds;
|
|
33746
33755
|
},
|
|
33756
|
+
get templateOverrides() {
|
|
33757
|
+
return e.templateOverrides;
|
|
33758
|
+
},
|
|
33747
33759
|
get prescriptionIds() {
|
|
33748
33760
|
return e.prescriptionIds;
|
|
33749
33761
|
},
|
|
@@ -33920,6 +33932,7 @@ $t("https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.4.0/dist/");
|
|
|
33920
33932
|
je("photon-prescribe-workflow", {
|
|
33921
33933
|
patientId: void 0,
|
|
33922
33934
|
templateIds: void 0,
|
|
33935
|
+
templateOverrides: void 0,
|
|
33923
33936
|
prescriptionIds: void 0,
|
|
33924
33937
|
hideSubmit: !1,
|
|
33925
33938
|
hideTemplates: !0,
|
|
@@ -34146,6 +34159,9 @@ je("photon-prescribe-workflow", {
|
|
|
34146
34159
|
get templateIds() {
|
|
34147
34160
|
return e.templateIds?.split(",") || [];
|
|
34148
34161
|
},
|
|
34162
|
+
get templateOverrides() {
|
|
34163
|
+
return e.templateOverrides || {};
|
|
34164
|
+
},
|
|
34149
34165
|
get prescriptionIds() {
|
|
34150
34166
|
return e.prescriptionIds?.split(",") || [];
|
|
34151
34167
|
},
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { TemplateOverrides } from '@photonhealth/components';
|
|
1
2
|
export declare const DraftPrescriptionCard: (props: {
|
|
2
3
|
templateIds: string[];
|
|
4
|
+
templateOverrides: TemplateOverrides;
|
|
3
5
|
prescriptionIds: string[];
|
|
4
6
|
prescriptionRef: HTMLDivElement | undefined;
|
|
5
7
|
actions: Record<string, (...args: any) => any>;
|