@ugandaemr/esm-ugandaemr-app
Version:
UgandaEMR microfrontend built on top of OpenMRS 3.x and OHRI
1 lines • 5.2 kB
JavaScript
;(globalThis.webpackChunk_ugandaemr_esm_ugandaemr_app=globalThis.webpackChunk_ugandaemr_esm_ugandaemr_app||[]).push([[482],{8028:(t,e,n)=>{n.d(e,{b_:()=>d,l7:()=>h,lf:()=>f,tG:()=>c});var r=n(1862),o=n(9346),a=n(1e3),i=n(5552);function u(t,e,n,r,o,a,i){try{var u=t[a](i),l=u.value}catch(t){return void n(t)}u.done?e(l):Promise.resolve(l).then(r,o)}function l(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function i(t){u(a,r,o,i,l,"next",t)}function l(t){u(a,r,o,i,l,"throw",t)}i(void 0)}))}}function s(t,e){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function c(t){var e,n,a,i="https://api-nhfr.health.go.ug/NHFRSearch?resource=".concat(t.resource,"&name=").concat(t.name),u=(a=l((function(){var t;return s(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,o.Z.get(i,{headers:{"Content-Type":"application/json"}})];case 1:return[2,e.sent().data];case 2:throw t=e.sent(),new Error("Error in fetcher: ".concat(t.message));case 3:return[2]}}))})),function(){return a.apply(this,arguments)}),c=(0,r.ZP)(i,u),f=c.data,p=c.error;return{data:null===(n=f)||void 0===n||null===(e=n.entry)||void 0===e?void 0:e.filter((function(t){var e,n,r;return null===(r=t)||void 0===r||null===(n=r.resource)||void 0===n||null===(e=n.extension)||void 0===e?void 0:e.find((function(t){return"levelOfCare"===t.url}))})),isLoading:!p&&!f,isError:p}}function f(t,e){return p.apply(this,arguments)}function p(){return(p=l((function(t,e){var n,r,o;return s(this,(function(i){switch(i.label){case 0:n=new AbortController,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,(0,a.openmrsFetch)("/ws/rest/v1/systemsetting/".concat(t),{method:"POST",headers:{"Content-Type":"application/json"},signal:n.signal,body:JSON.stringify({value:e})})];case 2:if(!(r=i.sent()).ok)throw new Error("Failed to update property value: ".concat(r.statusText));return[2,r.json()];case 3:throw o=i.sent(),new Error("Error in updatePropertyValue: ".concat(o.message));case 4:return[2]}}))}))).apply(this,arguments)}function d(){var t,e=(0,r.ZP)("/ws/rest/v1/systeminformation?v=full",a.openmrsFetch),n=e.data,o=e.error,i=e.isLoading;return{systemInfo:null===(t=n)||void 0===t?void 0:t.data,isLoading:i,isError:o}}function h(){var t,e="/ws/rest/v1/systemsetting?q=".concat(i.$U,"&v=full"),n=(0,r.ZP)(e,a.openmrsFetch),o=n.data,u=n.error,l=n.isLoading;return{facilityIds:null===(t=o)||void 0===t?void 0:t.data.results,isLoading:l,isError:u}}},5482:(t,e,n)=>{n.r(e),n.d(e,{default:()=>c});var r=n(268),o=n.n(r),a=n(6520),i=n(1e3),u=n(8028),l=n(5552);function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}const c=function(){var t,e,n=(t=(0,r.useState)(!1),e=2,function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a=[],i=!0,u=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==n.return||n.return()}finally{if(u)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=n[0],f=n[1],p=(0,u.l7)(),d=p.facilityIds;if(p.isLoading,p.isError,(0,r.useEffect)((function(){d&&d.length&&(null===d[0].value?f(!0):f(!1))}),[d]),c)return o().createElement(i.UserHasAccess,{privilege:l.y2},o().createElement(a.FQz,{actionButtonLabel:"Go to System Page","aria-label":"closes notification",onActionButtonClick:function(){return(0,i.navigate)({to:"${openmrsSpaBase}/about"})},onClose:function(){f(!1)},inline:!0,statusIconDescription:"notification",role:"alert",kind:"warning",subtitle:"Check system information page to ensure the facility details are upto date",title:"Update Facility Information"}))}}}]);