@@ -34,3 +34,35 @@ def _validate_clinical_impression_fields(
34
34
if auto_validated :
35
35
result ["auto_validated" ] = True
36
36
return result
37
+
38
+ def action_create_clinical_impression_report (self ):
39
+ self .mapped ("patient_id" ).ensure_one ()
40
+ self .mapped ("specialty_id" ).ensure_one ()
41
+ report = self .env ["medical.diagnostic.report" ].create (
42
+ self ._create_diagnostic_report_vals ()
43
+ )
44
+ return report .get_formview_action ()
45
+
46
+ def _create_diagnostic_report_vals (self ):
47
+ encounter = self [0 ].encounter_id
48
+ return {
49
+ "encounter_id" : encounter .id ,
50
+ "patient_name" : encounter .patient_id .name ,
51
+ "vat" : encounter .patient_id .vat ,
52
+ "patient_age" : self .env [
53
+ "medical.diagnostic.report.template"
54
+ ]._compute_age (encounter .patient_id ),
55
+ "composition" : self ._get_report_composition (),
56
+ "name" : self [0 ].specialty_id .name ,
57
+ "lang" : self .env .context .get ("lang" ) or self .env .user .lang ,
58
+ "item_blocked" : False ,
59
+ "with_conclusion" : False ,
60
+ "with_observation" : False ,
61
+ "with_composition" : True ,
62
+ }
63
+
64
+ def _get_report_composition (self ):
65
+ return self .env ["ir.qweb" ]._render (
66
+ "cb_medical_clinical_impression.impression_to_diagnostic_report" ,
67
+ {"impressions" : self },
68
+ )
0 commit comments