How to use filter_none method in Playwright Python

Best Python code snippet using playwright-python

therapy_record.py

Source:therapy_record.py Github

copy

Full Screen

...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',...

Full Screen

Full Screen

cycle.py

Source:cycle.py Github

copy

Full Screen

...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)...

Full Screen

Full Screen

Kfeature.py

Source:Kfeature.py Github

copy

Full Screen

...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##########################...

Full Screen

Full Screen

feature_calculators.py

Source:feature_calculators.py Github

copy

Full Screen

...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##########################...

Full Screen

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful