def testAttributeGroup(self): self.assertTrue(testIt(simpleAttributeGroup.parseString, '{74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17}')) self.assertTrue(testIt(simpleAttributeGroup.parseString, '( {74400008 <= #17} )')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17},{74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17}{74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17}{74400008 <= #17}{74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17} OR {74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17} AND {74400008 <= #17}')) self.assertTrue(testIt(attributeGroup.parseString, '{74400008 <= #17}({74400008 <= #17} AND {74400008 <= #17})', fail=True))
def testConceptReference(self): self.assertEqual( 123456, conceptReference.parseString('123456', parseAll=True)[0].sctid) self.assertEqual(123456, conceptReference.parseString('123456')[0].sctid) self.assertTrue(testIt(term.parseString, 'abc')) self.assertTrue(testIt(term.parseString, 'a')) self.assertTrue(testIt(term.parseString, 'a b cè')) self.assertTrue(testIt(term.parseString, ' ', fail=True)) self.assertTrue(testIt(term.parseString, 'a|b', fail=True)) self.assertTrue( testIt(conceptReference.parseString, '123456 | Something |')) res = conceptReference.parseString('123456 | Something | ', parseAll=True)[0] self.assertEqual('Something', res.term) res = conceptReference.parseString('123456 | Something good | ', parseAll=True)[0] self.assertEqual(123456, res.sctid) self.assertEqual('Something good', res.term) self.assertRaises(ParseException, conceptReference.parseString, '123456 | embedded | bar |', parseAll=True) self.assertTrue( testIt(conceptReference.parseString, '404684003 |clinical finding|'))
def testx(self): self.assertTrue(testIt(attributeSet.parseString, '74400008 = "abc"')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") or (74400008 = "def1") ')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") or (74400008 = "def2") ')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") or (74400008 = "def3") ')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") and (74400008 = "def4") ')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") and 74400008 = "def5" ')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") , 74400008 = "def6" '))
def test2(self): try: self.assertTrue(testIt(attributeSet.parseString, '363698007 |finding site| = << 39057004 |pulmonary valve structure|')) self.assertTrue(testIt(attributeSet.parseString, '116676008 |associated morphology| = << 415582006 |stenosis|')) # TODO: the item below does not parse, but I'm not sure it should... # attributeSet = attribute *(conjunction attribute) --> # attribute = attributeName "=" expressionConstraintValue 363698007 |finding site| = # expressionConstraintValue = simpleExpressionConstraint # simpleExpressionConstraint = conceptReference conjunction simpleEpressionConstraint :: |pulmonary valve structure|, 116676008 |associated morphology| self.assertTrue(testIt(attributeSet.parseString, '''363698007 |finding site| = << 39057004 |pulmonary valve structure|, 116676008 |associated morphology| = << 415582006 |stenosis|''')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc")')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = "abc") , 74400009 <= #2')) self.assertTrue(testIt(attributeSet.parseString, ' 74400008 = "abc" , 74400009 <= #2')) self.assertTrue(testIt(attributeSet.parseString, ' 74400008 = "abc" and 74400009 <= #2')) self.assertTrue(testIt(attributeSet.parseString, ' (74400008 = "abc") or 74400009 <= #2')) except ParseException as e: print(fmtException(e)) self.assertTrue(False)
def test_attributeSet(self): self.assertTrue(testIt(attributeSet.parseString, '74400008 <= #17')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 <= #17)'))
def test_attributeConcreteValue(self): self.assertTrue(testIt(attribute.parseString, '74400008 <= #17')) self.assertTrue(testIt(attribute.parseString, '74400008 = #0.000413')) self.assertTrue(testIt(attribute.parseString, '74400008 = #-0.001')) self.assertTrue(testIt(attribute.parseString, '74400008 < #17')) self.assertTrue(testIt(attribute.parseString, '74400008 >= #17')) self.assertTrue(testIt(attribute.parseString, '74400008 > #17')) self.assertTrue(testIt(attribute.parseString, '74400008 != #17')) self.assertTrue(testIt(attribute.parseString, '74400008 ! = #17')) self.assertTrue(testIt(attribute.parseString, '74400008 not= #17')) self.assertTrue(testIt(attribute.parseString, '74400008 not = #17')) self.assertRaises(ParseException, attribute.parseString,'74400008 not < #17', parseAll=True ) self.assertTrue(testIt(attribute.parseString, '74400008 = "abc"')) self.assertTrue(testIt(attribute.parseString, '74400008 = " ab c "'))
def test_attributeExpression(self): self.assertTrue(testIt(attribute.parseString, '< 74400008 |appendicitis| = < 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, '< 74400008 |appendicitis| = >> 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, ' 74400008 |appendicitis| = << 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, ' 744000008 |appendicitis| = > 74400008 |appendicitis| '))
def test_attribute(self): self.assertTrue(testIt(attribute.parseString, '74400008 = 74400008')) self.assertTrue(testIt(attribute.parseString, '74400008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, '< 74400008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, '<< 74400008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, 'descendantsof 74400008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, 'descendantsorselfof 744000008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, 'reverseof descendantsorselfof 744000008 |appendicitis| = 74400008 |appendicitis| ')) self.assertTrue(testIt(attribute.parseString, 'reverseof 744000008 |appendicitis| = 74400008 |appendicitis| ')) self.assertRaises(ParseException, attribute.parseString, '<< reverseof 744000008 = 74400008 ', parseAll=True) self.assertTrue(testIt(attribute.parseString, '[0..1]74400008 = 74400008')) self.assertTrue(testIt(attribute.parseString, '[0..*]74400008 = 74400008')) self.assertTrue(testIt(attribute.parseString, '[0..many]74400008 = 74400008')) self.assertTrue(testIt(attribute.parseString, '[1..1]74400008 = 74400008')) self.assertTrue(testIt(attributeSet.parseString, '(74400008 = 74400008)'))
def test_simple_expression_set2(self): self.assertTrue( testIt(simpleConstraintSet.parseString, '123456 OR 123466'))
def test_simple_expression_set(self): self.assertTrue( testIt(conceptReference.parseString, '404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '<404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, 'descendantsOf 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '<< 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, 'descendantsOrSelfOf 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '> 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, 'ancestorsOf 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '>> 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, 'ancestorsOrSelfOf 404684003 |clinical finding|')) self.assertTrue( testIt(simpleConstraintSet.parseString, '^ 700043003 |example problem list subset|')) self.assertTrue( testIt(simpleConstraintSet.parseString, 'membersof 700043003 |example problem list subset|')) self.assertTrue( testIt( simpleConstraintSet.parseString, '^^ 1111000000132 |medication reference sets reference set|')) self.assertTrue( testIt( simpleConstraintSet.parseString, 'membersof membersof 1111000000132 |medication reference sets reference set|' )) self.assertTrue( testIt( simpleConstraintSet.parseString, 'not << membersof membersof 1111000000132 |medication reference sets reference set|' )) self.assertTrue(testIt(simpleConstraintSet.parseString, 'not 123456')) self.assertTrue( testIt( simpleConstraintSet.parseString, '123456 OR < 123466 AND 1239999 | foo | , 74400008 | bar |'))