#V7给药开始日期-V6给药开始日期=7±3天,17行更改要核查的周期,44行修改对应的窗口期时间。
import openpyxl
wb=openpyxl.load_workbook(r'C:\Users\s\.spyder-py3\TE0.xlsx')
ws=wb['EX_给药记录']
rows=ws.rows
a1=[] #存储‘给药记录’中受试者编号列
a2=[] #存储‘给药记录’中访视列
b1=[] #存储‘给药记录'给药开始时间列
d31=['01','03','05','07','08','10','12']
d30=['04','06','09','11']
for row in rows:
a1.append(row[3].value)
a2.append(row[4].value)
b1.append(row[8].value)
for i in range (len(a1)-1):
m=i+1
if a1[i]==a1[m] and a2[i]=='V9第9周期(第1天)' and a2[m]=='V11第11周期(第1天)': #此处更改核查周期
first_d=b1[i]
second_d=b1[m]
if len(first_d)==0 or len(second_d)==0:
first_d='0-0-0'
second_d='0-0-0'
date1=first_d.split('-')
date2=second_d.split('-')
y1=date1[0]
m1=date1[1]
d1=date1[2]
y2=date2[0]
m2=date2[1]
d2=date2[2]
result=0
if y1==y2 and m1 in d31:
result=(int(m2)-int(m1))*31+int(d2)-int(d1)
if y1==y2 and m1=='02':
result=(int(m2)-int(m1))*29+int(d2)-int(d1)
if y1==y2 and m1 in d30:
result=(int(m2)-int(m1))*30+int(d2)-int(d1)
if y1!=y2 and m1 in d31:
result=31+int(d2)-int(d1)
if y1!=y2 and m1=='02':
result=31+int(d2)-int(d1)
if y1!=y2 and m1 in d30:
result=31+int(d2)-int(d1)
if result<11 or result >17: #此处更改时间窗
print (a1[i+1])
print (a2[i+1])
print (result) #输出超窗信息
#result=0,是两个日期有一个为空的情况
python用于临床数据管理_超窗判断
于 2021-05-07 09:50:17 首次发布