Best Python code snippet using playwright-python
therapy_record.py
Source:therapy_record.py
...173 obj2 = None174 for column in columns:175 if column == 'trement':176 trement_map = {'surgery': 'ææ¯', 'radiotherapy': 'æ¾ç', 'other': 'å
¶ä»', '/': '/'}177 value = self.filter_none(obj, column)178 value = trement_map.get(value) if trement_map.get(value) else value + '线'179 row = np.append(row, value)180 elif column == 'beEffEva':181 beEffEva_map = {'1': 'PD-è¿å±', '2': 'SD-稳å®', '3': 'PR-é¨åç¼è§£', '4': 'CR-å®å
¨ç¼è§£', '5': 'æ¯åæªåç°æ°ç
ç¶', '/': '/',182 'PD-è¿å±': 'PD-è¿å±', 'SD-稳å®': 'SD-稳å®', 'PR-é¨åç¼è§£': 'PR-é¨åç¼è§£', 'CR-å®å
¨ç¼è§£': 'CR-å®å
¨ç¼è§£',183 'æ¯åæªåç°æ°ç
ç¶': 'æ¯åæªåç°æ°ç
ç¶'}184 value = self.filter_none(obj, column)185 value = beEffEva_map.get(value)186 row = np.append(row, value)187 elif column == 'isRepBio':188 value = self.filter_none(self.change_bool_to_yes_or_no(getattr(obj2, column))) if obj2 else '/'189 row = np.append(row, value)190 elif column == 'matPart' or column == 'specNum':191 value_isRepBio = getattr(obj2, 'isRepBio') if obj2 else None192 value = self.filter_none(obj2, column) if value_isRepBio else '/'193 row = np.append(row, value)194 elif column == 'bioMet':195 value_isRepBio = getattr(obj2, 'isRepBio') if obj2 else None196 value = self.format_radio_data(obj2, column) if value_isRepBio else '/'197 row = np.append(row, value)198 elif column == 'patDia':199 value_isRepBio = getattr(obj2, 'isRepBio') if obj2 else None200 value = self.format_patDia(obj2) if value_isRepBio else '/'201 row = np.append(row, value)202 else:203 value = self.filter_none(obj, column)204 row = np.append(row, value)205 return row206 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´207 def get_export_header(self, columns, buffer):208 header = np.zeros(0, dtype=str)209 for column in columns:210 header = np.append(header, self.export_header_map.get(column))211 TreRec.header_num = len(header)212 return header213 def get_parent(self):214 data = {215 'id': self.id,216 'trement': self.trement,217 'treNum': self.treNum,218 'treIndex': self.treIndex219 }220 return data221 def compute_FPS_DFS(self):222 date1 = None223 if self.trement == 'surgery':224 surgery = Surgery.query.filter_by(pid=self.pid, treNum=self.treNum).first()225 if surgery:226 date1 = surgery.surDate227 elif self.trement in ["one", "two", "three", "four", "five", 'other']:228 trePlan = DetailTrePlan.query.filter(DetailTrePlan.is_delete == 0, DetailTrePlan.pid == self.pid,229 DetailTrePlan.treNum == self.treNum,230 DetailTrePlan.begDate != None).order_by(DetailTrePlan.begDate).first()231 one_to_five = OneToFive.query.filter_by(pid=self.pid, treNum=self.treNum).first()232 if one_to_five is None:233 with db.auto_commit():234 self.PFS_DFS = None235 return236 elif trePlan is None:237 with db.auto_commit():238 self.PFS_DFS = None239 return240 else:241 if one_to_five.begDate is not None and trePlan.begDate is not None:242 date1 = min(one_to_five.begDate, trePlan.begDate)243 else:244 date1 = one_to_five.begDate if one_to_five.begDate else trePlan.begDate245 date2 = self.proDate246 if date1 and date2:247 with db.auto_commit():248 months = (date2 - date1).days / 30249 time = str(round(months, 1)) + "æ"250 self.PFS_DFS = time251 def get_child(self):252 trement = self.trement253 if trement == 'surgery':254 child = Surgery.query.filter_by(pid=self.pid, treNum=self.treNum).first()255 elif trement == 'radiotherapy':256 child = Radiotherapy.query.filter_by(pid=self.pid, treNum=self.treNum).first()257 else:258 child = OneToFive.query.filter_by(pid=self.pid, treNum=self.treNum).first()259 return child if child else {}260 def delete(self):261 with db.auto_commit():262 self.is_delete = 1263 self.delete_in_cycle(OneToFive)264 self.delete_in_cycle(DetailTrePlan)265 self.delete_in_cycle(Surgery)266 self.delete_in_cycle(Radiotherapy)267 # å é¤å®éªå®¤æ£æ¥268 self.delete_in_cycle(BloodRoutine)269 self.delete_in_cycle(BloodBio)270 self.delete_in_cycle(Thyroid)271 self.delete_in_cycle(Coagulation)272 self.delete_in_cycle(MyocardialEnzyme)273 self.delete_in_cycle(Cytokines)274 self.delete_in_cycle(LymSubsets)275 self.delete_in_cycle(UrineRoutine)276 self.delete_in_cycle(TumorMarker)277 # å é¤å
¶ä»æ£æ¥278 self.delete_in_cycle(Lung)279 self.delete_in_cycle(OtherExams)280 self.delete_in_cycle(ImageExams)281 # å é¤å
ç«ç»åï¼ååæ£æµï¼çç¶ä½å¾ï¼å¯ååº282 self.delete_in_cycle(Immunohis)283 self.delete_in_cycle(MoleDetec)284 self.delete_in_cycle(Signs)285 self.delete_in_cycle(SideEffect)286 def delete_in_cycle(self, table):287 records = table.query.filter_by(pid=self.pid, treNum=self.treNum).all()288 with db.auto_commit():289 for record in records:290 record.delete()291# 1-5线åå
¶ä»è¡¨292class OneToFive(Base, PatDia, ModificationAndDoubt):293 __tablename__ = 'oneToFive'294 id = Column(Integer, primary_key=True, autoincrement=True)295 pid = Column(Integer, comment='ç
人id')296 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')297 isTre = Column(Integer, comment='æ¯å¦å å
¥ä¸´åºæ²»ç')298 clinTri = Column(String(40), comment='临åºå®éªå称') # é¿åº¦299 treSolu = Column(String(100),300 comment='æ²»çæ¹æ¡,å¤ä¸ªä»¥éå·åé(Chemotherapy,TargetedTherapy,ImmunityTherapy,AntivascularTherapy,Other)') # é¿åº¦301 spePlan = Column(String(60), comment='å
·ä½æ¹æ¡')302 begDate = Column(Date, comment='å¼å§æ¥æ')303 endDate = Column(Date, comment='ç»ææ¥æ')304 isRepBio = Column(Boolean, comment='æ¯å¦éå¤æ´»æ£')305 bioMet = Column(JSON, comment='æ´»æ£æ¹å¼') # é¿åº¦306 _bioMet = Column(String(40), comment='æ´»æ£æ¹å¼') # é¿åº¦307 matPart = Column(String(255), comment='åæé¨ä½') # é¿åº¦308 specNum = Column(String(255), comment='æ æ¬åºæµæ°´å·') # ç±»å æ¹ä¸ºå符串309 patDia = Column(JSON, comment='ç
çè¯æç»æ')310 patDiaRes = Column(Text(10000), comment='ç
çè¯æç»æ')311 patDiaOthers = Column(String(255), comment='ç
çè¯æ,å
¶ä»çå
容')312 note = Column(String(2048), comment='å¤æ³¨')313 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')314 doubt = Column(JSON, comment='è´¨çååå¤')315 # å导åºåè½æå
³316 chemo_detail_num = 0317 targeted_detail_num = 0318 immunity_detail_num = 0319 antivascular_detail_num = 0320 export_header_map = {'isTre': 'æ¯å¦å å
¥ä¸´åºæ²»ç', 'clinTri': '临åºå®éªå称', 'treSolu': 'æ²»çæ¹æ¡',321 'note': 'å
¶ä»', 'begDate': 'å¼å§æ¥æ', 'endDate': 'ç»ææ¥æ',322 'treatName': 'æ²»çå称', 'currPeriod': 'å¨æ', 'treSche': 'è¯ç©æ¹æ¡',323 'drugs': 'è¯ç©', 'detailBegDate': 'ç»è¯/æ²»çå¼å§æ¥æ', 'detailEndDate': 'ç»è¯/æ²»çç»ææ¥æ', 'detailNote': 'å¤æ³¨'}324 def keys(self):325 return ['id', 'pid', 'treNum', 'isTre', 'clinTri', 'treSolu', 'spePlan', 'begDate', 'endDate', 'isRepBio',326 'bioMet', 'matPart', 'specNum', 'patDiaRes', 'patDiaOthers', 'note', 'patDia', '_bioMet',327 'modification', 'doubt']328 # å导åºåè½æå
³329 def get_export_row(self, columns, buffer, pid, treIndex):330 detail_header = ['treatName', 'currPeriod', 'treSche', 'drugs', 'detailBegDate', 'detailEndDate',331 'detailNote']332 isTre_map = {0: 'å¦', 1: 'æ¯', -1: 'ä¸è¯¦', "/": "/"}333 row = np.zeros(0, dtype=str)334 if (buffer.get('OneToFive').get(pid) is None or buffer.get('OneToFive').get(pid).get(treIndex) is None335 or buffer.get('TreRec').get(pid) is None or buffer.get('TreRec').get(pid).get(treIndex) is None336 or not (buffer.get('TreRec').get(pid).get(treIndex).trement in ['one', 'two', 'three', 'four',337 'five'])):338 row = np.append(row, ['/'] * OneToFive.header_num)339 return row340 obj = buffer.get('OneToFive').get(pid).get(treIndex)341 my_detail_headers = []342 for column in columns:343 if column == 'detailBegDate':344 my_detail_headers.append('begDate')345 elif column == 'detailEndDate':346 my_detail_headers.append('endDate')347 elif column == 'detailNote':348 my_detail_headers.append('note')349 elif column in ['treatName', 'currPeriod', 'treSche', 'drugs']:350 my_detail_headers.append(column)351 if buffer.get('DetailTrePlan').get(pid) is None or buffer.get('DetailTrePlan').get(pid).get(treIndex) is None:352 detail_trePlan_array = None353 else:354 detail_trePlan_array = buffer.get('DetailTrePlan').get(pid).get(treIndex)355 detail_flag = False # æ å¿æ¯å¦å·²ç»å¤çäºè¯¦ç»æ²»çæ¹æ¡çå段356 for column in columns:357 if column == 'isTre':358 value = self.filter_none(obj, column)359 value = isTre_map.get(value)360 row = np.append(row, value)361 elif column == 'clinTri':362 value_isTre = self.filter_none(obj, 'isTre')363 value = self.filter_none(obj, column) if value_isTre == 1 else '/'364 row = np.append(row, value)365 elif column == 'treSolu':366 value = ''367 treSolu_value = self.filter_none(obj, column)368 if 'Chemotherapy' in treSolu_value:369 value += 'åç '370 if 'TargetedTherapy' in treSolu_value:371 value += 'é¶åæ²»ç '372 if 'ImmunityTherapy' in treSolu_value:373 value += 'å
ç«æ²»ç '374 if 'AntivascularTherapy' in treSolu_value:375 value += 'æè¡ç®¡æ²»ç '376 if 'Other' in treSolu_value:377 value += 'å
¶ä» '378 row = np.append(row, value)379 elif (not detail_flag) and (column in detail_header):380 detail_flag = True381 treSolu_value = self.filter_none(obj, 'treSolu')382 size = len(my_detail_headers)383 if not detail_trePlan_array:384 times = OneToFive.chemo_detail_num + OneToFive.targeted_detail_num + OneToFive.immunity_detail_num + OneToFive.antivascular_detail_num385 row = np.append(row, ['/'] * size * times)386 else:387 chemo_detail_num = 0388 targeted_detail_num = 0389 immunity_detail_num = 0390 antivascular_detail_num = 0391 if 'Chemotherapy' in treSolu_value and detail_trePlan_array.get('Chemotherapy'):392 chemo_detail_trePlan_array = detail_trePlan_array['Chemotherapy']393 chemo_detail_num = len(chemo_detail_trePlan_array)394 for detail_trePlan in chemo_detail_trePlan_array:395 for detail_column in my_detail_headers:396 if detail_column == 'drugs':397 value_drugs = self.filter_none(detail_trePlan, detail_column)398 row = np.append(row, self.format_drugs_of_detailTrePlan(value_drugs))399 else:400 row = np.append(row, self.filter_none(detail_trePlan, detail_column))401 row = np.append(row, ['/'] * size * (OneToFive.chemo_detail_num - chemo_detail_num))402 if 'TargetedTherapy' in treSolu_value and detail_trePlan_array.get('TargetedTherapy'):403 targeted_detail_trePlan_array = detail_trePlan_array['TargetedTherapy']404 targeted_detail_num = len(targeted_detail_trePlan_array)405 for detail_trePlan in targeted_detail_trePlan_array:406 for detail_column in my_detail_headers:407 if detail_column == 'drugs':408 value_drugs = self.filter_none(detail_trePlan, detail_column)409 row = np.append(row, self.format_drugs_of_detailTrePlan(value_drugs))410 else:411 row = np.append(row, self.filter_none(detail_trePlan, detail_column))412 row = np.append(row, ['/'] * size * (OneToFive.targeted_detail_num - targeted_detail_num))413 if 'ImmunityTherapy' in treSolu_value and detail_trePlan_array.get('ImmunityTherapy'):414 immunity_detail_trePlan_array = detail_trePlan_array['ImmunityTherapy']415 immunity_detail_num = len(immunity_detail_trePlan_array)416 for detail_trePlan in immunity_detail_trePlan_array:417 for detail_column in my_detail_headers:418 if detail_column == 'drugs':419 value_drugs = self.filter_none(detail_trePlan, detail_column)420 row = np.append(row, self.format_drugs_of_detailTrePlan(value_drugs))421 else:422 row = np.append(row, self.filter_none(detail_trePlan, detail_column))423 row = np.append(row, ['/'] * size * (OneToFive.immunity_detail_num - immunity_detail_num))424 if 'AntivascularTherapy' in treSolu_value and detail_trePlan_array.get('AntivascularTherapy'):425 antivascular_detail_trePlan_array = detail_trePlan_array['AntivascularTherapy']426 antivascular_detail_num = len(antivascular_detail_trePlan_array)427 for detail_trePlan in antivascular_detail_trePlan_array:428 for detail_column in my_detail_headers:429 if detail_column == 'drugs':430 value_drugs = self.filter_none(detail_trePlan, detail_column)431 row = np.append(row, self.format_drugs_of_detailTrePlan(value_drugs))432 else:433 row = np.append(row, self.filter_none(detail_trePlan, detail_column))434 row = np.append(row, ['/'] * size * (OneToFive.antivascular_detail_num - antivascular_detail_num))435 elif column == 'note':436 value_treSolu = self.filter_none(obj, 'treSolu')437 if 'Other' in value_treSolu:438 value = self.filter_none(obj, column)439 else:440 value = '/'441 row = np.append(row, value)442 elif not (column in detail_header):443 value = self.filter_none(obj, column)444 row = np.append(row, value)445 return row446 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´447 def get_export_header(self, columns, buffer):448 detail_header = ['treatName', 'currPeriod', 'treSche', 'drugs', 'detailBegDate', 'detailEndDate',449 'detailNote']450 header = np.zeros(0, dtype=str)451 # æ±æå¤æå¤å°æ¡452 max_chemo_detail_num = 0453 max_targeted_detail_num = 0454 max_immunity_detail_num = 0455 max_antivascular_detail_num = 0456 my_detail_headers = []457 for column in columns:458 if column in detail_header:459 my_detail_headers.append(column)460 for value1 in buffer.get('DetailTrePlan').values():461 for value2 in value1.values():462 if value2:463 chemo_detail_num = len(value2.get('Chemotherapy')) if value2.get('Chemotherapy') else 0464 targeted_detail_num = len(value2.get('TargetedTherapy')) if value2.get('TargetedTherapy') else 0465 immunity_detail_num = len(value2.get('ImmunityTherapy')) if value2.get('ImmunityTherapy') else 0466 antivascular_detail_num = len(value2.get('AntivascularTherapy')) if value2.get(467 'AntivascularTherapy') else 0468 if chemo_detail_num > max_chemo_detail_num:469 max_chemo_detail_num = chemo_detail_num470 if targeted_detail_num > max_targeted_detail_num:471 max_targeted_detail_num = targeted_detail_num472 if immunity_detail_num > max_immunity_detail_num:473 max_immunity_detail_num = immunity_detail_num474 if antivascular_detail_num > max_antivascular_detail_num:475 max_antivascular_detail_num = antivascular_detail_num476 detail_flag = False # æ å¿æ¯å¦å·²ç»å¤ç详ç»æ²»çæ¹æ¡å段477 for column in columns:478 if (not detail_flag) and (column in my_detail_headers):479 detail_flag = True480 for k in range(1, max_chemo_detail_num + 1):481 for detail_column in my_detail_headers:482 # header.append('åç:' + self.export_header_map.get(detail_column) + str(k))483 header = np.append(header, 'åç:' + self.export_header_map.get(detail_column) + str(k))484 for k in range(1, max_targeted_detail_num + 1):485 for detail_column in my_detail_headers:486 header = np.append(header, 'é¶åæ²»ç:' + self.export_header_map.get(detail_column) + str(k))487 for k in range(1, max_immunity_detail_num + 1):488 for detail_column in my_detail_headers:489 header = np.append(header, 'å
ç«æ²»ç:' + self.export_header_map.get(detail_column) + str(k))490 for k in range(1, max_antivascular_detail_num + 1):491 for detail_column in my_detail_headers:492 header = np.append(header, 'æè¡ç®¡æ²»ç:' + self.export_header_map.get(detail_column) + str(k))493 elif not (column in my_detail_headers):494 header = np.append(header, self.export_header_map.get(column))495 OneToFive.chemo_detail_num = max_chemo_detail_num496 OneToFive.targeted_detail_num = max_targeted_detail_num497 OneToFive.immunity_detail_num = max_immunity_detail_num498 OneToFive.antivascular_detail_num = max_antivascular_detail_num499 OneToFive.header_num = len(header)500 return header501 def format_drugs_of_detailTrePlan(self, value_drugs):502 drugs = ''503 if type(value_drugs) == dict:504 for key, value in value_drugs.items():505 drugs += key + ':'506 if 'drugDosa' in value.keys():507 drugs += self.filter_none(str(value['drugDosa']))508 if 'unit' in value.keys():509 drugs += self.filter_none(str(value['unit']))510 drugs += ' '511 elif type(value_drugs) == list:512 for each in value_drugs:513 if 'name' in each.keys():514 drugs += self.filter_none(each['name']) + ':'515 if 'dose' in each.keys():516 drugs += self.filter_none(each['dose'])517 drugs += ' '518 else:519 drugs = str(value_drugs)520 return drugs521# 详ç»æ²»çæ¹æ¡522class DetailTrePlan(Base, ModificationAndDoubt):523 __tablename__ = 'DetailTrePlan'524 id = Column(Integer, primary_key=True, autoincrement=True)525 pid = Column(Integer, comment='ç
人id')526 treNum = Column(Integer, comment='0对åºåè¯ä¿¡æ¯ã1-n表示对åºç¬¬xæ¡æ²»çè®°å½')527 treSolu = Column(String(255), comment='æ²»çæ¹æ¡,Chemotherapy/TargetedTherapy/ImmunityTherapy/AntivascularTherapy/Other')528 treSche = Column(String(255), comment='è¯ç©æ¹æ¡') # é¿åº¦529 currPeriod = Column(Integer, comment='å½åå¨æ')530 treatName = Column(String(255), comment='æ²»çå称') # é¿åº¦531 begDate = Column(Date, comment='å¼å§æ¶é´')532 endDate = Column(Date, comment='ç»ææ¶é´')533 drugs = Column(JSON, comment='è¯ç©ä½¿ç¨æ
åµ, [{"dose": "", "name": ""},...]')534 note = Column(String(2048), comment='è¯ç©ä½¿ç¨å¤æ³¨') # é¿åº¦535 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')536 doubt = Column(JSON, comment='è´¨çååå¤')537 export_header_map = {'treSche': 'è¯ç©æ¹æ¡', 'treatName': 'æ²»çå称', 'currPeriod': 'å½åå¨æ', 'begDate': 'ç»è¯/æ²»çå¼å§æ¥æ',538 'endDate': 'ç»è¯/æ²»çç»ææ¥æ', 'drugs': 'è¯ç©ä½¿ç¨æ
åµ', 'note': 'å¤æ³¨'}539 def keys(self):540 return ['id', 'treSolu', 'treSche', 'currPeriod', 'treatName', 'begDate', 'endDate', 'drugs', 'note',541 'modification', 'doubt']542# ææ¯è¡¨543class Surgery(Base, PatDia, ModificationAndDoubt):544 __tablename__ = 'surgery'545 id = Column(Integer, primary_key=True, autoincrement=True)546 pid = Column(Integer, comment='ç
人id')547 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')548 surSco = Column(JSON, comment='ææ¯èå´')549 _surSco = Column(JSON, comment='ææ¯èå´')550 lymDis = Column(JSON, comment='æ·å·´æ¸
æ«èå´')551 _lymDis = Column(JSON, comment='æ·å·´æ¸
æ«èå´')552 cleGro = Column(String(40), comment='æ¸
æ«ç»æ°')553 surDate = Column(Date, comment='ææ¯æ¥æ')554 posAdjChem = Column(Boolean, comment='æ¯åè¾
å©åç')555 isPro = Column(Boolean, comment='æ¯å¦è¿å±')556 proDate = Column(Date, comment='è¿å±æ¥æ')557 proDes = Column(String(2048), comment='è¿å±æè¿°')558 isRepBio = Column(Boolean, comment='æ¯å¦éå¤æ´»æ£')559 # bioMet = Column(JSON, comment='æ´»æ£æ¹å¼') # é¿åº¦560 bioMet = Column(JSON, comment='æ´»æ£æ¹å¼') # é¿åº¦561 matPart = Column(String(255), comment='åæé¨ä½')562 specNum = Column(String(255), comment='æ æ¬åºæµæ°´å·')563 patDia = Column(JSON, comment='ç
çè¯æç»æ')564 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')565 doubt = Column(JSON, comment='è´¨çååå¤')566 # å导åºåè½æå
³567 detail_header_num = 0568 export_header_map = {'surSco': 'ææ¯èå´', 'lymDis': 'æ·å·´æ¸
æ«èå´',569 'cleGro': 'æ¸
æ«ç»æ°', 'surDate': 'ææ¯æ¥æ', 'posAdjChem': 'æ¯åè¾
å©åç',570 'treatName': 'æ²»çå称', 'currPeriod': 'å¨æ', 'treSche': 'è¯ç©æ¹æ¡',571 'drugs': 'è¯ç©', 'detailBegDate': 'ç»è¯/æ²»çå¼å§æ¥æ', 'detailEndDate': 'ç»è¯/æ²»çç»ææ¥æ', 'detailNote': 'å¤æ³¨'}572 def get_export_row(self, columns, buffer, pid, treIndex):573 detail_header = ['treatName', 'currPeriod', 'treSche', 'drugs', 'detailBegDate', 'detailEndDate',574 'detailNote']575 row = np.zeros(0, dtype=str)576 if (buffer.get('Surgery').get(pid) is None or buffer.get('Surgery').get(pid).get(treIndex) is None577 or buffer.get('TreRec').get(pid) is None or buffer.get('TreRec').get(pid).get(treIndex) is None578 or buffer.get('TreRec').get(pid).get(treIndex).trement != 'surgery'):579 row = np.append(row, ['/'] * Surgery.header_num)580 return row581 obj = buffer.get('Surgery').get(pid).get(treIndex)582 my_detail_headers = []583 for column in columns:584 if column == 'detailBegDate':585 my_detail_headers.append('begDate')586 elif column == 'detailEndDate':587 my_detail_headers.append('endDate')588 elif column == 'detailNote':589 my_detail_headers.append('note')590 elif column in ['treatName', 'currPeriod', 'treSche', 'drugs']:591 my_detail_headers.append(column)592 if buffer.get('DetailTrePlan').get(pid) is None or buffer.get('DetailTrePlan').get(pid).get(treIndex) is None:593 detail_trePlan_array = None594 else:595 detail_trePlan_array = buffer.get('DetailTrePlan').get(pid).get(treIndex)596 detail_flag = False # æ å¿æ¯å¦å·²ç»å¤ç详ç»æ²»çæ¹æ¡å段597 for column in columns:598 if column == 'surSco' or column == 'lymDis':599 value = self.format_radio_data(obj, column)600 # row.append(value)601 row = np.append(row, value)602 elif column == 'posAdjChem':603 value = self.filter_none(self.change_bool_to_yes_or_no(getattr(obj, column)))604 # row.append(value)605 row = np.append(row, value)606 elif (not detail_flag) and (column in detail_header):607 detail_flag = True608 size = len(my_detail_headers)609 posAdjChem_value = self.filter_none(self.change_bool_to_yes_or_no(getattr(obj, 'posAdjChem')))610 if posAdjChem_value != 'æ¯' or not detail_trePlan_array or not detail_trePlan_array.get('Chemotherapy'):611 # row.extend(['/']*size*Surgery.detail_header_num)612 row = np.append(row, ['/'] * size * Surgery.detail_header_num)613 else:614 surgery_detail_trePlan_array = detail_trePlan_array.get('Chemotherapy')615 detail_num = len(surgery_detail_trePlan_array)616 for detail_trePlan in surgery_detail_trePlan_array:617 for detail_column in my_detail_headers:618 if detail_column == 'drugs':619 value_drugs = self.filter_none(detail_trePlan, detail_column)620 row = np.append(row, self.format_drugs_of_detailTrePlan(value_drugs))621 else:622 row = np.append(row, self.filter_none(detail_trePlan, detail_column))623 row = np.append(row, ['/'] * size * (Surgery.detail_header_num - detail_num))624 elif not (column in detail_header):625 value = self.filter_none(obj, column)626 row = np.append(row, value)627 return row628 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´629 def get_export_header(self, columns, buffer):630 detail_header = ['treatName', 'currPeriod', 'treSche', 'drugs', 'detailBegDate', 'detailEndDate',631 'detailNote']632 header = np.zeros(0, dtype=str)633 my_detail_headers = []634 for column in columns:635 if column in detail_header:636 my_detail_headers.append(column)637 # æ±æå¤æå¤å°æ¡638 max_num = 0639 for value1 in buffer.get('DetailTrePlan').values():640 for value2 in value1.values():641 if value2 and value2.get('Chemotherapy'):642 num = len(value2.get('Chemotherapy'))643 if num > max_num:644 max_num = num645 header_num = max_num if max_num > 1 else 1646 detail_flag = False # æ å¿æ¯å¦å·²ç»å¤ç详ç»æ²»çæ¹æ¡å段647 for column in columns:648 if (not detail_flag) and (column in my_detail_headers):649 detail_flag = True650 for k in range(1, header_num + 1):651 for detail_column in my_detail_headers:652 header = np.append(header, 'æ¯åè¾
å©åç:' + self.export_header_map.get(detail_column) + str(k))653 elif not (column in my_detail_headers):654 header = np.append(header, self.export_header_map.get(column))655 Surgery.detail_header_num = header_num656 Surgery.header_num = len(header)657 return header658 def format_drugs_of_detailTrePlan(self, value_drugs):659 drugs = ''660 if type(value_drugs) == dict:661 for key, value in value_drugs.items():662 drugs += key + ':'663 if 'drugDosa' in value.keys():664 drugs += self.filter_none(str(value['drugDosa']))665 if 'unit' in value.keys():666 drugs += self.filter_none(str(value['unit']))667 drugs += ' '668 elif type(value_drugs) == list:669 for each in value_drugs:670 if 'name' in each.keys():671 drugs += self.filter_none(each['name']) + ':'672 if 'dose' in each.keys():673 drugs += self.filter_none(each['dose'])674 drugs += ' '675 else:676 drugs = str(value_drugs)677 return drugs678 def keys(self):679 return ['id', 'pid', 'treNum', 'surSco', 'lymDis', 'cleGro', 'surDate', 'posAdjChem', 'isPro', 'proDate',680 'proDes', 'isRepBio', 'bioMet', 'matPart', 'specNum', 'patDia', '_surSco', '_lymDis',681 'modification', 'doubt']682# æ¾ç表683class Radiotherapy(Base, ModificationAndDoubt):684 __tablename__ = 'radiotherapy'685 id = Column(Integer, primary_key=True, autoincrement=True)686 pid = Column(Integer, comment='ç
人id')687 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')688 begDate = Column(Date, comment='å¼å§æ¥æ')689 endDate = Column(Date, comment='ç»ææ¥æ')690 _radSite = Column(JSON, comment='æ¾çé¨ä½')691 radSite = Column(JSON, comment='æ¾çé¨ä½')692 radDose = Column(Float, comment='æ¾å°åé')693 dosUnit = Column(Boolean, comment='åéåä½,0: Gy, 1:cGy')694 splTim = Column(Integer, comment='åå²æ¬¡æ°')695 method = Column(String(255), comment='åå²æ¬¡æ°åä½')696 isRepBio = Column(Boolean, comment='æ¯å¦éå¤æ´»æ£')697 bioMet = Column(JSON, comment='æ´»æ£æ¹å¼') # é¿åº¦698 matPart = Column(String(255), comment='åæé¨ä½')699 specNum = Column(String(255), comment='æ æ¬åºæµæ°´å·')700 patDia = Column(JSON, comment='ç
çè¯æç»æ')701 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')702 doubt = Column(JSON, comment='è´¨çååå¤')703 # å导åºåè½æå
³704 export_header_map = {'begDate': 'å¼å§æ¥æ', 'endDate': 'ç»ææ¥æ', 'radSite': 'æ¾çé¨ä½',705 'radDose': 'æ¾çåé', 'splTim': 'åå²æ¬¡æ°'}706 # å导åºåè½æå
³707 def get_export_row(self, columns, buffer, pid, treIndex):708 radosUnit_map = {0: 'Gy', 1: 'cGy', "/": "/"}709 row = np.zeros(0, dtype=str)710 if (buffer.get('Radiotherapy').get(pid) is None or buffer.get('Radiotherapy').get(pid).get(treIndex) is None711 or buffer.get('TreRec').get(pid) is None or buffer.get('TreRec').get(pid).get(treIndex) is None712 or buffer.get('TreRec').get(pid).get(treIndex).trement != 'radiotherapy'):713 row = np.append(row, ['/'] * Radiotherapy.header_num)714 return row715 obj = buffer.get('Radiotherapy').get(pid).get(treIndex)716 for column in columns:717 if column == 'radSite':718 value = self.format_radio_data(obj, column)719 row = np.append(row, value)720 elif column == 'radDose':721 value_radDose = self.filter_none(obj, column)722 value_dosUnit = radosUnit_map.get(self.filter_none(obj, 'dosUnit'))723 value = str(value_radDose) + value_dosUnit if value_radDose != '/' else '/'724 row = np.append(row, value)725 elif column == 'splTim':726 value_splTim = self.filter_none(obj, column)727 value_method = self.filter_none(obj, 'method')728 value = str(value_splTim) + value_method if value_splTim != '/' else '/'729 row = np.append(row, value)730 else:731 value = self.filter_none(obj, column)732 row = np.append(row, value)733 return row734 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´735 def get_export_header(self, columns, buffer):736 header = np.zeros(0, dtype=str)737 for column in columns:738 header = np.append(header, self.export_header_map.get(column))739 Radiotherapy.header_num = len(header)740 return header741 def keys(self):742 return ['id', 'pid', 'treNum', 'begDate', 'endDate', 'radSite', 'radDose', 'dosUnit', 'splTim', 'method',743 '_radSite', 'isRepBio', 'bioMet', 'matPart', 'specNum', 'patDia',...
cycle.py
Source:cycle.py
...78 return row79 obj = buffer.get('Immunohis').get(pid).get(treIndex)80 for column in columns:81 if column == 'Ki67' or column == 'other':82 value = self.filter_none(obj, column)83 value = str(value) + "%" if value != '/' else value84 row = np.append(row, value)85 elif column in ['detectTime', 'patNum']:86 value = self.filter_none(obj, column)87 row = np.append(row, value)88 else:89 value = self.filter_none(obj, column)90 value = immunohis_map.get(value)91 row = np.append(row, value)92 return row93 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´94 def get_export_header(self, columns, buffer):95 header = np.zeros(0, dtype=str)96 for column in columns:97 header = np.append(header, self.export_header_map.get(column))98 Immunohis.header_num = len(header)99 return header100# ç
人ååæ£æµä¿¡æ¯è¡¨101class MoleDetec(Base, ModificationAndDoubt):102 __tablename__ = 'moleDetec'103 id = Column(Integer, primary_key=True, autoincrement=True)104 pid = Column(Integer, comment='ç
人id')105 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')106 ALK = Column(Integer, comment='ALK(0-é´æ§,1-é³æ§,2-æ )')107 BIM = Column(Integer, comment='BIM(0-é´æ§,1-é³æ§,2-æ )')108 BRAF = Column(Integer, comment='BRAF(0-é´æ§,1-é³æ§,2-æ )')109 cMET = Column(Integer, comment='cMET(0-é´æ§,1-é³æ§,2-æ )')110 EGFR = Column(Integer, comment='EGFR(0-é´æ§,1-é³æ§,2-æ )')111 HER_2 = Column(Integer, comment='HER-2(0-é´æ§,1-é³æ§,2-æ )')112 KRAS = Column(Integer, comment='KRAS(0-é´æ§,1-é³æ§,2-æ )')113 PIK3CA = Column(Integer, comment='PIK3CA(0-é´æ§,1-é³æ§,2-æ )')114 ROS1 = Column(Integer, comment='ROS1(0-é´æ§,1-é³æ§,2-æ )')115 RET = Column(Integer, comment='RET(0-é´æ§,1-é³æ§,2-æ )')116 UGT1A1 = Column(Integer, comment='UGT1A1(0-é´æ§,1-é³æ§,2-æ )')117 NTRK = Column(Integer, comment='UGT1A1(0-é´æ§,1-é³æ§,2-æ )')118 ALKSam = Column(String(255), comment='ALKæ£æµæ ·æ¬') # ä¸é¢çææ¬é½è¦æ¹119 BIMSam = Column(String(255), comment='BIMæ£æµæ ·æ¬')120 BRAFSam = Column(String(255), comment='BRAFæ£æµæ ·æ¬')121 cMETSam = Column(String(255), comment='cMETæ£æµæ ·æ¬')122 EGFRSam = Column(String(255), comment='EGFRæ£æµæ ·æ¬')123 HER_2Sam = Column(String(255), comment='HER-2æ£æµæ ·æ¬')124 KRASSam = Column(String(255), comment='KRASæ£æµæ ·æ¬')125 PIK3CASam = Column(String(255), comment='PIK3CAæ£æµæ ·æ¬')126 ROS1Sam = Column(String(255), comment='ROS1æ£æµæ ·æ¬')127 RETSam = Column(String(255), comment='RETæ£æµæ ·æ¬')128 UGT1A1Sam = Column(String(255), comment='UGT1A1æ£æµæ ·æ¬')129 NTRKSam = Column(String(255), comment='NTRKæ£æµæ ·æ¬')130 ALKDetMed = Column(Integer, comment='ALKæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')131 BIMDetMed = Column(Integer, comment='BIMæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')132 BRAFDetMed = Column(Integer, comment='BRAFæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')133 cMETDetMed = Column(Integer, comment='cMETæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')134 EGFRDetMed = Column(Integer, comment='EGFRæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')135 HER_2DetMed = Column(Integer, comment='HER-2æ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')136 KRASDetMed = Column(Integer, comment='KRASæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')137 PIK3CADetMed = Column(Integer, comment='PIK3CAæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')138 ROS1DetMed = Column(Integer, comment='ROS1æ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')139 RETDetMed = Column(Integer, comment='RETæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')140 UGT1A1DetMed = Column(Integer, comment='UGT1A1æ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')141 NTRKDetMed = Column(Integer, comment='NTRKDetMedæ£æµæ¹æ³(1-ARMS,2-FISH,3-NGS)')142 ALKDesc = Column(String(255), comment='ALKç»ææè¿°')143 BIMDesc = Column(String(255), comment='BIMç»ææè¿°')144 BRAFDesc = Column(String(255), comment='BRAFç»ææè¿°')145 cMETDesc = Column(String(255), comment='cMETç»ææè¿°')146 EGFRDesc = Column(String(255), comment='EGFRç»ææè¿°')147 HER_2Desc = Column(String(255), comment='HER-2ç»ææè¿°')148 KRASDesc = Column(String(255), comment='KRASç»ææè¿°')149 PIK3CADesc = Column(String(255), comment='PIK3CAç»ææè¿°')150 ROS1Desc = Column(String(255), comment='ROS1ç»ææè¿°')151 RETDesc = Column(String(255), comment='RETç»ææè¿°')152 UGT1A1Desc = Column(String(255), comment='UGT1A1ç»ææè¿°')153 NTRKDesc = Column(String(255), comment='NTRKç»ææè¿°')154 path = Column(String(200), comment='æ¥åæ件路å¾')155 MSI = Column(Integer, comment='MSI 0-MSS,1-MSIH,2-MSIL')156 other = Column(Text)157 PDL1 = Column(Float, comment='PD-L1表达 0-æªæµ,1-ä¸è¯¦,2->50%,3-1%-50%,4-<1%,5-é´æ§')158 PDL1KT = Column(String(255), comment='PDL1æä½')159 PD1 = Column(Float, comment='PD1表达 0-æªæµ,1-ä¸è¯¦,2->50%,3-1%-50%,4-<1%,5-é´æ§')160 PD1KT = Column(String(255), comment='PD1æä½')161 TMB = Column(String(20), comment='TMB') # ???162 detectTime = Column(Date, comment='æ£æµæ¶é´')163 detectCompany = Column(String(255), comment='æ£æµå
¬å¸')164 sampleType = Column(String(255), comment='æ ·æ¬ç±»å')165 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')166 doubt = Column(JSON, comment='è´¨çååå¤')167 # å导åºåè½æå
³168 export_header_map = {169 'MSI': 'MSI', 'PD1': 'PD-1表达', 'PD1KT': 'PD1KT', 'PDL1': 'PD-L1表达', 'PDL1KT': 'PDL1KT', 'TMB': 'TMB',170 'other': 'å
¶ä»', 'detectTime': 'ååæ£æµæ£æµæ¶é´', 'detectCompany': 'æ£æµå
¬å¸', 'sampleType': 'æ ·æ¬ç±»å',171 'EGFR': 'EGFR', 'ALK': 'ALK', 'ROS1': 'ROS1', 'HER_2': 'HER_2', 'BRAF': 'BRAF',172 'cMET': 'cMET', 'RET': 'RET', 'NTRK': 'NTRK', 'KRAS': 'KRAS', 'BIM': 'BIM',173 'PIK3CA': 'PIK3CA', 'UGT1A1': 'UGT1A1',174 'EGFRSam': 'EGFRæ£æµæ ·æ¬', 'ALKSam': 'ALKæ£æµæ ·æ¬', 'ROS1Sam': 'ROS1æ£æµæ ·æ¬', 'HER_2Sam': 'HER_2æ£æµæ ·æ¬',175 'BRAFSam': 'BRAFæ£æµæ ·æ¬',176 'cMETSam': 'cMETæ£æµæ ·æ¬', 'RETSam': 'RETæ£æµæ ·æ¬', 'NTRKSam': 'NTRKæ£æµæ ·æ¬', 'KRASSam': 'KRASæ£æµæ ·æ¬', 'BIMSam': 'BIMæ£æµæ ·æ¬',177 'PIK3CASam': 'PIK3CAæ£æµæ ·æ¬', 'UGT1A1Sam': 'UGT1A1æ£æµæ ·æ¬',178 'EGFRMed': 'EGFRæ£æµæ¹æ³', 'ALKMed': 'ALKæ£æµæ¹æ³', 'ROS1Med': 'ROS1æ£æµæ¹æ³', 'HER_2Med': 'HER_2æ£æµæ¹æ³',179 'BRAFMed': 'BRAFæ£æµæ¹æ³',180 'cMETMed': 'cMETæ£æµæ¹æ³', 'RETMed': 'RETæ£æµæ¹æ³', 'NTRKMed': 'NTRKæ£æµæ¹æ³', 'KRASMed': 'KRASæ£æµæ¹æ³', 'BIMMed': 'BIMæ£æµæ¹æ³',181 'PIK3CAMed': 'PIK3CAæ£æµæ¹æ³', 'UGT1A1Med': 'UGT1A1æ£æµæ¹æ³',182 'EGFRDesc': 'EGFRç»ææè¿°', 'ALKDesc': 'ALKç»ææè¿°', 'ROS1Desc': 'ROS1ç»ææè¿°', 'HER_2Desc': 'HER_2ç»ææè¿°',183 'BRAFDesc': 'BRAFç»ææè¿°',184 'cMETDesc': 'cMETç»ææè¿°', 'RETDesc': 'RETç»ææè¿°', 'NTRKDesc': 'NTRKç»ææè¿°', 'KRASDesc': 'KRASç»ææè¿°',185 'BIMDesc': 'BIMç»ææè¿°',186 'PIK3CADesc': 'PIK3CAç»ææè¿°', 'UGT1A1Desc': 'UGT1A1ç»ææè¿°'187 }188 def keys(self):189 return ['id', 'pid', 'treNum', 'ALK', 'BIM', 'BRAF', 'cMET', 'EGFR', 'HER_2', 'KRAS', 'NTRK',190 'PIK3CA', 'ROS1', 'RET', 'UGT1A1', 'ALKSam', 'BIMSam', 'BRAFSam', 'cMETSam', 'EGFRSam', 'HER_2Sam',191 'KRASSam', 'PIK3CASam', 'ROS1Sam', 'NTRKSam',192 'RETSam', 'UGT1A1Sam', 'ALKDetMed', 'BIMDetMed', 'BRAFDetMed', 'cMETDetMed', 'EGFRDetMed',193 'HER_2DetMed', 'KRASDetMed', 'PIK3CADetMed', 'ROS1DetMed', 'NTRKDetMed',194 'RETDetMed', 'UGT1A1DetMed', 'ALKDesc', 'BIMDesc', 'BRAFDesc', 'cMETDesc', 'EGFRDesc', 'HER_2Desc',195 'KRASDesc', 'PIK3CADesc',196 'ROS1Desc', 'RETDesc', 'UGT1A1Desc', 'NTRKDesc', 'path', 'MSI', 'other', 'PDL1', 'PDL1KT', 'TMB', 'PD1',197 'PD1KT', 'sampleType', 'detectTime', 'detectCompany', 'modification', 'doubt']198 # å导åºåè½æå
³199 def get_export_row(self, columns, buffer, pid, treIndex):200 moleDetec_map = {0: 'é´æ§', 1: 'é³æ§', 2: 'æ ', "/": "/"}201 moleDetec_DetMed_map = {1: 'ARMS', 2: 'FISH', 3: 'NGS', "/": "/"}202 moleDetec_MSI_map = {0: 'MSS', 1: 'MSIH', 2: 'MSIL', "/": "/"}203 moleDetec_fields = ['ALK', 'BIM', 'BRAF', 'cMET', 'EGFR', 'HER_2', 'KRAS',204 'PIK3CA', 'ROS1', 'RET', 'UGT1A1', 'NTRK']205 row = np.zeros(0, dtype=str)206 if buffer.get('MoleDetec').get(pid) is None or buffer.get('MoleDetec').get(pid).get(treIndex) is None:207 row = np.append(row, ['/'] * MoleDetec.header_num)208 return row209 obj = buffer.get('MoleDetec').get(pid).get(treIndex)210 for column in columns:211 if column in moleDetec_fields:212 value = self.filter_none(obj, column)213 value = moleDetec_map.get(value)214 row = np.append(row, value)215 if value == 'é³æ§':216 valueSam = self.filter_none(obj, column + 'Sam')217 valueDetMed = self.filter_none(obj, column + 'DetMed')218 valueDetMed = moleDetec_DetMed_map.get(valueDetMed)219 valueDesc = self.filter_none(obj, column + 'Desc')220 row = np.append(row, [valueSam, valueDetMed, valueDesc])221 else:222 row = np.append(row, ['/', '/', '/'])223 elif column == 'MSI':224 value = self.filter_none(obj, column)225 value = moleDetec_MSI_map.get(value)226 row = np.append(row, value)227 elif column == 'PD1' or column == 'PDL1':228 value = self.filter_none(obj, column)229 value = str(value) + "%" if value != '/' else value230 row = np.append(row, value)231 else:232 value = self.filter_none(obj, column)233 row = np.append(row, value)234 return row235 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´236 def get_export_header(self, columns, buffer):237 header = np.zeros(0, dtype=str)238 for column in columns:239 if column in ['MSI', 'PD1', 'PD1KT', 'PDL1', 'PDL1KT', 'TMB',240 'other', 'detectTime', 'detectCompany', 'sampleType']:241 header = np.append(header, self.export_header_map.get(column))242 else:243 header = np.append(header, [self.export_header_map.get(column),244 self.export_header_map.get(column) + 'æ£æµæ ·æ¬',245 self.export_header_map.get(column) + 'æ£æµæ¹æ³',246 self.export_header_map.get(column) + 'æ£æµæè¿°'])247 MoleDetec.header_num = len(header)248 return header249# çç¶ä½å¾è¡¨250class Signs(Base, ModificationAndDoubt):251 __tablename__ = 'signs'252 id = Column(Integer, primary_key=True, autoincrement=True)253 pid = Column(Integer, comment='ç
人id')254 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')255 symName = Column(String(255), comment='çç¶å称')256 begDate = Column(DateTime, comment='å¼å§æ¥æ')257 isExe = Column(Integer, comment='ç®åæ¯å¦åå¨')258 endDate = Column(DateTime, comment='ç»ææ¥æ')259 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')260 doubt = Column(JSON, comment='è´¨çååå¤')261 # å导åºåè½æå
³262 export_header_map = {'symName': 'çç¶å称', 'begDate': 'å¼å§æ¥æ',263 'isExe': 'ç®åæ¯å¦åå¨', 'endDate': 'ç»ææ¥æ'}264 # å导åºåè½æå
³265 def get_export_row(self, columns, buffer, pid, treIndex):266 isExe_map = {0: 'å¦', 1: 'æ¯', '/': '/'}267 # row = []268 row = np.zeros(0, dtype=str)269 if buffer.get('Signs').get(pid) is None or buffer.get('Signs').get(pid).get(treIndex) is None:270 # row.extend(['/'] * Signs.header_num)271 row = np.append(row, ['/'] * Signs.header_num)272 return row273 obj_array = buffer.get('Signs').get(pid).get(treIndex)274 for obj in obj_array:275 for column in columns:276 if column == 'isExe':277 value = self.filter_none(obj, column)278 value = isExe_map.get(value)279 # row.append(value)280 row = np.append(row, value)281 elif column == 'endDate':282 value_isExe = self.filter_none(obj, 'isExe')283 if value_isExe == 0:284 value = self.filter_none(obj, column)285 else:286 value = '/'287 # row.append(value)288 row = np.append(row, value)289 else:290 value = self.filter_none(obj, column)291 # row.append(value)292 row = np.append(row, value)293 # row.extend(['/'] * (Signs.header_num - len(row)))294 row = np.append(row, ['/'] * (Signs.header_num - len(row)))295 return row296 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´297 def get_export_header(self, columns, buffer):298 # header = []299 header = np.zeros(0, dtype=str)300 # æ±æå¤æå¤å°æ¡301 max_num = 0302 for value1 in buffer.get('Signs').values():303 for value2 in value1.values():304 num = len(value2)305 if num > max_num:306 max_num = num307 if max_num > 1:308 header_num = max_num309 else:310 header_num = 1311 for i in range(1, header_num + 1):312 for column in columns:313 # header.append(self.export_header_map.get(column) + str(i))314 header = np.append(header, self.export_header_map.get(column) + str(i))315 Signs.header_num = len(header)316 return header317 def keys(self):318 return ['id', 'pid', 'treNum', 'symName', 'begDate', 'isExe', 'endDate',319 'modification', 'doubt']320# å¯ååºè¡¨321class SideEffect(Base, ModificationAndDoubt):322 __tablename__ = 'sideEffect'323 id = Column(Integer, primary_key=True, autoincrement=True)324 pid = Column(Integer, comment='ç
人id')325 treNum = Column(Integer, comment='number,对åºç
人çæä¸æ¡æ²»çè®°å½')326 sidReaName = Column(String(255), comment='å¯ååºå称')327 sidReaNameOther = Column(String(2048), comment='å¯ååºå
¶ä»å称') # é访æ°æ®åºå¥½å没æè¿å段äº328 sidRecCla = Column(Integer, comment='å¯ååºå级')329 begDate = Column(Date, comment='å¼å§æ¥æ')330 isExe = Column(Integer, comment='ç®åæ¯å¦åå¨')331 treatment = Column(String(2048), comment='æ²»çæ
åµ')332 endDate = Column(Date, comment='ç»ææ¥æ')333 modification = Column(JSON, comment='溯æºåè½ãè®°å½æ交åçä¿®æ¹è®°å½')334 doubt = Column(JSON, comment='è´¨çååå¤')335 # å导åºåè½æå
³336 export_header_map = {'sidReaName': 'çç¶æè¿°', 'sidRecCla': 'å¯ååºå级', 'begDate': 'å¼å§æ¥æ',337 'isExe': 'ç®åæ¯å¦åå¨', 'endDate': 'ç»ææ¥æ', 'treatment': 'æ²»çæ
åµ'}338 # å导åºåè½æå
³339 def get_export_row(self, columns, buffer, pid, treIndex):340 isExe_map = {0: 'å¦', 1: 'æ¯', '/': '/'}341 # row = []342 row = np.zeros(0, dtype=str)343 if buffer.get('SideEffect').get(pid) is None or buffer.get('SideEffect').get(pid).get(treIndex) is None:344 # row.extend(['/'] * SideEffect.header_num)345 row = np.append(row, ['/'] * SideEffect.header_num)346 return row347 obj_array = buffer.get('SideEffect').get(pid).get(treIndex)348 for obj in obj_array:349 for column in columns:350 if column == 'isExe':351 value = self.filter_none(obj, column)352 value = isExe_map.get(value)353 # row.append(value)354 row = np.append(row, value)355 elif column == 'endDate':356 value_isExe = self.filter_none(obj, 'isExe')357 if value_isExe == 0:358 value = self.filter_none(obj, column)359 else:360 value = '/'361 # row.append(value)362 row = np.append(row, value)363 elif column == 'sidReaName':364 value = self.filter_none(obj, column)365 if value == 'å
¶ä»å¯ä½ç¨_å
¶ä»':366 sidReaNameOther_value = self.filter_none(obj, 'sidReaNameOther')367 value = 'å
¶ä»å¯ä½ç¨_' + sidReaNameOther_value368 elif value == '骨é«æå¶_å
¶ä»':369 sidReaNameOther_value = self.filter_none(obj, 'sidReaNameOther')370 value = '骨é«æå¶_' + sidReaNameOther_value371 # row.append(value)372 row = np.append(row, value)373 else:374 value = self.filter_none(obj, column)375 # row.append(value)376 row = np.append(row, value)377 # row.extend(['/'] * (SideEffect.header_num - len(row)))378 row = np.append(row, ['/'] * (SideEffect.header_num - len(row)))379 return row380 # å导åºåè½æå
³ï¼å¾å°å¯¼åºç表çä¸ææ¬å¤´381 def get_export_header(self, columns, buffer):382 # header = []383 header = np.zeros(0, dtype=str)384 # æ±æå¤æå¤å°æ¡385 max_num = 0386 for value1 in buffer.get('SideEffect').values():387 for value2 in value1.values():388 num = len(value2)...
Kfeature.py
Source:Kfeature.py
...72 if not isinstance(x,list):73 x = list(x)74 return func(x)75 return listify76def filter_none(func):77 """78 filter None value in input list79 :param func:80 :return:81 """82 @wraps(func)83 def filterfunc(*args):84 x = args[0]85 x = [a for a in x if a is not None]86 return func(x)87 return filterfunc88##########################89## Supporting Funcitons ##90##########################...
feature_calculators.py
Source:feature_calculators.py
...26 if not isinstance(x,list):27 x = list(x)28 return func(x)29 return listify30def filter_none(func):31 """32 filter None value in input list33 :param func:34 :return:35 """36 @wraps(func)37 def filterfunc(*args):38 x = args[0]39 x = [a for a in x if a is not None]40 return func(x)41 return filterfunc42##########################43## Supporting Funcitons ##44##########################...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!