家谱图

关于家谱图

家谱图是一种超越传统家族树(仅记录姓名和日期)的家族关系图:它跨越三代或更多代记录家庭的情感医疗脉络。治疗师、社会工作者和遗传咨询师用它来揭示那些在文字病例记录中难以察觉的规律——疏离、过度卷入、反复出现的疾病。

Schematex 遵循临床培训中使用的 McGoldrick、Gerson & Petry(2020)标准,以及广泛采用的 GenoPro 32 类情感关系分类法。理论和历史背景请参见维基百科:家谱图。本页记录解析器当前支持的语法。

genogram·§ McGoldrick
↘ preview
100%
Genogram: The Potter Family Genogram diagram with 10 individuals across 3 generations The Potter Family Fleamont (1909-1979) 70 Euphemia (1920-1979) 59 Mr_evans (1925) Mrs_evans (1928) James (1960-1981) 21 Lily (1960-1981) 21 Vernon (1951) Petunia (1958) Harry (1980) Dudley (1980) Fleamont (1909–1979) Euphemia (1920–1979) Mr_evans (b. 1925) Mrs_evans (b. 1928) James (1960–1981) Lily (1960–1981) Vernon (b. 1951) Petunia (b. 1958) Harry (b. 1980) Dudley (b. 1980) m. 1978 SYMBOLS Deceased RELATIONSHIPS Close Hostile Cutoff MARKERS Index person (focal subject)
UTF-8 · LF · 17 lines · 486 chars✓ parsed·1.8 ms·15.4 KB SVG

1. 第一张家谱图

最小的临床实用家谱图:两位父母,一个孩子。

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 3 individuals across 2 generations Bob (1978) Alice (1980) Carol (2008) Bob (b. 1978) Alice (b. 1980) Carol (b. 2008) m. 2005
UTF-8 · LF · 5 lines · 92 chars✓ parsed·0.5 ms·5.3 KB SVG

四条规则涵盖 80% 的使用场景:

  1. 以关键字 genogram 开头,后可跟一个引号括起的标题。
  2. 在独立行上声明每个人:id [属性]。属性用方括号括起,以逗号分隔。
  3. 配偶运算符连接两人——这里使用 --(婚姻);其他六种运算符见§4.1。末尾的引号字符串是关系标签。
  4. 在配偶行下缩进以添加子女。

注释必须独占一行,以 #// 或 Mermaid 风格的 %% 开头。不支持行尾内联注释(bob [male, 1978] # ...),会导致解析器报错——见§8。


2. 个人

个人行的格式为 id [属性1, 属性2, …]。属性以逗号分隔,顺序无关,全部可选。

ID 规则。 必须匹配 [a-zA-Z][a-zA-Z0-9_-]*。ID 内部不区分大小写,但保留原始大小写作为显示标签(可用 label:"…" 覆盖)。

解析器当前支持的属性:

属性取值效果
性别malefemaleunknownother形状:正方形、圆形、菱形、菱形
状态deceasedstillbornmiscarriageabortion视觉修饰符(打叉、缩小形状等)
出生年份4 位数字,如 1980第一个 4 位数字词元 = 出生年份
死亡年份出生年份之后的 4 位数字,如 1980, 2055第二个 4 位数字词元 = 死亡年份
index标志同心形状 = 确认患者
unknown-siblings标志? 的菱形——≥1 个身份不明的兄弟姐妹的占位符
age:Nage:42在形状内显示年龄
death:YYYYdeath:2020显式死亡年份
label:"…"label:"张三医生"显示标签覆盖
sibling-of:<id>sibling-of:monica固定与被引用兄弟姐妹同代,绘制虚线括号——用于已知亲属但家世不明的情况。
conditions:…见§5医疗/心理状况
key:value任何自定义键值存储为元数据
genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 4 individuals across 1 generations Grandma (1920-2002) 82 Dad (1950) 74 Me (1985) Em (2012) Grandma (1920–2002) Dad (b. 1950) Me (b. 1985) Em (b. 2012) SYMBOLS Deceased MARKERS Index person (focal subject)
UTF-8 · LF · 5 lines · 131 chars✓ parsed·0.6 ms·6.9 KB SVG

3. 形状

视觉符号性别值含义
☐ 正方形male男性
○ 圆形female女性
◇ 菱形unknownother,或省略属性未知/未指定

状态修饰符叠加在基础形状上:

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 4 individuals across 1 generations Passed (1930-2010) 80 Alive (1960) Stillborn_child Lost Passed (1930–2010) Alive (b. 1960) Stillborn_child Lost SYMBOLS Unknown Deceased Stillborn Miscarriage
UTF-8 · LF · 5 lines · 128 chars✓ parsed·0.7 ms·7.1 KB SVG

4. 连接

4.1 配偶运算符

解析器按以下顺序尝试匹配,第一个匹配成功的获胜——因此 -x- 优先于 --

运算符类型示例含义
-x-离婚a -x- b离婚
-/-分居a -/- b分居(已婚)
-//分居a -// b分居(-/- 的别名)
-o-订婚a -o- b订婚
==血亲a == b血缘关系配偶
--婚姻a -- b婚姻
~同居a ~ b同居/长期伴侣(现在进行时)
~/~同居已终止a ~/~ b同居已结束(未婚)。在拉丁美洲儿童保护案例中常见,指亲生父母曾未婚同居而关系已经结束——区别于 -x- 离婚(无婚姻)和 -/- 分居(仍已婚)。

末尾的引号字符串成为关系标签(a -- b "m. 2005")。

4.2 右侧内联个人

若右侧人员尚未声明,可就地声明:

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 3 individuals across 2 generations Ben (1968) Ann (1970) Kim (1997) Ben (b. 1968) Ann (b. 1970) Kim (b. 1997) m. 1995
UTF-8 · LF · 4 lines · 82 chars✓ parsed·0.6 ms·5.3 KB SVG

4.3 子女(在配偶行下缩进)

在配偶行下缩进 = "这些是该配偶的子女。"任何大于配偶行的缩进均有效;按惯例多缩进 2 个空格。子女按声明顺序渲染(存在出生年份时也按出生年份排序)。

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 6 individuals across 2 generations Dad (1950) Mom (1952) Eldest (1975) Middle (1978) Twin_a (1985) Twin_b (1985) Dad (b. 1950) Mom (b. 1952) Eldest (b. 1975) Middle (b. 1978) Twin_a (b. 1985) Twin_b (b. 1985) STRUCTURAL Adopted Twin Identical
UTF-8 · LF · 8 lines · 186 chars✓ parsed·0.6 ms·7.9 KB SVG

特殊子女属性:

属性效果
adopted收养线条样式
foster寄养关系
guardian非父母亲属的监护权(如祖父母监护)。与 foster 使用相同原语——当亲生父母也已声明时,绘制为次要"当前监护人"链接。
twin-identical与同一配偶的其他 twin-identical 子女分组
twin-fraternal与其他 twin-fraternal 子女分组
unknown-siblings单个带 ? 字形的菱形——"≥1 个兄弟姐妹,数量和身份不明"(系谱惯例)。

4.3.1 双亲家庭(寄养、收养、监护)

被安置在非亲生监护人处而亲生父母仍属于案例的子女可在两对配偶下声明。第一次在亲生配偶下声明完整属性再在当前监护人下仅重新声明 [foster] / [adopted] / [guardian]。第一次声明决定布局;第二次绘制为次要虚线"当前监护人"链接,不将子女从其亲生父母位置移开。

genogram·§ McGoldrick
↘ preview
100%
Genogram: Foster placement Genogram diagram with 6 individuals across 2 generations Foster placement Bio dad Bio mom Foster dad Foster mom Own (2010) Child (2018) Bio dad Bio mom Foster dad Foster mom Own (b. 2010) Child (b. 2018) STRUCTURAL Cohabiting (ended) Foster MARKERS Index person (focal subject)
UTF-8 · LF · 10 lines · 240 chars✓ parsed·1.7 ms·8.9 KB SVG

同一原语适用于收养(封闭/开放)、寄养安置和亲属监护——仅关键字不同。重新声明会将不冲突的属性(性别、出生年份、标签、index 标记)合并到原记录中;声明冲突的 malefemale 会引发解析错误,而非静默覆盖。

4.3.2 未知数量的兄弟姐妹

当案例文件提到"该孩子有兄弟姐妹"但未具名时,可使用独立行上的 ? 简写,或对普通 ID 使用 [unknown-siblings]。两者均渲染为带有"?"字形的单个菱形——这是"一个或多个兄弟姐妹,身份不明"的标准系谱标记。

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 4 individuals across 2 generations Dad Mom Known_kid (2018) ? ? Dad Mom Known_kid (b. 2018) ? SYMBOLS Unknown MARKERS Sibling(s) — unknown count
UTF-8 · LF · 6 lines · 72 chars✓ parsed·0.8 ms·7.1 KB SVG

4.3.3 兄弟姐妹关系(已知亲属,家世不明)

若要表达"X 是 Y 的兄弟/姐妹"而无需虚构父母,可使用 sibling-of: <id> 属性。渲染器将 X 固定在 Y 的同一代,并在两者上方绘制虚线括号——这是已知亲属但家世不属于案例的标准系谱惯例。

genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 2 individuals across 1 generations Monica (1990) Tío materno Monica (b. 1990) Tío materno
UTF-8 · LF · 3 lines · 85 chars✓ parsed·0.4 ms·4.4 KB SVG

4.4 情感关系

独立行,解析器模式为 A -类型- B(无方向)或 A -类型-> B(有方向)。末尾可加可选的引号标签。两个人必须在情感行之前已声明。

harry -cutoff- petunia           # 无方向
harry -hostile- dudley "since 1991"
uncle -abuse-> nephew             # 有方向(箭头)

解析器当前支持的全部 32 种类型:

类别类型
正面/亲近harmonyclosebestfriendsloveinlovefriendship
负面/敌对hostileconflictenmitydistant-hostilecutoff
矛盾close-hostilefusedfused-hostile
距离distantnormalnevermet
虐待*(有方向)*abusephysical-abuseemotional-abusesexual-abuseneglect
控制*(有方向)*manipulativecontrollingjealous
特殊focusedfocused-negdistrustadmirerlimerence
genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 3 individuals across 1 generations since 2010 Dad (1950) Son (1985) Daughter (1988) Dad (b. 1950) Son (b. 1985) Daughter (b. 1988) RELATIONSHIPS Close Conflict Cutoff
UTF-8 · LF · 7 lines · 136 chars✓ parsed·1.5 ms·6.8 KB SVG

5. 医疗状况

语法:conditions: 名称(填充) [+ 名称(填充, #颜色)]…

father [male, 1945, conditions: heart(full, #E53935)]
mother [female, 1948, conditions: diabetes(half-left) + anxiety(half-right, #26A69A)]
  • 名称 — 您选择的任何标识符(在图例/提示中显示)。
  • 填充 — 必填,控制形状的哪个区域着色。见下表。
  • 颜色 — 可选的十六进制颜色。默认值取决于渲染器主题。
  • 多个状况用 + 连接。每个状况需有自己的 (填充)

填充位置:

fill区域
full整个形状
half-left / half-right左半 / 右半
half-top / half-bottom上半 / 下半
quad-tl / quad-tr / quad-bl / quad-br一个象限
striped斜线条纹图案(无症状携带者)
dotted点状图案
genogram·§ McGoldrick
↘ preview
100%
Genogram Genogram diagram with 3 individuals across 2 generations Dad (1950) Mom (1952) Son (1980) Dad (b. 1950) Mom (b. 1952) Son (b. 1980) CONDITIONS Heart Diabetes Depression Carrier
UTF-8 · LF · 5 lines · 205 chars✓ parsed·1.2 ms·8.5 KB SVG

6. 标签与注释

  • 标题: genogram "史密斯家族" — 仅限第一行。
  • 人物标签覆盖: alice [female, label:"Dr. Alice Smith"]
  • 关系标签: 在配偶行或情感行末尾加引号字符串 — alice -- bob "m. 2005"
  • 注释: #//%% 位于行首(前面可有空白)。不支持内联注释。
genogram "Smith Family"
  # this line is a comment — fine
  %% Mermaid-style comment — also fine
  alice [female, 1980]   # ← 这个行尾注释会导致解析器报错

7. 保留字与转义

行首保留字: genogram(标头关键字)。

行内保留运算符词元 — 避免在 ID 中使用以下序列: --~~/~==-x--/--//-o-,以及任何匹配情感关系类型的 -<类型>- / -<类型>->

保留 ID ? — 子女行上的裸 ? 自动生成一个带 unknown-siblings 标记的合成占位符。不要将 ? 用作真实 ID。

含空格的字符串必须用双引号括起:标题、标签、label:"…"。不支持单引号和反引号。


8. 常见错误

真实的解析器错误、触发原因和修正方法。

您写了解析器报错修正方法
alex [nonbinary, 1995]Unknown property 'nonbinary'使用 unknownother(nonbinary 见§13 路线图)
alice [female, transgender]Unknown property 'transgender'当前尚不可解析(§13 路线图)
dad -- mom ← 之后 child [male, 2010] 与配偶行同级缩进子女被解析为新的顶级个人,而非其子女将子女行缩进比配偶行更深(2 个空格即够)
A -- B,其中 A 从未声明Unknown individual 'A'在上方声明 A [性别, 年份]
father -- mother "married" 位于第 1 行(无 genogram 标头)Expected "genogram" headergenogramgenogram "标题" 开头
conditions: diabetes + cancer(无括号)Invalid condition format 'diabetes'添加填充:conditions: diabetes(half-left) + cancer(half-right)
[triplet-identical]Unknown property 'triplet-identical'三胞胎当前尚不可解析(§13 路线图)
dad -- mom # first marriage行尾 # 注释被视为标签的一部分或报错将注释移至独立行
同一 ID 以不同性别声明两次(x [male] 后又 x [female]Conflicting sex for 'x': previously 'male', now 'female'选择其一或重命名其中一个 ID
重新声明 child [foster] 但从未声明亲生父母child 成为寄养家庭的普通子女(不绘制次要链接)这是预期行为——次要链接需要先存在来自先前声明的亲生父母-子女关系

9. 语法(EBNF)

document       = header (blank | comment | individual | couple-block | emotional)*

header         = "genogram" ( WS quoted-string )? NEWLINE
quoted-string  = '"' any-char-but-quote* '"'

individual     = INDENT id ( "[" attrs "]" )? NEWLINE
couple-block   = INDENT id WS coupleOp WS right-side ( WS quoted-string )? NEWLINE
                   ( deeper-indent child )*
child          = INDENT id ( "[" attrs "]" )? NEWLINE
               | INDENT "?" NEWLINE                              // unknown-count sibling shorthand
right-side     = id ( "[" attrs "]" )?

emotional      = INDENT id WS "-" type "-"  id ( WS quoted-string )? NEWLINE
               | INDENT id WS "-" type "->" id ( WS quoted-string )? NEWLINE

coupleOp       = "~/~" | "-//" | "-x-" | "-/-" | "-o-" | "==" | "--" | "~"
type           = "harmony" | "close" | "bestfriends" | "love" | "inlove"
               | "friendship" | "hostile" | "conflict" | "enmity"
               | "distant-hostile" | "cutoff" | "close-hostile" | "fused"
               | "fused-hostile" | "distant" | "normal" | "nevermet"
               | "abuse" | "physical-abuse" | "emotional-abuse"
               | "sexual-abuse" | "neglect" | "manipulative" | "controlling"
               | "jealous" | "focused" | "focused-neg" | "distrust"
               | "admirer" | "limerence"

id             = [a-zA-Z] [a-zA-Z0-9_-]*
attrs          = attr ("," attr)*
attr           = "male" | "female" | "unknown" | "other"
               | "deceased" | "stillborn" | "miscarriage" | "abortion"
               | "adopted" | "foster" | "guardian"
               | "twin-identical" | "twin-fraternal"
               | "index" | "unknown-siblings"
               | digit digit digit digit                         // year
               | "age" ":" digits
               | "death" ":" digit digit digit digit
               | "label" ":" quoted-string
               | "sibling-of" ":" id
               | "conditions" ":" condition ("+" condition)*
               | key ":" value                                    // custom
condition      = name "(" fill ("," "#" hex)? ")"
fill           = "full" | "half-left" | "half-right" | "half-top" | "half-bottom"
               | "quad-tl" | "quad-tr" | "quad-bl" | "quad-br"
               | "striped" | "dotted"

comment        = INDENT ( "#" | "//" | "%%" ) any NEWLINE

权威来源:src/diagrams/genogram/parser.ts。若本文档与解析器有出入,以解析器为准——欢迎提 issue。


10. 标准合规性

Schematex 家谱图遵循 McGoldrick、Gerson & Petry(2020),《家谱图:评估与治疗》第 4 版的结构符号、配偶运算符和代际对齐规范。情感关系分类遵循 GenoPro 的 32 类分类(我们未完整实现 GenoPro 的 34 类分类;focused-admirer 和一个重复项归并至 focusedadmirer)。

当前已实现与标准的对应情况:

  • ✅ 核心结构符号(男性/女性/未知、死亡、死产、流产、堕胎)
  • ✅ McGoldrick 6 种配偶运算符系统
  • ✅ GenoPro 32 种情感类型,临床指定处使用有方向版本
  • ✅ 医疗状况象限填充系统(4 位置 + 条纹/点状图案)
  • ✅ 确认患者(同心形状)
  • ✅ 双胞胎分组(同卵/异卵)
  • ⏳ Bennett 2022 性别包容性增补——见§13
  • ⏳ 捐赠者/代孕/继子女连接类型——见§13

参考文献:

  • McGoldrick, M., Gerson, R., & Petry, S. (2020). Genograms: Assessment and Treatment (4th ed.).
  • Hardy, K.V. & Laszloffy, T.A. (1995). The cultural genogram. J Marital Fam Ther, 21(3), 227–237.
  • GenoPro 符号参考 — https://genopro.com/genogram/

11. 相关示例

来自示例库的可直接使用场景:

genogram·§ McGoldrick 2020
Genogram: Smith Family Genogram diagram with 3 individuals across 2 generations Smith Family John (1975) Mary (1977) Alice (2005) John (b. 1975) Mary (b. 1977) Alice (b. 2005) m. 2002 MARKERS Index person (focal subject)
Nuclear family (minimal template)
Minimal nuclear family genogram — married couple, one child, marriage date — the clinical intake starting template per McGoldrick 2020 notation.
healthcare & social
genogram·§ McGoldrick 2020
Genogram: Medical History Genogram diagram with 7 individuals across 3 generations Medical History Grandfather (1930-1990) 60 Grandmother (1935) Father (1960) Mother (1962) Uncle (1963) Patient (1988) Sister (1991) Grandfather (1930–1990) Grandmother (b. 1935) Father (b. 1960) Mother (b. 1962) Uncle (b. 1963) Patient (b. 1988) Sister (b. 1991) SYMBOLS Deceased CONDITIONS Heart Disease Diabetes Cancer Hypertension MARKERS Index person (focal subject)
Multi-generation medical history
Three-generation family medical history genogram with multi-condition color annotations using fill zones — heart disease, diabetes, cancer, hypertension.
healthcare & social
genogram·§ McGoldrick 2020
Genogram: BRCA1 Family Genogram diagram with 8 individuals across 3 generations BRCA1 Family I_1 (1930-1995) 65 I_2 (1932-1990) 58 II_4 (1954) II_1 (1955) II_2 (1958) II_3 (1960) III_1 (1985) III_2 (1988) I_1 (1930–1995) I_2 (1932–1990) II_4 (b. 1954) II_1 (b. 1955) II_2 (b. 1958) II_3 (b. 1960) III_1 (b. 1985) III_2 (b. 1988) SYMBOLS Deceased CONDITIONS Ovarian Cancer Breast Cancer MARKERS Index person (focal subject)
Hereditary cancer (BRCA1) family
Three-generation BRCA1 family genogram with hereditary breast/ovarian cancer conditions — captured at intake before formal clinical pedigree analysis.
healthcare & social
genogram·§ McGoldrick 2020
Genogram: The Potter Family Genogram diagram with 10 individuals across 3 generations The Potter Family Fleamont (1909-1979) 70 Euphemia (1920-1979) 59 Mr_evans (1925) Mrs_evans (1928) James (1960-1981) 21 Lily (1960-1981) 21 Vernon (1951) Petunia (1958) Harry (1980) Dudley (1980) Fleamont (1909–1979) Euphemia (1920–1979) Mr_evans (b. 1925) Mrs_evans (b. 1928) James (1960–1981) Lily (1960–1981) Vernon (b. 1951) Petunia (b. 1958) Harry (b. 1980) Dudley (b. 1980) m. 1978 SYMBOLS Deceased RELATIONSHIPS Close Hostile Cutoff MARKERS Index person (focal subject)
The Potter family
Three-generation Potter family genogram with emotional relationship lines — cutoff, hostile, and close — illustrating McGoldrick relational notation.
education
genogram·§ McGoldrick 2020 + Bennett 2022 (adopted-out / dual-parent convention)
Genogram: Familia Isaías Genogram diagram with 9 individuals across 2 generations Familia Isaías Víctor Seguel Mónica Barrientos Tío materno Don Pablo Doña Priscila Isaías (2020) 6 ? ? Pablo (jr) Alanis Víctor Seguel Mónica Barrientos Tío materno Don Pablo Doña Priscila Isaías (b. 2020) ? Pablo (jr) Alanis SYMBOLS Unknown STRUCTURAL Cohabiting (ended) Foster RELATIONSHIPS Nevermet Physical Abuse MARKERS Index person (focal subject) Sibling(s) — unknown count
Foster care / child protection
Foster-care genogram for a real LATAM child-protection case — biological parents (cohabitation ended), abuse, current foster placement (dotted secondary link), unknown-count siblings, and a maternal uncle as known-relative-with-unknown-ancestry.
social-work

13. 路线图

计划中——当前尚不可解析。 请勿在生成的 DSL 中使用以下功能;解析器将拒绝它们。

  • Bennett 2022 性别包容性nonbinaryintersex 作为性别值;transgender 作为标记。目前已在 src/core/types.ts 中定义类型,但解析器的 VALID_SEX 集合尚未包含它们。
  • 三胞胎及更高阶多胞胎triplet-identicaltriplet-fraternal
  • 现代家庭结构surrogate(代孕)、donor(捐赠)、step(继子女)作为子女类型属性。
  • 状况的类别简写conditions: cardiovascular + depression,无需 (fill),自动分配象限和默认颜色。
  • 同居伴侣运算符~dp~ / 显式 DP 标签。
  • 传承注释 — 个人的文化家谱传承标识符。
  • 家庭边界框 — 将共同居住的节点分组(寄养安置、多代同堂)。

如需提前实现以上功能,请在 GitHub issues 中跟踪。

Found this useful?

Schematex is free, fully open source, and zero-dependency. A star helps other developers discover it.