multi dpt
							parent
							
								
									df6c188c32
								
							
						
					
					
						commit
						e177f2744f
					
				| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					<record model="action">
 | 
				
			||||||
 | 
					    <field name="name">clinic_matching_payment</field>
 | 
				
			||||||
 | 
					    <field name="view">form_view</field>
 | 
				
			||||||
 | 
					    <field name="model">clinic.matching.payment</field>
 | 
				
			||||||
 | 
					    <field name="view_xml">clinic_matching_payment</field>
 | 
				
			||||||
 | 
					    <field name="menu">account_menu</field>
 | 
				
			||||||
 | 
					</record>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
    <group from_layout="stacked">
 | 
					    <group from_layout="stacked">
 | 
				
			||||||
        <field name="cycle_id" span="3" required="1"/>
 | 
					        <field name="cycle_id" span="3" required="1"/>
 | 
				
			||||||
        <field name="date" span="3" required="1"/>
 | 
					        <field name="date" span="3" required="1"/>
 | 
				
			||||||
 | 
					        <field name="department_id" span="3" required="1"/>
 | 
				
			||||||
        <field name="branch_id" span="3" required="1"/>
 | 
					        <field name="branch_id" span="3" required="1"/>
 | 
				
			||||||
        <field name="company_id" invisible="1"/>
 | 
					        <field name="company_id" invisible="1"/>
 | 
				
			||||||
    </group>
 | 
					    </group>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","validated"]]}'>
 | 
					<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","validated"]]}'>
 | 
				
			||||||
    <field name="cycle_id"/>
 | 
					    <field name="cycle_id"/>
 | 
				
			||||||
    <field name="date"/>
 | 
					    <field name="date"/>
 | 
				
			||||||
 | 
					    <field name="department_id"/>
 | 
				
			||||||
    <field name="branch_id"/>
 | 
					    <field name="branch_id"/>
 | 
				
			||||||
    <field name="state"/>
 | 
					    <field name="state"/>
 | 
				
			||||||
</list>
 | 
					</list>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					<form model="clinic.matching.payment" title="Matching Payment">
 | 
				
			||||||
 | 
					    <separator string="1. Click Match > 2. Review Items > 3. Import Payment"/>
 | 
				
			||||||
 | 
					    <group form_layout="stacked">
 | 
				
			||||||
 | 
					        <field name="file" span="3"/>
 | 
				
			||||||
 | 
					        <field name="patient_type_id" span="3"/>
 | 
				
			||||||
 | 
					        <field name="hcode_id" span="3"/>
 | 
				
			||||||
 | 
					    </group>
 | 
				
			||||||
 | 
					    <foot replace="1">
 | 
				
			||||||
 | 
					        <button string="Match" method="match" icon="ok" type="success"/>
 | 
				
			||||||
 | 
					        <button string="Import Payment" method="pay" icon="arrow-right" type="default"/>
 | 
				
			||||||
 | 
					    </foot>
 | 
				
			||||||
 | 
					    <related>
 | 
				
			||||||
 | 
					        <field name="expenes"/>
 | 
				
			||||||
 | 
					    </related>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,8 @@
 | 
				
			||||||
            <item string="Labor Cost" action="clinic_labor_cost"/>
 | 
					            <item string="Labor Cost" action="clinic_labor_cost"/>
 | 
				
			||||||
            <item string="Labor Cost Items" action="clinic_labor_cost_item"/>
 | 
					            <item string="Labor Cost Items" action="clinic_labor_cost_item"/>
 | 
				
			||||||
            <item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
 | 
					            <item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
 | 
				
			||||||
            <item string="Matching Invoices" action="clinic_report_payment_matching"/>
 | 
					            <!--<item string="Matching Invoices" action="clinic_report_payment_matching"/>-->
 | 
				
			||||||
 | 
					            <item string="Matching Payment" action="clinic_matching_payment"/>
 | 
				
			||||||
            <item string="HD Case Expenses" action="clinic_hd_case_expense"/>
 | 
					            <item string="HD Case Expenses" action="clinic_hd_case_expense"/>
 | 
				
			||||||
            <divider/>
 | 
					            <divider/>
 | 
				
			||||||
            <header string="REPORTS"/>
 | 
					            <header string="REPORTS"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,10 +2,11 @@
 | 
				
			||||||
    <field name="file" span="4" required="1"/>
 | 
					    <field name="file" span="4" required="1"/>
 | 
				
			||||||
    <field name="type_id" onchange="onchange_type" span="3"/>
 | 
					    <field name="type_id" onchange="onchange_type" span="3"/>
 | 
				
			||||||
    <field name="hcode_id" span="3" attrs='{"invisible":[["show_hcode","=",0]]}'/>
 | 
					    <field name="hcode_id" span="3" attrs='{"invisible":[["show_hcode","=",0]]}'/>
 | 
				
			||||||
    <newline/>
 | 
					 | 
				
			||||||
    <group span="6" columns="1">
 | 
					 | 
				
			||||||
        <button string='Match' span="2" type="success" size="small" icon="ok" method="match_invoice"/>
 | 
					 | 
				
			||||||
        <button string='Make A Payment' method="make_payment" span="2" type="default" size="small" icon="arrow-right"/>
 | 
					 | 
				
			||||||
    </group>
 | 
					 | 
				
			||||||
    <field name="show_hcode" invisible="1" span="3"/>
 | 
					    <field name="show_hcode" invisible="1" span="3"/>
 | 
				
			||||||
 | 
					    <group span="6" columns="1">
 | 
				
			||||||
 | 
					        <button string='Match' type="success" icon="ok" method="match_invoice"/>
 | 
				
			||||||
 | 
					        <button string='Make A Payment' method="make_payment" type="default" icon="arrow-right"/>
 | 
				
			||||||
 | 
					    </group>
 | 
				
			||||||
 | 
					    <group span="6" columns="1">
 | 
				
			||||||
 | 
					    </group>
 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,8 @@
 | 
				
			||||||
                </field>
 | 
					                </field>
 | 
				
			||||||
           </group>
 | 
					           </group>
 | 
				
			||||||
        </tab>
 | 
					        </tab>
 | 
				
			||||||
        <tab string="Testing">
 | 
					        <tab string="Development">
 | 
				
			||||||
 | 
					            <!--<field name='branch_id'/>-->
 | 
				
			||||||
            <button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
 | 
					            <button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
 | 
				
			||||||
        </tab>
 | 
					        </tab>
 | 
				
			||||||
    </tabs>
 | 
					    </tabs>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,8 +8,9 @@
 | 
				
			||||||
    <field name="name"/>
 | 
					    <field name="name"/>
 | 
				
			||||||
    <field name="available"/>
 | 
					    <field name="available"/>
 | 
				
			||||||
    <field name="sequence"/>
 | 
					    <field name="sequence"/>
 | 
				
			||||||
    <field name="branch_id" invisible="1"/>
 | 
					    <field name="department_id"/>
 | 
				
			||||||
    <field name="note"/>
 | 
					    <field name="note"/>
 | 
				
			||||||
 | 
					    <field name="branch_id" invisible="1"/>
 | 
				
			||||||
    <field name="company_id" invisible="1"/>
 | 
					    <field name="company_id" invisible="1"/>
 | 
				
			||||||
    <related>
 | 
					    <related>
 | 
				
			||||||
        <field name="hd_cases"/>
 | 
					        <field name="hd_cases"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
    <field name="date"/>
 | 
					    <field name="date"/>
 | 
				
			||||||
    <field name="patient_id"/>
 | 
					    <field name="patient_id"/>
 | 
				
			||||||
    <field name="image" preview="1"/>
 | 
					    <field name="image" preview="1"/>
 | 
				
			||||||
 | 
					    <field name="department_id"/>
 | 
				
			||||||
    <field name="branch_id"/>
 | 
					    <field name="branch_id"/>
 | 
				
			||||||
    <field name="note"/>
 | 
					    <field name="note"/>
 | 
				
			||||||
    <field name="state"/>
 | 
					    <field name="state"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,3 +89,4 @@ from . import product_categ
 | 
				
			||||||
from . import import_uc
 | 
					from . import import_uc
 | 
				
			||||||
from . import make_apt
 | 
					from . import make_apt
 | 
				
			||||||
from . import make_apt_line
 | 
					from . import make_apt_line
 | 
				
			||||||
 | 
					from . import matching_payment
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,7 @@ class CycleItem(Model):
 | 
				
			||||||
        "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
 | 
					        "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
 | 
				
			||||||
        'company_id': fields.Many2One("company", "Company"),
 | 
					        'company_id': fields.Many2One("company", "Company"),
 | 
				
			||||||
        'branch_id': fields.Many2One("clinic.branch", "Branch"),
 | 
					        'branch_id': fields.Many2One("clinic.branch", "Branch"),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department", "Department"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def _get_vark(self,context={}):
 | 
					    def _get_vark(self,context={}):
 | 
				
			||||||
| 
						 | 
					@ -50,6 +51,11 @@ class CycleItem(Model):
 | 
				
			||||||
        if b_ids:
 | 
					        if b_ids:
 | 
				
			||||||
            return b_ids[0]
 | 
					            return b_ids[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_department(self,context={}):
 | 
				
			||||||
 | 
					        dpt_ids=get_model('clinic.department').search([])
 | 
				
			||||||
 | 
					        if dpt_ids:
 | 
				
			||||||
 | 
					            return dpt_ids[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    _defaults={
 | 
				
			||||||
        'state': 'draft',
 | 
					        'state': 'draft',
 | 
				
			||||||
        'company_id': lambda *a: get_active_company(),
 | 
					        'company_id': lambda *a: get_active_company(),
 | 
				
			||||||
| 
						 | 
					@ -57,11 +63,12 @@ class CycleItem(Model):
 | 
				
			||||||
        'user_id': lambda *a: get_active_user(),
 | 
					        'user_id': lambda *a: get_active_user(),
 | 
				
			||||||
        'var_k': _get_vark,
 | 
					        'var_k': _get_vark,
 | 
				
			||||||
        'branch_id': _get_branch,
 | 
					        'branch_id': _get_branch,
 | 
				
			||||||
 | 
					        'department_id': _get_department,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _order="date desc"
 | 
					    _order="date desc"
 | 
				
			||||||
    _sql_constraints=[
 | 
					    _sql_constraints=[
 | 
				
			||||||
        ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id)","Cycle item should be unique"),
 | 
					        ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id,department_id)","Cycle item should be unique"),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def get_cycle_daily(self,date):
 | 
					    def get_cycle_daily(self,date):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -507,6 +507,7 @@ class HDCase(Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pick_vals={
 | 
					        pick_vals={
 | 
				
			||||||
            "type": "out",
 | 
					            "type": "out",
 | 
				
			||||||
 | 
					            'journal_id': stock_journal.id,
 | 
				
			||||||
            "ref": obj.number,
 | 
					            "ref": obj.number,
 | 
				
			||||||
            "related_id": "clinic.hd.case,%s"%obj.id,
 | 
					            "related_id": "clinic.hd.case,%s"%obj.id,
 | 
				
			||||||
            "partner_id": obj.patient_id.partner_id.id,
 | 
					            "partner_id": obj.patient_id.partner_id.id,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					from netforce.model import Model, fields, get_model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MatchingPayment(Model):
 | 
				
			||||||
 | 
					    _name="clinic.matching.payment"
 | 
				
			||||||
 | 
					    _transient=True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        'file': fields.File("File"),
 | 
				
			||||||
 | 
					        'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
 | 
				
			||||||
 | 
					        'hcode_id': fields.Many2One("clinic.hospital","HCode",required=True),
 | 
				
			||||||
 | 
					        'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    def _get_ptype(self,context={}):
 | 
				
			||||||
 | 
					        tids=get_model('clinic.patient.type').search([['default','=',True]])
 | 
				
			||||||
 | 
					        tid=None
 | 
				
			||||||
 | 
					        if tids:
 | 
				
			||||||
 | 
					            tid=tids[0]
 | 
				
			||||||
 | 
					        return tid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _defaults={
 | 
				
			||||||
 | 
					        'patient_type_id': _get_ptype,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def match(self,ids,context={}):
 | 
				
			||||||
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
 | 
					        for exp in obj.expenes:
 | 
				
			||||||
 | 
					            exp.delete()
 | 
				
			||||||
 | 
					        exp_ids=[]
 | 
				
			||||||
 | 
					        for exp in get_model('clinic.hd.case.expense').search_browse([]):
 | 
				
			||||||
 | 
					            exp_ids.append(exp.id)
 | 
				
			||||||
 | 
					        #TODO Checking
 | 
				
			||||||
 | 
					        obj.write({
 | 
				
			||||||
 | 
					            'expenes': [('add',exp_ids)]
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            'next': {
 | 
				
			||||||
 | 
					                'name': 'clinic_matching_payment',
 | 
				
			||||||
 | 
					                'mode': 'form',
 | 
				
			||||||
 | 
					                'active_id': obj.id,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'flash': 'Succesfully',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MatchingPayment.register()
 | 
				
			||||||
| 
						 | 
					@ -45,6 +45,7 @@ class Schedule(Model):
 | 
				
			||||||
        'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
 | 
					        'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
 | 
				
			||||||
        'company_id': fields.Many2One("company","Company"),
 | 
					        'company_id': fields.Many2One("company","Company"),
 | 
				
			||||||
        'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department","Department",required=True, search=True),
 | 
				
			||||||
        'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
 | 
					        'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
 | 
				
			||||||
        'user_id': fields.Many2One("base.user","Confirm By"),
 | 
					        'user_id': fields.Many2One("base.user","Confirm By"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -71,7 +72,7 @@ class Schedule(Model):
 | 
				
			||||||
    _order="date desc"
 | 
					    _order="date desc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _sql_constraints=[
 | 
					    _sql_constraints=[
 | 
				
			||||||
        ('schedule_uniq','unique (date,company_id,branch_id)','Date should be unique'),
 | 
					        ('schedule_uniq','unique (date,company_id,branch_id,department_id)','Date should be unique'),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def confirm(self,ids,context={}):
 | 
					    def confirm(self,ids,context={}):
 | 
				
			||||||
| 
						 | 
					@ -132,13 +133,21 @@ class Schedule(Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def copy2cycle_item(self,ids,context={}):
 | 
					    def copy2cycle_item(self,ids,context={}):
 | 
				
			||||||
        obj=self.browse(ids)[0]
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
 | 
					        branch=obj.branch_id
 | 
				
			||||||
 | 
					        department=obj.department_id
 | 
				
			||||||
        date=obj.date
 | 
					        date=obj.date
 | 
				
			||||||
        items={}
 | 
					        items={}
 | 
				
			||||||
        cycles=set()
 | 
					        cycles=set()
 | 
				
			||||||
        for line in obj.lines:
 | 
					        for line in obj.lines:
 | 
				
			||||||
            nurse=line.nurse_id
 | 
					            nurse=line.nurse_id
 | 
				
			||||||
            cycle=line.cycle_id
 | 
					            cycle=line.cycle_id
 | 
				
			||||||
            item_objs=get_model("clinic.cycle.item").search_browse([['date','=',date],['cycle_id','=',cycle.id]])
 | 
					            dom=[
 | 
				
			||||||
 | 
					                ['date','=',date],
 | 
				
			||||||
 | 
					                ['cycle_id','=',cycle.id],
 | 
				
			||||||
 | 
					                ['branch_id','=',branch.id],
 | 
				
			||||||
 | 
					                ['department_id','=',department.id],
 | 
				
			||||||
 | 
					                ]
 | 
				
			||||||
 | 
					            item_objs=get_model("clinic.cycle.item").search_browse(dom)
 | 
				
			||||||
            if item_objs:
 | 
					            if item_objs:
 | 
				
			||||||
                item=item_objs[0]
 | 
					                item=item_objs[0]
 | 
				
			||||||
                if item.state!='draft':
 | 
					                if item.state!='draft':
 | 
				
			||||||
| 
						 | 
					@ -157,6 +166,8 @@ class Schedule(Model):
 | 
				
			||||||
                item_id=get_model("clinic.cycle.item").create({
 | 
					                item_id=get_model("clinic.cycle.item").create({
 | 
				
			||||||
                    'cycle_id': cycle.id,
 | 
					                    'cycle_id': cycle.id,
 | 
				
			||||||
                    'date': date,
 | 
					                    'date': date,
 | 
				
			||||||
 | 
					                    'branch_id': branch.id,
 | 
				
			||||||
 | 
					                    'department_id': department.id,
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                items[item_id]=[]
 | 
					                items[item_id]=[]
 | 
				
			||||||
                items[item_id].append(('create',{
 | 
					                items[item_id].append(('create',{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,8 @@ class ClinicSetting(Model):
 | 
				
			||||||
        'auto_gen': fields.Boolean("Auto Gen"), # HD Case
 | 
					        'auto_gen': fields.Boolean("Auto Gen"), # HD Case
 | 
				
			||||||
        'schd_from': fields.Date("From"),
 | 
					        'schd_from': fields.Date("From"),
 | 
				
			||||||
        'schd_to': fields.Date("To"),
 | 
					        'schd_to': fields.Date("To"),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department","Department"),
 | 
				
			||||||
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    _defaults={
 | 
				
			||||||
| 
						 | 
					@ -89,34 +91,18 @@ class ClinicSetting(Model):
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def run_script(self,ids,context={}):
 | 
					    def run_script(self,ids,context={}):
 | 
				
			||||||
        dts={}
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
        for pt in get_model('clinic.patient').search_browse([]):
 | 
					        #sickbed: update department
 | 
				
			||||||
            doctor=pt.doctor_id
 | 
					        for sb in get_model('clinic.sickbed').search_browse([]):
 | 
				
			||||||
            if not dts.get(doctor.id):
 | 
					            hdcs=sorted(sb.hd_cases, key=lambda a: a.id)
 | 
				
			||||||
                dts[doctor.id]=[]
 | 
					            if hdcs:
 | 
				
			||||||
            dts[doctor.id].append(pt.id)
 | 
					                hdc=hdcs[0]
 | 
				
			||||||
        x=0
 | 
					                #patient=hdc.patient_id
 | 
				
			||||||
        y=0
 | 
					                sb.write({
 | 
				
			||||||
        c=1
 | 
					                    'department_id': hdc.department_id.id,
 | 
				
			||||||
        for doctor_id, pt_ids in dts.items():
 | 
					 | 
				
			||||||
            st=set()
 | 
					 | 
				
			||||||
            b_ids=[pt.branch_id.id for pt in get_model('clinic.patient').browse(pt_ids)]
 | 
					 | 
				
			||||||
            for b_id in b_ids:
 | 
					 | 
				
			||||||
                st.update({b_id})
 | 
					 | 
				
			||||||
            if len(st)>1:
 | 
					 | 
				
			||||||
                if doctor_id:
 | 
					 | 
				
			||||||
                    doctor=get_model('clinic.staff').browse(doctor_id)
 | 
					 | 
				
			||||||
                    doctor.write({
 | 
					 | 
				
			||||||
                        'branch_id': 5,
 | 
					 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                    print('%s %s'%(doctor_id, st))
 | 
					        # create new cycle item
 | 
				
			||||||
                # update doctor to ratchawat branch
 | 
					        print("Done!")
 | 
				
			||||||
                x+=1
 | 
					 | 
				
			||||||
            else:
 | 
					 | 
				
			||||||
                y+=1
 | 
					 | 
				
			||||||
            c+=1
 | 
					 | 
				
			||||||
        print("RD ", x)
 | 
					 | 
				
			||||||
        print("Other", y)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def reset_last_import(self,ids,context={}):
 | 
					    def reset_last_import(self,ids,context={}):
 | 
				
			||||||
        res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
 | 
					        res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,7 @@ class SickBed(Model):
 | 
				
			||||||
        'sequence': fields.Integer("Sequence"),
 | 
					        'sequence': fields.Integer("Sequence"),
 | 
				
			||||||
        'note': fields.Text("Note"),
 | 
					        'note': fields.Text("Note"),
 | 
				
			||||||
        'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
 | 
				
			||||||
 | 
					        'department_id': fields.Many2One("clinic.department","Department",required=True, search=True),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def _get_branch(self,context={}):
 | 
					    def _get_branch(self,context={}):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -201,6 +201,7 @@ class Visit(Model):
 | 
				
			||||||
        date=vals['time_start'][0:10]
 | 
					        date=vals['time_start'][0:10]
 | 
				
			||||||
        cycle=obj.cycle_id
 | 
					        cycle=obj.cycle_id
 | 
				
			||||||
        branch=obj.branch_id
 | 
					        branch=obj.branch_id
 | 
				
			||||||
 | 
					        department=obj.department_id
 | 
				
			||||||
        dom=[]
 | 
					        dom=[]
 | 
				
			||||||
        if date:
 | 
					        if date:
 | 
				
			||||||
            dom.append(['date','=',date])
 | 
					            dom.append(['date','=',date])
 | 
				
			||||||
| 
						 | 
					@ -208,6 +209,9 @@ class Visit(Model):
 | 
				
			||||||
            dom.append(['cycle_id','=',cycle.id])
 | 
					            dom.append(['cycle_id','=',cycle.id])
 | 
				
			||||||
        if branch:
 | 
					        if branch:
 | 
				
			||||||
            dom.append(['branch_id','=',branch.id])
 | 
					            dom.append(['branch_id','=',branch.id])
 | 
				
			||||||
 | 
					        if department:
 | 
				
			||||||
 | 
					            dom.append(['department_id','=',department.id])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        item_obj=get_model('clinic.cycle.item')
 | 
					        item_obj=get_model('clinic.cycle.item')
 | 
				
			||||||
        item_ids=item_obj.search(dom)
 | 
					        item_ids=item_obj.search(dom)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -223,6 +227,7 @@ class Visit(Model):
 | 
				
			||||||
        item_vals={
 | 
					        item_vals={
 | 
				
			||||||
            'cycle_id': cycle.id,
 | 
					            'cycle_id': cycle.id,
 | 
				
			||||||
            'branch_id': branch.id,
 | 
					            'branch_id': branch.id,
 | 
				
			||||||
 | 
					            'department_id': department.id,
 | 
				
			||||||
            'date': date,
 | 
					            'date': date,
 | 
				
			||||||
            'nurses': [],
 | 
					            'nurses': [],
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -235,10 +240,11 @@ class Visit(Model):
 | 
				
			||||||
            item_id=item_ids[0]
 | 
					            item_id=item_ids[0]
 | 
				
			||||||
            item=item_obj.browse(item_id)
 | 
					            item=item_obj.browse(item_id)
 | 
				
			||||||
            if item.state!='draft':
 | 
					            if item.state!='draft':
 | 
				
			||||||
 | 
					                # reset nurse
 | 
				
			||||||
                for nurse in item.nurses:
 | 
					                for nurse in item.nurses:
 | 
				
			||||||
                    nurse.delete()
 | 
					                    nurse.delete()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # get nurse from schedule
 | 
					        # copy nurse from schedule
 | 
				
			||||||
        item=item_obj.browse(item_id)
 | 
					        item=item_obj.browse(item_id)
 | 
				
			||||||
        if item.state!='draft':
 | 
					        if item.state!='draft':
 | 
				
			||||||
            schedule=get_schedule(date)
 | 
					            schedule=get_schedule(date)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,10 @@ class VisitBoard(Model):
 | 
				
			||||||
            'visit_id': None,
 | 
					            'visit_id': None,
 | 
				
			||||||
            'cycle_name': '',
 | 
					            'cycle_name': '',
 | 
				
			||||||
            'cycle_color': '',
 | 
					            'cycle_color': '',
 | 
				
			||||||
 | 
					            'department_id': None,
 | 
				
			||||||
 | 
					            'department_name': None,
 | 
				
			||||||
 | 
					            'branch_id': None,
 | 
				
			||||||
 | 
					            'branch_name': None,
 | 
				
			||||||
            'patient_id': None,
 | 
					            'patient_id': None,
 | 
				
			||||||
            'patient_name': '',
 | 
					            'patient_name': '',
 | 
				
			||||||
            'patient_type': '',
 | 
					            'patient_type': '',
 | 
				
			||||||
| 
						 | 
					@ -139,6 +143,11 @@ class VisitBoard(Model):
 | 
				
			||||||
                number='*รอการยืนยัน'
 | 
					                number='*รอการยืนยัน'
 | 
				
			||||||
            cycle=visit.cycle_id
 | 
					            cycle=visit.cycle_id
 | 
				
			||||||
            patient=visit.patient_id
 | 
					            patient=visit.patient_id
 | 
				
			||||||
 | 
					            branch=visit.branch_id
 | 
				
			||||||
 | 
					            department=visit.department_id
 | 
				
			||||||
 | 
					            if not branch:
 | 
				
			||||||
 | 
					                branch=department.branch_id 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            hn_name=patient.hn_no or '-'
 | 
					            hn_name=patient.hn_no or '-'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            visit_date=visit.visit_date
 | 
					            visit_date=visit.visit_date
 | 
				
			||||||
| 
						 | 
					@ -156,6 +165,10 @@ class VisitBoard(Model):
 | 
				
			||||||
                'sickbed_id': sickbed_id,
 | 
					                'sickbed_id': sickbed_id,
 | 
				
			||||||
                'cycle_name': cycle.name,
 | 
					                'cycle_name': cycle.name,
 | 
				
			||||||
                'cycle_color': cycle.color,
 | 
					                'cycle_color': cycle.color,
 | 
				
			||||||
 | 
					                'department_id': department.id,
 | 
				
			||||||
 | 
					                'department_name': department.name or '',
 | 
				
			||||||
 | 
					                'branch_id': branch.id,
 | 
				
			||||||
 | 
					                'branch_name': branch.name or '',
 | 
				
			||||||
                'patient_name': patient.name,
 | 
					                'patient_name': patient.name,
 | 
				
			||||||
                'patient_id': patient.id,
 | 
					                'patient_id': patient.id,
 | 
				
			||||||
                'patient_type': patient.type_id.name or "",
 | 
					                'patient_type': patient.type_id.name or "",
 | 
				
			||||||
| 
						 | 
					@ -211,9 +224,9 @@ class VisitBoard(Model):
 | 
				
			||||||
                index+=1
 | 
					                index+=1
 | 
				
			||||||
                # footer
 | 
					                # footer
 | 
				
			||||||
                line=empty_line.copy()
 | 
					                line=empty_line.copy()
 | 
				
			||||||
                patient_str='>> %s'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items())
 | 
					                patient_str='%s'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items())
 | 
				
			||||||
                cycle_str='>> %s'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items())
 | 
					                cycle_str='%s'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items())
 | 
				
			||||||
                summary_str='>> %s'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel])
 | 
					                summary_str='%s'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel])
 | 
				
			||||||
                line['details']='ทั้งหมด %s:  %s'%(total_qty,', '.join([summary_str,cycle_str,patient_str]))
 | 
					                line['details']='ทั้งหมด %s:  %s'%(total_qty,', '.join([summary_str,cycle_str,patient_str]))
 | 
				
			||||||
                line['details1']=summary_str
 | 
					                line['details1']=summary_str
 | 
				
			||||||
                line['details2']=cycle_str
 | 
					                line['details2']=cycle_str
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,8 +20,12 @@
 | 
				
			||||||
        <th>ใบนัดแพทย์</th>
 | 
					        <th>ใบนัดแพทย์</th>
 | 
				
			||||||
        <th>HN</th>
 | 
					        <th>HN</th>
 | 
				
			||||||
        <th>ผู้ป่วย</th>
 | 
					        <th>ผู้ป่วย</th>
 | 
				
			||||||
 | 
					        <!--
 | 
				
			||||||
 | 
					        <th>สาขา</th>
 | 
				
			||||||
 | 
					        -->
 | 
				
			||||||
        <th>สิทธ์</th>
 | 
					        <th>สิทธ์</th>
 | 
				
			||||||
        <th>แพทย์</th>
 | 
					        <th>แพทย์</th>
 | 
				
			||||||
 | 
					        <th>ชั้น</th>
 | 
				
			||||||
        <th>เตียง</th>
 | 
					        <th>เตียง</th>
 | 
				
			||||||
        <th>บันทึกการรักษา</th>
 | 
					        <th>บันทึกการรักษา</th>
 | 
				
			||||||
        <th>หมายเหตุ</th>
 | 
					        <th>หมายเหตุ</th>
 | 
				
			||||||
| 
						 | 
					@ -30,7 +34,7 @@
 | 
				
			||||||
        {{#each lines }}
 | 
					        {{#each lines }}
 | 
				
			||||||
            {{#if footer}}
 | 
					            {{#if footer}}
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td rowspan="3" align="middle" style="vertical-align:middle; background-color:#4183c4;color:white"><span><b>TOTAL</b></span></td>
 | 
					                    <td rowspan="3" align="middle" style="vertical-align:middle; background-color:#4183c4;color:white"><span><b>สรุป</b></span></td>
 | 
				
			||||||
                    <td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details1}}</b></td>
 | 
					                    <td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details1}}</b></td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
| 
						 | 
					@ -50,8 +54,12 @@
 | 
				
			||||||
                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
 | 
					                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
 | 
				
			||||||
                        <td style="background-color:{{visit_color}}">{{hn_name}}</td>
 | 
					                        <td style="background-color:{{visit_color}}">{{hn_name}}</td>
 | 
				
			||||||
                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_name}}</a></td>
 | 
					                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_name}}</a></td>
 | 
				
			||||||
 | 
					                        <!--
 | 
				
			||||||
 | 
					                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_branch&active_id={{branch_id}}&mode=form">{{branch_name}}</a></td>
 | 
				
			||||||
 | 
					                        -->
 | 
				
			||||||
                        <td style="background-color:{{visit_color}}">{{patient_type}}</td>
 | 
					                        <td style="background-color:{{visit_color}}">{{patient_type}}</td>
 | 
				
			||||||
                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_staff&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td>
 | 
					                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_staff&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td>
 | 
				
			||||||
 | 
					                        <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_department&active_id={{department_id}}&mode=form">{{department_name}}</a></td>
 | 
				
			||||||
                        {{#if sickbed_id}}
 | 
					                        {{#if sickbed_id}}
 | 
				
			||||||
                            <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_sickbed&active_id={{sickbed_id}}&mode=form">{{sickbed_name}}</a></td>
 | 
					                            <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_sickbed&active_id={{sickbed_id}}&mode=form">{{sickbed_name}}</a></td>
 | 
				
			||||||
                        {{else}}
 | 
					                        {{else}}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,20 @@
 | 
				
			||||||
todo:
 | 
					todo:
 | 
				
			||||||
 | 
					    - filter data
 | 
				
			||||||
 | 
					        1. company
 | 
				
			||||||
 | 
					        2. branch
 | 
				
			||||||
 | 
					        3. department
 | 
				
			||||||
 | 
					             - cycle item
 | 
				
			||||||
 | 
					             - sickedbed
 | 
				
			||||||
 | 
					             - patient
 | 
				
			||||||
 | 
					             - staff
 | 
				
			||||||
 | 
					    - script
 | 
				
			||||||
 | 
					        - after split department
 | 
				
			||||||
 | 
					    - cycle item should be see only that department
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    - accounting
 | 
					    - accounting
 | 
				
			||||||
        - doctor detail
 | 
					        - doctor detail
 | 
				
			||||||
        - import  
 | 
					        - import match hn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - visit summary -> ok
 | 
					    - visit summary -> ok
 | 
				
			||||||
    - calendar
 | 
					    - calendar
 | 
				
			||||||
        - search calendar
 | 
					        - search calendar
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue