@clinicemr/esm-post-registration-redirect-app 1.1.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/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)})))})))))})))}}}]);
|
|
@@ -328,9 +328,9 @@
|
|
|
328
328
|
"initial": false,
|
|
329
329
|
"entry": false,
|
|
330
330
|
"recorded": false,
|
|
331
|
-
"size":
|
|
331
|
+
"size": 13626,
|
|
332
332
|
"sizes": {
|
|
333
|
-
"javascript":
|
|
333
|
+
"javascript": 13626
|
|
334
334
|
},
|
|
335
335
|
"names": [],
|
|
336
336
|
"idHints": [],
|
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
"802.js"
|
|
343
343
|
],
|
|
344
344
|
"auxiliaryFiles": [],
|
|
345
|
-
"hash": "
|
|
345
|
+
"hash": "19b70b63b180ffb9",
|
|
346
346
|
"childrenByOrder": {}
|
|
347
347
|
},
|
|
348
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":[{"name":"registration-clerk-lockdown","component":"registrationClerkLockdown","slot":"top-nav-actions-slot"}],"version":"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":[{"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.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",
|
|
@@ -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);
|