def _split_inclusion_exclusion(self):
		""" Parses gender/age into document variables and then parses the
		textual inclusion/exclusion format into dictionaries stored in a
		"criteria" property.
		"""
		if not self.text:
			logging.info("No eligibility criteria text found")
			return
		
		# split criteria text into inclusion and exclusion
		crit = []
		(inclusion, exclusion) = split_inclusion_exclusion(self.text)
		
		self.inclusion_text = '{SEPARATOR}'.join(inclusion) if inclusion else ''
		if len(self.inclusion_text):
			self.inclusion_text = re.sub(r'\.?{SEPARATOR}\s*', '. ', self.inclusion_text)
		self.exclusion_text = '{SEPARATOR}'.join(exclusion) if exclusion else ''
		if len(self.exclusion_text):
			self.exclusion_text = re.sub(r'\.?{SEPARATOR}\s*', '. ', self.exclusion_text)
		
		# parsed by bulleted list, produce one criterion per item; we also could
		# concatenate them into one file each.
		for txt in inclusion:
			obj = {'id': str(uuid.uuid4()), 'is_inclusion': True, 'text': txt}
			crit.append(obj)
		
		for txt in exclusion:
			obj = {'id': str(uuid.uuid4()), 'is_inclusion': False, 'text': txt}
			crit.append(obj)
		
		self.criteria = crit
Example #2
0
	def process_eligibility_from_text(self):
		""" Does nothing if the "criteria" property already holds at least one
		StudyEligibility object, otherwise parses "criteria_text" into such
		objects.
		"""
		if self.criteria and len(self.criteria) > 0:
			return
		
		crit = []
		
		# split into arrays
		(inclusion, exclusion) = split_inclusion_exclusion(self.criteria_text)
		
		for txt in inclusion:
			obj = StudyEligibility(self)
			obj.is_inclusion = True
			obj.text = txt
			crit.append(obj)
		
		for txt in exclusion:
			obj = StudyEligibility(self)
			obj.is_inclusion = False
			obj.text = txt
			crit.append(obj)
		
		self.criteria = crit
		self.store_criteria()