feat(mobile): render direct overview and patterns list in four levels with bullet points for treatment and explanation #75
|
|
@ -133,7 +133,7 @@ const GalleryImage = memo(function GalleryImage({
|
||||||
previous.item.caption === next.item.caption
|
previous.item.caption === next.item.caption
|
||||||
);
|
);
|
||||||
|
|
||||||
export function ContentMediaGallery({ media, title = "Visual reference" }: ContentMediaGalleryProps) {
|
export function ContentMediaGallery({ media, title = "Visual Reference" }: ContentMediaGalleryProps) {
|
||||||
const items = useMemo(() => sortMedia(media ?? []), [media]);
|
const items = useMemo(() => sortMedia(media ?? []), [media]);
|
||||||
const { width: windowWidth } = useWindowDimensions();
|
const { width: windowWidth } = useWindowDimensions();
|
||||||
const carouselWidth = Math.max(windowWidth - Spacing.md * 2, 280);
|
const carouselWidth = Math.max(windowWidth - Spacing.md * 2, 280);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,15 @@ export function ModuleCatalogCardRenderer({
|
||||||
}: CollectionItemRendererProps) {
|
}: CollectionItemRendererProps) {
|
||||||
const attributes = item.attributes;
|
const attributes = item.attributes;
|
||||||
const title = asString(attributes.name) || item.title;
|
const title = asString(attributes.name) || item.title;
|
||||||
const label = asString(attributes.content_label) || item.summary || null;
|
const label =
|
||||||
|
asString(attributes.sub_title) ||
|
||||||
|
asString(attributes.content_label) ||
|
||||||
|
(asString(attributes.title) && asString(attributes.title) !== title
|
||||||
|
? asString(attributes.title)
|
||||||
|
: null) ||
|
||||||
|
asString(attributes.description) ||
|
||||||
|
item.summary ||
|
||||||
|
null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,43 @@ export function EovDetailRenderer({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clinicalManifestations = data.clinical_manifestation ?? data.clinical_manifestations;
|
||||||
|
if (!isEmptyValue(clinicalManifestations)) {
|
||||||
|
items.push({
|
||||||
|
key: "clinical_manifestation",
|
||||||
|
order: orderFor("clinical_manifestation", orderFor("clinical_manifestations", 125)),
|
||||||
|
render: () => (
|
||||||
|
<SectionCard title="Clinical Manifestations">
|
||||||
|
<BulletList items={asStringArray(clinicalManifestations)} />
|
||||||
|
</SectionCard>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEmptyValue(data.connecting_channel)) {
|
||||||
|
items.push({
|
||||||
|
key: "connecting_channel",
|
||||||
|
order: orderFor("connecting_channel", 130),
|
||||||
|
render: () => (
|
||||||
|
<SectionCard title="Connecting Channel">
|
||||||
|
<Text style={styles.pathway}>{asString(data.connecting_channel)}</Text>
|
||||||
|
</SectionCard>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEmptyValue(data.treatment)) {
|
||||||
|
items.push({
|
||||||
|
key: "treatment",
|
||||||
|
order: orderFor("treatment", 140),
|
||||||
|
render: () => (
|
||||||
|
<SectionCard title="Treatment">
|
||||||
|
<Text style={styles.pathway}>{asString(data.treatment)}</Text>
|
||||||
|
</SectionCard>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return items.sort((a, b) => a.order - b.order || a.key.localeCompare(b.key));
|
return items.sort((a, b) => a.order - b.order || a.key.localeCompare(b.key));
|
||||||
}, [data, orderFor, relationshipRows]);
|
}, [data, orderFor, relationshipRows]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,195 @@
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { ScrollView, StyleSheet } from "react-native";
|
||||||
|
|
||||||
|
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||||
|
import {
|
||||||
|
bareAttributeKey,
|
||||||
|
findAttributePresentationRule,
|
||||||
|
getEmptyDisplayText,
|
||||||
|
presentationDisplayOrder,
|
||||||
|
shouldRenderAttribute,
|
||||||
|
} from "../../utils/attribute-presentation";
|
||||||
|
import {
|
||||||
|
asRecord,
|
||||||
|
asString,
|
||||||
|
asStringArray,
|
||||||
|
humanizeKey,
|
||||||
|
} from "../helpers/value";
|
||||||
|
import { BulletList } from "../shared/BulletList";
|
||||||
|
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||||
|
import { ContentValue } from "../shared/ContentValue";
|
||||||
|
import { Hero } from "../shared/Hero";
|
||||||
|
import { ImageGallery } from "../shared/ImageGallery";
|
||||||
|
import { ObjectSections } from "../shared/ObjectSections";
|
||||||
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
|
|
||||||
|
const RESERVED_KEYS = new Set([
|
||||||
|
"name",
|
||||||
|
"title",
|
||||||
|
"sub_title",
|
||||||
|
"subtitle",
|
||||||
|
"code",
|
||||||
|
"sort_order",
|
||||||
|
"link",
|
||||||
|
"images",
|
||||||
|
"media",
|
||||||
|
"point_images",
|
||||||
|
]);
|
||||||
|
|
||||||
|
function toParagraphs(value: unknown): string[] {
|
||||||
|
if (!value) return [];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value.map(asString).filter(Boolean);
|
||||||
|
}
|
||||||
|
const str = asString(value);
|
||||||
|
if (!str) return [];
|
||||||
|
return str.split(/\n+/).map((s) => s.trim()).filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ExtraOrdinaryVesselsDetailRenderer({
|
||||||
|
content,
|
||||||
|
data,
|
||||||
|
definitions,
|
||||||
|
presentationAttributes,
|
||||||
|
}: DetailRendererProps) {
|
||||||
|
const title =
|
||||||
|
asString(data.name) ||
|
||||||
|
asString(data.title) ||
|
||||||
|
content.title;
|
||||||
|
|
||||||
|
const subtitle =
|
||||||
|
asString(data.sub_title) ||
|
||||||
|
asString(data.subtitle) ||
|
||||||
|
undefined;
|
||||||
|
|
||||||
|
const mediaValue = data.images ?? data.media ?? data.point_images;
|
||||||
|
const media = Array.isArray(mediaValue)
|
||||||
|
? mediaValue.filter(
|
||||||
|
(item): item is Record<string, unknown> =>
|
||||||
|
item !== null && typeof item === "object" && !Array.isArray(item),
|
||||||
|
)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const orderedAttributes = useMemo(() => {
|
||||||
|
const rootDefinitions = definitions.filter((definition) => definition.is_root);
|
||||||
|
const definitionByBareKey = new Map(
|
||||||
|
rootDefinitions.map((definition) => [
|
||||||
|
definition.code || bareAttributeKey(definition.attribute_key),
|
||||||
|
definition,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
const contractIndex = new Map(
|
||||||
|
presentationAttributes.map((rule, index) => [rule.attribute_key, index]),
|
||||||
|
);
|
||||||
|
|
||||||
|
const keys: string[] = [];
|
||||||
|
const seen = new Set<string>();
|
||||||
|
|
||||||
|
for (const definition of rootDefinitions) {
|
||||||
|
const key = definition.code || bareAttributeKey(definition.attribute_key);
|
||||||
|
if (!key || seen.has(key)) continue;
|
||||||
|
seen.add(key);
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback for attributes in data that may not have root definitions
|
||||||
|
for (const [key, value] of Object.entries(data)) {
|
||||||
|
if (!seen.has(key) && value !== null && value !== undefined && value !== "") {
|
||||||
|
seen.add(key);
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys
|
||||||
|
.flatMap((key) => {
|
||||||
|
if (RESERVED_KEYS.has(key)) return [];
|
||||||
|
|
||||||
|
const value = data[key];
|
||||||
|
const definition = definitionByBareKey.get(key);
|
||||||
|
const rule = findAttributePresentationRule(
|
||||||
|
definition?.attribute_key ?? key,
|
||||||
|
presentationAttributes,
|
||||||
|
);
|
||||||
|
if (rule && !shouldRenderAttribute(value, rule)) return [];
|
||||||
|
|
||||||
|
const label =
|
||||||
|
definition?.label?.trim() ||
|
||||||
|
humanizeKey(key);
|
||||||
|
const emptyText = getEmptyDisplayText(value, rule);
|
||||||
|
const index = rule ? contractIndex.get(rule.attribute_key) ?? 0 : 0;
|
||||||
|
const order = presentationDisplayOrder(rule, definition?.sort_order, index);
|
||||||
|
|
||||||
|
return [{ key, label, value, emptyText, order }];
|
||||||
|
})
|
||||||
|
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||||
|
}, [data, definitions, presentationAttributes]);
|
||||||
|
|
||||||
|
const renderAttributeValue = (key: string, value: unknown, emptyText: string | null) => {
|
||||||
|
if (key === "clinical_manifestation" || key === "clinical_manifestations") {
|
||||||
|
const items = Array.isArray(value)
|
||||||
|
? asStringArray(value)
|
||||||
|
: typeof value === "string"
|
||||||
|
? value
|
||||||
|
.split(/,\s*(?![^()]*\))/)
|
||||||
|
.map((s) => s.trim().replace(/\.$/, ""))
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (items.length > 0) {
|
||||||
|
return <BulletList items={items} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
const strings = asStringArray(value);
|
||||||
|
if (strings.length > 0) {
|
||||||
|
return <BulletList items={strings} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
||||||
|
return <ObjectSections value={asRecord(value)} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const paragraphs = toParagraphs(value);
|
||||||
|
if (paragraphs.length > 0) {
|
||||||
|
return <Paragraphs items={paragraphs} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <ContentValue value={value} emptyText={emptyText ?? undefined} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView
|
||||||
|
contentContainerStyle={styles.content}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
>
|
||||||
|
<Hero title={title} subtitle={subtitle} />
|
||||||
|
|
||||||
|
{media.length > 0 ? <ImageGallery images={media} /> : null}
|
||||||
|
|
||||||
|
{orderedAttributes.map((attribute) => (
|
||||||
|
<SectionCard key={attribute.key} title={attribute.label}>
|
||||||
|
{renderAttributeValue(attribute.key, attribute.value, attribute.emptyText)}
|
||||||
|
</SectionCard>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<ContentLinkAttributeSections
|
||||||
|
data={data}
|
||||||
|
definitions={definitions}
|
||||||
|
presentationAttributes={presentationAttributes}
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
content: {
|
||||||
|
paddingHorizontal: 18,
|
||||||
|
paddingTop: 16,
|
||||||
|
paddingBottom: 40,
|
||||||
|
gap: 14,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
buildContentReferenceRoute,
|
buildContentReferenceRoute,
|
||||||
parseNavigableContentReference,
|
parseNavigableContentReference,
|
||||||
} from "../../utils/content-reference";
|
} from "../../utils/content-reference";
|
||||||
import { asRecord, asString } from "../helpers/value";
|
import { asRecord, asString, asStringArray } from "../helpers/value";
|
||||||
import { BulletList } from "../shared/BulletList";
|
import { BulletList } from "../shared/BulletList";
|
||||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
|
|
@ -83,10 +83,13 @@ export function FourLevelsDetailRenderer({
|
||||||
const rawPatterns = Array.isArray(data.patterns) ? data.patterns : [];
|
const rawPatterns = Array.isArray(data.patterns) ? data.patterns : [];
|
||||||
const hasPatterns = rawPatterns.length > 0;
|
const hasPatterns = rawPatterns.length > 0;
|
||||||
|
|
||||||
const clinicalManifestations =
|
const clinicalManifestationsRaw =
|
||||||
asString(data.clinical_manifestation) ||
|
data.clinical_manifestation ??
|
||||||
asString(data.clinical_manifestations) ||
|
data.clinical_manifestations ??
|
||||||
asString(data.clinical_menifestation);
|
data.clinical_menifestation;
|
||||||
|
const clinicalManifestationItems = asStringArray(clinicalManifestationsRaw).filter(
|
||||||
|
(item) => item.trim().length > 0,
|
||||||
|
);
|
||||||
const tongue = asString(data.tongue);
|
const tongue = asString(data.tongue);
|
||||||
const pulse = asString(data.pulse);
|
const pulse = asString(data.pulse);
|
||||||
const pathology = asString(data.pathology);
|
const pathology = asString(data.pathology);
|
||||||
|
|
@ -203,9 +206,9 @@ export function FourLevelsDetailRenderer({
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{clinicalManifestations ? (
|
{clinicalManifestationItems.length > 0 ? (
|
||||||
<SectionCard title="Clinical Manifestations">
|
<SectionCard title="Clinical Manifestations">
|
||||||
<Paragraphs items={[clinicalManifestations]} />
|
<BulletList items={clinicalManifestationItems} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,16 @@ import { asString } from "../helpers/value";
|
||||||
import { Hero } from "../shared/Hero"; import { ImageGallery } from "../shared/ImageGallery";
|
import { Hero } from "../shared/Hero"; import { ImageGallery } from "../shared/ImageGallery";
|
||||||
import { KeyValueGrid } from "../shared/KeyValueGrid";
|
import { KeyValueGrid } from "../shared/KeyValueGrid";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
export function IndexEntryDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={content.title}/><ImageGallery images={[]}/><SectionCard title="Details"><KeyValueGrid rows={Object.entries(data).filter(([,v])=>typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/></SectionCard><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
export function IndexEntryDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){
|
||||||
|
const subtitle = asString(data.sub_title) || asString(data.subtitle) || undefined;
|
||||||
|
return (
|
||||||
|
<ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}>
|
||||||
|
<Hero title={content.title} subtitle={subtitle}/>
|
||||||
|
<ImageGallery images={[]}/>
|
||||||
|
<SectionCard title="Details">
|
||||||
|
<KeyValueGrid rows={Object.entries(data).filter(([,v])=>typeof v==="string"||typeof v==="number").map(([k,v])=>({label:k,value:String(v)}))}/>
|
||||||
|
</SectionCard>
|
||||||
|
<ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/>
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,11 @@ import type { DetailRendererProps } from "../../types/renderer.types";
|
||||||
|
|
||||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
|
import { BulletList } from "../shared/BulletList";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
import { Paragraphs } from "../shared/Paragraphs";
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
import { ImageGallery } from "../shared/ImageGallery";
|
import { ImageGallery } from "../shared/ImageGallery";
|
||||||
import { asString } from "../helpers/value";
|
import { asString, asStringArray } from "../helpers/value";
|
||||||
|
|
||||||
export function PathogenicFactorsDetailRenderer({
|
export function PathogenicFactorsDetailRenderer({
|
||||||
content,
|
content,
|
||||||
|
|
@ -22,7 +23,12 @@ export function PathogenicFactorsDetailRenderer({
|
||||||
content.title;
|
content.title;
|
||||||
|
|
||||||
const overview = asString(data.overview);
|
const overview = asString(data.overview);
|
||||||
const clinicalManifestations = asString(data.clinical_manifestations);
|
const clinicalManifestationsRaw =
|
||||||
|
data.clinical_manifestations ??
|
||||||
|
data.clinical_manifestation;
|
||||||
|
const clinicalManifestationItems = asStringArray(clinicalManifestationsRaw).filter(
|
||||||
|
(item) => item.trim().length > 0,
|
||||||
|
);
|
||||||
const analysis = asString(data.analysis);
|
const analysis = asString(data.analysis);
|
||||||
const contentText = asString(data.content);
|
const contentText = asString(data.content);
|
||||||
const defaultImage = asString(data["default image"]);
|
const defaultImage = asString(data["default image"]);
|
||||||
|
|
@ -56,9 +62,9 @@ export function PathogenicFactorsDetailRenderer({
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{clinicalManifestations ? (
|
{clinicalManifestationItems.length > 0 ? (
|
||||||
<SectionCard title="Clinical Manifestations">
|
<SectionCard title="Clinical Manifestations">
|
||||||
<Paragraphs items={[clinicalManifestations]} />
|
<BulletList items={clinicalManifestationItems} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,9 @@ import { BackActionContext } from "../../context/BackActionContext";
|
||||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
|
import { BulletList } from "../shared/BulletList";
|
||||||
import { Paragraphs } from "../shared/Paragraphs";
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
import { asString, humanizeKey } from "../helpers/value";
|
import { asString, asStringArray, humanizeKey } from "../helpers/value";
|
||||||
|
|
||||||
const RESERVED_METADATA_KEYS = new Set([
|
const RESERVED_METADATA_KEYS = new Set([
|
||||||
"name",
|
"name",
|
||||||
|
|
@ -36,12 +37,46 @@ interface PatternItem {
|
||||||
|
|
||||||
interface ParsedNode {
|
interface ParsedNode {
|
||||||
overview?: string;
|
overview?: string;
|
||||||
clinical?: string;
|
clinicalItems: string[];
|
||||||
analysis?: string;
|
analysis?: string;
|
||||||
subItems: PatternItem[];
|
subItems: PatternItem[];
|
||||||
otherTextEntries: Array<{ key: string; text: string }>;
|
otherTextEntries: Array<{ key: string; text: string }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseClinicalManifestations(raw: unknown): string[] {
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
return asStringArray(raw);
|
||||||
|
}
|
||||||
|
const text = asString(raw).trim();
|
||||||
|
if (!text) return [];
|
||||||
|
|
||||||
|
// Check if string is semicolon or newline separated
|
||||||
|
if (text.includes("\n")) {
|
||||||
|
return text
|
||||||
|
.split("\n")
|
||||||
|
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If semicolon separated
|
||||||
|
if (text.includes(";")) {
|
||||||
|
return text
|
||||||
|
.split(";")
|
||||||
|
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split by comma outside parentheses
|
||||||
|
const parts = text.split(/,\s*(?![^()]*\))/);
|
||||||
|
if (parts.length > 1) {
|
||||||
|
return parts
|
||||||
|
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [text];
|
||||||
|
}
|
||||||
|
|
||||||
function extractCategoryOverview(data: Record<string, unknown>, categoryCode: string): string {
|
function extractCategoryOverview(data: Record<string, unknown>, categoryCode: string): string {
|
||||||
const normalizedCode = categoryCode.toLowerCase().replace(/[^a-z0-9_]/g, "_");
|
const normalizedCode = categoryCode.toLowerCase().replace(/[^a-z0-9_]/g, "_");
|
||||||
|
|
||||||
|
|
@ -121,12 +156,13 @@ function parseNode(raw: Record<string, unknown>): ParsedNode {
|
||||||
(typeof raw.content === "string" ? raw.content.trim() : undefined) ||
|
(typeof raw.content === "string" ? raw.content.trim() : undefined) ||
|
||||||
(typeof raw.overview === "string" ? raw.overview.trim() : undefined);
|
(typeof raw.overview === "string" ? raw.overview.trim() : undefined);
|
||||||
|
|
||||||
const clinical =
|
const clinicalRaw =
|
||||||
asString(contentTarget["Clinical manifestations"]) ||
|
contentTarget["Clinical manifestations"] ??
|
||||||
asString(contentTarget.clinical_manifestations) ||
|
contentTarget.clinical_manifestations ??
|
||||||
asString(contentTarget.clinical_manifestation) ||
|
contentTarget.clinical_manifestation ??
|
||||||
asString(raw["Clinical manifestations"]) ||
|
raw["Clinical manifestations"] ??
|
||||||
asString(raw.clinical_manifestations);
|
raw.clinical_manifestations;
|
||||||
|
const clinicalItems = parseClinicalManifestations(clinicalRaw);
|
||||||
|
|
||||||
const analysis =
|
const analysis =
|
||||||
asString(contentTarget.Analysis) ||
|
asString(contentTarget.Analysis) ||
|
||||||
|
|
@ -161,7 +197,7 @@ function parseNode(raw: Record<string, unknown>): ParsedNode {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
overview: overview || undefined,
|
overview: overview || undefined,
|
||||||
clinical: clinical || undefined,
|
clinicalItems,
|
||||||
analysis: analysis || undefined,
|
analysis: analysis || undefined,
|
||||||
subItems,
|
subItems,
|
||||||
otherTextEntries,
|
otherTextEntries,
|
||||||
|
|
@ -227,9 +263,9 @@ export function QiBloodDetailRenderer({
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* 2. Clinical Manifestations Card */}
|
{/* 2. Clinical Manifestations Card */}
|
||||||
{parsed.clinical ? (
|
{parsed.clinicalItems.length > 0 ? (
|
||||||
<SectionCard title="Clinical Manifestations">
|
<SectionCard title="Clinical Manifestations">
|
||||||
<Paragraphs items={[parsed.clinical]} />
|
<BulletList items={parsed.clinicalItems} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,49 @@ import { BackActionContext } from "../../context/BackActionContext";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
import { Paragraphs } from "../shared/Paragraphs";
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
import { asString } from "../helpers/value";
|
import { BulletList } from "../shared/BulletList";
|
||||||
|
import { asString, asStringArray } from "../helpers/value";
|
||||||
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
||||||
|
|
||||||
interface PatternData {
|
interface PatternData {
|
||||||
name: string;
|
name: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
clinicalManifestation?: string;
|
clinicalManifestation?: string | string[];
|
||||||
pathology?: string;
|
pathology?: string;
|
||||||
treatment?: string;
|
treatment?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseBullets(raw: unknown): string[] {
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
return asStringArray(raw);
|
||||||
|
}
|
||||||
|
const text = asString(raw).trim();
|
||||||
|
if (!text) return [];
|
||||||
|
|
||||||
|
if (text.includes("\n")) {
|
||||||
|
return text
|
||||||
|
.split("\n")
|
||||||
|
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text.includes(";")) {
|
||||||
|
return text
|
||||||
|
.split(";")
|
||||||
|
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts = text.split(/,\s*(?![^()]*\))/);
|
||||||
|
if (parts.length > 1) {
|
||||||
|
return parts
|
||||||
|
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [text];
|
||||||
|
}
|
||||||
|
|
||||||
interface BurnerCategory {
|
interface BurnerCategory {
|
||||||
key: string;
|
key: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -183,7 +215,10 @@ export function ThreeBurnersDetailRenderer({
|
||||||
|
|
||||||
// 1. Seed fallback patterns
|
// 1. Seed fallback patterns
|
||||||
for (const p of Object.values(FALLBACK_PATTERNS)) {
|
for (const p of Object.values(FALLBACK_PATTERNS)) {
|
||||||
map.set(normalizeKey(p.name), p);
|
map.set(normalizeKey(p.name), {
|
||||||
|
...p,
|
||||||
|
clinicalManifestation: parseBullets(p.clinicalManifestation),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Hydrate from live search query
|
// 2. Hydrate from live search query
|
||||||
|
|
@ -193,19 +228,20 @@ export function ThreeBurnersDetailRenderer({
|
||||||
const name = asString(a.name) || it.title;
|
const name = asString(a.name) || it.title;
|
||||||
if (!name) continue;
|
if (!name) continue;
|
||||||
|
|
||||||
const clinical =
|
const clinicalRaw =
|
||||||
asString(a["clinical menifestation"]) ||
|
a["clinical menifestation"] ??
|
||||||
asString(a["clinical manifestation"]) ||
|
a["clinical manifestation"] ??
|
||||||
asString(a.clinical_manifestations) ||
|
a.clinical_manifestations ??
|
||||||
asString(a.clinical_manifestation);
|
a.clinical_manifestation;
|
||||||
|
|
||||||
|
const clinical = parseBullets(clinicalRaw);
|
||||||
const pathology = asString(a.pathology);
|
const pathology = asString(a.pathology);
|
||||||
const treatment = asString(a.treatment);
|
const treatment = asString(a.treatment);
|
||||||
|
|
||||||
map.set(normalizeKey(name), {
|
map.set(normalizeKey(name), {
|
||||||
name,
|
name,
|
||||||
code: asString(a.code) || undefined,
|
code: asString(a.code) || undefined,
|
||||||
clinicalManifestation: clinical || undefined,
|
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||||
pathology: pathology || undefined,
|
pathology: pathology || undefined,
|
||||||
treatment: treatment || undefined,
|
treatment: treatment || undefined,
|
||||||
});
|
});
|
||||||
|
|
@ -241,13 +277,18 @@ export function ThreeBurnersDetailRenderer({
|
||||||
const activePatternData: PatternData | null = useMemo(() => {
|
const activePatternData: PatternData | null = useMemo(() => {
|
||||||
if (isDirectLeafPattern) {
|
if (isDirectLeafPattern) {
|
||||||
const name = asString(data.name) || content.title || "Three Burners Pattern";
|
const name = asString(data.name) || content.title || "Three Burners Pattern";
|
||||||
|
const clinicalRaw =
|
||||||
|
data["clinical menifestation"] ??
|
||||||
|
data["clinical manifestation"] ??
|
||||||
|
data.clinical_manifestations ??
|
||||||
|
data.clinical_manifestation;
|
||||||
|
|
||||||
|
const clinical = parseBullets(clinicalRaw);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
code: asString(data.code) || undefined,
|
code: asString(data.code) || undefined,
|
||||||
clinicalManifestation:
|
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||||
asString(data["clinical menifestation"]) ||
|
|
||||||
asString(data["clinical manifestation"]) ||
|
|
||||||
asString(data.clinical_manifestations),
|
|
||||||
pathology: asString(data.pathology) || undefined,
|
pathology: asString(data.pathology) || undefined,
|
||||||
treatment: asString(data.treatment) || undefined,
|
treatment: asString(data.treatment) || undefined,
|
||||||
};
|
};
|
||||||
|
|
@ -296,7 +337,13 @@ export function ThreeBurnersDetailRenderer({
|
||||||
{/* 1. Clinical Manifestations Card */}
|
{/* 1. Clinical Manifestations Card */}
|
||||||
{activePatternData.clinicalManifestation ? (
|
{activePatternData.clinicalManifestation ? (
|
||||||
<SectionCard title="Clinical Manifestations">
|
<SectionCard title="Clinical Manifestations">
|
||||||
<Paragraphs items={[activePatternData.clinicalManifestation]} />
|
<BulletList
|
||||||
|
items={
|
||||||
|
Array.isArray(activePatternData.clinicalManifestation)
|
||||||
|
? activePatternData.clinicalManifestation
|
||||||
|
: parseBullets(activePatternData.clinicalManifestation)
|
||||||
|
}
|
||||||
|
/>
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,40 @@ import { BackActionContext } from "../../context/BackActionContext";
|
||||||
import { Hero } from "../shared/Hero";
|
import { Hero } from "../shared/Hero";
|
||||||
import { SectionCard } from "../shared/SectionCard";
|
import { SectionCard } from "../shared/SectionCard";
|
||||||
import { Paragraphs } from "../shared/Paragraphs";
|
import { Paragraphs } from "../shared/Paragraphs";
|
||||||
import { asString } from "../helpers/value";
|
import { BulletList } from "../shared/BulletList";
|
||||||
|
import { asString, asStringArray } from "../helpers/value";
|
||||||
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
||||||
|
|
||||||
interface ConnectingChannelDetails {
|
interface ConnectingChannelDetails {
|
||||||
empty?: string;
|
empty?: string[];
|
||||||
full?: string;
|
full?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChannelData {
|
interface ChannelData {
|
||||||
name: string;
|
name: string;
|
||||||
code?: string;
|
code?: string;
|
||||||
mainChannel?: string;
|
mainChannel?: string[];
|
||||||
connectingChannel?: ConnectingChannelDetails | string;
|
connectingChannel?: ConnectingChannelDetails | string[];
|
||||||
muscleChannel?: string;
|
muscleChannel?: string[];
|
||||||
greatConnectingChannelOfSpleen?: string;
|
greatConnectingChannelOfSpleen?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const FALLBACK_CHANNELS: ChannelData[] = [
|
interface RawChannelData {
|
||||||
|
name: string;
|
||||||
|
code?: string;
|
||||||
|
mainChannel?: string | string[];
|
||||||
|
connectingChannel?:
|
||||||
|
| {
|
||||||
|
empty?: string | string[];
|
||||||
|
full?: string | string[];
|
||||||
|
}
|
||||||
|
| string
|
||||||
|
| string[];
|
||||||
|
muscleChannel?: string | string[];
|
||||||
|
greatConnectingChannelOfSpleen?: string | string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const FALLBACK_CHANNELS: RawChannelData[] = [
|
||||||
{
|
{
|
||||||
name: "Lungs",
|
name: "Lungs",
|
||||||
code: "lungs",
|
code: "lungs",
|
||||||
|
|
@ -217,23 +233,74 @@ function normalizeKey(str: string): string {
|
||||||
return str.toLowerCase().replace(/[^a-z0-9]/g, "");
|
return str.toLowerCase().replace(/[^a-z0-9]/g, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseConnectingChannel(val: unknown): ConnectingChannelDetails | string | undefined {
|
function parseBullets(raw: unknown): string[] {
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
return asStringArray(raw);
|
||||||
|
}
|
||||||
|
const text = asString(raw).trim();
|
||||||
|
if (!text) return [];
|
||||||
|
|
||||||
|
if (text.includes("\n")) {
|
||||||
|
return text
|
||||||
|
.split("\n")
|
||||||
|
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text.includes(";")) {
|
||||||
|
return text
|
||||||
|
.split(";")
|
||||||
|
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts = text.split(/,\s*(?![^()]*\))/);
|
||||||
|
if (parts.length > 1) {
|
||||||
|
return parts
|
||||||
|
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [text];
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseConnectingChannel(val: unknown): ConnectingChannelDetails | string[] | undefined {
|
||||||
if (!val) return undefined;
|
if (!val) return undefined;
|
||||||
if (typeof val === "string") return val;
|
if (Array.isArray(val)) {
|
||||||
|
const arr = parseBullets(val);
|
||||||
|
return arr.length > 0 ? arr : undefined;
|
||||||
|
}
|
||||||
|
if (typeof val === "string") {
|
||||||
|
const bullets = parseBullets(val);
|
||||||
|
return bullets.length > 0 ? bullets : undefined;
|
||||||
|
}
|
||||||
if (typeof val === "object") {
|
if (typeof val === "object") {
|
||||||
const obj = val as Record<string, unknown>;
|
const obj = val as Record<string, unknown>;
|
||||||
const empty = asString(obj.empty);
|
const empty = parseBullets(obj.empty);
|
||||||
const full = asString(obj.full);
|
const full = parseBullets(obj.full);
|
||||||
if (empty || full) {
|
if (empty.length > 0 || full.length > 0) {
|
||||||
return {
|
return {
|
||||||
empty: empty || undefined,
|
empty: empty.length > 0 ? empty : undefined,
|
||||||
full: full || undefined,
|
full: full.length > 0 ? full : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toChannelData(raw: RawChannelData): ChannelData {
|
||||||
|
return {
|
||||||
|
name: raw.name,
|
||||||
|
code: raw.code,
|
||||||
|
mainChannel: raw.mainChannel ? parseBullets(raw.mainChannel) : undefined,
|
||||||
|
connectingChannel: parseConnectingChannel(raw.connectingChannel),
|
||||||
|
muscleChannel: raw.muscleChannel ? parseBullets(raw.muscleChannel) : undefined,
|
||||||
|
greatConnectingChannelOfSpleen: raw.greatConnectingChannelOfSpleen
|
||||||
|
? parseBullets(raw.greatConnectingChannelOfSpleen)
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function TwelveChannelsDetailRenderer({
|
export function TwelveChannelsDetailRenderer({
|
||||||
content,
|
content,
|
||||||
data,
|
data,
|
||||||
|
|
@ -259,9 +326,10 @@ export function TwelveChannelsDetailRenderer({
|
||||||
|
|
||||||
// 1. Seed fallback channels
|
// 1. Seed fallback channels
|
||||||
for (const ch of FALLBACK_CHANNELS) {
|
for (const ch of FALLBACK_CHANNELS) {
|
||||||
map.set(normalizeKey(ch.name), ch);
|
const parsed = toChannelData(ch);
|
||||||
if (ch.code) map.set(normalizeKey(ch.code), ch);
|
map.set(normalizeKey(parsed.name), parsed);
|
||||||
list.push(ch);
|
if (parsed.code) map.set(normalizeKey(parsed.code), parsed);
|
||||||
|
list.push(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Overlay live queried items if available
|
// 2. Overlay live queried items if available
|
||||||
|
|
@ -272,27 +340,29 @@ export function TwelveChannelsDetailRenderer({
|
||||||
const name = asString(a.name) || item.title;
|
const name = asString(a.name) || item.title;
|
||||||
if (!name) continue;
|
if (!name) continue;
|
||||||
|
|
||||||
const mainChannel = asString(a.main_channel);
|
const mainChannel = parseBullets(a.main_channel);
|
||||||
const connectingChannel = parseConnectingChannel(a.connecting_channel);
|
const connectingChannel = parseConnectingChannel(a.connecting_channel);
|
||||||
const muscleChannel = asString(a.muscle_channel);
|
const muscleChannel = parseBullets(a.muscle_channel);
|
||||||
|
|
||||||
const greatConnecting = a.great_connecting_channel_of_the_spleen;
|
const greatConnecting = a.great_connecting_channel_of_the_spleen;
|
||||||
let greatConnectingStr: string | undefined;
|
let greatConnectingBullets: string[] | undefined;
|
||||||
if (typeof greatConnecting === "object" && greatConnecting !== null) {
|
if (typeof greatConnecting === "object" && greatConnecting !== null) {
|
||||||
greatConnectingStr = asString(
|
const g = parseBullets(
|
||||||
(greatConnecting as Record<string, unknown>).clinical_manifestations,
|
(greatConnecting as Record<string, unknown>).clinical_manifestations,
|
||||||
);
|
);
|
||||||
} else if (typeof greatConnecting === "string") {
|
if (g.length > 0) greatConnectingBullets = g;
|
||||||
greatConnectingStr = greatConnecting;
|
} else if (greatConnecting) {
|
||||||
|
const g = parseBullets(greatConnecting);
|
||||||
|
if (g.length > 0) greatConnectingBullets = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channelData: ChannelData = {
|
const channelData: ChannelData = {
|
||||||
name,
|
name,
|
||||||
code: asString(a.code) || item.slug,
|
code: asString(a.code) || item.slug,
|
||||||
mainChannel: mainChannel || undefined,
|
mainChannel: mainChannel.length > 0 ? mainChannel : undefined,
|
||||||
connectingChannel,
|
connectingChannel,
|
||||||
muscleChannel: muscleChannel || undefined,
|
muscleChannel: muscleChannel.length > 0 ? muscleChannel : undefined,
|
||||||
greatConnectingChannelOfSpleen: greatConnectingStr || undefined,
|
greatConnectingChannelOfSpleen: greatConnectingBullets,
|
||||||
};
|
};
|
||||||
|
|
||||||
const key = normalizeKey(name);
|
const key = normalizeKey(name);
|
||||||
|
|
@ -324,23 +394,29 @@ export function TwelveChannelsDetailRenderer({
|
||||||
const activeChannelData: ChannelData | null = useMemo(() => {
|
const activeChannelData: ChannelData | null = useMemo(() => {
|
||||||
if (isDirectLeafChannel) {
|
if (isDirectLeafChannel) {
|
||||||
const name = asString(data.name) || content.title || "Twelve Channels";
|
const name = asString(data.name) || content.title || "Twelve Channels";
|
||||||
|
const mainChannel = parseBullets(data.main_channel);
|
||||||
|
const connectingChannel = parseConnectingChannel(data.connecting_channel);
|
||||||
|
const muscleChannel = parseBullets(data.muscle_channel);
|
||||||
|
|
||||||
const greatConnecting = data.great_connecting_channel_of_the_spleen;
|
const greatConnecting = data.great_connecting_channel_of_the_spleen;
|
||||||
let greatConnectingStr: string | undefined;
|
let greatConnectingBullets: string[] | undefined;
|
||||||
if (typeof greatConnecting === "object" && greatConnecting !== null) {
|
if (typeof greatConnecting === "object" && greatConnecting !== null) {
|
||||||
greatConnectingStr = asString(
|
const g = parseBullets(
|
||||||
(greatConnecting as Record<string, unknown>).clinical_manifestations,
|
(greatConnecting as Record<string, unknown>).clinical_manifestations,
|
||||||
);
|
);
|
||||||
} else if (typeof greatConnecting === "string") {
|
if (g.length > 0) greatConnectingBullets = g;
|
||||||
greatConnectingStr = greatConnecting;
|
} else if (greatConnecting) {
|
||||||
|
const g = parseBullets(greatConnecting);
|
||||||
|
if (g.length > 0) greatConnectingBullets = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
code: asString(data.code) || undefined,
|
code: asString(data.code) || undefined,
|
||||||
mainChannel: asString(data.main_channel) || undefined,
|
mainChannel: mainChannel.length > 0 ? mainChannel : undefined,
|
||||||
connectingChannel: parseConnectingChannel(data.connecting_channel),
|
connectingChannel,
|
||||||
muscleChannel: asString(data.muscle_channel) || undefined,
|
muscleChannel: muscleChannel.length > 0 ? muscleChannel : undefined,
|
||||||
greatConnectingChannelOfSpleen: greatConnectingStr,
|
greatConnectingChannelOfSpleen: greatConnectingBullets,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,9 +464,9 @@ export function TwelveChannelsDetailRenderer({
|
||||||
<Hero title={activeChannelData.name} />
|
<Hero title={activeChannelData.name} />
|
||||||
|
|
||||||
{/* 1. Main Channel Card */}
|
{/* 1. Main Channel Card */}
|
||||||
{activeChannelData.mainChannel ? (
|
{activeChannelData.mainChannel && activeChannelData.mainChannel.length > 0 ? (
|
||||||
<SectionCard title="Main Channel" defaultExpanded>
|
<SectionCard title="Main Channel" defaultExpanded>
|
||||||
<Paragraphs items={[activeChannelData.mainChannel]} />
|
<BulletList items={activeChannelData.mainChannel} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|
@ -399,47 +475,46 @@ export function TwelveChannelsDetailRenderer({
|
||||||
<SectionCard title="Connecting Channel" defaultExpanded>
|
<SectionCard title="Connecting Channel" defaultExpanded>
|
||||||
{isConnectingObj ? (
|
{isConnectingObj ? (
|
||||||
<View style={styles.connectingDetailsContainer}>
|
<View style={styles.connectingDetailsContainer}>
|
||||||
{(connecting as ConnectingChannelDetails).full ? (
|
{(connecting as ConnectingChannelDetails).full &&
|
||||||
|
(connecting as ConnectingChannelDetails).full!.length > 0 ? (
|
||||||
<View style={styles.conditionBlock}>
|
<View style={styles.conditionBlock}>
|
||||||
<View style={styles.conditionHeader}>
|
<View style={styles.conditionHeader}>
|
||||||
<View style={[styles.conditionDot, { backgroundColor: Colors.error || "#EF4444" }]} />
|
<View style={[styles.conditionDot, { backgroundColor: Colors.error || "#EF4444" }]} />
|
||||||
<Text style={styles.conditionTitle}>Full Condition</Text>
|
<Text style={styles.conditionTitle}>Full Condition</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.conditionText}>
|
<BulletList items={(connecting as ConnectingChannelDetails).full!} />
|
||||||
{(connecting as ConnectingChannelDetails).full}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{(connecting as ConnectingChannelDetails).empty ? (
|
{(connecting as ConnectingChannelDetails).empty &&
|
||||||
|
(connecting as ConnectingChannelDetails).empty!.length > 0 ? (
|
||||||
<View style={[styles.conditionBlock, { marginTop: moderateScale(10) }]}>
|
<View style={[styles.conditionBlock, { marginTop: moderateScale(10) }]}>
|
||||||
<View style={styles.conditionHeader}>
|
<View style={styles.conditionHeader}>
|
||||||
<View style={[styles.conditionDot, { backgroundColor: "#3B82F6" }]} />
|
<View style={[styles.conditionDot, { backgroundColor: "#3B82F6" }]} />
|
||||||
<Text style={styles.conditionTitle}>Empty Condition</Text>
|
<Text style={styles.conditionTitle}>Empty Condition</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.conditionText}>
|
<BulletList items={(connecting as ConnectingChannelDetails).empty!} />
|
||||||
{(connecting as ConnectingChannelDetails).empty}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
) : typeof connecting === "string" ? (
|
) : Array.isArray(connecting) ? (
|
||||||
<Paragraphs items={[connecting]} />
|
<BulletList items={connecting} />
|
||||||
) : null}
|
) : null}
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* 3. Muscle Channel Card */}
|
{/* 3. Muscle Channel Card */}
|
||||||
{activeChannelData.muscleChannel ? (
|
{activeChannelData.muscleChannel && activeChannelData.muscleChannel.length > 0 ? (
|
||||||
<SectionCard title="Muscle Channel" defaultExpanded>
|
<SectionCard title="Muscle Channel" defaultExpanded>
|
||||||
<Paragraphs items={[activeChannelData.muscleChannel]} />
|
<BulletList items={activeChannelData.muscleChannel} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* 4. Great Connecting Channel of the Spleen (if present) */}
|
{/* 4. Great Connecting Channel of the Spleen (if present) */}
|
||||||
{activeChannelData.greatConnectingChannelOfSpleen ? (
|
{activeChannelData.greatConnectingChannelOfSpleen &&
|
||||||
|
activeChannelData.greatConnectingChannelOfSpleen.length > 0 ? (
|
||||||
<SectionCard title="Great Connecting Channel of the Spleen" defaultExpanded>
|
<SectionCard title="Great Connecting Channel of the Spleen" defaultExpanded>
|
||||||
<Paragraphs items={[activeChannelData.greatConnectingChannelOfSpleen]} />
|
<BulletList items={activeChannelData.greatConnectingChannelOfSpleen} />
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
) : null}
|
) : null}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import { ThreeBurnersCollectionRenderer, ThreeBurnersCardRenderer } from "./coll
|
||||||
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
|
import { ThreeBurnersDetailRenderer } from "./details/ThreeBurnersDetailRenderer";
|
||||||
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
|
import { SixStagesDetailRenderer } from "./details/SixStagesDetailRenderer";
|
||||||
import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer";
|
import { TcmPatternDetailRenderer } from "./details/TcmPatternDetailRenderer";
|
||||||
|
import { ExtraOrdinaryVesselsDetailRenderer } from "./details/ExtraOrdinaryVesselsDetailRenderer";
|
||||||
|
|
||||||
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
||||||
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
||||||
|
|
@ -109,6 +110,7 @@ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRend
|
||||||
m0017_ct0002_card: ThreeBurnersCardRenderer,
|
m0017_ct0002_card: ThreeBurnersCardRenderer,
|
||||||
});
|
});
|
||||||
export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({
|
export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({
|
||||||
|
extra_ordinary_vessel_detail: ExtraOrdinaryVesselsDetailRenderer,
|
||||||
module_catalog_detail: IndexEntryDetailRenderer,
|
module_catalog_detail: IndexEntryDetailRenderer,
|
||||||
acu_point_index_detail: IndexEntryDetailRenderer,
|
acu_point_index_detail: IndexEntryDetailRenderer,
|
||||||
meridian_index_detail: MeridianPointsDetailRenderer,
|
meridian_index_detail: MeridianPointsDetailRenderer,
|
||||||
|
|
@ -355,6 +357,13 @@ export function resolveDetailRenderer(
|
||||||
) {
|
) {
|
||||||
return TcmPatternDetailRenderer;
|
return TcmPatternDetailRenderer;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
normalizedTemplate?.startsWith("m0020_") ||
|
||||||
|
normalizedModule === "m0020" ||
|
||||||
|
code === "extra_ordinary_vessel_detail"
|
||||||
|
) {
|
||||||
|
return ExtraOrdinaryVesselsDetailRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
if (code && detailRenderers[code]) return detailRenderers[code];
|
if (code && detailRenderers[code]) return detailRenderers[code];
|
||||||
reportMissingRenderer("detail", code);
|
reportMissingRenderer("detail", code);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { Spacing } from "@/theme/spacing";
|
||||||
import { ContentLink } from "../../components/navigation/ContentLink";
|
import { ContentLink } from "../../components/navigation/ContentLink";
|
||||||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||||
import { humanizeKey } from "../helpers/value";
|
import { humanizeKey } from "../helpers/value";
|
||||||
|
import { BulletList } from "./BulletList";
|
||||||
|
|
||||||
export interface ContentValueProps {
|
export interface ContentValueProps {
|
||||||
value: unknown;
|
value: unknown;
|
||||||
|
|
@ -20,6 +21,28 @@ export interface ContentValueProps {
|
||||||
emptyText?: string | null;
|
emptyText?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseBullets(text: string): string[] {
|
||||||
|
if (text.includes("\n")) {
|
||||||
|
return text
|
||||||
|
.split("\n")
|
||||||
|
.map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim())
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
if (text.includes(";")) {
|
||||||
|
return text
|
||||||
|
.split(";")
|
||||||
|
.map((s) => s.trim().replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
const parts = text.split(/,\s*(?![^()]*\))/);
|
||||||
|
if (parts.length > 1) {
|
||||||
|
return parts
|
||||||
|
.map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, ""))
|
||||||
|
.filter((s) => s.length > 0);
|
||||||
|
}
|
||||||
|
return [text];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference-aware fallback renderer for arbitrary nested attribute values.
|
* Reference-aware fallback renderer for arbitrary nested attribute values.
|
||||||
*
|
*
|
||||||
|
|
@ -54,6 +77,10 @@ export function ContentValue({
|
||||||
) : null;
|
) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (visible.every((item) => typeof item === "string")) {
|
||||||
|
return <BulletList items={visible as string[]} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.stack}>
|
<View style={styles.stack}>
|
||||||
{visible.map((item, index) => (
|
{visible.map((item, index) => (
|
||||||
|
|
@ -84,12 +111,32 @@ export function ContentValue({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.object}>
|
<View style={styles.object}>
|
||||||
{entries.map(([key, child]) => (
|
{entries.map(([key, child]) => {
|
||||||
<View key={key} style={styles.objectRow}>
|
const isClinical =
|
||||||
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
key.toLowerCase().includes("clinical") ||
|
||||||
<ContentValue value={child} textStyle={textStyle} />
|
key.toLowerCase().includes("manifestation");
|
||||||
</View>
|
|
||||||
))}
|
const renderChild = () => {
|
||||||
|
if (
|
||||||
|
isClinical &&
|
||||||
|
typeof child === "string" &&
|
||||||
|
child.trim().length > 0
|
||||||
|
) {
|
||||||
|
const bullets = parseBullets(child);
|
||||||
|
if (bullets.length > 1) {
|
||||||
|
return <BulletList items={bullets} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <ContentValue value={child} textStyle={textStyle} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={key} style={styles.objectRow}>
|
||||||
|
<Text style={styles.objectLabel}>{humanizeKey(key)}</Text>
|
||||||
|
{renderChild()}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export function ImageGallery({ images }: { images: Record<string, unknown>[] })
|
||||||
const relationalMedia = useRelationalContentMedia();
|
const relationalMedia = useRelationalContentMedia();
|
||||||
|
|
||||||
if (relationalMedia.length > 0) {
|
if (relationalMedia.length > 0) {
|
||||||
return <ContentMediaGallery media={relationalMedia} title="Visual reference" />;
|
return <ContentMediaGallery media={relationalMedia} title="Visual Reference" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const visible = images.filter((item) => asString(item.image_path).trim().length > 0);
|
const visible = images.filter((item) => asString(item.image_path).trim().length > 0);
|
||||||
|
|
@ -37,7 +37,7 @@ export function ImageGallery({ images }: { images: Record<string, unknown>[] })
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return <ContentMediaGallery media={fallbackMedia} title="Visual reference" />;
|
return <ContentMediaGallery media={fallbackMedia} title="Visual Reference" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue