:root{--bg: #f5f6f4;--surface: #ffffff;--surface-2: #fafaf7;--ink: #16241f;--ink-soft: #4a5a52;--ink-faint: #7a8a82;--line: #dfe3de;--line-soft: #ecefe9;--accent: #0b3a52;--accent-soft: #d6e3eb;--positive: #2d6a4f;--warn: #b45309;--danger: #9b2c2c;--danger-soft: #fde8e8;--shadow-sm: 0 1px 2px rgba(15,30,25,.04);--shadow: 0 4px 16px rgba(15,30,25,.06);--r-sm: 6px;--r: 10px;--r-lg: 16px;--font-sans: ui-sans-serif, -apple-system, "SF Pro Text", "Inter", system-ui, sans-serif;--font-display: "Fraunces", Georgia, "Times New Roman", serif;--font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace}*{box-sizing:border-box}html,body,#root{margin:0;padding:0;height:100%;background:var(--bg);color:var(--ink);font-family:var(--font-sans);font-size:15px;line-height:1.45;-webkit-font-smoothing:antialiased}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}input,button,textarea,select{font:inherit;color:inherit}button{cursor:pointer;border:1px solid var(--line);background:var(--surface);border-radius:var(--r-sm);padding:7px 14px;transition:background .15s,border-color .15s}button:hover{background:var(--surface-2)}button.primary{background:var(--accent);color:#fff;border-color:var(--accent)}button.primary:hover{background:#082c40}button.danger{color:var(--danger);border-color:var(--danger);background:#fff}button.danger:hover{background:var(--danger-soft)}button:disabled{opacity:.45;cursor:not-allowed}input[type=text],input[type=email],input[type=password],input[type=date],input[type=number],input[type=search],textarea,select{border:1px solid var(--line);border-radius:var(--r-sm);padding:8px 10px;background:#fff;width:100%}input:focus,textarea:focus,select:focus{outline:2px solid var(--accent-soft);outline-offset:-1px;border-color:var(--accent)}label{display:block;font-size:12px;font-weight:600;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.04em;margin-bottom:4px}h1,h2,h3{font-family:var(--font-display);font-weight:600;letter-spacing:-.01em}h1{font-size:28px;margin:0 0 4px}h2{font-size:20px;margin:0 0 12px}h3{font-size:16px;margin:0 0 8px}.app-shell{display:flex;flex-direction:column;min-height:100vh}.nav{background:var(--surface);border-bottom:1px solid var(--line);padding:10px 16px;display:flex;align-items:center;gap:16px;position:sticky;top:0;z-index:10}.nav-brand{font-family:var(--font-display);font-weight:600;font-size:18px;color:var(--accent);display:flex;align-items:center;gap:8px}.nav-brand .dot{width:10px;height:10px;border-radius:50%;background:var(--accent);display:inline-block}.nav-spacer{flex:1}.nav-links{display:flex;gap:4px}.nav-links a{padding:6px 10px;border-radius:var(--r-sm);color:var(--ink-soft);font-size:14px}.nav-links a:hover{background:var(--surface-2);text-decoration:none}.nav-links a.active{background:var(--accent-soft);color:var(--accent)}.nav-user{font-size:13px;color:var(--ink-faint)}.container{max-width:1100px;margin:0 auto;padding:24px 16px 80px;width:100%}.page-header{margin-bottom:20px}.page-header .sub{color:var(--ink-faint);font-size:14px}.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:16px;box-shadow:var(--shadow-sm)}.card-title{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px}.card-title h3{margin:0}.card-title .count{font-size:12px;color:var(--ink-faint);font-variant-numeric:tabular-nums}.grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(280px,1fr))}.stat-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-bottom:24px}.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:12px 14px}.stat .label{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--ink-faint);font-weight:600}.stat .value{font-family:var(--font-display);font-size:28px;font-weight:600;color:var(--ink);font-variant-numeric:tabular-nums;line-height:1.1}.list{display:flex;flex-direction:column}.list-item{display:flex;align-items:flex-start;gap:12px;padding:10px 0;border-bottom:1px solid var(--line-soft)}.list-item:last-child{border-bottom:0}.list-item .main{flex:1;min-width:0}.list-item .main .name{font-weight:500}.list-item .main .meta{color:var(--ink-faint);font-size:13px;margin-top:2px}.list-item .right{text-align:right;font-size:13px;color:var(--ink-soft);font-variant-numeric:tabular-nums;flex-shrink:0}.badge{display:inline-block;font-size:11px;padding:2px 8px;border-radius:999px;background:var(--surface-2);color:var(--ink-soft);border:1px solid var(--line);text-transform:capitalize;letter-spacing:.02em}.badge.accent{background:var(--accent-soft);color:var(--accent);border-color:transparent}.badge.warn{background:#fef3c7;color:var(--warn);border-color:transparent}.badge.danger{background:var(--danger-soft);color:var(--danger);border-color:transparent}.badge.positive{background:#d4f1e0;color:var(--positive);border-color:transparent}.empty{text-align:center;color:var(--ink-faint);padding:24px 8px;font-size:14px}.dropzone{border:2px dashed var(--line);border-radius:var(--r-lg);padding:40px 20px;text-align:center;background:var(--surface-2);transition:border .15s,background .15s}.dropzone.over{border-color:var(--accent);background:var(--accent-soft)}.dropzone input[type=file]{display:none}.dropzone .hint{color:var(--ink-faint);font-size:13px;margin-top:4px}.upload-row{display:grid;grid-template-columns:1fr 160px 140px 100px;gap:8px;padding:10px;border:1px solid var(--line);border-radius:var(--r-sm);margin-bottom:6px;background:#fff;align-items:center}.upload-row .filename{font-size:13px;truncate:ellipsis;overflow:hidden;white-space:nowrap}.upload-row .progress{font-size:12px;color:var(--ink-faint);font-variant-numeric:tabular-nums}.upload-row.ok{background:#d4f1e030;border-color:#2d6a4f55}.upload-row.err{background:var(--danger-soft);border-color:var(--danger)}.merge-pair{border:1px solid var(--line);border-radius:var(--r);padding:14px;margin-bottom:12px;background:var(--surface)}.merge-pair .heading{font-size:13px;color:var(--ink-faint);margin-bottom:10px;display:flex;gap:8px;align-items:center}.merge-side{background:var(--surface-2);border-radius:var(--r-sm);padding:10px 12px;font-size:14px}.merge-side .src{font-size:11px;color:var(--ink-faint);margin-bottom:4px}.merge-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}.merge-actions{display:flex;gap:8px;flex-wrap:wrap}.error-banner{background:var(--danger-soft);color:var(--danger);border:1px solid var(--danger);padding:10px 12px;border-radius:var(--r-sm);margin-bottom:16px;font-size:14px}.spinner{display:inline-block;width:14px;height:14px;border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:spin .6s linear infinite;vertical-align:-2px}@keyframes spin{to{transform:rotate(360deg)}}@media (max-width: 640px){.nav{gap:8px;padding:8px 12px}.nav-brand{font-size:16px}.nav-links a{padding:5px 8px;font-size:13px}.container{padding:16px 12px 80px}h1,.stat .value{font-size:22px}.upload-row,.merge-grid{grid-template-columns:1fr}}// CCDA-to-HTML stylesheet embedded as a string. // Used by CCDAViewer to transform CDA XML into formatted HTML. // Generated from ccda.xsl — keep in sync. export const CCDA_STYLESHEET = ` <?xml version="1.0" encoding="UTF-8"?> <!-- Compact CCDA → HTML stylesheet for personal health record viewer. Renders the common CCDA sections (allergies,medications,problems,immunizations,labs,vitals,social history,care teams,narrative) into clean semantic HTML. Designed to work with the host app's CSS variables for theme integration.
--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cda="urn:hl7-org:v3" xmlns:sdtc="urn:hl7-org:sdtc" exclude-result-prefixes="cda sdtc"> <xsl:output method="html" indent="yes" omit-xml-declaration="yes" /> <!-- ========================================================= Root: Build the document ========================================================= --> <xsl:template match="/cda:ClinicalDocument"> <div class="ccda-doc"> <header class="ccda-header"> <h1> <xsl:choose> <xsl:when test="cda:title"><xsl:value-of select="cda:title" /></xsl:when> <xsl:otherwise>Clinical Document</xsl:otherwise> </xsl:choose> </h1> <div class="ccda-meta"> <xsl:if test="cda:effectiveTime/@value"> <span class="ccda-date"> Created: <xsl:call-template name="format-date"> <xsl:with-param name="value" select="cda:effectiveTime/@value" /> </xsl:call-template> </span> </xsl:if> <xsl:if test="cda:custodian/cda:assignedCustodian/cda:representedCustodianOrganization/cda:name"> <span class="ccda-org"> From: <xsl:value-of select="cda:custodian/cda:assignedCustodian/cda:representedCustodianOrganization/cda:name" /> </span> </xsl:if> </div> </header> <!-- Patient banner --> <xsl:apply-templates select="cda:recordTarget/cda:patientRole" /> <!-- All CCDA sections in document order --> <xsl:apply-templates select="cda:component/cda:structuredBody/cda:component/cda:section" /> </div> </xsl:template> <!-- ========================================================= Patient banner ========================================================= --> <xsl:template match="cda:patientRole"> <section class="ccda-section ccda-patient"> <h2>Patient</h2> <dl class="ccda-kv"> <xsl:if test="cda:patient/cda:name"> <dt>Name</dt> <dd> <xsl:value-of select="cda:patient/cda:name/cda:given" /> <xsl:text> </xsl:text> <xsl:value-of select="cda:patient/cda:name/cda:family" /> </dd> </xsl:if> <xsl:if test="cda:patient/cda:birthTime/@value"> <dt>Date of birth</dt> <dd> <xsl:call-template name="format-date"> <xsl:with-param name="value" select="cda:patient/cda:birthTime/@value" /> </xsl:call-template> </dd> </xsl:if> <xsl:if test="cda:patient/cda:administrativeGenderCode/@displayName"> <dt>Sex</dt> <dd><xsl:value-of select="cda:patient/cda:administrativeGenderCode/@displayName" /></dd> </xsl:if> <xsl:if test="cda:patient/cda:raceCode/@displayName"> <dt>Race</dt> <dd><xsl:value-of select="cda:patient/cda:raceCode/@displayName" /></dd> </xsl:if> <xsl:if test="cda:telecom[1]/@value"> <dt>Phone</dt> <dd> <xsl:for-each select="cda:telecom"> <xsl:value-of select="substring-after(@value, 'tel:')" /> <xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> </dd> </xsl:if> </dl> </section> </xsl:template> <!-- ========================================================= Generic section: render the embedded narrative <text> blocks. The <text> element in CCDA contains pre-formatted human-readable content (lists,tables,etc.). ========================================================= --> <xsl:template match="cda:section"> <xsl:if test="cda:title or cda:code/@displayName"> <section class="ccda-section"> <h2> <xsl:choose> <xsl:when test="cda:title"><xsl:value-of select="cda:title" /></xsl:when> <xsl:otherwise><xsl:value-of select="cda:code/@displayName" /></xsl:otherwise> </xsl:choose> </h2> <xsl:choose> <xsl:when test="@nullFlavor"> <p class="ccda-empty">No information on file.</p> </xsl:when> <xsl:when test="cda:text"> <div class="ccda-narrative"> <xsl:apply-templates select="cda:text/*" mode="narrative" /> </div> </xsl:when> <xsl:otherwise> <p class="ccda-empty">No information available.</p> </xsl:otherwise> </xsl:choose> </section> </xsl:if> </xsl:template> <!-- ========================================================= Narrative content (lists,tables,paragraphs,content) ========================================================= --> <xsl:template match="cda:list" mode="narrative"> <ul class="ccda-list"> <xsl:apply-templates select="cda:item" mode="narrative" /> </ul> </xsl:template> <xsl:template match="cda:item" mode="narrative"> <li> <xsl:apply-templates mode="narrative" /> </li> </xsl:template> <xsl:template match="cda:table" mode="narrative"> <div class="ccda-table-wrap"> <table class="ccda-table"> <xsl:apply-templates mode="narrative" /> </table> </div> </xsl:template> <xsl:template match="cda:thead" mode="narrative"> <thead><xsl:apply-templates mode="narrative" /></thead> </xsl:template> <xsl:template match="cda:tbody" mode="narrative"> <tbody><xsl:apply-templates mode="narrative" /></tbody> </xsl:template> <xsl:template match="cda:tr" mode="narrative"> <tr><xsl:apply-templates mode="narrative" /></tr> </xsl:template> <xsl:template match="cda:th" mode="narrative"> <th><xsl:apply-templates mode="narrative" /></th> </xsl:template> <xsl:template match="cda:td" mode="narrative"> <td><xsl:apply-templates mode="narrative" /></td> </xsl:template> <xsl:template match="cda:colgroup | cda:col" mode="narrative"> <!-- skip column definitions; not needed for HTML rendering --> </xsl:template> <xsl:template match="cda:paragraph" mode="narrative"> <p> <xsl:if test="@styleCode = 'xIndent'"> <xsl:attribute name="class">ccda-indent</xsl:attribute> </xsl:if> <xsl:apply-templates mode="narrative" /> </p> </xsl:template> <xsl:template match="cda:content" mode="narrative"> <xsl:choose> <xsl:when test="@styleCode = 'Bold'"> <strong><xsl:apply-templates mode="narrative" /></strong> </xsl:when> <xsl:when test="@styleCode = 'Italics'"> <em><xsl:apply-templates mode="narrative" /></em> </xsl:when> <xsl:when test="@styleCode = 'Underline'"> <u><xsl:apply-templates mode="narrative" /></u> </xsl:when> <xsl:otherwise> <span><xsl:apply-templates mode="narrative" /></span> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="cda:br" mode="narrative"> <br /> </xsl:template> <xsl:template match="cda:linkHtml" mode="narrative"> <a> <xsl:if test="@href"> <xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:attribute name="rel">noopener noreferrer</xsl:attribute> </xsl:if> <xsl:apply-templates mode="narrative" /> </a> </xsl:template> <!-- Skip references to internal IDs (they're for entry-relationship
linking,not human content) --> <xsl:template match="cda:reference" mode="narrative"> <!-- intentionally empty --> </xsl:template> <!-- Default text passthrough --> <xsl:template match="text()" mode="narrative"> <xsl:value-of select="." /> </xsl:template> <!-- ========================================================= Date formatter: HL7 yyyymmddhhmmss[+-]TZ → readable date ========================================================= --> <xsl:template name="format-date"> <xsl:param name="value" /> <xsl:variable name="y" select="substring($value, 1, 4)" /> <xsl:variable name="m" select="substring($value, 5, 2)" /> <xsl:variable name="d" select="substring($value, 7, 2)" /> <xsl:variable name="month-name"> <xsl:choose> <xsl:when test="$m = '01'">Jan</xsl:when> <xsl:when test="$m = '02'">Feb</xsl:when> <xsl:when test="$m = '03'">Mar</xsl:when> <xsl:when test="$m = '04'">Apr</xsl:when> <xsl:when test="$m = '05'">May</xsl:when> <xsl:when test="$m = '06'">Jun</xsl:when> <xsl:when test="$m = '07'">Jul</xsl:when> <xsl:when test="$m = '08'">Aug</xsl:when> <xsl:when test="$m = '09'">Sep</xsl:when> <xsl:when test="$m = '10'">Oct</xsl:when> <xsl:when test="$m = '11'">Nov</xsl:when> <xsl:when test="$m = '12'">Dec</xsl:when> </xsl:choose> </xsl:variable> <xsl:value-of select="$month-name" /> <xsl:text> </xsl:text> <xsl:value-of select="number($d)" /> <xsl:text>,</xsl:text> <xsl:value-of select="$y" /> </xsl:template> </xsl:stylesheet> `;{}
