-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from Eyas/enum-build-branch
Enum build branch
- Loading branch information
Showing
6 changed files
with
223 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/MedicalProcedureType> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/SurgicalProcedure> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/MedicalProcedure> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2000/01/rdf-schema#comment> "A type of medical procedure that involves invasive surgical techniques." . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2002/07/owl#equivalentClass> <http://purl.bioontology.org/ontology/SNOMEDCT/387713003> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2002/07/owl#equivalentClass> <http://purl.bioontology.org/ontology/SNOMEDCT/387713003> . | ||
<http://schema.org/MedicalProcedureType> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalProcedureType> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/MedicalEnumeration> . | ||
<http://schema.org/MedicalProcedureType> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/MedicalProcedure> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/MedicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalProcedure> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Thing> . | ||
<http://schema.org/MedicalEnumeration> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalEnumeration> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Enumeration> . | ||
<http://schema.org/Enumeration> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/Enumeration> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Intangible> . | ||
<http://schema.org/Intangible> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/Intangible> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Thing> . | ||
<http://schema.org/Thing> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
type EnumerationBase = IntangibleBase; | ||
export type Enumeration = ({ | ||
"@type": "Enumeration"; | ||
} & EnumerationBase) | MedicalEnumeration; | ||
|
||
type IntangibleBase = ThingBase; | ||
export type Intangible = ({ | ||
"@type": "Intangible"; | ||
} & IntangibleBase) | Enumeration; | ||
|
||
type MedicalEnumerationBase = EnumerationBase; | ||
export type MedicalEnumeration = ({ | ||
"@type": "MedicalEnumeration"; | ||
} & MedicalEnumerationBase) | MedicalProcedureType; | ||
|
||
type MedicalProcedureBase = ThingBase; | ||
export type MedicalProcedure = ({ | ||
"@type": "MedicalProcedure"; | ||
} & MedicalProcedureBase) | SurgicalProcedure; | ||
|
||
type MedicalProcedureTypeBase = MedicalEnumerationBase; | ||
export type MedicalProcedureType = "http://schema.org/SurgicalProcedure" | ({ | ||
"@type": "MedicalProcedureType"; | ||
} & MedicalProcedureTypeBase); | ||
export const MedicalProcedureType = { | ||
/** A type of medical procedure that involves invasive surgical techniques. */ | ||
SurgicalProcedure: ("http://schema.org/SurgicalProcedure" as const) | ||
}; | ||
|
||
type SurgicalProcedureBase = MedicalProcedureBase; | ||
/** A type of medical procedure that involves invasive surgical techniques. */ | ||
export type SurgicalProcedure = { | ||
"@type": "SurgicalProcedure"; | ||
} & SurgicalProcedureBase; | ||
|
||
type ThingBase = { | ||
/** IRI identifying the canonical address of this object. */ | ||
"@id"?: string; | ||
}; | ||
export type Thing = ({ | ||
"@type": "Thing"; | ||
} & ThingBase) | (Intangible | MedicalProcedure); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/MedicalProcedureType> . | ||
<http://schema.org/SurgicalProcedure> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/MedicalProcedure> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2000/01/rdf-schema#comment> "A type of medical procedure that involves invasive surgical techniques." . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2002/07/owl#equivalentClass> <http://purl.bioontology.org/ontology/SNOMEDCT/387713003> . | ||
<http://schema.org/SurgicalProcedure> <http://www.w3.org/2002/07/owl#equivalentClass> <http://purl.bioontology.org/ontology/SNOMEDCT/387713003> . | ||
<http://schema.org/MedicalProcedureType> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalProcedureType> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/MedicalEnumeration> . | ||
<http://schema.org/MedicalProcedureType> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/MedicalProcedure> <http://schema.org/isPartOf> <http://health-lifesci.schema.org> . | ||
<http://schema.org/MedicalProcedure> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalProcedure> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Thing> . | ||
<http://schema.org/MedicalEnumeration> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/MedicalEnumeration> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Enumeration> . | ||
<http://schema.org/Enumeration> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/Enumeration> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Intangible> . | ||
<http://schema.org/Intangible> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/Intangible> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Thing> . | ||
<http://schema.org/Thing> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
type EnumerationBase = IntangibleBase; | ||
export type Enumeration = ({ | ||
"@type": "Enumeration"; | ||
} & EnumerationBase) | MedicalEnumeration; | ||
|
||
type IntangibleBase = ThingBase; | ||
export type Intangible = ({ | ||
"@type": "Intangible"; | ||
} & IntangibleBase) | Enumeration; | ||
|
||
type MedicalEnumerationBase = EnumerationBase; | ||
export type MedicalEnumeration = ({ | ||
"@type": "MedicalEnumeration"; | ||
} & MedicalEnumerationBase) | MedicalProcedureType; | ||
|
||
type MedicalProcedureBase = ThingBase; | ||
export type MedicalProcedure = ({ | ||
"@type": "MedicalProcedure"; | ||
} & MedicalProcedureBase) | SurgicalProcedure; | ||
|
||
type MedicalProcedureTypeBase = MedicalEnumerationBase; | ||
export type MedicalProcedureType = "http://schema.org/SurgicalProcedure" | ({ | ||
"@type": "MedicalProcedureType"; | ||
} & MedicalProcedureTypeBase); | ||
export const MedicalProcedureType = { | ||
/** A type of medical procedure that involves invasive surgical techniques. */ | ||
SurgicalProcedure: ("http://schema.org/SurgicalProcedure" as const) | ||
}; | ||
|
||
type SurgicalProcedureBase = MedicalProcedureBase; | ||
/** A type of medical procedure that involves invasive surgical techniques. */ | ||
export type SurgicalProcedure = { | ||
"@type": "SurgicalProcedure"; | ||
} & SurgicalProcedureBase; | ||
|
||
type ThingBase = { | ||
/** IRI identifying the canonical address of this object. */ | ||
"@id"?: string; | ||
}; | ||
export type Thing = ({ | ||
"@type": "Thing"; | ||
} & ThingBase) | (Intangible | MedicalProcedure); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {expect} from 'chai'; | ||
import {stub} from 'sinon'; | ||
import {UrlNode} from '../../src/triples/types'; | ||
import {EnumValue} from '../../src/ts/enum'; | ||
import {makeClass, makeClassMap} from '../helpers/make_class'; | ||
|
||
describe('EnumValue', () => { | ||
describe('constructor', () => { | ||
it('Throws when referencing a non-existent type', () => { | ||
const map = makeClassMap( | ||
makeClass('https://schema.org/Foo'), | ||
makeClass('https://schema.org/Bar'), | ||
makeClass('https://schema.org/Baz')); | ||
expect( | ||
() => new EnumValue( | ||
UrlNode.Parse('https://schema.org/Wednesday'), | ||
[UrlNode.Parse('https://schema.org/DayOfWeek')], map)) | ||
.to.throw('Couldn\'t find'); | ||
}); | ||
|
||
it('Works fine when called for plain enum', () => { | ||
const dayOfWeek = makeClass('https://schema.org/DayOfWeek'); | ||
const addEnum = stub(dayOfWeek, 'addEnum'); | ||
const map = makeClassMap( | ||
makeClass('https://schema.org/Foo'), | ||
makeClass('https://schema.org/Bar'), dayOfWeek); | ||
|
||
const myEnum = new EnumValue( | ||
UrlNode.Parse('https://schema.org/Wednesday'), | ||
[UrlNode.Parse('https://schema.org/DayOfWeek')], map); | ||
|
||
expect(addEnum.calledWith(myEnum)).to.be.true; | ||
addEnum.restore(); | ||
}); | ||
|
||
it('Works fine when called for an enum/class', () => { | ||
const medicalProcedureType = | ||
makeClass('https://schema.org/MedicalProcedureType'); | ||
const addEnum = stub(medicalProcedureType, 'addEnum'); | ||
|
||
const map = makeClassMap( | ||
makeClass('https://schema.org/Foo'), | ||
makeClass('https://schema.org/Bar'), medicalProcedureType); | ||
|
||
const myEnum = new EnumValue( | ||
UrlNode.Parse('https://schema.org/SurgicalProcedure'), | ||
[ | ||
UrlNode.Parse('https://schema.org/MedicalProcedureType'), | ||
UrlNode.Parse('http://www.w3.org/2000/01/rdf-schema#Class') | ||
], | ||
map); | ||
|
||
expect(addEnum.calledWith(myEnum)).to.be.true; | ||
addEnum.restore(); | ||
}); | ||
}); | ||
}); |