hi-profiles
Version:
React components for the ABDM Health Information Profiles
24 lines (23 loc) • 36.8 kB
JavaScript
(function(R,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],h):(R=typeof globalThis<"u"?globalThis:R||self,h(R["hi-profiles"]={},R.React))})(this,function(R,h){"use strict";var Ge=Object.defineProperty;var Xe=(R,h,D)=>h in R?Ge(R,h,{enumerable:!0,configurable:!0,writable:!0,value:D}):R[h]=D;var re=(R,h,D)=>Xe(R,typeof h!="symbol"?h+"":h,D);var D={exports:{}},$={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var oe;function he(){if(oe)return $;oe=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(e,l,s){var c=null;if(s!==void 0&&(c=""+s),l.key!==void 0&&(c=""+l.key),"key"in l){s={};for(var d in l)d!=="key"&&(s[d]=l[d])}else s=l;return l=s.ref,{$$typeof:n,type:e,key:c,ref:l!==void 0?l:null,props:s}}return $.Fragment=t,$.jsx=i,$.jsxs=i,$}var I={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ce;function ye(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&function(){function n(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===ae?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case O:return"Fragment";case J:return"Profiler";case Z:return"StrictMode";case K:return"Suspense";case ee:return"SuspenseList";case ne:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case C:return"Portal";case X:return(r.displayName||"Context")+".Provider";case G:return(r._context.displayName||"Context")+".Consumer";case Q:var m=r.render;return r=r.displayName,r||(r=m.displayName||m.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case te:return m=r.displayName||null,m!==null?m:n(r.type)||"Memo";case M:m=r._payload,r=r._init;try{return n(r(m))}catch{}}return null}function t(r){return""+r}function i(r){try{t(r);var m=!1}catch{m=!0}if(m){m=console;var g=m.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return g.call(m,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),t(r)}}function e(r){if(r===O)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===M)return"<...>";try{var m=n(r);return m?"<"+m+">":"<...>"}catch{return"<...>"}}function l(){var r=T.A;return r===null?null:r.getOwner()}function s(){return Error("react-stack-top-frame")}function c(r){if(z.call(r,"key")){var m=Object.getOwnPropertyDescriptor(r,"key").get;if(m&&m.isReactWarning)return!1}return r.key!==void 0}function d(r,m){function g(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",m))}g.isReactWarning=!0,Object.defineProperty(r,"key",{get:g,configurable:!0})}function o(){var r=n(this.type);return V[r]||(V[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function u(r,m,g,y,w,A,_,k){return g=A.ref,r={$$typeof:b,type:r,key:m,props:A,_owner:w},(g!==void 0?g:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:o}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:k}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function p(r,m,g,y,w,A,_,k){var N=m.children;if(N!==void 0)if(y)if(ie(N)){for(y=0;y<N.length;y++)f(N[y]);Object.freeze&&Object.freeze(N)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(N);if(z.call(m,"key")){N=n(r);var B=Object.keys(m).filter(function(Je){return Je!=="key"});y=0<B.length?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}",H[N+y]||(B=0<B.length?"{"+B.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,y,N,B,N),H[N+y]=!0)}if(N=null,g!==void 0&&(i(g),N=""+g),c(m)&&(i(m.key),N=""+m.key),"key"in m){g={};for(var se in m)se!=="key"&&(g[se]=m[se])}else g=m;return N&&d(g,typeof r=="function"?r.displayName||r.name||"Unknown":r),u(r,N,A,w,l(),g,_,k)}function f(r){typeof r=="object"&&r!==null&&r.$$typeof===b&&r._store&&(r._store.validated=1)}var v=h,b=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),X=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),ae=Symbol.for("react.client.reference"),T=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,ie=Array.isArray,E=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(r){return r()}};var U,V={},Y=v["react-stack-bottom-frame"].bind(v,s)(),F=E(e(s)),H={};I.Fragment=O,I.jsx=function(r,m,g,y,w){var A=1e4>T.recentlyCreatedOwnerStacks++;return p(r,m,g,!1,y,w,A?Error("react-stack-top-frame"):Y,A?E(e(r)):F)},I.jsxs=function(r,m,g,y,w){var A=1e4>T.recentlyCreatedOwnerStacks++;return p(r,m,g,!0,y,w,A?Error("react-stack-top-frame"):Y,A?E(e(r)):F)}}()),I}var de;function je(){return de||(de=1,process.env.NODE_ENV==="production"?D.exports=he():D.exports=ye()),D.exports}var a=je();class ve{constructor(t){re(this,"_bundle");re(this,"_composition");re(this,"_entries");this._bundle=t,this._composition=this.composition,this._entries=this.entries}get bundle(){return this._bundle}get composition(){var t,i;if(!this._composition){const e=(i=(t=this.bundle.entry)==null?void 0:t.find(l=>{var s;return((s=l.resource)==null?void 0:s.resourceType.toLowerCase())==="composition"}))==null?void 0:i.resource;if(!e)throw new Error("No composition found in bundle");this._composition=e}return this._composition}get entries(){return this._entries||(this._entries=this.bundle.entry??[]),this._entries}get details(){var t,i;return{title:this.composition.title,date:this.composition.date??((t=this.composition.meta)==null?void 0:t.lastUpdated)??this.bundle.timestamp,authors:(i=this.composition.author)==null?void 0:i.map(e=>this.getResource(e.reference)).filter(e=>e),status:this.composition.status}}parseHumanName(t){return t?[t.prefix??"",t.text??[t.given??"",t.family??""].join(" ").trim(),t.suffix??""].join(" ").trim():""}getAuthorName(t){var i,e,l,s;if(!t)return null;switch(t.resourceType){case"Patient":return this.parseHumanName((i=t.name)==null?void 0:i[0]);case"Practitioner":return this.parseHumanName((e=t.name)==null?void 0:e[0]);case"PractitionerRole":return`${(l=t.practitioner)==null?void 0:l.display}`;case"Organization":return`${t.name}`;case"Device":return`${t.deviceName}`;case"RelatedPerson":return this.parseHumanName((s=t.name)==null?void 0:s[0]);default:return""}}getConceptDisplay(t){if(!t)return null;if(t.text)return t.text;if(t.coding)for(const i of t.coding){const e=this.getCodingDisplay(i);if(e)return e}return""}getCodingDisplay(t){return t.display??t.code??""}getObservationValue(t){var i,e,l,s,c,d,o,u,p,f,v,b,C,O,Z,J,G,X,Q,K,ee,te,M,ne,ae,T,z,ie,E,U,V,Y,F,H,r,m,g,y,w,A,_,k;return"valueString"in t?t.valueString??"":"valueQuantity"in t?((e=(i=t.valueQuantity)==null?void 0:i.value)==null?void 0:e.toString())+" "+((l=t.valueQuantity)==null?void 0:l.unit):"valueCodeableConcept"in t?this.getConceptDisplay(t.valueCodeableConcept)??"":"valueBoolean"in t?((s=t.valueBoolean)==null?void 0:s.toString())??"":"valueInteger"in t?((c=t.valueInteger)==null?void 0:c.toString())??"":"valueDateTime"in t?((d=t.valueDateTime)==null?void 0:d.toString())??"":"valueTime"in t?((o=t.valueTime)==null?void 0:o.toString())??"":"valueRange"in t?((f=(p=(u=t.valueRange)==null?void 0:u.low)==null?void 0:p.value)==null?void 0:f.toString())??" "+((b=(v=t.valueRange)==null?void 0:v.low)==null?void 0:b.unit)??" - "+((Z=(O=(C=t.valueRange)==null?void 0:C.high)==null?void 0:O.value)==null?void 0:Z.toString())??" "+((G=(J=t.valueRange)==null?void 0:J.high)==null?void 0:G.unit)??"":"valueRatio"in t?((K=(Q=(X=t.valueRatio)==null?void 0:X.numerator)==null?void 0:Q.value)==null?void 0:K.toString())??" "+((te=(ee=t.valueRatio)==null?void 0:ee.numerator)==null?void 0:te.unit)??" : "+((ae=(ne=(M=t.valueRatio)==null?void 0:M.denominator)==null?void 0:ne.value)==null?void 0:ae.toString())??" "+((z=(T=t.valueRatio)==null?void 0:T.denominator)==null?void 0:z.unit)??"":"valueSampledData"in t?((U=(E=(ie=t.valueSampledData)==null?void 0:ie.origin)==null?void 0:E.value)==null?void 0:U.toString())??" "+((Y=(V=t.valueSampledData)==null?void 0:V.origin)==null?void 0:Y.unit)??" : "+((H=(F=t.valueSampledData)==null?void 0:F.period)==null?void 0:H.toString())??" "+((m=(r=t.valueSampledData)==null?void 0:r.dimensions)==null?void 0:m.toString())??" "+((y=(g=t.valueSampledData)==null?void 0:g.data)==null?void 0:y.toString())??"":"valuePeriod"in t?((A=(w=t.valuePeriod)==null?void 0:w.start)==null?void 0:A.toString())??" "+((k=(_=t.valuePeriod)==null?void 0:_.end)==null?void 0:k.toString())??"":""}getResource(t){var i;return t?((i=this.entries.find(e=>e.fullUrl===t))==null?void 0:i.resource)??null:null}get encounter(){var t;return this.getResource((t=this.composition.encounter)==null?void 0:t.reference)??null}}const le=h.createContext({profile:null});function j(){if(!h.useContext(le))throw new Error("useProfile must be used within a ProfileProvider");return h.useContext(le)}function Ne({bundle:n,downloadable:t,children:i}){return a.jsx(le.Provider,{value:{profile:new ve(n),downloadable:t},children:i})}var me={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ue=h.createContext&&h.createContext(me),be=["attr","size","title"];function Re(n,t){if(n==null)return{};var i=Ae(n,t),e,l;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(l=0;l<s.length;l++)e=s[l],!(t.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(n,e)&&(i[e]=n[e])}return i}function Ae(n,t){if(n==null)return{};var i={};for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)){if(t.indexOf(e)>=0)continue;i[e]=n[e]}return i}function W(){return W=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(n[e]=i[e])}return n},W.apply(this,arguments)}function pe(n,t){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);t&&(e=e.filter(function(l){return Object.getOwnPropertyDescriptor(n,l).enumerable})),i.push.apply(i,e)}return i}function q(n){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?pe(Object(i),!0).forEach(function(e){we(n,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):pe(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}function we(n,t,i){return t=Ce(t),t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i,n}function Ce(n){var t=De(n,"string");return typeof t=="symbol"?t:t+""}function De(n,t){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var e=i.call(n,t);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function fe(n){return n&&n.map((t,i)=>h.createElement(t.tag,q({key:i},t.attr),fe(t.child)))}function L(n){return t=>h.createElement(Se,W({attr:q({},n.attr)},t),fe(n.child))}function Se(n){var t=i=>{var{attr:e,size:l,title:s}=n,c=Re(n,be),d=l||i.size||"1em",o;return i.className&&(o=i.className),n.className&&(o=(o?o+" ":"")+n.className),h.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,e,c,{className:o,style:q(q({color:n.color||i.color},i.style),n.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),s&&h.createElement("title",null,s),n.children)};return ue!==void 0?h.createElement(ue.Consumer,null,i=>t(i)):t(me)}function Pe(n){return L({attr:{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M12 2.25a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V3a.75.75 0 0 1 .75-.75Zm-9 13.5a.75.75 0 0 1 .75.75v2.25a1.5 1.5 0 0 0 1.5 1.5h13.5a1.5 1.5 0 0 0 1.5-1.5V16.5a.75.75 0 0 1 1.5 0v2.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V16.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"},child:[]}]})(n)}function Oe(n){return L({attr:{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M6.75 2.25A.75.75 0 0 1 7.5 3v1.5h9V3A.75.75 0 0 1 18 3v1.5h.75a3 3 0 0 1 3 3v11.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V7.5a3 3 0 0 1 3-3H6V3a.75.75 0 0 1 .75-.75Zm13.5 9a1.5 1.5 0 0 0-1.5-1.5H5.25a1.5 1.5 0 0 0-1.5 1.5v7.5a1.5 1.5 0 0 0 1.5 1.5h13.5a1.5 1.5 0 0 0 1.5-1.5v-7.5Z",clipRule:"evenodd"},child:[]}]})(n)}function ge(n){return L({attr:{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M18.97 3.659a2.25 2.25 0 0 0-3.182 0l-10.94 10.94a3.75 3.75 0 1 0 5.304 5.303l7.693-7.693a.75.75 0 0 1 1.06 1.06l-7.693 7.693a5.25 5.25 0 1 1-7.424-7.424l10.939-10.94a3.75 3.75 0 1 1 5.303 5.304L9.097 18.835l-.008.008-.007.007-.002.002-.003.002A2.25 2.25 0 0 1 5.91 15.66l7.81-7.81a.75.75 0 0 1 1.061 1.06l-7.81 7.81a.75.75 0 0 0 1.054 1.068L18.97 6.84a2.25 2.25 0 0 0 0-3.182Z",clipRule:"evenodd"},child:[]}]})(n)}function Te(n){return L({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"},child:[]}]})(n)}function Ee(n){return L({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M15.621 4.379a3 3 0 0 0-4.242 0l-7 7a3 3 0 0 0 4.241 4.243h.001l.497-.5a.75.75 0 0 1 1.064 1.057l-.498.501-.002.002a4.5 4.5 0 0 1-6.364-6.364l7-7a4.5 4.5 0 0 1 6.368 6.36l-3.455 3.553A2.625 2.625 0 1 1 9.52 9.52l3.45-3.451a.75.75 0 1 1 1.061 1.06l-3.45 3.451a1.125 1.125 0 0 0 1.587 1.595l3.454-3.553a3 3 0 0 0 0-4.242Z",clipRule:"evenodd"},child:[]}]})(n)}function P(...n){return n.filter(Boolean).join(" ")}function x(n,t=!1){return n?new Date(n).toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric",...t&&{hour:"numeric",minute:"numeric",hour12:!0}}):null}function _e(){const{profile:n,downloadable:t}=j(),{title:i,authors:e,date:l,status:s}=n.details;return a.jsxs(a.Fragment,{children:[a.jsx("h2",{className:"text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight",children:i}),a.jsxs("div",{className:"flex items-end justify-between",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsxs("div",{className:"mt-1 flex flex-col sm:mt-0 sm:flex-row sm:flex-wrap sm:gap-x-6",children:[a.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500",children:[a.jsx(Te,{className:"mr-1.5 h-5 w-5 shrink-0 text-gray-400","aria-hidden":"true"}),a.jsx("p",{className:"flex items-center gap-2",children:e==null?void 0:e.map((c,d)=>a.jsxs("span",{className:"cursor-pointer hover:text-gray-700",children:[n.getAuthorName(c)," ",d<e.length-1&&"•"]}))})]}),a.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500",children:[a.jsx(Ee,{className:"mr-1.5 h-5 w-5 shrink-0 text-gray-400","aria-hidden":"true"}),s]}),a.jsxs("div",{className:"mt-2 flex items-center text-sm text-gray-500",children:[a.jsx(Oe,{className:"mr-1.5 h-5 w-5 shrink-0 text-gray-400","aria-hidden":"true"}),x(l)]})]})}),t&&a.jsx("div",{className:"flex lg:ml-4",children:a.jsx("span",{children:a.jsxs("button",{type:"button",onClick:()=>{const c=new Blob([JSON.stringify(n.bundle)],{type:"application/json"}),d=URL.createObjectURL(c),o=document.createElement("a");o.href=d,o.download="bundle.json",o.click()},className:"inline-flex items-center rounded-md bg-white px-3 py-2 text-xs font-semibold text-gray-900 shadow-xs ring-1 ring-inset ring-gray-300 hover:bg-gray-50",children:[a.jsx(Pe,{className:"-ml-0.5 mr-1.5 h-4 w-4","aria-hidden":"true"}),"Download Raw FHIR Bundle"]})})})]})]})}function S({heads:n,rows:t,className:i}){return a.jsx("div",{className:P("-mx-4 mt-10 overflow-x-auto ring-1 ring-gray-300 sm:mx-0 sm:rounded-lg",i),children:a.jsxs("table",{className:"min-w-full divide-y divide-gray-300",children:[a.jsx("thead",{children:a.jsx("tr",{children:n.map(e=>a.jsx("th",{scope:"col",className:"py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6",children:e}))})}),a.jsx("tbody",{children:t.map((e,l)=>a.jsx("tr",{children:e.map((s,c)=>a.jsx("td",{className:P(l===0?"":"border-t border-gray-200","px-3 py-3.5 text-sm text-gray-500 lg:table-cell"),children:s},c))},l))})]})})}function xe({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="Observation").map(e=>{var l,s;return[e.effectiveDateTime?x(e.effectiveDateTime,!0):null,t.getConceptDisplay(e.code),a.jsxs("p",{children:[t.getObservationValue(e),a.jsx("p",{className:"flex flex-col gap-1",children:(l=e.component)==null?void 0:l.map(c=>a.jsxs("span",{children:[t.getConceptDisplay(c.code)," :"," ",t.getObservationValue(c)]}))})]}),[e.status,(s=e.interpretation)==null?void 0:s[0].text].filter(Boolean).join(" - ")]});return a.jsx(S,{heads:["Date","Observation","Value","Status & Interpretation"],rows:i})}function ke({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="Immunization").map(e=>{var l,s,c,d;return[e.occurrenceDateTime?x(e.occurrenceDateTime):"NA",t.getConceptDisplay(e.vaccineCode),e.lotNumber??"NA",e.route?t.getConceptDisplay(e.route):"NA",t.getResource((l=e.manufacturer)==null?void 0:l.reference).name??"NA",((s=e.protocolApplied)==null?void 0:s[0].doseNumberPositiveInt)??((c=e.protocolApplied)==null?void 0:c[0].doseNumberString)??"NA",((d=e.reasonCode)==null?void 0:d.map(o=>t.getConceptDisplay(o)).join(", "))??"NA",e.status]});return a.jsx(S,{heads:["Date","Vaccine","Lot Number","Route","Manufacturer","Dose","Reason","Status"],rows:i})}function Be({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="MedicationRequest").map(e=>{var l,s,c,d,o,u;return[e.authoredOn?x(e.authoredOn):"NA",t.getConceptDisplay((s=t.getResource((l=e.medicationReference)==null?void 0:l.reference))==null?void 0:s.code)??t.getConceptDisplay(e.medicationCodeableConcept)??"NA",((c=e.dosageInstruction)==null?void 0:c.map(p=>{var f;return[p.text,...((f=p.additionalInstruction)==null?void 0:f.map(v=>t.getConceptDisplay(v)))??[]]}).filter(Boolean).join(", "))||"NA",[...((d=e.reasonReference)==null?void 0:d.map(p=>t.getConceptDisplay(t.getResource(p.reference).code)))??[],...((o=e.reasonCode)==null?void 0:o.map(p=>t.getConceptDisplay(p)))??[]].filter(Boolean).join(", ")||"NA",e.status,[...((u=e.note)==null?void 0:u.map(p=>p.text))??[],e.priority&&`Priority: ${e.priority}`].filter(Boolean).join(", ")||"NA"]});return a.jsx(S,{heads:["Date","Medication","Dose","Reason","Status","Additional Info"],rows:i})}function $e({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="Condition").map(e=>{var l,s,c,d;return[e.recordedDate?x(e.recordedDate):"NA",t.getConceptDisplay(e.code)??"NA",((l=e.category)==null?void 0:l.map(o=>t.getConceptDisplay(o)).filter(Boolean).join(", "))||"NA",t.getConceptDisplay(e.severity)??"NA",[`Clinical Status: ${t.getConceptDisplay(e.clinicalStatus)}`,`Verification Status: ${t.getConceptDisplay(e.verificationStatus)}`].join(", "),[e.onsetDateTime?`Onset: ${x(e.onsetDateTime)??"NA"}`:"",e.onsetAge?`Onset: ${e.onsetAge.value??"NA"} ${e.onsetAge.unit}`:"",e.onsetPeriod?`Onset: ${x(e.onsetPeriod.start)??"NA"} - ${x(e.onsetPeriod.end)??"NA"}`:"",e.onsetRange?`Onset: ${((s=e.onsetRange.low)==null?void 0:s.value)??"NA"} - ${((c=e.onsetRange.high)==null?void 0:c.value)??"NA"}`:"",e.onsetString?`Onset: ${e.onsetString??"NA"}`:"",...((d=e.note)==null?void 0:d.map(o=>o.text))??[]].filter(Boolean).join(", ")||"NA"]});return a.jsx(S,{heads:["Date","Condition","Category","Severity","Status","Additional Info"],rows:i})}function Ie({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="AllergyIntolerance").map(e=>{var l;return[e.recordedDate?x(e.recordedDate):"NA",t.getConceptDisplay(e.code)??"NA",[`Clinical Status: ${t.getConceptDisplay(e.clinicalStatus)}`,`Verification Status: ${t.getConceptDisplay(e.verificationStatus)}`].join(", "),[...((l=e.note)==null?void 0:l.map(s=>s.text))??[]].filter(Boolean).join(", ")]});return a.jsx(S,{heads:["Date","Allergy","Status","Additional Info"],rows:i})}function Le({document:n}){var e,l,s,c,d;const{profile:t}=j(),i=[{label:"Authors",value:(e=n.author)==null?void 0:e.map(o=>t.getAuthorName(t.getResource(o.reference))).filter(Boolean).join(", ")},{label:"Date",value:x(n.date)},{label:"Description",value:n.description},{label:"Status",value:n.status},{label:"Document Status",value:n.docStatus},{label:"Context",value:((s=(l=n.context)==null?void 0:l.encounter)==null?void 0:s.map(o=>o.display).filter(Boolean).join(", "))||((d=(c=n.context)==null?void 0:c.encounter)==null?void 0:d.map(o=>{var u,p;return(p=(u=t.getResource(o.reference))==null?void 0:u.type)==null?void 0:p.map(f=>t.getConceptDisplay(f)).filter(Boolean).join("; ")}).filter(Boolean).join(", "))||"NA"}];return a.jsxs("div",{className:"",children:[a.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:i.map(o=>o.value?a.jsxs("div",{className:"px-4 py-4 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:o.label}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:o.value})]}):null)}),a.jsxs("div",{className:"px-4 py-4 sm:col-span-2 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Attachments"}),a.jsx("dd",{className:"mt-2 text-sm text-gray-900",children:a.jsx("ul",{role:"list",className:"divide-y divide-gray-100 rounded-md border border-gray-200",children:n.content.map(o=>{var u,p,f,v,b,C;return a.jsxs("li",{className:"flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6",children:[a.jsxs("div",{className:"flex w-0 flex-1 items-center",children:[a.jsx(ge,{className:"h-5 w-5 shrink-0 text-gray-400","aria-hidden":"true"}),a.jsxs("div",{className:"ml-4 flex min-w-0 flex-1 gap-2",children:[a.jsx("span",{className:"truncate font-medium",children:((u=o.attachment)==null?void 0:u.title)??"Link to document"}),((p=o.attachment)==null?void 0:p.size)&&a.jsxs("span",{className:"shrink-0 text-gray-400",children:[((f=o.attachment)==null?void 0:f.size)/1e3," KB"]})]})]}),a.jsx("div",{className:"ml-4 shrink-0",children:a.jsx("a",{href:((v=o.attachment)==null?void 0:v.url)??URL.createObjectURL(new Blob([atob(((b=o.attachment)==null?void 0:b.data)??"")],{type:((C=o.attachment)==null?void 0:C.contentType)??"application/octet-stream"}))??"#",className:"font-medium text-indigo-600 hover:text-indigo-500",children:"Download"})})]})})})})]})]})}function Me({references:n,className:t}){const{profile:i}=j();if(n.length===0)return null;const e=n.map(l=>i.getResource(l.reference)).filter(l=>l&&(l==null?void 0:l.resourceType)==="DocumentReference");return a.jsx("div",{className:P("-mx-4 mt-10 ring-1 ring-gray-300 sm:mx-0 sm:rounded-lg p-6 min-w-full divide-y divide-gray-300",t),children:e.map((l,s)=>a.jsx(Le,{document:l},s))})}function ze({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="Procedure").map(e=>{var l,s,c,d,o,u,p;return[x(e.performedDateTime)??(e.performedAge&&`${e.performedAge.value??"NA"} ${(l=e.performedAge)==null?void 0:l.unit}`)??(e.performedPeriod&&`${x(e.performedPeriod.start)??"NA"} - ${x(e.performedPeriod.end)??"NA"}`)??(e.performedRange&&`${((s=e.performedRange.low)==null?void 0:s.value)??"NA"} - ${((c=e.performedRange.high)==null?void 0:c.value)??"NA"}`)??(e.performedString&&`${e.performedString??"NA"}`)??"NA",t.getConceptDisplay(e.code)??"NA",t.getConceptDisplay(e.category)??"NA",[e.status,t.getConceptDisplay(e.statusReason)].filter(Boolean).join(" - ")||"NA",t.getConceptDisplay(e.outcome)??"NA",[e.performer&&("Performer: "+((d=e.performer)==null?void 0:d.map(f=>t.getAuthorName(t.getResource(f.actor.reference))+(f.function?`(${t.getConceptDisplay(f.function)})`:"")).filter(Boolean).join(", "))||"NA"),e.reasonCode&&("Reason: "+((o=e.reasonCode)==null?void 0:o.map(f=>t.getConceptDisplay(f)).filter(Boolean).join(", "))||"NA"),e.bodySite&&("Body Site: "+((u=e.bodySite)==null?void 0:u.map(f=>t.getConceptDisplay(f)).filter(Boolean).join(", "))||"NA"),e.complication&&("Complication: "+((p=e.complication)==null?void 0:p.map(f=>t.getConceptDisplay(f)).filter(Boolean).join(", "))||"NA")].filter(Boolean).join(", ")||"NA"]});return a.jsx(S,{heads:["Date","Procedure","Category","Status","Outcome","Additional Info"],rows:i})}function Ue({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="Appointment").map(e=>{var l,s,c,d,o;return[[x(e.start,!0),x(e.end,!0)].filter(Boolean).join(" - ")||"NA",[e.text,e.description,...((l=e.serviceCategory)==null?void 0:l.map(u=>t.getConceptDisplay(u)))??[],...((s=e.serviceType)==null?void 0:s.map(u=>t.getConceptDisplay(u)))??[],...((c=e.specialty)==null?void 0:c.map(u=>t.getConceptDisplay(u)))??[],t.getConceptDisplay(e.appointmentType),...((d=e.reasonCode)==null?void 0:d.map(u=>t.getConceptDisplay(u)))??[]].filter(Boolean).join(", ")||"NA",[e.status,t.getConceptDisplay(e.cancelationReason)].filter(Boolean).join(" - ")||"NA",[e.priority&&`Priority: ${e.priority}`,e.created&&`Created On: ${x(e.created)}`,e.comment,e.patientInstruction,"Participants: "+((o=e.participant)==null?void 0:o.map(u=>{var p;return t.getAuthorName(t.getResource((p=u.actor)==null?void 0:p.reference))+(u.status?` (${u.status})`:"")}).filter(Boolean).join(", "))].filter(Boolean).join(", ")||"NA"]});return a.jsx(S,{heads:["Time","Appointment","Status","Additional Info"],rows:i})}function Ve({references:n}){const{profile:t}=j();if(n.length===0)return null;const i=n.map(e=>t.getResource(e.reference)).filter(e=>e&&(e==null?void 0:e.resourceType)==="CarePlan").map(e=>{var l,s,c;return[(e.period&&`${x(e.period.start)??"NA"} - ${x(e.period.end)??"NA"}`)??"NA",[e.title,e.description,e.text].filter(Boolean).join(", ")||"NA",t.getAuthorName(t.getResource((l=e.author)==null?void 0:l.reference))??"NA",`${e.status} - ${e.intent}`,((s=e.category)==null?void 0:s.map(d=>t.getConceptDisplay(d)).filter(Boolean).join(", "))||"NA",[e.created&&`Created On: ${x(e.created)}`,...((c=e.note)==null?void 0:c.map(d=>d.text))??[]].filter(Boolean).join(", ")||"NA"]});return a.jsx(S,{heads:["Period","Care Plan","Author","Status - Intent","Categories","Additional Info"],rows:i})}function Ye({report:n}){var e,l,s,c,d;const{profile:t}=j(),i=[{label:"Date",value:x(n.effectiveDateTime)??[x((e=n.effectivePeriod)==null?void 0:e.start),x((l=n.effectivePeriod)==null?void 0:l.end)].filter(Boolean).join(" - ")},{label:"Status",value:n.status},{label:"Categories",value:(s=n.category)==null?void 0:s.map(o=>t.getConceptDisplay(o)).filter(Boolean).join(", ")},{label:"Conclusion",value:n.conclusion},{label:"Performers",value:(c=n.performer)==null?void 0:c.map(o=>t.getAuthorName(t.getResource(o.reference))).filter(Boolean).join(", ")},{label:"Interpreters",value:(d=n.resultsInterpreter)==null?void 0:d.map(o=>t.getAuthorName(t.getResource(o.reference))).filter(Boolean).join(", ")}];return a.jsxs("div",{className:"",children:[a.jsxs("div",{className:"px-4 py-6 sm:px-6",children:[a.jsx("h3",{className:"text-base font-semibold leading-7 text-gray-900",children:t.getConceptDisplay(n.code)}),n.text&&a.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-6 text-gray-500",children:n.text.div})]}),a.jsx("dl",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:i.map(o=>o.value?a.jsxs("div",{className:"px-4 py-4 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:o.label}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:o.value})]}):null)}),a.jsxs("div",{className:"px-4 py-4 sm:col-span-2 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Results"}),a.jsx("dd",{className:"mt-2 text-sm text-gray-900",children:a.jsx(xe,{references:n.result??[]})})]}),n.presentedForm&&a.jsxs("div",{className:"px-4 py-4 sm:col-span-2 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Attachments"}),a.jsx("dd",{className:"mt-2 text-sm text-gray-900",children:a.jsx("ul",{role:"list",className:"divide-y divide-gray-100 rounded-md border border-gray-200",children:n.presentedForm.map(o=>a.jsxs("li",{className:"flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6",children:[a.jsxs("div",{className:"flex w-0 flex-1 items-center",children:[a.jsx(ge,{className:"h-5 w-5 shrink-0 text-gray-400","aria-hidden":"true"}),a.jsxs("div",{className:"ml-4 flex min-w-0 flex-1 gap-2",children:[a.jsx("span",{className:"truncate font-medium",children:o.title??"Link to document"}),o.size&&a.jsxs("span",{className:"shrink-0 text-gray-400",children:[o.size/1e3," KB"]})]})]}),a.jsx("div",{className:"ml-4 shrink-0",children:a.jsx("a",{href:o.url??URL.createObjectURL(new Blob([atob(o.data??"")],{type:o.contentType??"application/octet-stream"}))??"#",className:"font-medium text-indigo-600 hover:text-indigo-500",children:"Download"})})]}))})})]})]})}function Fe({references:n,className:t}){const{profile:i}=j();if(n.length===0)return null;const e=n.map(l=>i.getResource(l.reference)).filter(l=>l&&(l==null?void 0:l.resourceType)==="DiagnosticReport");return a.jsx("div",{className:P("-mx-4 mt-10 ring-1 ring-gray-300 sm:mx-0 sm:rounded-lg p-6 min-w-full divide-y divide-gray-300",t),children:e.map((l,s)=>a.jsx(Ye,{report:l},s))})}function He({section:n}){var l,s,c,d;const{profile:t}=j(),e=(o=>{var p;return(p=o.entry)==null?void 0:p.reduce((f,v)=>{var C;const b=(C=t==null?void 0:t.getResource(v.reference))==null?void 0:C.resourceType;return console.log(b,v),b&&(f[b]=f[b]??[],f[b].push(v)),f},{})})(n);return a.jsxs("div",{className:"mt-6 rounded-sm shadow-sm p-4 pl-6",children:[a.jsx("div",{className:"sm:flex sm:items-center",children:a.jsxs("div",{className:"sm:flex-auto",children:[a.jsx("h1",{className:"text-base font-semibold leading-6 text-gray-900",children:n.title}),a.jsx("p",{className:"mt-2 text-sm text-gray-700",children:((s=(l=n.code)==null?void 0:l.coding)==null?void 0:s[0].display)??((d=(c=n.code)==null?void 0:c.coding)==null?void 0:d[0].code)})]})}),a.jsx(xe,{references:(e==null?void 0:e.Observation)??[]}),a.jsx(ke,{references:(e==null?void 0:e.Immunization)??[]}),a.jsx(Be,{references:(e==null?void 0:e.MedicationRequest)??[]}),a.jsx($e,{references:(e==null?void 0:e.Condition)??[]}),a.jsx(Ie,{references:(e==null?void 0:e.AllergyIntolerance)??[]}),a.jsx(Me,{references:(e==null?void 0:e.DocumentReference)??[]}),a.jsx(ze,{references:(e==null?void 0:e.Procedure)??[]}),a.jsx(Ue,{references:(e==null?void 0:e.Appointment)??[]}),a.jsx(Ve,{references:(e==null?void 0:e.CarePlan)??[]}),a.jsx(Fe,{references:(e==null?void 0:e.DiagnosticReport)??[]})]})}function We({className:n}){var e,l,s,c,d;const{profile:t}=j(),{encounter:i}=t;return i?a.jsxs("div",{className:P("rounded-sm shadow-sm p-4 pl-6",n),children:[a.jsxs("div",{className:"px-4 sm:px-0",children:[a.jsx("h3",{className:"text-xl font-semibold leading-7 text-gray-900",children:"Encounter Details"}),a.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-6 text-gray-500",children:"This includes the dates like admission and discharge, and some extra details."})]}),a.jsx("div",{className:"mt-6",children:a.jsxs("dl",{className:"grid grid-cols-1 sm:grid-cols-2",children:[a.jsxs("div",{className:"border-t border-gray-100 px-4 py-6 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Category"}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:i.class.display??i.class.code})]}),a.jsxs("div",{className:"border-t border-gray-100 px-4 py-6 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Status"}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:i.status})]}),a.jsxs("div",{className:"border-t border-gray-100 px-4 py-6 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Start Date"}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:(e=i.period)!=null&&e.start?x((l=i.period)==null?void 0:l.start):"Not available"})]}),a.jsxs("div",{className:"border-t border-gray-100 px-4 py-6 sm:col-span-1 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"End Date"}),a.jsx("dd",{className:"mt-1 text-sm leading-6 text-gray-700 sm:mt-2",children:(s=i.period)!=null&&s.end?x((c=i.period)==null?void 0:c.end):"Not available"})]}),((d=i.diagnosis)==null?void 0:d.length)&&a.jsxs("div",{className:"border-t border-gray-100 px-4 py-6 sm:col-span-2 sm:px-0",children:[a.jsx("dt",{className:"text-sm font-medium leading-6 text-gray-900",children:"Diagnosis"}),a.jsx("dd",{className:"mt-2 text-sm text-gray-900",children:a.jsx("ul",{role:"list",className:"divide-y divide-gray-100 rounded-md border border-gray-200",children:i.diagnosis.map(o=>{var u,p;return a.jsx("li",{className:"flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6",children:a.jsx("div",{className:"flex w-0 flex-1 items-center",children:a.jsxs("span",{className:"truncate font-medium",children:[((u=o.condition)==null?void 0:u.display)??((p=o.condition)==null?void 0:p.reference)," "]})})})})})})]})]})})]}):a.jsx("p",{className:P("text-gray-400 p-4 pl-6",n),children:"No Encounter Found"})}function qe(){var i;const{profile:n}=j(),{composition:t}=n;return a.jsxs("main",{className:"max-w-7xl mx-auto px-4 py-6 sm:px-6 lg:px-8 rounded-sm shadow-sm border border-gray-200 w-full flex flex-col gap-4",children:[a.jsx(_e,{}),a.jsx(We,{className:"mt-6"}),(i=t.section)==null?void 0:i.map((e,l)=>a.jsx(He,{section:e},l))]})}function Ze({bundle:n,downloadable:t}){return a.jsx(Ne,{bundle:n,downloadable:t,children:a.jsx(qe,{})})}R.HIProfile=Ze,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map