refactoring

This commit is contained in:
frankknoll
2023-03-24 18:07:59 +01:00
parent 918215cd40
commit 6c7a27f258

View File

@@ -6,6 +6,11 @@ class BatchcodeCompletion:
self.ADR_by_Batchcode = ADR_by_Batchcode.sort_values(by = 'Adverse Reaction Reports', ascending = False) self.ADR_by_Batchcode = ADR_by_Batchcode.sort_values(by = 'Adverse Reaction Reports', ascending = False)
def completeBatchcode(self, partialBatchcode): def completeBatchcode(self, partialBatchcode):
return self._getBatchcodeHavingMostADRs(self._filterBy(partialBatchcode))
def _filterBy(self, partialBatchcode):
smartRegexp = SmartRegexpFactory().createSmartRegexp(partialBatchcode) smartRegexp = SmartRegexpFactory().createSmartRegexp(partialBatchcode)
filteredBbatchCodeTable = self.ADR_by_Batchcode[self.ADR_by_Batchcode.index.str.contains(smartRegexp, na=False, regex=True)] return self.ADR_by_Batchcode[self.ADR_by_Batchcode.index.str.contains(smartRegexp, na = False, regex = True)]
return filteredBbatchCodeTable.index[0] if not filteredBbatchCodeTable.empty else None
def _getBatchcodeHavingMostADRs(self, ADR_by_Batchcode):
return ADR_by_Batchcode.index[0] if not ADR_by_Batchcode.empty else None