@ampath/esm-dispensing-app 1.10.0-next.2 → 1.10.0-next.21

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.
Files changed (51) hide show
  1. package/dist/3568.js +1 -1
  2. package/dist/3568.js.map +1 -1
  3. package/dist/3693.js +1 -0
  4. package/dist/3693.js.map +1 -0
  5. package/dist/{7252.js → 4099.js} +1 -1
  6. package/dist/{7252.js.map → 4099.js.map} +1 -1
  7. package/dist/4300.js +1 -1
  8. package/dist/6841.js +1 -1
  9. package/dist/6841.js.map +1 -1
  10. package/dist/963.js +1 -1
  11. package/dist/963.js.map +1 -1
  12. package/dist/9764.js +1 -0
  13. package/dist/9764.js.map +1 -0
  14. package/dist/main.js +1 -1
  15. package/dist/main.js.map +1 -1
  16. package/dist/openmrs-esm-dispensing-app.js +1 -1
  17. package/dist/openmrs-esm-dispensing-app.js.buildmanifest.json +87 -87
  18. package/dist/routes.json +1 -1
  19. package/package.json +2 -1
  20. package/src/bill/bill.resource.ts +89 -0
  21. package/src/components/action-buttons.component.tsx +97 -5
  22. package/src/components/action-buttons.test.tsx +22 -2
  23. package/src/components/prescription-actions/close-action-button.component.tsx +3 -0
  24. package/src/components/prescription-actions/dispense-action-button.component.tsx +17 -4
  25. package/src/components/prescription-actions/generate-bill-action-button.component.tsx +53 -0
  26. package/src/components/prescription-actions/pause-action-button.component.tsx +3 -0
  27. package/src/config-schema.ts +36 -0
  28. package/src/forms/close-dispense-form.workspace.tsx +13 -1
  29. package/src/forms/pause-dispense-form.workspace.tsx +13 -1
  30. package/src/index.ts +3 -1
  31. package/src/location/location.resource.test.tsx +46 -8
  32. package/src/location/location.resource.tsx +7 -4
  33. package/src/medication-request/medication-request.resource.test.tsx +2 -6
  34. package/src/medication-request/medication-request.resource.tsx +97 -11
  35. package/src/prescriptions/prescription-details.component.tsx +59 -18
  36. package/src/prescriptions/prescription-details.test.tsx +70 -1
  37. package/src/prescriptions/prescription-tab-panel.component.tsx +23 -2
  38. package/src/prescriptions/prescriptions-table.component.tsx +53 -23
  39. package/src/prescriptions/priority-tag.component.tsx +44 -0
  40. package/src/prescriptions/priority-tag.scss +12 -0
  41. package/src/print-prescription/prescription-printout.component.tsx +10 -3
  42. package/src/routes.json +5 -0
  43. package/src/types.ts +53 -1
  44. package/src/utils.test.ts +9 -9
  45. package/src/utils.ts +36 -2
  46. package/src/visit/visit.resource.ts +1 -1
  47. package/translations/en.json +5 -0
  48. package/dist/609.js +0 -1
  49. package/dist/609.js.map +0 -1
  50. package/dist/8885.js +0 -1
  51. package/dist/8885.js.map +0 -1
@@ -1 +1 @@
1
- var _ampath_esm_dispensing_app;(()=>{"use strict";var e,r,t,n,a,o,i,s,l,u,f,p,d,h,c,m,v,g,b,y,w,_={35092:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(2177),t.e(8569),t.e(6825),t.e(6072),t.e(7858),t.e(8885)]).then((()=>()=>t(38885)))},a=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),o=(e,r)=>{if(t.S){var n="default",a=t.S[n];if(a&&a!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>a,init:()=>o})}},j={};function P(e){var r=j[e];if(void 0!==r)return r.exports;var t=j[e]={id:e,loaded:!1,exports:{}};return _[e].call(t.exports,t,t.exports,P),t.loaded=!0,t.exports}P.m=_,P.c=j,P.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return P.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,P.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var a=Object.create(null);P.r(a);var o={};e=e||[null,r({}),r([]),r(r)];for(var i=2&n&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>o[e]=()=>t[e]));return o.default=()=>t,P.d(a,o),a},P.d=(e,r)=>{for(var t in r)P.o(r,t)&&!P.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},P.f={},P.e=e=>Promise.all(Object.keys(P.f).reduce(((r,t)=>(P.f[t](e,r),r)),[])),P.u=e=>e+".js",P.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),P.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@ampath/esm-dispensing-app:",P.l=(e,r,a,o)=>{if(t[e])t[e].push(r);else{var i,s;if(void 0!==a)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var f=l[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+a){i=f;break}}i||(s=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,P.nc&&i.setAttribute("nonce",P.nc),i.setAttribute("data-webpack",n+a),i.src=e),t[e]=[r];var p=(r,n)=>{i.onerror=i.onload=null,clearTimeout(d);var a=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),s&&document.head.appendChild(i)}},P.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},P.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{P.S={};var e={},r={};P.I=(t,n)=>{n||(n=[]);var a=r[t];if(a||(a=r[t]={}),!(n.indexOf(a)>=0)){if(n.push(a),e[t])return e[t];P.o(P.S,t)||(P.S[t]={});var o=P.S[t],i="@ampath/esm-dispensing-app",s=(e,r,t,n)=>{var a=o[e]=o[e]||{},s=a[r];(!s||!s.loaded&&(!n!=!s.eager?n:i>s.from))&&(a[r]={get:t,from:i,eager:!!n})},l=[];return"default"===t&&(s("@openmrs/esm-framework","9.0.1-pre.4001",(()=>Promise.all([P.e(2177),P.e(2890),P.e(8569),P.e(6072),P.e(7858),P.e(1997)]).then((()=>()=>P(12890))))),s("dayjs","1.11.13",(()=>P.e(4353).then((()=>()=>P(74353))))),s("react-dom","18.3.1",(()=>Promise.all([P.e(961),P.e(6072)]).then((()=>()=>P(40961))))),s("react-i18next","16.0.0",(()=>Promise.all([P.e(7255),P.e(6072)]).then((()=>()=>P(77255))))),s("react","18.3.1",(()=>P.e(6540).then((()=>()=>P(96540))))),s("rxjs","6.6.7",(()=>P.e(3184).then((()=>()=>P(63184))))),s("swr/immutable","2.3.3",(()=>Promise.all([P.e(2177),P.e(6072),P.e(4225)]).then((()=>()=>P(54225))))),s("swr/infinite","2.3.3",(()=>Promise.all([P.e(2177),P.e(6072),P.e(3041)]).then((()=>()=>P(23041)))))),e[t]=l.length?Promise.all(l).then((()=>e[t]=1)):1}}})(),(()=>{var e;P.g.importScripts&&(e=P.g.location+"");var r=P.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),P.p=e})(),a=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},o=(e,r)=>{e=a(e),r=a(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],o=(typeof n)[0];if(t>=r.length)return"u"==o;var i=r[t],s=(typeof i)[0];if(o!=s)return"o"==o&&"n"==s||"s"==s||"u"==o;if("o"!=o&&"u"!=o&&n!=i)return n<i;t++}},i=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,a=1;a<e.length;a++)n--,t+="u"==(typeof(s=e[a]))[0]?"-":(n>0?".":"")+(n=2,s);return t}var o=[];for(a=1;a<e.length;a++){var s=e[a];o.push(0===s?"not("+l()+")":1===s?"("+l()+" || "+l()+")":2===s?o.pop()+" "+o.pop():i(s))}return l();function l(){return o.pop().replace(/^\((.+)\)$/,"$1")}},s=(e,r)=>{if(0 in e){r=a(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var o=0,i=1,l=!0;;i++,o++){var u,f,p=i<e.length?(typeof e[i])[0]:"";if(o>=r.length||"o"==(f=(typeof(u=r[o]))[0]))return!l||("u"==p?i>t&&!n:""==p!=n);if("u"==f){if(!l||"u"!=p)return!1}else if(l)if(p==f)if(i<=t){if(u!=e[i])return!1}else{if(n?u>e[i]:u<e[i])return!1;u!=e[i]&&(l=!1)}else if("s"!=p&&"n"!=p){if(n||i<=t)return!1;l=!1,i--}else{if(i<=t||f<p!=n)return!1;l=!1}else"s"!=p&&"n"!=p&&(l=!1,i--)}}var d=[],h=d.pop.bind(d);for(o=1;o<e.length;o++){var c=e[o];d.push(1==c?h()|h():2==c?h()&h():c?s(c,r):!h())}return!!h()},l=(e,r)=>e&&P.o(e,r),u=e=>(e.loaded=1,e.get()),f=e=>Object.keys(e).reduce(((r,t)=>(e[t].eager&&(r[t]=e[t]),r)),{}),p=(e,r,t)=>{var n=t?f(e[r]):e[r];return Object.keys(n).reduce(((e,r)=>!e||!n[e].loaded&&o(e,r)?r:e),0)},d=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+i(n)+")",h=e=>{throw new Error(e)},c=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},m=(e,r,t)=>t?t():((e,r)=>h("Shared module "+r+" doesn't exist in shared scope "+e))(e,r),v=(e=>function(r,t,n,a,o){var i=P.I(r);return i&&i.then&&!n?i.then(e.bind(e,r,P.S[r],t,!1,a,o)):e(r,P.S[r],t,n,a,o)})(((e,r,t,n,a,o)=>{if(!l(r,t))return m(e,t,o);var i=p(r,t,n);return s(a,i)||c(d(r,t,i,a)),u(r[t][i])})),g={},b={16072:()=>v("default","react",!1,[1,18],(()=>P.e(6540).then((()=>()=>P(96540))))),2076:()=>v("default","react-i18next",!1,[1,16],(()=>P.e(7255).then((()=>()=>P(77255))))),36920:()=>v("default","@openmrs/esm-framework",!1,[1,9],(()=>Promise.all([P.e(2890),P.e(1997)]).then((()=>()=>P(12890))))),70231:()=>v("default","dayjs",!1,[1,1],(()=>P.e(4353).then((()=>()=>P(74353))))),92646:()=>v("default","react-dom",!1,[1,18],(()=>P.e(961).then((()=>()=>P(40961))))),44209:()=>v("default","swr/immutable",!1,[1,2],(()=>P.e(6606).then((()=>()=>P(54225))))),53083:()=>v("default","rxjs",!1,[1,6],(()=>P.e(3184).then((()=>()=>P(63184))))),56339:()=>v("default","swr/infinite",!1,[1,2],(()=>P.e(5422).then((()=>()=>P(23041)))))},y={1997:[44209,53083,56339],6072:[16072],7858:[2076,36920,70231,92646]},w={},P.f.consumes=(e,r)=>{P.o(y,e)&&y[e].forEach((e=>{if(P.o(g,e))return r.push(g[e]);if(!w[e]){var t=r=>{g[e]=0,P.m[e]=t=>{delete P.c[e],t.exports=r()}};w[e]=!0;var n=r=>{delete g[e],P.m[e]=t=>{throw delete P.c[e],r}};try{var a=b[e]();a.then?r.push(g[e]=a.then(t).catch(n)):t(a)}catch(e){n(e)}}}))},(()=>{var e={3257:0};P.f.j=(r,t)=>{var n=P.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(1997|6072|7858)$/.test(r))e[r]=0;else{var a=new Promise(((t,a)=>n=e[r]=[t,a]));t.push(n[2]=a);var o=P.p+P.u(r),i=new Error;P.l(o,(t=>{if(P.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var a=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,a,[o,i,s]=t,l=0;if(o.some((r=>0!==e[r]))){for(n in i)P.o(i,n)&&(P.m[n]=i[n]);s&&s(P)}for(r&&r(t);l<o.length;l++)a=o[l],P.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=globalThis.webpackChunk_ampath_esm_dispensing_app=globalThis.webpackChunk_ampath_esm_dispensing_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),P.nc=void 0;var S=P(35092);_ampath_esm_dispensing_app=S})();
1
+ var _ampath_esm_dispensing_app;(()=>{"use strict";var e,r,t,n,a,o,i,s,l,u,f,p,d,h,c,m,v,g,b,y,w,_={35092:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(2177),t.e(8569),t.e(6825),t.e(6072),t.e(7858),t.e(3693)]).then((()=>()=>t(63693)))},a=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),o=(e,r)=>{if(t.S){var n="default",a=t.S[n];if(a&&a!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>a,init:()=>o})}},j={};function P(e){var r=j[e];if(void 0!==r)return r.exports;var t=j[e]={id:e,loaded:!1,exports:{}};return _[e].call(t.exports,t,t.exports,P),t.loaded=!0,t.exports}P.m=_,P.c=j,P.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return P.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,P.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var a=Object.create(null);P.r(a);var o={};e=e||[null,r({}),r([]),r(r)];for(var i=2&n&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>o[e]=()=>t[e]));return o.default=()=>t,P.d(a,o),a},P.d=(e,r)=>{for(var t in r)P.o(r,t)&&!P.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},P.f={},P.e=e=>Promise.all(Object.keys(P.f).reduce(((r,t)=>(P.f[t](e,r),r)),[])),P.u=e=>e+".js",P.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),P.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@ampath/esm-dispensing-app:",P.l=(e,r,a,o)=>{if(t[e])t[e].push(r);else{var i,s;if(void 0!==a)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var f=l[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+a){i=f;break}}i||(s=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,P.nc&&i.setAttribute("nonce",P.nc),i.setAttribute("data-webpack",n+a),i.src=e),t[e]=[r];var p=(r,n)=>{i.onerror=i.onload=null,clearTimeout(d);var a=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),s&&document.head.appendChild(i)}},P.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},P.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{P.S={};var e={},r={};P.I=(t,n)=>{n||(n=[]);var a=r[t];if(a||(a=r[t]={}),!(n.indexOf(a)>=0)){if(n.push(a),e[t])return e[t];P.o(P.S,t)||(P.S[t]={});var o=P.S[t],i="@ampath/esm-dispensing-app",s=(e,r,t,n)=>{var a=o[e]=o[e]||{},s=a[r];(!s||!s.loaded&&(!n!=!s.eager?n:i>s.from))&&(a[r]={get:t,from:i,eager:!!n})},l=[];return"default"===t&&(s("@openmrs/esm-framework","9.0.1-pre.4001",(()=>Promise.all([P.e(2177),P.e(2890),P.e(8569),P.e(6072),P.e(7858),P.e(1997)]).then((()=>()=>P(12890))))),s("dayjs","1.11.13",(()=>P.e(4353).then((()=>()=>P(74353))))),s("react-dom","18.3.1",(()=>Promise.all([P.e(961),P.e(6072)]).then((()=>()=>P(40961))))),s("react-i18next","16.0.0",(()=>Promise.all([P.e(7255),P.e(6072)]).then((()=>()=>P(77255))))),s("react","18.3.1",(()=>P.e(6540).then((()=>()=>P(96540))))),s("rxjs","6.6.7",(()=>P.e(3184).then((()=>()=>P(63184))))),s("swr/immutable","2.3.3",(()=>Promise.all([P.e(2177),P.e(6072),P.e(4225)]).then((()=>()=>P(54225))))),s("swr/infinite","2.3.3",(()=>Promise.all([P.e(2177),P.e(6072),P.e(3041)]).then((()=>()=>P(23041)))))),e[t]=l.length?Promise.all(l).then((()=>e[t]=1)):1}}})(),(()=>{var e;P.g.importScripts&&(e=P.g.location+"");var r=P.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),P.p=e})(),a=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},o=(e,r)=>{e=a(e),r=a(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],o=(typeof n)[0];if(t>=r.length)return"u"==o;var i=r[t],s=(typeof i)[0];if(o!=s)return"o"==o&&"n"==s||"s"==s||"u"==o;if("o"!=o&&"u"!=o&&n!=i)return n<i;t++}},i=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,a=1;a<e.length;a++)n--,t+="u"==(typeof(s=e[a]))[0]?"-":(n>0?".":"")+(n=2,s);return t}var o=[];for(a=1;a<e.length;a++){var s=e[a];o.push(0===s?"not("+l()+")":1===s?"("+l()+" || "+l()+")":2===s?o.pop()+" "+o.pop():i(s))}return l();function l(){return o.pop().replace(/^\((.+)\)$/,"$1")}},s=(e,r)=>{if(0 in e){r=a(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var o=0,i=1,l=!0;;i++,o++){var u,f,p=i<e.length?(typeof e[i])[0]:"";if(o>=r.length||"o"==(f=(typeof(u=r[o]))[0]))return!l||("u"==p?i>t&&!n:""==p!=n);if("u"==f){if(!l||"u"!=p)return!1}else if(l)if(p==f)if(i<=t){if(u!=e[i])return!1}else{if(n?u>e[i]:u<e[i])return!1;u!=e[i]&&(l=!1)}else if("s"!=p&&"n"!=p){if(n||i<=t)return!1;l=!1,i--}else{if(i<=t||f<p!=n)return!1;l=!1}else"s"!=p&&"n"!=p&&(l=!1,i--)}}var d=[],h=d.pop.bind(d);for(o=1;o<e.length;o++){var c=e[o];d.push(1==c?h()|h():2==c?h()&h():c?s(c,r):!h())}return!!h()},l=(e,r)=>e&&P.o(e,r),u=e=>(e.loaded=1,e.get()),f=e=>Object.keys(e).reduce(((r,t)=>(e[t].eager&&(r[t]=e[t]),r)),{}),p=(e,r,t)=>{var n=t?f(e[r]):e[r];return Object.keys(n).reduce(((e,r)=>!e||!n[e].loaded&&o(e,r)?r:e),0)},d=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+i(n)+")",h=e=>{throw new Error(e)},c=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},m=(e,r,t)=>t?t():((e,r)=>h("Shared module "+r+" doesn't exist in shared scope "+e))(e,r),v=(e=>function(r,t,n,a,o){var i=P.I(r);return i&&i.then&&!n?i.then(e.bind(e,r,P.S[r],t,!1,a,o)):e(r,P.S[r],t,n,a,o)})(((e,r,t,n,a,o)=>{if(!l(r,t))return m(e,t,o);var i=p(r,t,n);return s(a,i)||c(d(r,t,i,a)),u(r[t][i])})),g={},b={16072:()=>v("default","react",!1,[1,18],(()=>P.e(6540).then((()=>()=>P(96540))))),2076:()=>v("default","react-i18next",!1,[1,16],(()=>P.e(7255).then((()=>()=>P(77255))))),36920:()=>v("default","@openmrs/esm-framework",!1,[1,9],(()=>Promise.all([P.e(2890),P.e(1997)]).then((()=>()=>P(12890))))),70231:()=>v("default","dayjs",!1,[1,1],(()=>P.e(4353).then((()=>()=>P(74353))))),92646:()=>v("default","react-dom",!1,[1,18],(()=>P.e(961).then((()=>()=>P(40961))))),44209:()=>v("default","swr/immutable",!1,[1,2],(()=>P.e(6606).then((()=>()=>P(54225))))),53083:()=>v("default","rxjs",!1,[1,6],(()=>P.e(3184).then((()=>()=>P(63184))))),56339:()=>v("default","swr/infinite",!1,[1,2],(()=>P.e(5422).then((()=>()=>P(23041)))))},y={1997:[44209,53083,56339],6072:[16072],7858:[2076,36920,70231,92646]},w={},P.f.consumes=(e,r)=>{P.o(y,e)&&y[e].forEach((e=>{if(P.o(g,e))return r.push(g[e]);if(!w[e]){var t=r=>{g[e]=0,P.m[e]=t=>{delete P.c[e],t.exports=r()}};w[e]=!0;var n=r=>{delete g[e],P.m[e]=t=>{throw delete P.c[e],r}};try{var a=b[e]();a.then?r.push(g[e]=a.then(t).catch(n)):t(a)}catch(e){n(e)}}}))},(()=>{var e={3257:0};P.f.j=(r,t)=>{var n=P.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(1997|6072|7858)$/.test(r))e[r]=0;else{var a=new Promise(((t,a)=>n=e[r]=[t,a]));t.push(n[2]=a);var o=P.p+P.u(r),i=new Error;P.l(o,(t=>{if(P.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var a=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+a+": "+o+")",i.name="ChunkLoadError",i.type=a,i.request=o,n[1](i)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,a,[o,i,s]=t,l=0;if(o.some((r=>0!==e[r]))){for(n in i)P.o(i,n)&&(P.m[n]=i[n]);s&&s(P)}for(r&&r(t);l<o.length;l++)a=o[l],P.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=globalThis.webpackChunk_ampath_esm_dispensing_app=globalThis.webpackChunk_ampath_esm_dispensing_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),P.nc=void 0;var S=P(35092);_ampath_esm_dispensing_app=S})();
@@ -22,31 +22,6 @@
22
22
  "hash": "cb5e9a7589c2fa09",
23
23
  "childrenByOrder": {}
24
24
  },
25
- {
26
- "rendered": true,
27
- "initial": false,
28
- "entry": false,
29
- "recorded": false,
30
- "reason": "split chunk (cache group: default)",
31
- "size": 39486,
32
- "sizes": {
33
- "javascript": 39486
34
- },
35
- "names": [],
36
- "idHints": [],
37
- "runtime": [
38
- "@ampath/esm-dispensing-app",
39
- "main"
40
- ],
41
- "files": [
42
- "609.js"
43
- ],
44
- "auxiliaryFiles": [
45
- "609.js.map"
46
- ],
47
- "hash": "3a6ab0fefb0b96d2",
48
- "childrenByOrder": {}
49
- },
50
25
  {
51
26
  "rendered": true,
52
27
  "initial": false,
@@ -145,9 +120,9 @@
145
120
  "initial": false,
146
121
  "entry": false,
147
122
  "recorded": false,
148
- "size": 12934,
123
+ "size": 13569,
149
124
  "sizes": {
150
- "javascript": 12934
125
+ "javascript": 13569
151
126
  },
152
127
  "names": [],
153
128
  "idHints": [],
@@ -161,7 +136,7 @@
161
136
  "auxiliaryFiles": [
162
137
  "963.js.map"
163
138
  ],
164
- "hash": "e773a3f92dde9052",
139
+ "hash": "19b67e0ea74b31a4",
165
140
  "childrenByOrder": {}
166
141
  },
167
142
  {
@@ -207,7 +182,7 @@
207
182
  "auxiliaryFiles": [
208
183
  "1043.js.map"
209
184
  ],
210
- "hash": "5f428d3c181d78c9",
185
+ "hash": "d50e59843c8f013c",
211
186
  "childrenByOrder": {}
212
187
  },
213
188
  {
@@ -494,7 +469,7 @@
494
469
  "auxiliaryFiles": [
495
470
  "openmrs-esm-dispensing-app.js.map"
496
471
  ],
497
- "hash": "2d23cfe260fc6cb5",
472
+ "hash": "c25e90c2642aab0b",
498
473
  "childrenByOrder": {}
499
474
  },
500
475
  {
@@ -502,9 +477,9 @@
502
477
  "initial": false,
503
478
  "entry": false,
504
479
  "recorded": false,
505
- "size": 64172,
480
+ "size": 64508,
506
481
  "sizes": {
507
- "javascript": 64172
482
+ "javascript": 64508
508
483
  },
509
484
  "names": [],
510
485
  "idHints": [],
@@ -518,7 +493,7 @@
518
493
  "auxiliaryFiles": [
519
494
  "3568.js.map"
520
495
  ],
521
- "hash": "6572dad3532f18df",
496
+ "hash": "b478e7dca213847e",
522
497
  "childrenByOrder": {}
523
498
  },
524
499
  {
@@ -543,6 +518,29 @@
543
518
  "hash": "12daaa34d4456d1f",
544
519
  "childrenByOrder": {}
545
520
  },
521
+ {
522
+ "rendered": true,
523
+ "initial": false,
524
+ "entry": false,
525
+ "recorded": false,
526
+ "size": 420862,
527
+ "sizes": {
528
+ "javascript": 420862
529
+ },
530
+ "names": [],
531
+ "idHints": [],
532
+ "runtime": [
533
+ "@ampath/esm-dispensing-app"
534
+ ],
535
+ "files": [
536
+ "3693.js"
537
+ ],
538
+ "auxiliaryFiles": [
539
+ "3693.js.map"
540
+ ],
541
+ "hash": "1c762213ead18534",
542
+ "childrenByOrder": {}
543
+ },
546
544
  {
547
545
  "rendered": true,
548
546
  "initial": false,
@@ -565,6 +563,30 @@
565
563
  "hash": "e7acd7c3fb028b95",
566
564
  "childrenByOrder": {}
567
565
  },
566
+ {
567
+ "rendered": true,
568
+ "initial": false,
569
+ "entry": false,
570
+ "recorded": false,
571
+ "size": 126188,
572
+ "sizes": {
573
+ "javascript": 126188
574
+ },
575
+ "names": [],
576
+ "idHints": [],
577
+ "runtime": [
578
+ "@ampath/esm-dispensing-app",
579
+ "main"
580
+ ],
581
+ "files": [
582
+ "4099.js"
583
+ ],
584
+ "auxiliaryFiles": [
585
+ "4099.js.map"
586
+ ],
587
+ "hash": "aed00fc516ce4dd2",
588
+ "childrenByOrder": {}
589
+ },
568
590
  {
569
591
  "rendered": true,
570
592
  "initial": false,
@@ -616,9 +638,9 @@
616
638
  "initial": false,
617
639
  "entry": false,
618
640
  "recorded": false,
619
- "size": 5341,
641
+ "size": 5526,
620
642
  "sizes": {
621
- "javascript": 5341
643
+ "javascript": 5526
622
644
  },
623
645
  "names": [],
624
646
  "idHints": [],
@@ -630,7 +652,7 @@
630
652
  "4300.js"
631
653
  ],
632
654
  "auxiliaryFiles": [],
633
- "hash": "b7955b7d86cc3b0c",
655
+ "hash": "d80ce1f44c857fb4",
634
656
  "childrenByOrder": {}
635
657
  },
636
658
  {
@@ -1091,9 +1113,9 @@
1091
1113
  "initial": false,
1092
1114
  "entry": false,
1093
1115
  "recorded": false,
1094
- "size": 12932,
1116
+ "size": 13567,
1095
1117
  "sizes": {
1096
- "javascript": 12932
1118
+ "javascript": 13567
1097
1119
  },
1098
1120
  "names": [],
1099
1121
  "idHints": [],
@@ -1107,7 +1129,7 @@
1107
1129
  "auxiliaryFiles": [
1108
1130
  "6841.js.map"
1109
1131
  ],
1110
- "hash": "97884dc3ee42ab83",
1132
+ "hash": "3af2687c7a431016",
1111
1133
  "childrenByOrder": {}
1112
1134
  },
1113
1135
  {
@@ -1203,30 +1225,6 @@
1203
1225
  "hash": "68c5e45307d98943",
1204
1226
  "childrenByOrder": {}
1205
1227
  },
1206
- {
1207
- "rendered": true,
1208
- "initial": false,
1209
- "entry": false,
1210
- "recorded": false,
1211
- "size": 131118,
1212
- "sizes": {
1213
- "javascript": 131118
1214
- },
1215
- "names": [],
1216
- "idHints": [],
1217
- "runtime": [
1218
- "@ampath/esm-dispensing-app",
1219
- "main"
1220
- ],
1221
- "files": [
1222
- "7252.js"
1223
- ],
1224
- "auxiliaryFiles": [
1225
- "7252.js.map"
1226
- ],
1227
- "hash": "1faa82e1ce6a390a",
1228
- "childrenByOrder": {}
1229
- },
1230
1228
  {
1231
1229
  "rendered": true,
1232
1230
  "initial": false,
@@ -1441,10 +1439,10 @@
1441
1439
  "initial": true,
1442
1440
  "entry": true,
1443
1441
  "recorded": false,
1444
- "size": 3695102,
1442
+ "size": 3738287,
1445
1443
  "sizes": {
1446
1444
  "consume-shared": 210,
1447
- "javascript": 3672853,
1445
+ "javascript": 3716038,
1448
1446
  "share-init": 336,
1449
1447
  "runtime": 21703
1450
1448
  },
@@ -1461,7 +1459,7 @@
1461
1459
  "auxiliaryFiles": [
1462
1460
  "main.js.map"
1463
1461
  ],
1464
- "hash": "1e5b4e9eb8456d0c",
1462
+ "hash": "78d4663c6c512e52",
1465
1463
  "childrenByOrder": {}
1466
1464
  },
1467
1465
  {
@@ -1469,22 +1467,21 @@
1469
1467
  "initial": false,
1470
1468
  "entry": false,
1471
1469
  "recorded": false,
1472
- "size": 377677,
1470
+ "size": 5381,
1473
1471
  "sizes": {
1474
- "javascript": 377677
1472
+ "javascript": 5381
1475
1473
  },
1476
1474
  "names": [],
1477
1475
  "idHints": [],
1478
1476
  "runtime": [
1479
- "@ampath/esm-dispensing-app"
1477
+ "@ampath/esm-dispensing-app",
1478
+ "main"
1480
1479
  ],
1481
1480
  "files": [
1482
- "8885.js"
1483
- ],
1484
- "auxiliaryFiles": [
1485
- "8885.js.map"
1481
+ "9214.js"
1486
1482
  ],
1487
- "hash": "3f65626280cb34d8",
1483
+ "auxiliaryFiles": [],
1484
+ "hash": "e7c4e74879145e2c",
1488
1485
  "childrenByOrder": {}
1489
1486
  },
1490
1487
  {
@@ -1492,9 +1489,9 @@
1492
1489
  "initial": false,
1493
1490
  "entry": false,
1494
1491
  "recorded": false,
1495
- "size": 5381,
1492
+ "size": 5768,
1496
1493
  "sizes": {
1497
- "javascript": 5381
1494
+ "javascript": 5768
1498
1495
  },
1499
1496
  "names": [],
1500
1497
  "idHints": [],
@@ -1503,10 +1500,10 @@
1503
1500
  "main"
1504
1501
  ],
1505
1502
  "files": [
1506
- "9214.js"
1503
+ "9538.js"
1507
1504
  ],
1508
1505
  "auxiliaryFiles": [],
1509
- "hash": "e7c4e74879145e2c",
1506
+ "hash": "1bc2e5fb8d30dec1",
1510
1507
  "childrenByOrder": {}
1511
1508
  },
1512
1509
  {
@@ -1514,9 +1511,9 @@
1514
1511
  "initial": false,
1515
1512
  "entry": false,
1516
1513
  "recorded": false,
1517
- "size": 5768,
1514
+ "size": 5341,
1518
1515
  "sizes": {
1519
- "javascript": 5768
1516
+ "javascript": 5341
1520
1517
  },
1521
1518
  "names": [],
1522
1519
  "idHints": [],
@@ -1525,10 +1522,10 @@
1525
1522
  "main"
1526
1523
  ],
1527
1524
  "files": [
1528
- "9538.js"
1525
+ "9569.js"
1529
1526
  ],
1530
1527
  "auxiliaryFiles": [],
1531
- "hash": "1bc2e5fb8d30dec1",
1528
+ "hash": "6b0421d538adbb15",
1532
1529
  "childrenByOrder": {}
1533
1530
  },
1534
1531
  {
@@ -1536,9 +1533,10 @@
1536
1533
  "initial": false,
1537
1534
  "entry": false,
1538
1535
  "recorded": false,
1539
- "size": 5341,
1536
+ "reason": "split chunk (cache group: default)",
1537
+ "size": 44402,
1540
1538
  "sizes": {
1541
- "javascript": 5341
1539
+ "javascript": 44402
1542
1540
  },
1543
1541
  "names": [],
1544
1542
  "idHints": [],
@@ -1547,10 +1545,12 @@
1547
1545
  "main"
1548
1546
  ],
1549
1547
  "files": [
1550
- "9569.js"
1548
+ "9764.js"
1551
1549
  ],
1552
- "auxiliaryFiles": [],
1553
- "hash": "6b0421d538adbb15",
1550
+ "auxiliaryFiles": [
1551
+ "9764.js.map"
1552
+ ],
1553
+ "hash": "5acde1452f51839d",
1554
1554
  "childrenByOrder": {}
1555
1555
  },
1556
1556
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"pages":[{"component":"dispensing","route":"dispensing","online":true,"offline":true}],"extensions":[{"name":"dispensing-link","slot":"app-menu-slot","component":"dispensingLink","online":true,"offline":true},{"name":"patient-diagnoses","component":"patientDiagnoses","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"patient-conditions","component":"patientConditions","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"dispensing-dashboard","slot":"dispensing-dashboard-slot","component":"dispensingDashboard","online":true,"offline":true},{"name":"dispensing-dashboard-link","component":"dispensingDashboardLink","meta":{"name":"dispensing","slot":"dispensing-dashboard-slot","title":"Dispensing"}},{"name":"dispense-action-button","slot":"prescription-action-button-slot","component":"dispenseActionButton"},{"name":"pause-action-button","slot":"prescription-action-button-slot","component":"pauseActionButton"},{"name":"close-action-button","slot":"prescription-action-button-slot","component":"closeActionButton"}],"workspaces2":[{"name":"close-dispense-workspace","component":"closeDispenseWorkspace","window":"dispensing-window"},{"name":"pause-dispense-workspace","component":"pauseDispenseWorkspace","window":"dispensing-window"},{"name":"dispense-workspace","component":"dispenseWorkspace","window":"dispensing-window"},{"name":"dispensing-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"fill-prescription-window"},{"name":"dispensing-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"fill-prescription-window"},{"name":"dispensing-order-basket-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"fill-prescription-window"},{"name":"dispensing-order-basket-add-drug-order-workspace","component":"@openmrs/esm-patient-medications-app#exportedAddDrugOrderWorkspace","window":"fill-prescription-window"}],"workspaceWindows2":[{"name":"dispensing-window","group":"dispensing-group"},{"name":"fill-prescription-window","group":"dispensing-group"}],"workspaceGroups2":[{"name":"dispensing-group","overlay":true}],"modals":[{"name":"prescription-print-preview-modal","component":"printPrescriptionPreviewModal"},{"name":"delete-confirm-modal","component":"deleteConfirmModal"},{"name":"on-prescription-filled-modal","component":"onPrescriptionFilledModal"}],"version":"1.10.0-next.2"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"pages":[{"component":"dispensing","route":"dispensing","online":true,"offline":true}],"extensions":[{"name":"dispensing-link","slot":"app-menu-slot","component":"dispensingLink","online":true,"offline":true},{"name":"patient-diagnoses","component":"patientDiagnoses","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"patient-conditions","component":"patientConditions","slot":"dispensing-condition-and-diagnoses","online":true,"offline":true},{"name":"dispensing-dashboard","slot":"dispensing-dashboard-slot","component":"dispensingDashboard","online":true,"offline":true},{"name":"dispensing-dashboard-link","component":"dispensingDashboardLink","meta":{"name":"dispensing","slot":"dispensing-dashboard-slot","title":"Dispensing"}},{"name":"dispense-action-button","slot":"prescription-action-button-slot","component":"dispenseActionButton"},{"name":"pause-action-button","slot":"prescription-action-button-slot","component":"pauseActionButton"},{"name":"close-action-button","slot":"prescription-action-button-slot","component":"closeActionButton"},{"name":"generate-bill-action-button","slot":"prescription-action-button-slot","component":"generateBillActionButton"}],"workspaces2":[{"name":"close-dispense-workspace","component":"closeDispenseWorkspace","window":"dispensing-window"},{"name":"pause-dispense-workspace","component":"pauseDispenseWorkspace","window":"dispensing-window"},{"name":"dispense-workspace","component":"dispenseWorkspace","window":"dispensing-window"},{"name":"dispensing-patient-search-workspace","component":"@openmrs/esm-patient-search-app#patientSearchWorkspace2","window":"fill-prescription-window"},{"name":"dispensing-start-visit-workspace","component":"@openmrs/esm-patient-chart-app#exportedVisitForm","window":"fill-prescription-window"},{"name":"dispensing-order-basket-workspace","component":"@openmrs/esm-patient-orders-app#exportedOrderBasketWorkspace","window":"fill-prescription-window"},{"name":"dispensing-order-basket-add-drug-order-workspace","component":"@openmrs/esm-patient-medications-app#exportedAddDrugOrderWorkspace","window":"fill-prescription-window"}],"workspaceWindows2":[{"name":"dispensing-window","group":"dispensing-group"},{"name":"fill-prescription-window","group":"dispensing-group"}],"workspaceGroups2":[{"name":"dispensing-group","overlay":true}],"modals":[{"name":"prescription-print-preview-modal","component":"printPrescriptionPreviewModal"},{"name":"delete-confirm-modal","component":"deleteConfirmModal"},{"name":"on-prescription-filled-modal","component":"onPrescriptionFilledModal"}],"version":"1.10.0-next.21"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampath/esm-dispensing-app",
3
- "version": "1.10.0-next.2",
3
+ "version": "1.10.0-next.21",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Medication dispensing application",
6
6
  "browser": "dist/openmrs-esm-dispensing-app.js",
@@ -8,6 +8,7 @@
8
8
  "source": true,
9
9
  "scripts": {
10
10
  "start": "openmrs develop",
11
+ "dev": "openmrs develop --backend=https://staging.ampath.or.ke --api-url=/openmrs --config-url=https://ngx.ampath.or.ke/o3-config.json --port=8000",
11
12
  "serve": "webpack serve --mode=development",
12
13
  "build": "webpack --mode production",
13
14
  "analyze": "webpack --mode=production --env.analyze=true",
@@ -0,0 +1,89 @@
1
+ import { openmrsFetch, type OpenmrsResource, restBaseUrl } from '@openmrs/esm-framework';
2
+ import useSWR, { mutate } from 'swr';
3
+ import { type BillInvoice } from '../types';
4
+ import { getHieBaseUrl, postJson } from '../utils';
5
+ import { useCallback } from 'react';
6
+ import dayjs from 'dayjs';
7
+
8
+ export const useBills = (patientUuid: string = '', billStatus: string = 'PENDING') => {
9
+ const url = `${restBaseUrl}/billing/bill?patientUuid=${patientUuid}&v=custom:(uuid,patient:(uuid),lineItems:(uuid,billableService,quantity,price,item,priceUuid,priceName,paymentStatus),status)`;
10
+
11
+ const {
12
+ data,
13
+ error,
14
+ isLoading,
15
+ isValidating,
16
+ mutate: mutated,
17
+ } = useSWR<{ data: { results: Array<BillInvoice> } }>(url, openmrsFetch, {
18
+ errorRetryCount: 2,
19
+ });
20
+
21
+ const results = data?.data?.results ?? [];
22
+
23
+ return {
24
+ bills: results,
25
+ error,
26
+ isLoading,
27
+ isValidating,
28
+ mutated,
29
+ };
30
+ };
31
+
32
+ export function useInvalidateBills(patientUuid: string) {
33
+ return useCallback(() => {
34
+ mutate(
35
+ (key) => typeof key === 'string' && key.startsWith(`${restBaseUrl}/billing/bill?patientUuid=${patientUuid}`),
36
+ undefined,
37
+ { revalidate: true },
38
+ );
39
+ }, [patientUuid]);
40
+ }
41
+
42
+ export const getOrderNumberFromHie = async (orderNumber: string) => {
43
+ const hieBaseUrl = await getHieBaseUrl();
44
+ const url = `${hieBaseUrl}/bill-order?order_no=${orderNumber}`;
45
+ return postJson<{ bill_uuid: string; line_item_uuid: string }>(url, null, 'GET');
46
+ };
47
+
48
+ export const usePatientBills = (patientUuid: string, billStatus: string = 'PENDING,POSTED') => {
49
+ const url = `${restBaseUrl}/billing/bill?patientUuid=${patientUuid}&status=${billStatus}&v=custom:(uuid,lineItems,dateCreated)`;
50
+
51
+ const {
52
+ data,
53
+ error,
54
+ isLoading,
55
+ isValidating,
56
+ mutate: mutated,
57
+ } = useSWR<{ data: { results: Array<OpenmrsResource> } }>(url, openmrsFetch, {
58
+ errorRetryCount: 2,
59
+ });
60
+
61
+ const results = data?.data?.results ?? [];
62
+
63
+ const today = dayjs().startOf('day');
64
+
65
+ const currentDayBills = results.filter((bill) => {
66
+ const billDate = dayjs(bill?.dateCreated).startOf('day');
67
+ return billDate.isSame(today);
68
+ });
69
+
70
+ return {
71
+ currentDayBills,
72
+ error,
73
+ isLoading,
74
+ isValidating,
75
+ mutated,
76
+ };
77
+ };
78
+
79
+ export const getOdooBills = async (patientUuid: string) => {
80
+ const url = `/openmrs/etl/odoo/billing/patient/${patientUuid}`;
81
+ return postJson<{
82
+ orders: Array<{
83
+ order_lines: Array<{
84
+ billing_status: string;
85
+ openmrs_order_id: string;
86
+ }>;
87
+ }>;
88
+ }>(url, null, 'GET');
89
+ };
@@ -1,6 +1,12 @@
1
- import React from 'react';
2
- import { ExtensionSlot, useConfig, useSession } from '@openmrs/esm-framework';
3
- import { MedicationDispenseStatus, type MedicationRequestBundle, MedicationRequestStatus } from '../types';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { ExtensionSlot, type Order, useConfig, useSession } from '@openmrs/esm-framework';
3
+ import {
4
+ type BillInvoice,
5
+ type BillStatus,
6
+ MedicationDispenseStatus,
7
+ type MedicationRequestBundle,
8
+ MedicationRequestStatus,
9
+ } from '../types';
4
10
  import {
5
11
  computeMedicationRequestStatus,
6
12
  computeQuantityRemaining,
@@ -10,12 +16,20 @@ import {
10
16
  import { type PharmacyConfig } from '../config-schema';
11
17
  import { useProviders } from '../medication-dispense/medication-dispense.resource';
12
18
  import styles from './action-buttons.scss';
19
+ import { getOdooBills, getOrderNumberFromHie } from '../bill/bill.resource';
20
+ import { InlineLoading } from '@carbon/react';
13
21
 
14
22
  interface ActionButtonsProps {
15
23
  medicationRequestBundle: MedicationRequestBundle;
16
24
  patientUuid: string;
17
25
  encounterUuid: string;
18
26
  disabled: boolean;
27
+ orders: Order[];
28
+ bills: BillInvoice[];
29
+ isLoading: boolean;
30
+ isLoadingOrders?: boolean;
31
+ hasActiveRequests?: boolean;
32
+ mutated: () => void;
19
33
  }
20
34
 
21
35
  const ActionButtons: React.FC<ActionButtonsProps> = ({
@@ -23,10 +37,77 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
23
37
  patientUuid,
24
38
  encounterUuid,
25
39
  disabled,
40
+ orders,
41
+ bills,
42
+ isLoading,
43
+ isLoadingOrders,
44
+ hasActiveRequests,
45
+ mutated,
26
46
  }) => {
47
+ const [status, setStatus] = useState<BillStatus>('BLANK');
48
+ const [isLoadingOdooBills, setIsLoadingOdooBills] = useState(false);
27
49
  const config = useConfig<PharmacyConfig>();
28
50
  const session = useSession();
29
51
  const providers = useProviders(config.dispenserProviderRoles);
52
+ const order = useMemo(() => {
53
+ const medicationReference = medicationRequestBundle.request.medicationReference.reference;
54
+ if (!isLoadingOrders) {
55
+ return orders.find((o) => medicationReference.includes(o?.drug?.uuid));
56
+ }
57
+ return {} as Order;
58
+ }, [orders, medicationRequestBundle, isLoadingOrders]);
59
+
60
+ useEffect(() => {
61
+ const getBillStatus = async () => {
62
+ try {
63
+ const response = await getOrderNumberFromHie(order?.orderNumber);
64
+ const billUuid = response.bill_uuid;
65
+ const bill = bills.find((b) => b.uuid === billUuid);
66
+ const lineItem = bill?.lineItems?.find((i) => i.uuid === response?.line_item_uuid);
67
+ if (lineItem) {
68
+ if (!config.blockedPaymentModes.includes(lineItem.priceName.toUpperCase())) {
69
+ setStatus('PAID');
70
+ } else {
71
+ setStatus(lineItem?.paymentStatus as BillStatus);
72
+ }
73
+ } else {
74
+ setStatus('BLANK');
75
+ }
76
+ } catch (error) {
77
+ setStatus('BLANK');
78
+ }
79
+ };
80
+
81
+ const odooBills = async () => {
82
+ try {
83
+ setIsLoadingOdooBills(true);
84
+ const results = await getOdooBills(order?.patient?.uuid);
85
+ if (results.orders && results.orders[0].order_lines && results.orders[0].order_lines.length) {
86
+ const currentOrder = results.orders[0].order_lines.find((o) => o.openmrs_order_id === order?.uuid);
87
+ if (currentOrder) {
88
+ if (currentOrder.billing_status.toUpperCase() === 'PAID') {
89
+ setStatus('PAID');
90
+ } else {
91
+ setStatus('PENDING');
92
+ }
93
+ }
94
+ }
95
+ } catch (error) {
96
+ console.error(error);
97
+ } finally {
98
+ setIsLoadingOdooBills(false);
99
+ }
100
+ };
101
+
102
+ if (config.enableOdooBilling) {
103
+ odooBills();
104
+ } else {
105
+ if (order?.orderNumber) {
106
+ getBillStatus();
107
+ }
108
+ }
109
+ }, [order, bills, isLoadingOrders, config.enableOdooBilling, config.blockedPaymentModes]);
110
+
30
111
  const mostRecentMedicationDispenseStatus: MedicationDispenseStatus = getMostRecentMedicationDispenseStatus(
31
112
  medicationRequestBundle.dispenses,
32
113
  );
@@ -42,12 +123,14 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
42
123
  config.actionButtons.pauseButton.enabled &&
43
124
  medicationRequestStatus === MedicationRequestStatus.active &&
44
125
  mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.on_hold &&
45
- mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined;
126
+ mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined &&
127
+ status === 'BLANK';
46
128
 
47
129
  const closeable =
48
130
  config.actionButtons.closeButton.enabled &&
49
131
  medicationRequestStatus === MedicationRequestStatus.active &&
50
- mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined;
132
+ mostRecentMedicationDispenseStatus !== MedicationDispenseStatus.declined &&
133
+ status === 'BLANK';
51
134
 
52
135
  let quantityRemaining = null;
53
136
  if (config.dispenseBehavior.restrictTotalQuantityDispensed) {
@@ -71,8 +154,17 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
71
154
  session,
72
155
  providers,
73
156
  disabled,
157
+ order,
158
+ billStatus: status,
159
+ isLoading: isLoading,
160
+ hasActiveRequests,
161
+ mutated,
74
162
  };
75
163
 
164
+ if (isLoadingOdooBills) {
165
+ return <InlineLoading />;
166
+ }
167
+
76
168
  return (
77
169
  <div className={styles.actionBtns}>
78
170
  <ExtensionSlot