@clinicemr/esm-post-registration-redirect-app 1.0.0 → 1.1.1
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/173.js +1 -1
- package/dist/312.js +1 -0
- package/dist/802.js +1 -1
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-post-registration-redirect-app.js.buildmanifest.json +32 -10
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -0
- package/src/my-registered-patients.component.tsx +13 -5
- package/src/registration-clerk-lockdown.component.tsx +101 -0
- package/src/routes.json +7 -1
package/dist/173.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[]).push([[173],{6173(e,t,r){"use strict";r.r(t),r.d(t,{importTranslation:()=>
|
|
1
|
+
(globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[]).push([[173],{6173(e,t,r){"use strict";r.r(t),r.d(t,{importTranslation:()=>a,myRegisteredPatients:()=>p,postRegistrationRedirect:()=>d,registrationClerkLockdown:()=>l,startupApp:()=>c});var i=r(5940),n={registrationClerkRoleName:{_type:i.Type.String,_default:"Organizational: Registration Clerk",_description:"Name of the OpenMRS role that, when held by the current user, makes the post-registration page redirect to the My Registered Patients list instead of the patient chart."},registeredPatientsListPath:{_type:i.Type.String,_default:"my-registered-patients",_description:"SPA-relative path to redirect Registration Clerks to after a successful registration."},registrationEncounterTypeUuid:{_type:i.Type.String,_default:"dd528487-82a5-4082-9c72-ed246bd49591",_description:"UUID of the encounter type recorded during patient registration. Used to look up patients registered by the current user."},pageSize:{_type:i.Type.Number,_default:25,_description:"Maximum number of recent registrations to load for the My Registered Patients list."}},s="@clinicemr/esm-post-registration-redirect-app",o={featureName:"post-registration-redirect",moduleName:s},a=r(4767);function c(){(0,i.defineConfigSchema)(s,n)}var d=(0,i.getAsyncLifecycle)((function(){return Promise.all([r.e(803),r.e(343),r.e(339),r.e(918)]).then(r.bind(r,2918))}),o),p=(0,i.getAsyncLifecycle)((function(){return Promise.all([r.e(803),r.e(686),r.e(343),r.e(339),r.e(802)]).then(r.bind(r,5802))}),o),l=(0,i.getAsyncLifecycle)((function(){return Promise.all([r.e(343),r.e(312)]).then(r.bind(r,3312))}),o)},4767(e,t,r){var i={"./en.json":[4300,[300]]};function n(e){try{if(!r.o(i,e))return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}))}catch(e){return Promise.reject(e)}var t=i[e],n=t[0];return r.e(t[1][0]).then((()=>r(n)))}n.keys=()=>Object.keys(i),n.id=4767,e.exports=n}}]);
|
package/dist/312.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[]).push([[312],{3312(e,t,n){n.r(t),n.d(t,{default:()=>c});var o=n(1343),i=n(5940),a=["patient-registration","my-registered-patients","post-registration","login","logout"],r="registration-clerk-mode",s="registration-clerk-lockdown-style",d="\nbody.".concat(r,' [data-testid="appSearchIconButton"],\nbody.').concat(r,' [data-testid="appSearchBar"],\nbody.').concat(r,' [data-testid="appMenuButton"],\nbody.').concat(r,' [data-testid="offlineToolsMenuButton"],\nbody.').concat(r,' [data-testid="implementerToolsIcon"] {\n display: none !important;\n}\n');const c=function(){var e=(0,i.useSession)(),t=(0,i.useConfig)();return(0,o.useEffect)((function(){var n;if(null==e?void 0:e.user){if((null!==(n=e.user.roles)&&void 0!==n?n:[]).map((function(e){var t,n;return String(null!==(t=null!==(n=e.display)&&void 0!==n?n:e.name)&&void 0!==t?t:"")})).some((function(e){return e.trim().toLowerCase()===t.registrationClerkRoleName.trim().toLowerCase()}))){document.body.classList.add(r),function(){if(!document.getElementById(s)){var e=document.createElement("style");e.id=s,e.textContent=d,document.head.appendChild(e)}}();var o=function(){var e=(window.location.pathname.replace(/^\/openmrs\/spa\/?/,"").replace(/^\/+/,"").split("/")[0]||"").toLowerCase();e&&(a.includes(e)||(0,i.navigate)({to:"${openmrsSpaBase}/".concat(t.registeredPatientsListPath)}))};o();var c=function(){return o()};return window.addEventListener("single-spa:before-routing-event",c),window.addEventListener("popstate",c),function(){window.removeEventListener("single-spa:before-routing-event",c),window.removeEventListener("popstate",c)}}document.body.classList.remove(r)}}),[e,t.registrationClerkRoleName,t.registeredPatientsListPath]),null}}}]);
|
package/dist/802.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[]).push([[802],{7237(e,t,n){n.d(t,{A:()=>a});var r=n(935),i=n.n(r)()((function(e){return e[1]}));i.push([e.id,".-esm-post-registration-redirect__my-registered-patients__container___qhgFl{padding:1.5rem 2rem;max-width:1200px;margin:0 auto}.-esm-post-registration-redirect__my-registered-patients__title___qy2WX{margin-bottom:1rem;font-weight:600}.-esm-post-registration-redirect__my-registered-patients__emptyTile___yyuEf{padding:2rem;text-align:center}",""]),i.locals={container:"-esm-post-registration-redirect__my-registered-patients__container___qhgFl",title:"-esm-post-registration-redirect__my-registered-patients__title___qy2WX",emptyTile:"-esm-post-registration-redirect__my-registered-patients__emptyTile___yyuEf"};const a=i},5802(e,t,n){n.r(t),n.d(t,{default:()=>
|
|
1
|
+
"use strict";(globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[]).push([[802],{7237(e,t,n){n.d(t,{A:()=>a});var r=n(935),i=n.n(r)()((function(e){return e[1]}));i.push([e.id,".-esm-post-registration-redirect__my-registered-patients__container___qhgFl{padding:1.5rem 2rem;max-width:1200px;margin:0 auto}.-esm-post-registration-redirect__my-registered-patients__title___qy2WX{margin-bottom:1rem;font-weight:600}.-esm-post-registration-redirect__my-registered-patients__emptyTile___yyuEf{padding:2rem;text-align:center}",""]),i.locals={container:"-esm-post-registration-redirect__my-registered-patients__container___qhgFl",title:"-esm-post-registration-redirect__my-registered-patients__title___qy2WX",emptyTile:"-esm-post-registration-redirect__my-registered-patients__emptyTile___yyuEf"};const a=i},5802(e,t,n){n.r(t),n.d(t,{default:()=>S});var r=n(1343),i=n(2339),a=n(1123),o=n(5803),l=n(5848),s=n(5940),c=n(2591),d=n.n(c),u=n(1740),m=n.n(u),p=n(8128),g=n.n(p),y=n(855),f=n.n(y),_=n(3051),v=n.n(_),h=n(3656),b=n.n(h),O=n(7237),E={};E.styleTagTransform=b(),E.setAttributes=f(),E.insert=g().bind(null,"head"),E.domAPI=m(),E.insertStyleElement=v(),d()(O.A,E);const w=O.A&&O.A.locals?O.A.locals:void 0;function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){k(e,t,n[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const S=function(){var e,t,n,c=(0,i.useTranslation)().t,d=(0,s.useSession)(),u=(0,s.useConfig)(),m=null==d||null===(e=d.user)||void 0===e?void 0:e.uuid,p=m&&u.registrationEncounterTypeUuid?"".concat(s.restBaseUrl,"/encounter?encounterType=").concat(u.registrationEncounterTypeUuid)+"&fromdate=".concat(((t=new Date).setDate(t.getDate()-365),t.toISOString().split("T")[0]))+"&v=full&limit=".concat(Math.max(50,4*u.pageSize)):null,g=(0,a.Ay)(p,s.openmrsFetch),y=g.data,f=g.error,_=g.isLoading,v=(0,r.useMemo)((function(){var e,t,n=(null!==(e=null==y||null===(t=y.data)||void 0===t?void 0:t.results)&&void 0!==e?e:[]).filter((function(e){var t,n;return(null===(n=e.auditInfo)||void 0===n||null===(t=n.creator)||void 0===t?void 0:t.uuid)===m})),r=new Map,i=!0,a=!1,o=void 0;try{for(var l,c=n[Symbol.iterator]();!(i=(l=c.next()).done);i=!0){var d,p,g=l.value,f=r.get(g.patient.uuid);(!f||(null!==(d=g.encounterDatetime)&&void 0!==d?d:"")>(null!==(p=f.encounterDatetime)&&void 0!==p?p:""))&&r.set(g.patient.uuid,g)}}catch(e){a=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(a)throw o}}return Array.from(r.values()).sort((function(e,t){var n,r;return(null!==(n=t.encounterDatetime)&&void 0!==n?n:"").localeCompare(null!==(r=e.encounterDatetime)&&void 0!==r?r:"")})).slice(0,u.pageSize).map((function(e){var t,n,r,i,a,o,l,c=null!==(t=null===(i=e.patient.identifiers)||void 0===i?void 0:i.find((function(e){return e.preferred})))&&void 0!==t?t:null===(a=e.patient.identifiers)||void 0===a?void 0:a[0];return{id:e.patient.uuid,name:e.patient.display,identifier:null!==(n=null==c?void 0:c.identifier)&&void 0!==n?n:"—",gender:null!==(r=null===(o=e.patient.person)||void 0===o?void 0:o.gender)&&void 0!==r?r:"—",age:null!=(null===(l=e.patient.person)||void 0===l?void 0:l.age)?String(e.patient.person.age):"—",registeredOn:e.encounterDatetime?(0,s.formatDate)(new Date(e.encounterDatetime)):"—"}}))}),[y,m,u.pageSize]),h=[{key:"name",header:c("patientName","Name")},{key:"identifier",header:c("identifier","Identifier")},{key:"gender",header:c("gender","Gender")},{key:"age",header:c("age","Age")},{key:"registeredOn",header:c("registeredOn","Registered on")},{key:"actions",header:""}];return _?r.createElement("div",{className:w.container},r.createElement("h2",{className:w.title},c("myRegisteredPatients","My Registered Patients")),r.createElement(o.OOb,{headers:h,rowCount:5})):f?r.createElement("div",{className:w.container},r.createElement(o.jeF,{kind:"error",title:c("errorLoading","Could not load patients you've registered."),subtitle:String(null!==(n=null==f?void 0:f.message)&&void 0!==n?n:""),lowContrast:!0,hideCloseButton:!0})):r.createElement("div",{className:w.container},r.createElement("h2",{className:w.title},c("myRegisteredPatients","My Registered Patients")),0===v.length?r.createElement(o.FAs,{className:w.emptyTile},r.createElement("p",null,c("noPatientsRegistered","You haven't registered any patients yet."))):r.createElement(o.bQt,{rows:v,headers:h,useZebraStyles:!0},(function(e){var t=e.rows,n=e.headers,i=e.getHeaderProps,a=e.getRowProps,d=e.getTableProps;return r.createElement(o.K3K,null,r.createElement(o.XIK,d(),r.createElement(o.ndF,null,r.createElement(o.Hjg,null,n.map((function(e){return r.createElement(o.A0N,j(P({},i({header:e})),{key:e.key}),e.header)})))),r.createElement(o.BFY,null,t.map((function(e){return r.createElement(o.Hjg,j(P({},a({row:e})),{key:e.id}),e.cells.map((function(t){return"actions"===t.info.header?r.createElement(o.nA6,{key:t.id},r.createElement(o.$nd,{kind:"ghost",size:"sm",renderIcon:l.Qp,onClick:function(){return(0,s.navigate)({to:"${openmrsSpaBase}/patient/".concat(e.id,"/chart")})}},c("openChart","Open chart"))):r.createElement(o.nA6,{key:t.id},t.value)})))})))))})))}}}]);
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e,r,t,n,o={6173(e,r,t){"use strict";var n=t(5940),o={featureName:"post-registration-redirect",moduleName:(n.Type.String,n.Type.String,n.Type.String,n.Type.Number,"@clinicemr/esm-post-registration-redirect-app")};t(4767),(0,n.getAsyncLifecycle)((function(){return Promise.all([t.e(803),t.e(343),t.e(339),t.e(918)]).then(t.bind(t,2918))}),o),(0,n.getAsyncLifecycle)((function(){return Promise.all([t.e(803),t.e(686),t.e(343),t.e(339),t.e(802)]).then(t.bind(t,5802))}),o)},4767(e,r,t){var n={"./en.json":[4300,[300]]};function o(e){try{if(!t.o(n,e))return Promise.resolve().then((()=>{var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}))}catch(e){return Promise.reject(e)}var r=n[e],o=r[0];return t.e(r[1][0]).then((()=>t(o)))}o.keys=()=>Object.keys(n),o.id=4767,e.exports=o}},a={};function i(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={id:e,exports:{}};return o[e].call(t.exports,t,t.exports,i),t.exports}i.m=o,i.c=a,i.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return i.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.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 o=Object.create(null);i.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var l=2&n&&t;("object"==typeof l||"function"==typeof l)&&!~e.indexOf(l);l=r(l))Object.getOwnPropertyNames(l).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,i.d(o,a),o},i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((r,t)=>(i.f[t](e,r),r)),[])),i.u=e=>e+".js",i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@clinicemr/esm-post-registration-redirect-app:",i.l=(e,r,o,a)=>{if(t[e])t[e].push(r);else{var l,s;if(void 0!==o)for(var u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var f=u[c];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){l=f;break}}l||(s=!0,(l=document.createElement("script")).charset="utf-8",i.nc&&l.setAttribute("nonce",i.nc),l.setAttribute("data-webpack",n+o),l.src=e),t[e]=[r];var p=(r,n)=>{l.onerror=l.onload=null,clearTimeout(d);var o=t[e];if(delete t[e],l.parentNode&&l.parentNode.removeChild(l),o&&o.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=p.bind(null,l.onerror),l.onload=p.bind(null,l.onload),s&&document.head.appendChild(l)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{i.S={};var e={},r={};i.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];i.o(i.S,t)||(i.S[t]={});var a=i.S[t],l="@clinicemr/esm-post-registration-redirect-app",s=(e,r,t,n)=>{var o=a[e]=a[e]||{},i=o[r];(!i||!i.loaded&&(!n!=!i.eager?n:l>i.from))&&(o[r]={get:t,from:l,eager:!!n})},u=[];return"default"===t&&(s("@openmrs/esm-framework","9.0.3-pre.4643",(()=>Promise.all([i.e(803),i.e(686),i.e(777),i.e(343),i.e(339),i.e(277)]).then((()=>()=>i(1777))))),s("dayjs","1.11.13",(()=>i.e(464).then((()=>()=>i(3464))))),s("react-i18next","16.0.0",(()=>Promise.all([i.e(336),i.e(343)]).then((()=>()=>i(6336))))),s("react-router-dom","6.16.0",(()=>Promise.all([i.e(913),i.e(343)]).then((()=>()=>i(2913))))),s("react","18.3.1",(()=>i.e(41).then((()=>()=>i(4041))))),s("rxjs","6.6.7",(()=>i.e(457).then((()=>()=>i(2457)))))),e[t]=u.length?Promise.all(u).then((()=>e[t]=1)):1}}})(),(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var r=globalThis.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(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e=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},r=e=>{var t=e[0],n="";if(1===e.length)return"*";if(t+.5){n+=0==t?">=":-1==t?"<":1==t?"^":2==t?"~":t>0?"=":"!=";for(var o=1,a=1;a<e.length;a++)o--,n+="u"==(typeof(l=e[a]))[0]?"-":(o>0?".":"")+(o=2,l);return n}var i=[];for(a=1;a<e.length;a++){var l=e[a];i.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?i.pop()+" "+i.pop():r(l))}return s();function s(){return i.pop().replace(/^\((.+)\)$/,"$1")}},t=(r,n)=>{if(0 in r){n=e(n);var o=r[0],a=o<0;a&&(o=-o-1);for(var i=0,l=1,s=!0;;l++,i++){var u,c,f=l<r.length?(typeof r[l])[0]:"";if(i>=n.length||"o"==(c=(typeof(u=n[i]))[0]))return!s||("u"==f?l>o&&!a:""==f!=a);if("u"==c){if(!s||"u"!=f)return!1}else if(s)if(f==c)if(l<=o){if(u!=r[l])return!1}else{if(a?u>r[l]:u<r[l])return!1;u!=r[l]&&(s=!1)}else if("s"!=f&&"n"!=f){if(a||l<=o)return!1;s=!1,l--}else{if(l<=o||c<f!=a)return!1;s=!1}else"s"!=f&&"n"!=f&&(s=!1,l--)}}var p=[],d=p.pop.bind(p);for(i=1;i<r.length;i++){var h=r[i];p.push(1==h?d()|d():2==h?d()&d():h?t(h,n):!d())}return!!d()},n=(r,t,n)=>{var o=n?(e=>Object.keys(e).reduce(((r,t)=>(e[t].eager&&(r[t]=e[t]),r)),{}))(r[t]):r[t];return Object.keys(o).reduce(((r,t)=>!r||!o[r].loaded&&((r,t)=>{r=e(r),t=e(t);for(var n=0;;){if(n>=r.length)return n<t.length&&"u"!=(typeof t[n])[0];var o=r[n],a=(typeof o)[0];if(n>=t.length)return"u"==a;var i=t[n],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&o!=i)return o<i;n++}})(r,t)?t:r),0)},o=(e,r,t)=>t?t():((e,r)=>(e=>{throw new Error(e)})("Shared module "+r+" doesn't exist in shared scope "+e))(e,r),a=(e=>function(r,t,n,o,a){var l=i.I(r);return l&&l.then&&!n?l.then(e.bind(e,r,i.S[r],t,!1,o,a)):e(r,i.S[r],t,n,o,a)})(((e,a,l,s,u,c)=>{if(!((e,r)=>e&&i.o(e,r))(a,l))return o(e,l,c);var f,p,d=n(a,l,s);return t(u,d)||(p=((e,t,n,o)=>"Unsatisfied version "+n+" from "+(n&&e[t][n].from)+" of shared singleton module "+t+" (required "+r(o)+")")(a,l,d,u),"undefined"!=typeof console&&console.warn&&console.warn(p)),(f=a[l][d]).loaded=1,f.get()})),l={},s={5940:()=>a("default","@openmrs/esm-framework",!1,[0],(()=>Promise.all([i.e(803),i.e(686),i.e(777),i.e(343),i.e(339),i.e(277)]).then((()=>()=>i(1777))))),1343:()=>a("default","react",!1,[1,18],(()=>i.e(41).then((()=>()=>i(4041))))),2339:()=>a("default","react-i18next",!1,[1,16],(()=>i.e(336).then((()=>()=>i(6336))))),4818:()=>a("default","rxjs",!1,[1,6],(()=>i.e(457).then((()=>()=>i(2457))))),6372:()=>a("default","dayjs",!1,[1,1],(()=>i.e(464).then((()=>()=>i(3464))))),8877:()=>a("default","react-router-dom",!1,[1,6],(()=>i.e(913).then((()=>()=>i(2913)))))};[5940].forEach((e=>{i.m[e]=r=>{l[e]=0,delete i.c[e];var t=s[e]();if("function"!=typeof t)throw new Error("Shared module is not available for eager consumption: "+e);r.exports=t()}}));var u={277:[4818,6372,8877],339:[2339],343:[1343],792:[5940]},c={};i.f.consumes=(e,r)=>{i.o(u,e)&&u[e].forEach((e=>{if(i.o(l,e))return r.push(l[e]);if(!c[e]){var t=r=>{l[e]=0,i.m[e]=t=>{delete i.c[e],t.exports=r()}};c[e]=!0;var n=r=>{delete l[e],i.m[e]=t=>{throw delete i.c[e],r}};try{var o=s[e]();o.then?r.push(l[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}}))}})(),(()=>{var e={173:0,792:0};i.f.j=(r,t)=>{var n=i.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(277|339|343)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=i.p+i.u(r),l=new Error;i.l(a,(t=>{if(i.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+o+": "+a+")",l.name="ChunkLoadError",l.type=o,l.request=a,n[1](l)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,o,[a,l,s]=t,u=0;if(a.some((r=>0!==e[r]))){for(n in l)i.o(l,n)&&(i.m[n]=l[n]);s&&s(i)}for(r&&r(t);u<a.length;u++)o=a[u],i.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),i.nc=void 0,i(6173)})();
|
|
1
|
+
(()=>{var e,r,t,n,o={6173(e,r,t){"use strict";var n=t(5940),o={featureName:"post-registration-redirect",moduleName:(n.Type.String,n.Type.String,n.Type.String,n.Type.Number,"@clinicemr/esm-post-registration-redirect-app")};t(4767),(0,n.getAsyncLifecycle)((function(){return Promise.all([t.e(803),t.e(343),t.e(339),t.e(918)]).then(t.bind(t,2918))}),o),(0,n.getAsyncLifecycle)((function(){return Promise.all([t.e(803),t.e(686),t.e(343),t.e(339),t.e(802)]).then(t.bind(t,5802))}),o),(0,n.getAsyncLifecycle)((function(){return Promise.all([t.e(343),t.e(312)]).then(t.bind(t,3312))}),o)},4767(e,r,t){var n={"./en.json":[4300,[300]]};function o(e){try{if(!t.o(n,e))return Promise.resolve().then((()=>{var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}))}catch(e){return Promise.reject(e)}var r=n[e],o=r[0];return t.e(r[1][0]).then((()=>t(o)))}o.keys=()=>Object.keys(n),o.id=4767,e.exports=o}},a={};function i(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={id:e,exports:{}};return o[e].call(t.exports,t,t.exports,i),t.exports}i.m=o,i.c=a,i.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return i.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.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 o=Object.create(null);i.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var l=2&n&&t;("object"==typeof l||"function"==typeof l)&&!~e.indexOf(l);l=r(l))Object.getOwnPropertyNames(l).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,i.d(o,a),o},i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((r,t)=>(i.f[t](e,r),r)),[])),i.u=e=>e+".js",i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@clinicemr/esm-post-registration-redirect-app:",i.l=(e,r,o,a)=>{if(t[e])t[e].push(r);else{var l,s;if(void 0!==o)for(var u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var f=u[c];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){l=f;break}}l||(s=!0,(l=document.createElement("script")).charset="utf-8",i.nc&&l.setAttribute("nonce",i.nc),l.setAttribute("data-webpack",n+o),l.src=e),t[e]=[r];var p=(r,n)=>{l.onerror=l.onload=null,clearTimeout(d);var o=t[e];if(delete t[e],l.parentNode&&l.parentNode.removeChild(l),o&&o.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=p.bind(null,l.onerror),l.onload=p.bind(null,l.onload),s&&document.head.appendChild(l)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{i.S={};var e={},r={};i.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];i.o(i.S,t)||(i.S[t]={});var a=i.S[t],l="@clinicemr/esm-post-registration-redirect-app",s=(e,r,t,n)=>{var o=a[e]=a[e]||{},i=o[r];(!i||!i.loaded&&(!n!=!i.eager?n:l>i.from))&&(o[r]={get:t,from:l,eager:!!n})},u=[];return"default"===t&&(s("@openmrs/esm-framework","9.0.3-pre.4643",(()=>Promise.all([i.e(803),i.e(686),i.e(777),i.e(343),i.e(339),i.e(277)]).then((()=>()=>i(1777))))),s("dayjs","1.11.13",(()=>i.e(464).then((()=>()=>i(3464))))),s("react-i18next","16.0.0",(()=>Promise.all([i.e(336),i.e(343)]).then((()=>()=>i(6336))))),s("react-router-dom","6.16.0",(()=>Promise.all([i.e(913),i.e(343)]).then((()=>()=>i(2913))))),s("react","18.3.1",(()=>i.e(41).then((()=>()=>i(4041))))),s("rxjs","6.6.7",(()=>i.e(457).then((()=>()=>i(2457)))))),e[t]=u.length?Promise.all(u).then((()=>e[t]=1)):1}}})(),(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var r=globalThis.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(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e=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},r=e=>{var t=e[0],n="";if(1===e.length)return"*";if(t+.5){n+=0==t?">=":-1==t?"<":1==t?"^":2==t?"~":t>0?"=":"!=";for(var o=1,a=1;a<e.length;a++)o--,n+="u"==(typeof(l=e[a]))[0]?"-":(o>0?".":"")+(o=2,l);return n}var i=[];for(a=1;a<e.length;a++){var l=e[a];i.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?i.pop()+" "+i.pop():r(l))}return s();function s(){return i.pop().replace(/^\((.+)\)$/,"$1")}},t=(r,n)=>{if(0 in r){n=e(n);var o=r[0],a=o<0;a&&(o=-o-1);for(var i=0,l=1,s=!0;;l++,i++){var u,c,f=l<r.length?(typeof r[l])[0]:"";if(i>=n.length||"o"==(c=(typeof(u=n[i]))[0]))return!s||("u"==f?l>o&&!a:""==f!=a);if("u"==c){if(!s||"u"!=f)return!1}else if(s)if(f==c)if(l<=o){if(u!=r[l])return!1}else{if(a?u>r[l]:u<r[l])return!1;u!=r[l]&&(s=!1)}else if("s"!=f&&"n"!=f){if(a||l<=o)return!1;s=!1,l--}else{if(l<=o||c<f!=a)return!1;s=!1}else"s"!=f&&"n"!=f&&(s=!1,l--)}}var p=[],d=p.pop.bind(p);for(i=1;i<r.length;i++){var h=r[i];p.push(1==h?d()|d():2==h?d()&d():h?t(h,n):!d())}return!!d()},n=(r,t,n)=>{var o=n?(e=>Object.keys(e).reduce(((r,t)=>(e[t].eager&&(r[t]=e[t]),r)),{}))(r[t]):r[t];return Object.keys(o).reduce(((r,t)=>!r||!o[r].loaded&&((r,t)=>{r=e(r),t=e(t);for(var n=0;;){if(n>=r.length)return n<t.length&&"u"!=(typeof t[n])[0];var o=r[n],a=(typeof o)[0];if(n>=t.length)return"u"==a;var i=t[n],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&o!=i)return o<i;n++}})(r,t)?t:r),0)},o=(e,r,t)=>t?t():((e,r)=>(e=>{throw new Error(e)})("Shared module "+r+" doesn't exist in shared scope "+e))(e,r),a=(e=>function(r,t,n,o,a){var l=i.I(r);return l&&l.then&&!n?l.then(e.bind(e,r,i.S[r],t,!1,o,a)):e(r,i.S[r],t,n,o,a)})(((e,a,l,s,u,c)=>{if(!((e,r)=>e&&i.o(e,r))(a,l))return o(e,l,c);var f,p,d=n(a,l,s);return t(u,d)||(p=((e,t,n,o)=>"Unsatisfied version "+n+" from "+(n&&e[t][n].from)+" of shared singleton module "+t+" (required "+r(o)+")")(a,l,d,u),"undefined"!=typeof console&&console.warn&&console.warn(p)),(f=a[l][d]).loaded=1,f.get()})),l={},s={5940:()=>a("default","@openmrs/esm-framework",!1,[0],(()=>Promise.all([i.e(803),i.e(686),i.e(777),i.e(343),i.e(339),i.e(277)]).then((()=>()=>i(1777))))),1343:()=>a("default","react",!1,[1,18],(()=>i.e(41).then((()=>()=>i(4041))))),2339:()=>a("default","react-i18next",!1,[1,16],(()=>i.e(336).then((()=>()=>i(6336))))),4818:()=>a("default","rxjs",!1,[1,6],(()=>i.e(457).then((()=>()=>i(2457))))),6372:()=>a("default","dayjs",!1,[1,1],(()=>i.e(464).then((()=>()=>i(3464))))),8877:()=>a("default","react-router-dom",!1,[1,6],(()=>i.e(913).then((()=>()=>i(2913)))))};[5940].forEach((e=>{i.m[e]=r=>{l[e]=0,delete i.c[e];var t=s[e]();if("function"!=typeof t)throw new Error("Shared module is not available for eager consumption: "+e);r.exports=t()}}));var u={277:[4818,6372,8877],339:[2339],343:[1343],792:[5940]},c={};i.f.consumes=(e,r)=>{i.o(u,e)&&u[e].forEach((e=>{if(i.o(l,e))return r.push(l[e]);if(!c[e]){var t=r=>{l[e]=0,i.m[e]=t=>{delete i.c[e],t.exports=r()}};c[e]=!0;var n=r=>{delete l[e],i.m[e]=t=>{throw delete i.c[e],r}};try{var o=s[e]();o.then?r.push(l[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}}))}})(),(()=>{var e={173:0,792:0};i.f.j=(r,t)=>{var n=i.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(277|339|343)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=i.p+i.u(r),l=new Error;i.l(a,(t=>{if(i.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+o+": "+a+")",l.name="ChunkLoadError",l.type=o,l.request=a,n[1](l)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,o,[a,l,s]=t,u=0;if(a.some((r=>0!==e[r]))){for(n in l)i.o(l,n)&&(i.m[n]=l[n]);s&&s(i)}for(r&&r(t);u<a.length;u++)o=a[u],i.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app=globalThis.webpackChunk_clinicemr_esm_post_registration_redirect_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),i.nc=void 0,i(6173)})();
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"initial": false,
|
|
28
28
|
"entry": false,
|
|
29
29
|
"recorded": false,
|
|
30
|
-
"size":
|
|
30
|
+
"size": 2161,
|
|
31
31
|
"sizes": {
|
|
32
32
|
"consume-shared": 42,
|
|
33
|
-
"javascript":
|
|
33
|
+
"javascript": 2119
|
|
34
34
|
},
|
|
35
35
|
"names": [],
|
|
36
36
|
"idHints": [],
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"173.js"
|
|
42
42
|
],
|
|
43
43
|
"auxiliaryFiles": [],
|
|
44
|
-
"hash": "
|
|
44
|
+
"hash": "0dc70afbfaac35d6",
|
|
45
45
|
"childrenByOrder": {}
|
|
46
46
|
},
|
|
47
47
|
{
|
|
@@ -86,6 +86,28 @@
|
|
|
86
86
|
"hash": "c31905dc24e19f4e",
|
|
87
87
|
"childrenByOrder": {}
|
|
88
88
|
},
|
|
89
|
+
{
|
|
90
|
+
"rendered": true,
|
|
91
|
+
"initial": false,
|
|
92
|
+
"entry": false,
|
|
93
|
+
"recorded": false,
|
|
94
|
+
"size": 4108,
|
|
95
|
+
"sizes": {
|
|
96
|
+
"javascript": 4108
|
|
97
|
+
},
|
|
98
|
+
"names": [],
|
|
99
|
+
"idHints": [],
|
|
100
|
+
"runtime": [
|
|
101
|
+
"@clinicemr/esm-post-registration-redirect-app",
|
|
102
|
+
"main"
|
|
103
|
+
],
|
|
104
|
+
"files": [
|
|
105
|
+
"312.js"
|
|
106
|
+
],
|
|
107
|
+
"auxiliaryFiles": [],
|
|
108
|
+
"hash": "35b92bb1a4537de2",
|
|
109
|
+
"childrenByOrder": {}
|
|
110
|
+
},
|
|
89
111
|
{
|
|
90
112
|
"rendered": true,
|
|
91
113
|
"initial": false,
|
|
@@ -222,7 +244,7 @@
|
|
|
222
244
|
"openmrs-esm-post-registration-redirect-app.js"
|
|
223
245
|
],
|
|
224
246
|
"auxiliaryFiles": [],
|
|
225
|
-
"hash": "
|
|
247
|
+
"hash": "1e8d532e6c9c7f32",
|
|
226
248
|
"childrenByOrder": {}
|
|
227
249
|
},
|
|
228
250
|
{
|
|
@@ -280,10 +302,10 @@
|
|
|
280
302
|
"initial": true,
|
|
281
303
|
"entry": true,
|
|
282
304
|
"recorded": false,
|
|
283
|
-
"size":
|
|
305
|
+
"size": 23033,
|
|
284
306
|
"sizes": {
|
|
285
307
|
"consume-shared": 42,
|
|
286
|
-
"javascript":
|
|
308
|
+
"javascript": 2119,
|
|
287
309
|
"share-init": 252,
|
|
288
310
|
"runtime": 20620
|
|
289
311
|
},
|
|
@@ -298,7 +320,7 @@
|
|
|
298
320
|
"main.js"
|
|
299
321
|
],
|
|
300
322
|
"auxiliaryFiles": [],
|
|
301
|
-
"hash": "
|
|
323
|
+
"hash": "41d0d164ee92bcaa",
|
|
302
324
|
"childrenByOrder": {}
|
|
303
325
|
},
|
|
304
326
|
{
|
|
@@ -306,9 +328,9 @@
|
|
|
306
328
|
"initial": false,
|
|
307
329
|
"entry": false,
|
|
308
330
|
"recorded": false,
|
|
309
|
-
"size":
|
|
331
|
+
"size": 13626,
|
|
310
332
|
"sizes": {
|
|
311
|
-
"javascript":
|
|
333
|
+
"javascript": 13626
|
|
312
334
|
},
|
|
313
335
|
"names": [],
|
|
314
336
|
"idHints": [],
|
|
@@ -320,7 +342,7 @@
|
|
|
320
342
|
"802.js"
|
|
321
343
|
],
|
|
322
344
|
"auxiliaryFiles": [],
|
|
323
|
-
"hash": "
|
|
345
|
+
"hash": "19b70b63b180ffb9",
|
|
324
346
|
"childrenByOrder": {}
|
|
325
347
|
},
|
|
326
348
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"postRegistrationRedirect","route":"post-registration"},{"component":"myRegisteredPatients","route":"my-registered-patients"}],"extensions":[],"version":"1.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"postRegistrationRedirect","route":"post-registration"},{"component":"myRegisteredPatients","route":"my-registered-patients"}],"extensions":[{"name":"registration-clerk-lockdown","component":"registrationClerkLockdown","slot":"top-nav-actions-slot"}],"version":"1.1.1"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clinicemr/esm-post-registration-redirect-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Role-aware post-registration redirect for OpenMRS SSUUBO distro",
|
|
6
6
|
"browser": "dist/openmrs-esm-post-registration-redirect-app.js",
|
package/src/index.ts
CHANGED
|
@@ -23,3 +23,8 @@ export const myRegisteredPatients = getAsyncLifecycle(
|
|
|
23
23
|
() => import('./my-registered-patients.component'),
|
|
24
24
|
options,
|
|
25
25
|
);
|
|
26
|
+
|
|
27
|
+
export const registrationClerkLockdown = getAsyncLifecycle(
|
|
28
|
+
() => import('./registration-clerk-lockdown.component'),
|
|
29
|
+
options,
|
|
30
|
+
);
|
|
@@ -45,10 +45,17 @@ interface EncounterListResponse {
|
|
|
45
45
|
results: RegistrationEncounter[];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// Use the built-in `full` representation. Some OpenMRS REST builds return
|
|
49
|
+
// 500 when asked to resolve deeply-nested custom reps (particularly the
|
|
50
|
+
// `auditInfo:(creator:(...))` shape) on the encounter search endpoint.
|
|
51
|
+
// `full` always works and gives us everything we need; we filter client-side.
|
|
52
|
+
const FROM_DATE_DAYS_BACK = 365;
|
|
53
|
+
|
|
54
|
+
function isoFromDate(daysBack: number): string {
|
|
55
|
+
const d = new Date();
|
|
56
|
+
d.setDate(d.getDate() - daysBack);
|
|
57
|
+
return d.toISOString().split('T')[0];
|
|
58
|
+
}
|
|
52
59
|
|
|
53
60
|
const MyRegisteredPatients: React.FC = () => {
|
|
54
61
|
const { t } = useTranslation();
|
|
@@ -59,7 +66,8 @@ const MyRegisteredPatients: React.FC = () => {
|
|
|
59
66
|
const url =
|
|
60
67
|
currentUserUuid && config.registrationEncounterTypeUuid
|
|
61
68
|
? `${restBaseUrl}/encounter?encounterType=${config.registrationEncounterTypeUuid}` +
|
|
62
|
-
`&
|
|
69
|
+
`&fromdate=${isoFromDate(FROM_DATE_DAYS_BACK)}` +
|
|
70
|
+
`&v=full&limit=${Math.max(50, config.pageSize * 4)}`
|
|
63
71
|
: null;
|
|
64
72
|
|
|
65
73
|
const { data, error, isLoading } = useSWR<{ data: EncounterListResponse }>(url, openmrsFetch);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { navigate, useConfig, useSession } from '@openmrs/esm-framework';
|
|
3
|
+
import type { PostRegistrationRedirectConfig } from './config-schema';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Globally-mounted guard that restricts Registration Clerks to a small
|
|
7
|
+
* allow-list of pages:
|
|
8
|
+
* - /patient-registration (create a new patient)
|
|
9
|
+
* - /my-registered-patients (list of patients they've registered)
|
|
10
|
+
* - /post-registration/* (the redirect gateway they land on post-save)
|
|
11
|
+
* - /login, /logout (auth pages)
|
|
12
|
+
*
|
|
13
|
+
* If they somehow land on any other URL (typed manually, clicked a stale
|
|
14
|
+
* link, etc.) they are bounced back to /my-registered-patients.
|
|
15
|
+
*
|
|
16
|
+
* It also toggles a `registration-clerk-mode` class on <body> so CSS can
|
|
17
|
+
* hide top-nav shortcuts (search, app switcher, etc.) for this role.
|
|
18
|
+
*/
|
|
19
|
+
const ALLOWED_PATH_PREFIXES = [
|
|
20
|
+
'patient-registration',
|
|
21
|
+
'my-registered-patients',
|
|
22
|
+
'post-registration',
|
|
23
|
+
'login',
|
|
24
|
+
'logout',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const BODY_CLASS = 'registration-clerk-mode';
|
|
28
|
+
const STYLE_ELEMENT_ID = 'registration-clerk-lockdown-style';
|
|
29
|
+
|
|
30
|
+
// CSS that hides nav shortcuts. Uses broad, conservative selectors so we
|
|
31
|
+
// don't accidentally hide the user menu (needed to log out).
|
|
32
|
+
const LOCKDOWN_CSS = `
|
|
33
|
+
body.${BODY_CLASS} [data-testid="appSearchIconButton"],
|
|
34
|
+
body.${BODY_CLASS} [data-testid="appSearchBar"],
|
|
35
|
+
body.${BODY_CLASS} [data-testid="appMenuButton"],
|
|
36
|
+
body.${BODY_CLASS} [data-testid="offlineToolsMenuButton"],
|
|
37
|
+
body.${BODY_CLASS} [data-testid="implementerToolsIcon"] {
|
|
38
|
+
display: none !important;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
function ensureStyleInjected() {
|
|
43
|
+
if (document.getElementById(STYLE_ELEMENT_ID)) return;
|
|
44
|
+
const style = document.createElement('style');
|
|
45
|
+
style.id = STYLE_ELEMENT_ID;
|
|
46
|
+
style.textContent = LOCKDOWN_CSS;
|
|
47
|
+
document.head.appendChild(style);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function currentFirstPathSegment(): string {
|
|
51
|
+
const path = window.location.pathname;
|
|
52
|
+
// Strip any common OpenMRS SPA prefix like /openmrs/spa/
|
|
53
|
+
const stripped = path.replace(/^\/openmrs\/spa\/?/, '').replace(/^\/+/, '');
|
|
54
|
+
return (stripped.split('/')[0] || '').toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const RegistrationClerkLockdown: React.FC = () => {
|
|
58
|
+
const session = useSession();
|
|
59
|
+
const config = useConfig<PostRegistrationRedirectConfig>();
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!session?.user) return;
|
|
63
|
+
|
|
64
|
+
const roles: string[] = (session.user.roles ?? []).map(
|
|
65
|
+
(r: { display?: string; name?: string }) => String(r.display ?? r.name ?? ''),
|
|
66
|
+
);
|
|
67
|
+
const isClerk = roles.some(
|
|
68
|
+
(role) => role.trim().toLowerCase() === config.registrationClerkRoleName.trim().toLowerCase(),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (!isClerk) {
|
|
72
|
+
document.body.classList.remove(BODY_CLASS);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
document.body.classList.add(BODY_CLASS);
|
|
77
|
+
ensureStyleInjected();
|
|
78
|
+
|
|
79
|
+
const enforcePath = () => {
|
|
80
|
+
const first = currentFirstPathSegment();
|
|
81
|
+
if (!first) return; // landing on /openmrs/spa/ → let the home page handle it
|
|
82
|
+
if (ALLOWED_PATH_PREFIXES.includes(first)) return;
|
|
83
|
+
navigate({ to: `\${openmrsSpaBase}/${config.registeredPatientsListPath}` });
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Run once for the current URL and then on every single-spa route change.
|
|
87
|
+
enforcePath();
|
|
88
|
+
const handler = () => enforcePath();
|
|
89
|
+
window.addEventListener('single-spa:before-routing-event', handler);
|
|
90
|
+
window.addEventListener('popstate', handler);
|
|
91
|
+
|
|
92
|
+
return () => {
|
|
93
|
+
window.removeEventListener('single-spa:before-routing-event', handler);
|
|
94
|
+
window.removeEventListener('popstate', handler);
|
|
95
|
+
};
|
|
96
|
+
}, [session, config.registrationClerkRoleName, config.registeredPatientsListPath]);
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default RegistrationClerkLockdown;
|
package/src/routes.json
CHANGED