@openmrs/esm-fast-data-entry-app 1.0.1-pre.82 → 1.0.1-pre.85
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/132.js +1 -1
- package/dist/595.js +1 -1
- package/dist/595.js.LICENSE.txt +2 -0
- package/dist/617.js +1 -1
- package/dist/{569.js → 658.js} +2 -2
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +31 -31
- package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
- package/jest.config.json +2 -1
- package/package.json +1 -1
- package/src/hooks/useGetPatient.ts +1 -1
- /package/dist/{569.js.LICENSE.txt → 658.js.LICENSE.txt} +0 -0
package/dist/595.js.LICENSE.txt
CHANGED
package/dist/617.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_openmrs_esm_fast_data_entry_app=self.webpackChunk_openmrs_esm_fast_data_entry_app||[]).push([[617],{5672:(t,e,r)=>{r.d(e,{AB:()=>p,ZP:()=>y,ol:()=>v});var n=r(1672),o=r.n(n),i=r(2126),u=r(1338),a=r(7612),l=r(1132);function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function f(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){s(t,e,r[e])}))}return t}var d={addPatient:function(t){},openPatientSearch:function(){},saveEncounter:function(t){},editEncounter:function(t){},submitForNext:function(){},submitForReview:function(){},submitForComplete:function(){},goToReview:function(){},destroySession:function(){},closeSession:function(){}},v={activeFormUuid:null,forms:{},workflowState:null,activePatientUuid:null,activeEncounterUuid:null,patientUuids:[],encounters:{},singleSessionVisitTypeUuid:null,userUuid:null},m=o().createContext(f({},v,d)),p=function(t){var e,r,s,p,y,b,w,h,U,S,E,O,g,P,F,T,_,I,k,j,A,R,N,C=t.children,x=(0,l.useSession)().user,M=(0,u.useParams)().formUuid.split("&")[0],D=(0,u.useLocation)().search,B=new URLSearchParams(D).get("patientUuid"),W=(j=(0,n.useReducer)(i.ZP,f({},v,d)),A=2,function(t){if(Array.isArray(t))return t}(j)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(j,A)||function(t,e){if(t){if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}(j,A)||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.")}()),V=W[0],L=W[1],Z=(0,a.Z)("@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid"),$=null==Z||null===(e=Z.result)||void 0===e||null===(r=e.data)||void 0===r||null===(s=r.results)||void 0===s||null===(p=s[0])||void 0===p?void 0:p.value,G=(0,n.useMemo)((function(){return{initializeWorkflowState:function(t){var e=t.activeFormUuid,r=t.newPatientUuid;return L({type:"INITIALIZE_WORKFLOW_STATE",activeFormUuid:e,newPatientUuid:r,userUuid:x.uuid})},addPatient:function(t){return L({type:"ADD_PATIENT",patientUuid:t})},openPatientSearch:function(){return L({type:"OPEN_PATIENT_SEARCH"})},saveEncounter:function(t){return L({type:"SAVE_ENCOUNTER",encounterUuid:t})},submitForNext:function(){return L({type:"SUBMIT_FOR_NEXT"})},submitForReview:function(){return L({type:"SUBMIT_FOR_REVIEW"})},submitForComplete:function(){return L({type:"SUBMIT_FOR_COMPLETE"})},editEncounter:function(t){return L({type:"EDIT_ENCOUNTER",patientUuid:t})},goToReview:function(){return L({type:"GO_TO_REVIEW"})},destroySession:function(){return L({type:"DESTROY_SESSION"})},closeSession:function(){return L({type:"CLOSE_SESSION"})}}}),[x]);return(0,n.useEffect)((function(){null===(null==V?void 0:V.workflowState)&&M&&G.initializeWorkflowState({activeFormUuid:M,newPatientUuid:B})}),[M,B,null==V?void 0:V.workflowState,G]),o().createElement(m.Provider,{value:(R=f({},V,G),N={workflowState:null!==(F=null===(y=V.forms)||void 0===y||null===(b=y[V.activeFormUuid])||void 0===b?void 0:b.workflowState)&&void 0!==F?F:v.workflowState,activePatientUuid:null!==(T=null===(w=V.forms)||void 0===w||null===(h=w[V.activeFormUuid])||void 0===h?void 0:h.activePatientUuid)&&void 0!==T?T:v.activePatientUuid,activeEncounterUuid:null!==(_=null===(U=V.forms)||void 0===U||null===(S=U[V.activeFormUuid])||void 0===S?void 0:S.activeEncounterUuid)&&void 0!==_?_:v.activeEncounterUuid,patientUuids:null!==(I=null===(E=V.forms)||void 0===E||null===(O=E[V.activeFormUuid])||void 0===O?void 0:O.patientUuids)&&void 0!==I?I:v.patientUuids,encounters:null!==(k=null===(g=V.forms)||void 0===g||null===(P=g[V.activeFormUuid])||void 0===P?void 0:P.encounters)&&void 0!==k?k:v.encounters,singleSessionVisitTypeUuid:$},N=null!=N?N:{},Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(N)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r}(Object(N)).forEach((function(t){Object.defineProperty(R,t,Object.getOwnPropertyDescriptor(N,t))})),R)},C)};const y=m},2126:(t,e,r)=>{r.d(e,{Go:()=>v,IE:()=>d,ZP:()=>y});var n=r(1132),o=r(5672);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){u(t,e,r[e])}))}return t}function l(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function c(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t){var e=function(t,e){if("object"!==f(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"===f(e)?e:String(e)}var f=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},d="1.1.0",v="openmrs:fastDataEntryWorkflowState",m=function(t){localStorage.setItem(v+":"+t.userUuid,JSON.stringify(t))},p={workflowState:"NEW_PATIENT",activePatientUuid:null,activeEncounterUuid:null,patientUuids:[],encounters:{}};const y=function(t,e){switch(e.type){case"INITIALIZE_WORKFLOW_STATE":var r,f=localStorage.getItem(v+":"+e.userUuid),y=f?JSON.parse(f):{},b={},w=e.newPatientUuid?{activePatientUuid:e.newPatientUuid,workflowState:"EDIT_FORM"}:{};return f&&y._storageVersion===d?(b=l(a({},y),{activeFormUuid:e.activeFormUuid,forms:l(a({},y.forms),u({},e.activeFormUuid,l(a({},p,y.forms[e.activeFormUuid],w),{patientUuids:(null===(r=y.forms[e.activeFormUuid])||void 0===r?void 0:r.patientUuids)||p.patientUuids})))}),e.newPatientUuid&&!b.forms[e.activeFormUuid].patientUuids.includes(e.newPatientUuid)&&b.forms[e.activeFormUuid].patientUuids.push(e.newPatientUuid)):b=l(a({},o.ol),{_storageVersion:d,forms:u({},e.activeFormUuid,p),activeFormUuid:e.activeFormUuid,userUuid:e.userUuid}),m(b),a({},b);case"ADD_PATIENT":var h=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{patientUuids:(R=t.forms[t.activeFormUuid].patientUuids,function(t){if(Array.isArray(t))return i(t)}(R)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(R)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(R)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.patientUuid]),activePatientUuid:e.patientUuid,activeEncounterUuid:null,workflowState:"EDIT_FORM"})))});return m(h),h;case"OPEN_PATIENT_SEARCH":var U=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activePatientUuid:null,activeEncounterUuid:null,workflowState:"NEW_PATIENT"})))});return m(U),U;case"SAVE_ENCOUNTER":if("SUBMIT_FOR_COMPLETE"===t.forms[t.activeFormUuid].workflowState){var S=t.forms,E=t.activeFormUuid,O=(S[E],c(S,[E].map(s))),g=l(a({},t),{forms:O,activeFormUuid:null});return m(g),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),g}var P=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{encounters:l(a({},t.forms[t.activeFormUuid].encounters),u({},t.forms[t.activeFormUuid].activePatientUuid,e.encounterUuid)),activePatientUuid:null,activeEncounterUuid:null,workflowState:"SUBMIT_FOR_NEXT"===t.forms[t.activeFormUuid].workflowState?"NEW_PATIENT":"SUBMIT_FOR_REVIEW"===t.forms[t.activeFormUuid].workflowState?"REVIEW":t.forms[t.activeFormUuid].workflowState})))});return m(P),P;case"EDIT_ENCOUNTER":var F=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activeEncounterUuid:t.forms[t.activeFormUuid].encounters[e.patientUuid],activePatientUuid:e.patientUuid,workflowState:"EDIT_FORM"})))});return m(F),F;case"SUBMIT_FOR_NEXT":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_NEXT"})))});case"SUBMIT_FOR_REVIEW":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_REVIEW"})))});case"SUBMIT_FOR_COMPLETE":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_COMPLETE"})))});case"GO_TO_REVIEW":var T=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activeEncounterUuid:null,activePatientUuid:null,workflowState:"REVIEW"})))});return m(T),T;case"DESTROY_SESSION":var _=t.forms,I=t.activeFormUuid,k=(_[I],c(_,[I].map(s))),j=l(a({},t),{forms:k,activeFormUuid:null});return m(j),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),j;case"CLOSE_SESSION":var A=l(a({},t),{activeFormUuid:null});return m(A),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),A;default:return t}var R}},282:(t,e,r)=>{r.d(e,{wJ:()=>f,lQ:()=>y,Eu:()=>d.Z,zg:()=>S});var n=r(1132),o=r(821);function i(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var u=t.apply(e,r);function a(t){i(u,n,o,a,l,"next",t)}function l(t){i(u,n,o,a,l,"throw",t)}a(void 0)}))}}var a=function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},l="(uuid,name,display,encounterType:(uuid,name,viewPrivilege,editPrivilege),version,published,retired,resources:(uuid,name,dataType,valueReference))",c="/ws/rest/v1/form?v=custom:".concat(l),s="/ws/rest/v1/form?v=custom:".concat(l,"&q=poc");const f=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=(0,n.useSession)(),r=!0,i=r?c:s,l=(0,o.ZP)([i,t],u((function(){var t,e,r,o;return a(this,(function(u){switch(u.label){case 0:return[4,(0,n.openmrsFetch)(i)];case 1:return r=u.sent(),[2,null!==(o=null===(t=r.data)||void 0===t||null===(e=t.results)||void 0===e?void 0:e.filter((function(t){return t.published&&!/component/i.test(t.name)})))&&void 0!==o?o:[]]}}))}))),f=l.data,d=l.error;return{forms:null==f?void 0:f.filter((function(t){var r,o;return Boolean((0,n.userHasAccess)(null===(r=t.encounterType)||void 0===r||null===(o=r.editPrivilege)||void 0===o?void 0:o.display,null==e?void 0:e.user))})),isLoading:!d&&!f,error:d}};var d=r(4439),v=r(1672);function m(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function p(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){m(i,n,o,u,a,"next",t)}function a(t){m(i,n,o,u,a,"throw",t)}u(void 0)}))}}const y=function(t){var e="".concat("/ws/rest/v1/encounter/").concat(t),r=(0,o.ZP)(e,p((function(){return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(t){switch(t.label){case 0:return[4,(0,n.openmrsFetch)(e)];case 1:return[2,t.sent().data||null]}}))}))),i=r.data,u=r.error;return{encounter:i,isLoading:!u&&i,error:u}};function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function w(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(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.")}()}var U=function(t){var e,r,o=t.endpointUrl,i=h((0,v.useState)(null),2),u=i[0],a=i[1],l=h((0,v.useState)(null),2),c=l[0],s=l[1],f=h((0,v.useState)(null),2),d=f[0],m=f[1],p=(0,v.useCallback)((function(t){a(!1),d&&m(null),s(t.data)}),[d]),y=(0,v.useCallback)((function(t){var e,r,n;a(!1),c&&s(null),m(null!==(n=null!==(r=null==t||null===(e=t.responseBody)||void 0===e?void 0:e.error)&&void 0!==r?r:null==t?void 0:t.responseBody)&&void 0!==n?n:t)}),[c]),b=(0,v.useCallback)((e=function(t){var e;return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(r){return a(!0),e={},[2,(0,n.openmrsFetch)(o,(e.method="POST",e.headers={"Content-Type":"application/json"},e.body=t,e)).then(p).catch(y)]}))},r=function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(t){w(i,n,o,u,a,"next",t)}function a(t){w(i,n,o,u,a,"throw",t)}u(void 0)}))},function(t){return r.apply(this,arguments)}),[o,y,p]);return{post:b,isPosting:u,result:c,error:d,reset:function(){a(null),s(null),m(null)}}},S=function(){return U({endpointUrl:"/ws/rest/v1/cohortm/cohort"})}},4439:(t,e,r)=>{r.d(e,{Z:()=>a});var n=r(1132),o=r(1672);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}const a=function(t){var e,r,a=(e=(0,o.useState)(null),r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,r)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(e,r)||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.")}()),l=a[0],c=a[1];(0,o.useEffect)((function(){t?d(t):c(null)}),[t]);var s,f,d=(s=function(t){var e;return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(r){switch(r.label){case 0:return[4,(0,n.fetchCurrentPatient)(t)];case 1:return e=r.sent(),c(null==e?void 0:e.data),[2]}}))},f=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=s.apply(t,e);function i(t){u(o,r,n,i,a,"next",t)}function a(t){u(o,r,n,i,a,"throw",t)}i(void 0)}))},function(t){return f.apply(this,arguments)});return l}},7612:(t,e,r)=>{r.d(e,{Z:()=>a});var n=r(1672),o=r(1132);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(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.")}()}const a=function(t){var e=u((0,n.useState)(!1),2),r=e[0],i=e[1],a=u((0,n.useState)(null),2),l=a[0],c=a[1],s=u((0,n.useState)(null),2),f=s[0],d=s[1],v=(0,n.useCallback)((function(t){i(!1),d(!1),c(t)}),[]),m=(0,n.useCallback)((function(t){i(!1),c(null),d(t)}),[]),p=(0,n.useCallback)((function(){(0,o.openmrsFetch)("/ws/rest/v1/systemsetting?q=".concat(t,"&v=default")).then(v).catch(m)}),[m,v,t]);return(0,n.useEffect)((function(){p()}),[p]),{result:l,error:f,isSubmitting:r}}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_openmrs_esm_fast_data_entry_app=self.webpackChunk_openmrs_esm_fast_data_entry_app||[]).push([[617],{5672:(t,e,r)=>{r.d(e,{AB:()=>p,ZP:()=>y,ol:()=>v});var n=r(1672),o=r.n(n),i=r(2126),u=r(1338),a=r(7612),l=r(1132);function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function f(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){s(t,e,r[e])}))}return t}var d={addPatient:function(t){},openPatientSearch:function(){},saveEncounter:function(t){},editEncounter:function(t){},submitForNext:function(){},submitForReview:function(){},submitForComplete:function(){},goToReview:function(){},destroySession:function(){},closeSession:function(){}},v={activeFormUuid:null,forms:{},workflowState:null,activePatientUuid:null,activeEncounterUuid:null,patientUuids:[],encounters:{},singleSessionVisitTypeUuid:null,userUuid:null},m=o().createContext(f({},v,d)),p=function(t){var e,r,s,p,y,b,w,h,U,S,E,O,g,P,F,T,_,I,k,j,A,R,N,C=t.children,x=(0,l.useSession)().user,M=(0,u.useParams)().formUuid.split("&")[0],D=(0,u.useLocation)().search,B=new URLSearchParams(D).get("patientUuid"),W=(j=(0,n.useReducer)(i.ZP,f({},v,d)),A=2,function(t){if(Array.isArray(t))return t}(j)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(j,A)||function(t,e){if(t){if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}(j,A)||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.")}()),V=W[0],L=W[1],Z=(0,a.Z)("@openmrs/esm-fast-data-entry-app.groupSessionVisitTypeUuid"),$=null==Z||null===(e=Z.result)||void 0===e||null===(r=e.data)||void 0===r||null===(s=r.results)||void 0===s||null===(p=s[0])||void 0===p?void 0:p.value,G=(0,n.useMemo)((function(){return{initializeWorkflowState:function(t){var e=t.activeFormUuid,r=t.newPatientUuid;return L({type:"INITIALIZE_WORKFLOW_STATE",activeFormUuid:e,newPatientUuid:r,userUuid:x.uuid})},addPatient:function(t){return L({type:"ADD_PATIENT",patientUuid:t})},openPatientSearch:function(){return L({type:"OPEN_PATIENT_SEARCH"})},saveEncounter:function(t){return L({type:"SAVE_ENCOUNTER",encounterUuid:t})},submitForNext:function(){return L({type:"SUBMIT_FOR_NEXT"})},submitForReview:function(){return L({type:"SUBMIT_FOR_REVIEW"})},submitForComplete:function(){return L({type:"SUBMIT_FOR_COMPLETE"})},editEncounter:function(t){return L({type:"EDIT_ENCOUNTER",patientUuid:t})},goToReview:function(){return L({type:"GO_TO_REVIEW"})},destroySession:function(){return L({type:"DESTROY_SESSION"})},closeSession:function(){return L({type:"CLOSE_SESSION"})}}}),[x]);return(0,n.useEffect)((function(){null===(null==V?void 0:V.workflowState)&&M&&G.initializeWorkflowState({activeFormUuid:M,newPatientUuid:B})}),[M,B,null==V?void 0:V.workflowState,G]),o().createElement(m.Provider,{value:(R=f({},V,G),N={workflowState:null!==(F=null===(y=V.forms)||void 0===y||null===(b=y[V.activeFormUuid])||void 0===b?void 0:b.workflowState)&&void 0!==F?F:v.workflowState,activePatientUuid:null!==(T=null===(w=V.forms)||void 0===w||null===(h=w[V.activeFormUuid])||void 0===h?void 0:h.activePatientUuid)&&void 0!==T?T:v.activePatientUuid,activeEncounterUuid:null!==(_=null===(U=V.forms)||void 0===U||null===(S=U[V.activeFormUuid])||void 0===S?void 0:S.activeEncounterUuid)&&void 0!==_?_:v.activeEncounterUuid,patientUuids:null!==(I=null===(E=V.forms)||void 0===E||null===(O=E[V.activeFormUuid])||void 0===O?void 0:O.patientUuids)&&void 0!==I?I:v.patientUuids,encounters:null!==(k=null===(g=V.forms)||void 0===g||null===(P=g[V.activeFormUuid])||void 0===P?void 0:P.encounters)&&void 0!==k?k:v.encounters,singleSessionVisitTypeUuid:$},N=null!=N?N:{},Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(N)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r}(Object(N)).forEach((function(t){Object.defineProperty(R,t,Object.getOwnPropertyDescriptor(N,t))})),R)},C)};const y=m},2126:(t,e,r)=>{r.d(e,{Go:()=>v,IE:()=>d,ZP:()=>y});var n=r(1132),o=r(5672);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){u(t,e,r[e])}))}return t}function l(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function c(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t){var e=function(t,e){if("object"!==f(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!==f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"===f(e)?e:String(e)}var f=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},d="1.1.0",v="openmrs:fastDataEntryWorkflowState",m=function(t){localStorage.setItem(v+":"+t.userUuid,JSON.stringify(t))},p={workflowState:"NEW_PATIENT",activePatientUuid:null,activeEncounterUuid:null,patientUuids:[],encounters:{}};const y=function(t,e){switch(e.type){case"INITIALIZE_WORKFLOW_STATE":var r,f=localStorage.getItem(v+":"+e.userUuid),y=f?JSON.parse(f):{},b={},w=e.newPatientUuid?{activePatientUuid:e.newPatientUuid,workflowState:"EDIT_FORM"}:{};return f&&y._storageVersion===d?(b=l(a({},y),{activeFormUuid:e.activeFormUuid,forms:l(a({},y.forms),u({},e.activeFormUuid,l(a({},p,y.forms[e.activeFormUuid],w),{patientUuids:(null===(r=y.forms[e.activeFormUuid])||void 0===r?void 0:r.patientUuids)||p.patientUuids})))}),e.newPatientUuid&&!b.forms[e.activeFormUuid].patientUuids.includes(e.newPatientUuid)&&b.forms[e.activeFormUuid].patientUuids.push(e.newPatientUuid)):b=l(a({},o.ol),{_storageVersion:d,forms:u({},e.activeFormUuid,p),activeFormUuid:e.activeFormUuid,userUuid:e.userUuid}),m(b),a({},b);case"ADD_PATIENT":var h=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{patientUuids:(R=t.forms[t.activeFormUuid].patientUuids,function(t){if(Array.isArray(t))return i(t)}(R)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(R)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(R)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([e.patientUuid]),activePatientUuid:e.patientUuid,activeEncounterUuid:null,workflowState:"EDIT_FORM"})))});return m(h),h;case"OPEN_PATIENT_SEARCH":var U=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activePatientUuid:null,activeEncounterUuid:null,workflowState:"NEW_PATIENT"})))});return m(U),U;case"SAVE_ENCOUNTER":if("SUBMIT_FOR_COMPLETE"===t.forms[t.activeFormUuid].workflowState){var S=t.forms,E=t.activeFormUuid,O=(S[E],c(S,[E].map(s))),g=l(a({},t),{forms:O,activeFormUuid:null});return m(g),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),g}var P=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{encounters:l(a({},t.forms[t.activeFormUuid].encounters),u({},t.forms[t.activeFormUuid].activePatientUuid,e.encounterUuid)),activePatientUuid:null,activeEncounterUuid:null,workflowState:"SUBMIT_FOR_NEXT"===t.forms[t.activeFormUuid].workflowState?"NEW_PATIENT":"SUBMIT_FOR_REVIEW"===t.forms[t.activeFormUuid].workflowState?"REVIEW":t.forms[t.activeFormUuid].workflowState})))});return m(P),P;case"EDIT_ENCOUNTER":var F=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activeEncounterUuid:t.forms[t.activeFormUuid].encounters[e.patientUuid],activePatientUuid:e.patientUuid,workflowState:"EDIT_FORM"})))});return m(F),F;case"SUBMIT_FOR_NEXT":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_NEXT"})))});case"SUBMIT_FOR_REVIEW":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_REVIEW"})))});case"SUBMIT_FOR_COMPLETE":return window.dispatchEvent(new CustomEvent("ampath-form-action",{detail:{formUuid:t.activeFormUuid,patientUuid:t.forms[t.activeFormUuid].activePatientUuid,action:"onSubmit"}})),l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{workflowState:"SUBMIT_FOR_COMPLETE"})))});case"GO_TO_REVIEW":var T=l(a({},t),{forms:l(a({},t.forms),u({},t.activeFormUuid,l(a({},t.forms[t.activeFormUuid]),{activeEncounterUuid:null,activePatientUuid:null,workflowState:"REVIEW"})))});return m(T),T;case"DESTROY_SESSION":var _=t.forms,I=t.activeFormUuid,k=(_[I],c(_,[I].map(s))),j=l(a({},t),{forms:k,activeFormUuid:null});return m(j),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),j;case"CLOSE_SESSION":var A=l(a({},t),{activeFormUuid:null});return m(A),(0,n.navigate)({to:"${openmrsSpaBase}/forms"}),A;default:return t}var R}},282:(t,e,r)=>{r.d(e,{wJ:()=>f,lQ:()=>y,Eu:()=>d.Z,zg:()=>S});var n=r(1132),o=r(821);function i(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var u=t.apply(e,r);function a(t){i(u,n,o,a,l,"next",t)}function l(t){i(u,n,o,a,l,"throw",t)}a(void 0)}))}}var a=function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},l="(uuid,name,display,encounterType:(uuid,name,viewPrivilege,editPrivilege),version,published,retired,resources:(uuid,name,dataType,valueReference))",c="/ws/rest/v1/form?v=custom:".concat(l),s="/ws/rest/v1/form?v=custom:".concat(l,"&q=poc");const f=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=(0,n.useSession)(),r=!0,i=r?c:s,l=(0,o.ZP)([i,t],u((function(){var t,e,r,o;return a(this,(function(u){switch(u.label){case 0:return[4,(0,n.openmrsFetch)(i)];case 1:return r=u.sent(),[2,null!==(o=null===(t=r.data)||void 0===t||null===(e=t.results)||void 0===e?void 0:e.filter((function(t){return t.published&&!/component/i.test(t.name)})))&&void 0!==o?o:[]]}}))}))),f=l.data,d=l.error;return{forms:null==f?void 0:f.filter((function(t){var r,o;return Boolean((0,n.userHasAccess)(null===(r=t.encounterType)||void 0===r||null===(o=r.editPrivilege)||void 0===o?void 0:o.display,null==e?void 0:e.user))})),isLoading:!d&&!f,error:d}};var d=r(4439),v=r(1672);function m(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function p(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){m(i,n,o,u,a,"next",t)}function a(t){m(i,n,o,u,a,"throw",t)}u(void 0)}))}}const y=function(t){var e="".concat("/ws/rest/v1/encounter/").concat(t),r=(0,o.ZP)(e,p((function(){return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(t){switch(t.label){case 0:return[4,(0,n.openmrsFetch)(e)];case 1:return[2,t.sent().data||null]}}))}))),i=r.data,u=r.error;return{encounter:i,isLoading:!u&&i,error:u}};function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function w(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(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.")}()}var U=function(t){var e,r,o=t.endpointUrl,i=h((0,v.useState)(null),2),u=i[0],a=i[1],l=h((0,v.useState)(null),2),c=l[0],s=l[1],f=h((0,v.useState)(null),2),d=f[0],m=f[1],p=(0,v.useCallback)((function(t){a(!1),d&&m(null),s(t.data)}),[d]),y=(0,v.useCallback)((function(t){var e,r,n;a(!1),c&&s(null),m(null!==(n=null!==(r=null==t||null===(e=t.responseBody)||void 0===e?void 0:e.error)&&void 0!==r?r:null==t?void 0:t.responseBody)&&void 0!==n?n:t)}),[c]),b=(0,v.useCallback)((e=function(t){var e;return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(r){return a(!0),e={},[2,(0,n.openmrsFetch)(o,(e.method="POST",e.headers={"Content-Type":"application/json"},e.body=t,e)).then(p).catch(y)]}))},r=function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(t){w(i,n,o,u,a,"next",t)}function a(t){w(i,n,o,u,a,"throw",t)}u(void 0)}))},function(t){return r.apply(this,arguments)}),[o,y,p]);return{post:b,isPosting:u,result:c,error:d,reset:function(){a(null),s(null),m(null)}}},S=function(){return U({endpointUrl:"/ws/rest/v1/cohortm/cohort"})}},4439:(t,e,r)=>{r.d(e,{Z:()=>a});var n=r(1132),o=r(1672);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e,r,n,o,i,u){try{var a=t[i](u),l=a.value}catch(t){return void r(t)}a.done?e(l):Promise.resolve(l).then(n,o)}const a=function(t){var e,r,a=(e=(0,o.useState)(null),r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,r)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(e,r)||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.")}()),l=a[0],c=a[1];(0,o.useEffect)((function(){t?d(t):c(null)}),[t]);var s,f,d=(s=function(t){var e;return function(t,e){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(r){switch(r.label){case 0:return[4,(0,n.fetchCurrentPatient)(t)];case 1:return e=r.sent(),c(e),[2]}}))},f=function(){var t=this,e=arguments;return new Promise((function(r,n){var o=s.apply(t,e);function i(t){u(o,r,n,i,a,"next",t)}function a(t){u(o,r,n,i,a,"throw",t)}i(void 0)}))},function(t){return f.apply(this,arguments)});return l}},7612:(t,e,r)=>{r.d(e,{Z:()=>a});var n=r(1672),o=r(1132);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(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.")}()}const a=function(t){var e=u((0,n.useState)(!1),2),r=e[0],i=e[1],a=u((0,n.useState)(null),2),l=a[0],c=a[1],s=u((0,n.useState)(null),2),f=s[0],d=s[1],v=(0,n.useCallback)((function(t){i(!1),d(!1),c(t)}),[]),m=(0,n.useCallback)((function(t){i(!1),c(null),d(t)}),[]),p=(0,n.useCallback)((function(){(0,o.openmrsFetch)("/ws/rest/v1/systemsetting?q=".concat(t,"&v=default")).then(v).catch(m)}),[m,v,t]);return(0,n.useEffect)((function(){p()}),[p]),{result:l,error:f,isSubmitting:r}}}}]);
|