#総合script.py
import openpyxl as xl
from openpyxl.styles import Font, Side, Border
import datetime
from tqdm import tqdm

wb = xl.load_workbook('フォーマット総合実施.xlsx')
wb2 = xl.load_workbook('Pt_data.xlsx')
sheet3 = wb['総合フォーマット']
sheet2 = wb2['患者データ']

Pt_list = []

header_cells = None

for row in sheet2.rows:
    if row[0].row == 1:
        header_cells = row
    else:

        row_dic = {}
        for k, v in zip(header_cells, row):
            row_dic[k.value] = v.value
        Pt_list.append(row_dic)


for i in tqdm(range(len(Pt_list))):
    sheet3['AQ1'] = Pt_list[i]["カルテNo"]
    sheet3['G2'] = Pt_list[i]["氏名"]
    sheet3['X2'] = Pt_list[i]["性別"]
    sheet3['G4'] = Pt_list[i]["診断名"]
    sheet3['AO4'] = Pt_list[i]["初診日"]
    sheet3['AO5'] = Pt_list[i]["発症日"]
    sheet3['AO8'] = Pt_list[i]["リハ開始日"]
    sheet3['AI2'] = Pt_list[i]["生年月日"]
    sheet3['U8'] = Pt_list[i]["その他合併症"]
    
    #リハ内容・筋力低下1
    if '股' in Pt_list[i]["診断名"] or '臼蓋' in Pt_list[i]["診断名"] or '鼡' in Pt_list[i]["診断名"] or '内転筋' in Pt_list[i]["診断名"] or '膝' in Pt_list[i]["診断名"] or '足' in Pt_list[i]["診断名"] or '腸脛' in Pt_list[i]["診断名"] or '腿' in Pt_list[i]["診断名"] or '趾' in Pt_list[i]["診断名"] or 'ヒラメ' in Pt_list[i]["診断名"] or 'アキレス' in Pt_list[i]["診断名"] or '前腸骨棘' in Pt_list[i]["診断名"] or '回内' in Pt_list[i]["診断名"] or '脛骨' in Pt_list[i]["診断名"] or '腓骨' in Pt_list[i]["診断名"] or 'ハムストリング' in Pt_list[i]["診断名"] or '広筋' in Pt_list[i]["診断名"] or '腓腹' in Pt_list[i]["診断名"]:
        reha_check = 'kasi'
    elif '肩' in Pt_list[i]["診断名"] or '胸郭出口' in Pt_list[i]["診断名"] or '棘上' in Pt_list[i]["診断名"] or '棘下' in Pt_list[i]["診断名"] or '肘' in Pt_list[i]["診断名"] or '手指' in Pt_list[i]["診断名"] or '手' in Pt_list[i]["診断名"] or '上腕' in Pt_list[i]["診断名"] or '橈' in Pt_list[i]["診断名"] or '尺' in Pt_list[i]["診断名"] or '広背筋' in Pt_list[i]["診断名"] or '僧帽筋' in Pt_list[i]["診断名"] or '菱' in Pt_list[i]["診断名"] or '有鉤' in Pt_list[i]["診断名"] or '有頭' in Pt_list[i]["診断名"] or '月状' in Pt_list[i]["診断名"]:
        reha_check = 'jousi'
    elif '腰' in Pt_list[i]["診断名"] or '胸椎' in Pt_list[i]["診断名"] or '殿部' in Pt_list[i]["診断名"] or '臀部' in Pt_list[i]["診断名"]:
        reha_check = 'kasi_taikan'
    else:
        reha_check = 'taikan'

    reha_check2 = '無し'
    if Pt_list[i]["運動合併症"] == None:
        pass
    else:
        #リハ内容・筋力低下2
        if '股' in Pt_list[i]["運動合併症"] or '臼蓋' in Pt_list[i]["運動合併症"] or '鼡' in Pt_list[i]["運動合併症"] or '内転筋' in Pt_list[i]["運動合併症"] or '膝' in Pt_list[i]["運動合併症"] or '足' in Pt_list[i]["運動合併症"] or '腸脛' in Pt_list[i]["運動合併症"] or '腿' in Pt_list[i]["運動合併症"] or '趾' in Pt_list[i]["運動合併症"] or 'ヒラメ' in Pt_list[i]["運動合併症"] or 'アキレス' in Pt_list[i]["運動合併症"] or '前腸骨棘' in Pt_list[i]["運動合併症"] or '回内' in Pt_list[i]["運動合併症"] or '脛骨' in Pt_list[i]["運動合併症"] or '腓骨' in Pt_list[i]["運動合併症"] or 'ハムストリング' in Pt_list[i]["運動合併症"] or '広筋' in Pt_list[i]["運動合併症"] or '腓腹' in Pt_list[i]["運動合併症"]:
            reha_check2 = 'kasi'
        elif '肩' in Pt_list[i]["運動合併症"] or '胸郭出口' in Pt_list[i]["運動合併症"] or '棘上' in Pt_list[i]["運動合併症"] or '棘下' in Pt_list[i]["運動合併症"] or '肘' in Pt_list[i]["運動合併症"] or '手指' in Pt_list[i]["運動合併症"] or '手' in Pt_list[i]["運動合併症"] or '上腕' in Pt_list[i]["運動合併症"] or '橈' in Pt_list[i]["運動合併症"] or '尺' in Pt_list[i]["運動合併症"] or '広背筋' in Pt_list[i]["運動合併症"] or '僧帽筋' in Pt_list[i]["運動合併症"] or '菱' in Pt_list[i]["運動合併症"] or '有鉤' in Pt_list[i]["運動合併症"] or '有頭' in Pt_list[i]["運動合併症"] or '月状' in Pt_list[i]["運動合併症"]:
            reha_check2 = 'jousi'
        elif '腰' in Pt_list[i]["運動合併症"] or '胸椎' in Pt_list[i]["運動合併症"] or '殿部' in Pt_list[i]["運動合併症"] or '臀部' in Pt_list[i]["運動合併症"]:
            reha_check2 = 'kasi_taikan'
        else:
            reha_check2 = 'taikan'

        #入力 
        sheet3['K8'] = Pt_list[i]["運動合併症"]
            
        #関節可動域制限2
        if '股' in Pt_list[i]["運動合併症"] or '臼蓋' in Pt_list[i]["運動合併症"] or '鼡' in Pt_list[i]["運動合併症"] or 'ハムストリング' in Pt_list[i]["運動合併症"] or '内転筋' in Pt_list[i]["運動合併症"] or '前腸骨棘' in Pt_list[i]["運動合併症"] or '殿' in Pt_list[i]["運動合併症"] or '臀' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '股関節'
        elif '膝' in Pt_list[i]["運動合併症"] or '広筋' in Pt_list[i]["運動合併症"] or '脛骨高原' in Pt_list[i]["運動合併症"] or '腸脛' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '膝関節'
        elif '足' in Pt_list[i]["運動合併症"] or 'アキレス' in Pt_list[i]["運動合併症"] or 'ヒラメ' in Pt_list[i]["運動合併症"] or 'シンスプリント' in Pt_list[i]["運動合併症"] or '腓骨' in Pt_list[i]["運動合併症"] or '脛骨' in Pt_list[i]["運動合併症"] or '回内' in Pt_list[i]["運動合併症"] or '腓腹' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '足関節'
        elif '腿' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '膝関節・股関節'
        elif '趾' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '足趾'
        elif '肩' in Pt_list[i]["運動合併症"] or '棘上' in Pt_list[i]["運動合併症"] or '棘下' in Pt_list[i]["運動合併症"] or '広背筋' in Pt_list[i]["運動合併症"] or '菱形筋' in Pt_list[i]["運動合併症"] or '胸郭出口' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '肩関節'
        elif '僧帽筋' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '肩甲帯'
        elif '肘' in Pt_list[i]["運動合併症"] or '上腕' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '肘関節'
        elif '手' in Pt_list[i]["運動合併症"] or '橈' in Pt_list[i]["運動合併症"] or '尺' in Pt_list[i]["運動合併症"] or '有鉤' in Pt_list[i]["運動合併症"] or '有頭' in Pt_list[i]["運動合併症"] or '月状' in Pt_list[i]["運動合併症"] or '菱形骨' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '手関節'
        elif '手指' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '手指'
        elif '胸椎' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '胸腰部'
        elif '腰' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '腰部'
        elif '頚' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '頚部'
        elif '頸' in Pt_list[i]["運動合併症"]:
            sheet3['AG12'] = '頸部'
        else:
            sheet3['AG12'] = ' '

        #疼痛部位2
        if '右' in Pt_list[i]["運動合併症"]:
            sheet3['AS11'] = '右'
        elif '左' in Pt_list[i]["運動合併症"]:
            sheet3['AS11'] = '左'
        elif '両' in Pt_list[i]["運動合併症"]:
            sheet3['AS11'] = '右・左'
        else:
            sheet3['AS11'] = '　'

        #疼痛部位2
        if '股' in Pt_list[i]["運動合併症"] or '臼蓋' in Pt_list[i]["運動合併症"] or '鼡' in Pt_list[i]["運動合併症"] or '前腸骨棘' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '股関節'
        elif '膝' in Pt_list[i]["運動合併症"] or '脛骨高原' in Pt_list[i]["運動合併症"] or '腸脛' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '膝関節'
        elif '広筋' in Pt_list[i]["運動合併症"] or  'ハムストリング' in Pt_list[i]["運動合併症"] or  '大腿' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '大腿'
        elif '足関節' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '足関節'
        elif '趾' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '足趾'
        elif '足底' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '足底'
        elif 'ヒラメ' in Pt_list[i]["運動合併症"] or '下腿' in Pt_list[i]["運動合併症"] or '腓腹' in Pt_list[i]["運動合併症"] or '脛骨' in Pt_list[i]["運動合併症"] or '腓骨' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '下腿'
        elif 'アキレス' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = 'アキレス腱'
        elif '肩' in Pt_list[i]["運動合併症"] or '棘上' in Pt_list[i]["運動合併症"] or '棘下' in Pt_list[i]["運動合併症"] :
            sheet3['AW11'] = '肩関節'
        elif '肘' in Pt_list[i]["運動合併症"] or '上腕骨' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '肘関節'
        elif '上腕三頭筋' in Pt_list[i]["運動合併症"] or '上腕二頭筋' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '上腕'
        elif '胸郭出口' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '上肢'
        elif '広背筋' in Pt_list[i]["運動合併症"] or '菱形筋' in Pt_list[i]["運動合併症"] or '僧帽筋' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '背中'
        elif '手' in Pt_list[i]["運動合併症"] or '橈' in Pt_list[i]["運動合併症"] or '尺' in Pt_list[i]["運動合併症"] or '有鉤' in Pt_list[i]["運動合併症"] or '有頭' in Pt_list[i]["運動合併症"] or '月状' in Pt_list[i]["運動合併症"] or '菱形骨' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '手関節'
        elif '指' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '手指'
        elif '腰' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '腰部'
        elif '頚' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '頚部'
        elif '頸' in Pt_list[i]["運動合併症"]:
            sheet3['AW11'] = '頸部'
        else:
            sheet3['AW11'] = ' '

    if reha_check == 'kasi' and reha_check2 == 'kasi':
        sheet3['B53'] = '下肢'
        sheet3['B59'] = '下肢'
        sheet3['AC59'] = '下肢'
        sheet3['I13'] = '下肢'
    elif reha_check == 'kasi' and reha_check2 == 'jousi':
        sheet3['B53'] = '下肢、上肢'
        sheet3['B59'] = '下肢、上肢'
        sheet3['AC59'] = '下肢、上肢'
        sheet3['I13'] = '下肢、上肢'
    elif reha_check == 'kasi' and reha_check2 == 'kasi_taikan':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'kasi' and reha_check2 == 'taikan':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'jousi' and reha_check2 == 'kasi':
        sheet3['B53'] = '上肢、下肢'
        sheet3['B59'] = '上肢、下肢'
        sheet3['AC59'] = '上肢、下肢'
        sheet3['I13'] = '上肢、下肢'
    elif reha_check == 'jousi' and reha_check2 == 'jousi':
        sheet3['B53'] = '上肢'
        sheet3['B59'] = '上肢'
        sheet3['AC59'] = '上肢'
        sheet3['I13'] = '上肢'
    elif reha_check == 'jousi' and reha_check2 == 'kasi_taikan':
        sheet3['B53'] = '上肢、下肢、体幹'
        sheet3['B59'] = '上肢、下肢、体幹'
        sheet3['AC59'] = '上肢、下肢、体幹'
        sheet3['I13'] = '上肢、下肢、体幹'
    elif reha_check == 'jousi' and reha_check2 == 'taikan':
        sheet3['B53'] = '上肢、体幹'
        sheet3['B59'] = '上肢、体幹'
        sheet3['AC59'] = '上肢、体幹'
        sheet3['I13'] = '上肢、体幹'
    elif reha_check == 'kasi_taikan' and reha_check2 == 'kasi':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'kasi_taikan' and reha_check2 == 'jousi':
        sheet3['B53'] = '下肢、体幹、上肢'
        sheet3['B59'] = '下肢、体幹、上肢'
        sheet3['AC59'] = '下肢、体幹、上肢'
        sheet3['I13'] = '下肢、体幹、上肢'
    elif reha_check == 'kasi_taikan' and reha_check2 == 'kasi_taikan':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'kasi_taikan' and reha_check2 == 'taikan':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'taikan' and reha_check2 == 'kasi':
        sheet3['B53'] = '体幹、下肢'
        sheet3['B59'] = '体幹、下肢'
        sheet3['AC59'] = '体幹、下肢'
        sheet3['I13'] = '体幹、下肢'
    elif reha_check == 'taikan' and reha_check2 == 'jousi':
        sheet3['B53'] = '体幹、上肢'
        sheet3['B59'] = '体幹、上肢'
        sheet3['AC59'] = '体幹、上肢'
        sheet3['I13'] = '体幹、上肢'
    elif reha_check == 'taikan' and reha_check2 == 'kasi_taikan' :
        sheet3['B53'] = '体幹、下肢'
        sheet3['B59'] = '体幹、下肢'
        sheet3['AC59'] = '体幹、下肢'
        sheet3['I13'] = '体幹、下肢'
    elif reha_check == 'taikan' and reha_check2 == 'taikan' :
        sheet3['B53'] = '体幹'
        sheet3['B59'] = '体幹'
        sheet3['AC59'] = '体幹'
        sheet3['I13'] = '体幹'
    elif reha_check == 'kasi' and reha_check2 == '無し':
        sheet3['B53'] = '下肢'
        sheet3['B59'] = '下肢'
        sheet3['AC59'] = '下肢'
        sheet3['I13'] = '下肢'
    elif reha_check == 'jousi' and reha_check2 == '無し':
        sheet3['B53'] = '上肢'
        sheet3['B59'] = '上肢'
        sheet3['AC59'] = '上肢'
        sheet3['I13'] = '上肢'
    elif reha_check == 'kasi_taikan' and reha_check2 == '無し':
        sheet3['B53'] = '下肢、体幹'
        sheet3['B59'] = '下肢、体幹'
        sheet3['AC59'] = '下肢、体幹'
        sheet3['I13'] = '下肢、体幹'
    elif reha_check == 'taikan' and reha_check2 == '無し':
        sheet3['B53'] = '体幹'
        sheet3['B59'] = '体幹'
        sheet3['AC59'] = '体幹'
        sheet3['I13'] = '体幹'
    else:
        sheet3['B53'] = ' '
        sheet3['B59'] = ' '
        sheet3['AC59'] = ' '
        sheet3['I13'] = ' '

    #関節可動域制限1
    if '股' in Pt_list[i]["診断名"] or '臼蓋' in Pt_list[i]["診断名"] or '鼡' in Pt_list[i]["診断名"]  or 'ハムストリング' in Pt_list[i]["診断名"] or '内転筋' in Pt_list[i]['診断名'] or '前腸骨棘' in Pt_list[i]["診断名"] or '殿' in Pt_list[i]["診断名"] or '臀' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '股関節'
    elif '膝' in Pt_list[i]["診断名"] or '広筋' in Pt_list[i]["診断名"] or '脛骨高原' in Pt_list[i]["診断名"] or '腸脛' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '膝関節'
    elif '足' in Pt_list[i]["診断名"] or 'アキレス' in Pt_list[i]["診断名"] or 'ヒラメ' in Pt_list[i]["診断名"] or 'シンスプリント' in Pt_list[i]["診断名"] or '腓骨' in Pt_list[i]["診断名"] or '脛骨' in Pt_list[i]["診断名"] or '足底' in Pt_list[i]["診断名"] or '回内' in Pt_list[i]["診断名"] or '腓腹' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '足関節'
    elif '腿' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '膝関節・股関節'
    elif '鼡' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '股関節'
    elif '趾' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '足趾'
    elif '肩' in Pt_list[i]["診断名"] or '棘上' in Pt_list[i]["診断名"] or '棘下' in Pt_list[i]["診断名"] or '広背筋' in Pt_list[i]["診断名"] or '菱形筋' in Pt_list[i]["診断名"] or '胸郭出口' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '肩関節'
    elif '僧帽筋' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '肩甲帯'
    elif '肘' in Pt_list[i]["診断名"] or '上腕' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '肘関節'
    elif '手' in Pt_list[i]["診断名"] or '橈' in Pt_list[i]["診断名"] or '尺' in Pt_list[i]["診断名"] or '有鉤' in Pt_list[i]["診断名"] or '有頭' in Pt_list[i]["診断名"] or '月状' in Pt_list[i]["診断名"] or '菱形骨' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '手関節'
    elif '手指'in Pt_list[i]["診断名"]:
        sheet3['I12'] = '手指'
    elif '胸椎'in Pt_list[i]["診断名"]:
        sheet3['I12'] = '胸腰部'
    elif '腰' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '腰部'
    elif '頸' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '頸部'
    elif '頚' in Pt_list[i]["診断名"]:
        sheet3['I12'] = '頚部'
    else:
        sheet3['I12'] = ' '
       
    #疼痛部位1
    if '右' in Pt_list[i]["診断名"]:
        sheet3['X11'] = '右'
    elif '左' in Pt_list[i]["診断名"]:
        sheet3['X11'] = '左'
    elif '両' in Pt_list[i]["診断名"]:
        sheet3['X11'] = '右・左'
    else:
        sheet3['X11'] = '　'

    #疼痛部位1
    if '股' in Pt_list[i]["診断名"] or '臼蓋' in Pt_list[i]["診断名"] or '鼡' in Pt_list[i]["診断名"] or '前腸骨棘' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '股関節'
    elif '膝' in Pt_list[i]["診断名"] or '脛骨高原' in Pt_list[i]["診断名"] or '腸脛' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '膝関節'
    elif '広筋' in Pt_list[i]["診断名"] or 'ハムストリング' in Pt_list[i]["診断名"] or '大腿' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '大腿'
    elif '足関節' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '足関節'
    elif '趾' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '足趾'
    elif 'ヒラメ' in Pt_list[i]["診断名"] or '下腿' in Pt_list[i]["診断名"] or '腓腹' in Pt_list[i]["診断名"] or '脛骨' in Pt_list[i]["診断名"] or '腓骨' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '下腿'
    elif 'アキレス' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = 'アキレス腱'
    elif '足底' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '足底'
    elif '肩' in Pt_list[i]["診断名"] or '棘上' in Pt_list[i]["診断名"] or '棘下' in Pt_list[i]["診断名"] :
        sheet3['AB11'] = '肩関節'
    elif '肘' in Pt_list[i]["診断名"] or '上腕骨' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '肘関節'
    elif '上腕三頭筋' in Pt_list[i]["診断名"] or '上腕二頭筋' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '上腕'
    elif '胸郭出口' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '上肢'
    elif '広背筋' in Pt_list[i]["診断名"] or '菱形筋' in Pt_list[i]["診断名"] or '僧帽筋' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '背中'
    elif '手' in Pt_list[i]["診断名"] or '橈' in Pt_list[i]["診断名"] or '尺' in Pt_list[i]["診断名"] or '有鉤' in Pt_list[i]["診断名"] or '有頭' in Pt_list[i]["診断名"] or '月状' in Pt_list[i]["診断名"] or '菱形骨' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '手関節'
    elif '指' in Pt_list[i]["診断名"]:
        
        sheet3['AB11'] = '手指'
    elif '胸椎' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '胸腰部'
    elif '腰' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '腰部'
    elif '頚' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '頚部'
    elif '頸部' in Pt_list[i]["診断名"]:
        sheet3['AB11'] = '頸部'
    else:
        sheet3['AB11'] = ' ' 
    sheet3.title = str(Pt_list[i]["カルテNo"])
    wb.save(str(Pt_list[i]["カルテNo"]) + '.xlsx')

print('総合：Complete')