跳至内容
菜单
此问题已终结
1761 查看

I have a list of vaccines e.g Covid, Cholera, etc, the patient's name, and the dose. A patient can have Cholera dose 1,2,3 now and in future dose 1,2.

Now, how can I show just the first name (John) of the patient in a given vaccine using python?

This is the data I have:

Vaccine      patient_name     dose

Cholera      John             1
             John             2
             John             3
             John             1
             John             2

Covid        John             1
             John             2
             John             2

Here's my Code. Any assistance will be greatly appreciated.

@api.multi
def print_report(self):
   data = {
       'sizes': [],
     }

p_list = self.env['med.vaccines'].search([])
patient_list = []
for i in p_list:
     if i.vaccine not in patient_list and i.patient not in patient_list:
        data['sizes'].append({
            'patient': i.patient,
            'vaccine': i.vaccine,
             'dose': i.dose                                
             })
             patient_list.append(i.vaccine and i.patient)
      else:
           data['sizes'].append({
              'patient': '',
               'vaccine': '',
               'dose': '', 
       })   
    return self.env.ref('med_vaccines.report_patient').report_action(self, data=data)


形象
丢弃
相关帖文 回复 查看 活动
5
10月 24
32542
1
7月 23
7204
2
7月 22
11427
2
10月 21
3226
0
8月 21
1987