feat(domain): equine legacy importer (packages/anatomy) + generated official equine sheet seed as draft
This commit is contained in:
1 parent
f4682cdba5
commit
52bfc11553
43 files changed
+18466
-33
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { EQUINE_SOURCE_PATHS, type ImportResult } from '../src'
|
||||
import { legacyAnnoIds, runImport } from './helpers'
|
||||
|
||||
let result: ImportResult
|
||||
|
||||
beforeAll(async () => {
|
||||
result = await runImport()
|
||||
})
|
||||
|
||||
describe('equine import volumes', () => {
|
||||
it('imports 27 annotations, 26 linked to a finding zone', () => {
|
||||
const annotations = result.document.annotations
|
||||
expect(annotations).toHaveLength(27)
|
||||
const linked = annotations.filter(
|
||||
(a) => a.kind !== 'detail_trigger' && a.finding_zone_id !== null,
|
||||
)
|
||||
expect(linked).toHaveLength(26)
|
||||
})
|
||||
|
||||
it('has two views and one trigger opening head from main', () => {
|
||||
expect(result.document.views.map((v) => v.id)).toEqual(['main', 'head'])
|
||||
const triggers = result.document.annotations.filter(
|
||||
(a) => a.kind === 'detail_trigger',
|
||||
)
|
||||
expect(triggers).toHaveLength(1)
|
||||
expect(triggers[0]).toMatchObject({
|
||||
view_id: 'main',
|
||||
opens_view_id: 'head',
|
||||
})
|
||||
})
|
||||
|
||||
it('codes exactly the five zone-colonne polygons with C, T, L, S, Cd', () => {
|
||||
const coded = result.document.annotations.filter(
|
||||
(a) => a.kind !== 'detail_trigger' && a.vertebral_region_code !== null,
|
||||
)
|
||||
expect(coded).toHaveLength(5)
|
||||
expect(new Set(coded.map((a) => a.kind))).toEqual(new Set(['zone']))
|
||||
expect(new Set(coded.map((a) => a.category_id))).toEqual(
|
||||
new Set(['zone-colonne']),
|
||||
)
|
||||
const codes = coded.map((a) =>
|
||||
a.kind === 'detail_trigger' ? null : a.vertebral_region_code,
|
||||
)
|
||||
expect(new Set(codes)).toEqual(new Set(['C', 'T', 'L', 'S', 'Cd']))
|
||||
})
|
||||
|
||||
it('counts 9 bilateral annotations', () => {
|
||||
const bilateral = result.document.annotations.filter(
|
||||
(a) => a.laterality === 'bilateral',
|
||||
)
|
||||
expect(bilateral).toHaveLength(9)
|
||||
})
|
||||
|
||||
it('keeps 26 zones, 792 nodes, 612 leaves, 41 vet referrals', () => {
|
||||
expect(result.document.finding_zones).toHaveLength(26)
|
||||
expect(result.stats).toMatchObject({
|
||||
findingZones: 26,
|
||||
nodes: 792,
|
||||
leaves: 612,
|
||||
vetReferrals: 41,
|
||||
})
|
||||
})
|
||||
|
||||
it('maps every data-anno-id of both SVGs', async () => {
|
||||
const ids = [
|
||||
...(await legacyAnnoIds(EQUINE_SOURCE_PATHS.mainSvg)),
|
||||
...(await legacyAnnoIds(EQUINE_SOURCE_PATHS.headSvg)),
|
||||
]
|
||||
expect(ids).toHaveLength(27)
|
||||
expect(Object.keys(result.legacyIdMap.annotations).sort()).toEqual(
|
||||
ids.sort(),
|
||||
)
|
||||
})
|
||||
|
||||
it('places the nine head annotations in view head', async () => {
|
||||
const headIds = await legacyAnnoIds(EQUINE_SOURCE_PATHS.headSvg)
|
||||
const newIds = new Set(
|
||||
headIds.map((id) => result.legacyIdMap.annotations[id]),
|
||||
)
|
||||
const inHead = result.document.annotations.filter((a) => newIds.has(a.id))
|
||||
expect(inHead).toHaveLength(9)
|
||||
expect(inHead.every((a) => a.view_id === 'head')).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user