diff --git a/README.md b/README.md index a0566ec..e55dbf5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This PHP code library provides tools for extracting [Medical Subject Headings](https://www.nlm.nih.gov/mesh/meshhome.html) (MeSH) descriptors and associated data from a given XML file into an object representation. -It expects its input to be compliant with the 2023 or 2024 [MeSH DTDs](https://www.nlm.nih.gov/databases/download/mesh.html). +It expects its input to be compliant with the 2024 or 2025 [MeSH DTDs](https://www.nlm.nih.gov/databases/download/mesh.html). ## Installation diff --git a/src/Ilios/MeSH/Model/Concept.php b/src/Ilios/MeSH/Model/Concept.php index bce1260..1c1a8c9 100644 --- a/src/Ilios/MeSH/Model/Concept.php +++ b/src/Ilios/MeSH/Model/Concept.php @@ -14,8 +14,6 @@ class Concept extends Reference protected ?string $casn1Name = null; - protected ?string $registryNumber = null; - protected ?string $scopeNote = null; protected ?string $translatorsEnglishScopeNote = null; @@ -28,6 +26,8 @@ class Concept extends Reference protected array $terms = []; + protected array $registryNumbers = []; + public function isPreferred(): bool { return $this->preferred; @@ -48,16 +48,6 @@ public function setCasn1Name(?string $casn1Name): void $this->casn1Name = $casn1Name; } - public function getRegistryNumber(): ?string - { - return $this->registryNumber; - } - - public function setRegistryNumber(?string $registryNumber): void - { - $this->registryNumber = $registryNumber; - } - public function getScopeNote(): ?string { return $this->scopeNote; @@ -117,4 +107,14 @@ public function addTerm(Term $term): void { $this->terms[] = $term; } + + public function getRegistryNumbers(): array + { + return $this->registryNumbers; + } + + public function addRegistryNumber(string $registryNumber): void + { + $this->registryNumbers[] = $registryNumber; + } } diff --git a/src/Ilios/MeSH/Parser.php b/src/Ilios/MeSH/Parser.php index c1f699f..f277862 100644 --- a/src/Ilios/MeSH/Parser.php +++ b/src/Ilios/MeSH/Parser.php @@ -270,7 +270,7 @@ public function parse(string $uri): DescriptorSet break; case self::REGISTRY_NUMBER: $number = $this->getNodeContents($reader); - $currentConcept->setRegistryNumber($number); + $currentConcept->addRegistryNumber($number); break; case self::RELATED_REGISTRY_NUMBER: $number = $this->getNodeContents($reader); diff --git a/tests/Ilios/MeSH/Model/ConceptTest.php b/tests/Ilios/MeSH/Model/ConceptTest.php index c388106..4711b2f 100644 --- a/tests/Ilios/MeSH/Model/ConceptTest.php +++ b/tests/Ilios/MeSH/Model/ConceptTest.php @@ -44,9 +44,9 @@ public function testGetSetCasn1Name(): void $this->basicSetTest($this->object, 'casn1Name', 'string', true); } - public function testGetSetRegistryNumber(): void + public function testAddGetRegistryNumbers(): void { - $this->basicSetTest($this->object, 'registryNumber', 'string', true); + $this->addTextToListTest($this->object, 'registryNumber'); } public function testGetSetScopeNote(): void diff --git a/tests/Ilios/MeSH/ParserTest.php b/tests/Ilios/MeSH/ParserTest.php index cb12406..6db0995 100644 --- a/tests/Ilios/MeSH/ParserTest.php +++ b/tests/Ilios/MeSH/ParserTest.php @@ -165,14 +165,19 @@ public function testParse(): void $this->assertTrue($concept->isPreferred()); $this->assertEquals('M0000001', $concept->getUi()); $this->assertEquals('a casn1 name', $concept->getCasn1Name()); - $this->assertEquals('00000AAAAA', $concept->getRegistryNumber()); + + $registryNumbers = $concept->getRegistryNumbers(); + $this->assertEquals(2, count($registryNumbers)); + $this->assertEquals('00000AAAAA', $registryNumbers[0]); + $this->assertEquals('11111BBBBB', $registryNumbers[1]); + $this->assertEquals('a scope note', $concept->getScopeNote()); $this->assertEquals('something in English.', $concept->getTranslatorsEnglishScopeNote()); $this->assertEquals('i got nothing', $concept->getTranslatorsScopeNote()); - $registryNumbers = $concept->getRelatedRegistryNumbers(); - $this->assertEquals(1, count($registryNumbers)); - $this->assertEquals('a related registry number', $registryNumbers[0]); + $relatedRegistryNumbers = $concept->getRelatedRegistryNumbers(); + $this->assertEquals(1, count($relatedRegistryNumbers)); + $this->assertEquals('a related registry number', $relatedRegistryNumbers[0]); $relations = $concept->getConceptRelations(); $this->assertEquals(1, count($relations)); @@ -202,7 +207,7 @@ public function testParse(): void $this->assertFalse($concept->isPreferred()); $this->assertEquals('M0000002', $concept->getUi()); $this->assertEquals('another concept', $concept->getName()); - $this->assertEquals('0', $concept->getRegistryNumber()); + $this->assertCount(0, $concept->getRegistryNumbers()); $relations = $concept->getConceptRelations(); $this->assertEquals(1, count($relations)); diff --git a/tests/Ilios/MeSH/desc.xml b/tests/Ilios/MeSH/desc.xml index 3d5c25a..f52261a 100644 --- a/tests/Ilios/MeSH/desc.xml +++ b/tests/Ilios/MeSH/desc.xml @@ -3,7 +3,7 @@ Fake MeSH descriptors set, for testing purposes. It contains all possible elements defined by the schema. --> - + D000000 @@ -133,7 +133,10 @@ It contains all possible elements defined by the schema. a concept a casn1 name - 00000AAAAA + + 00000AAAAA + 11111BBBBB + a scope note something in English. i got nothing @@ -170,7 +173,6 @@ It contains all possible elements defined by the schema. another concept - 0 M0000002