Project

General

Profile

« Previous | Next » 

Revision f9afb714

Added by Mikaël Ates over 12 years ago

facturation: List acts billable for billing at the CMPP.

View differences:

calebasse/facturation/list_acts.py
201 201
    return (acts_not_locked, days_not_locked, acts_not_valide,
202 202
        acts_not_billable, acts_bad_state, acts_missing_valid_notification,
203 203
        acts_accepted)
204

  
205

  
206
def list_acts_for_billing_CMPP(end_day, service):
207
    """Used to sort acts billable by specific service requirements.
208

  
209
    For the CMPP, acts are billable if
210

  
211
    acts = acts_not_locked + \
212
        acts_not_valide + \
213
            acts_not_billable + \
214
                acts_diagnostic + \
215
                    acts_treatment + \
216
                        acts_losts
217

  
218
    :param end_day: formatted date that gives the last day when acts are taken
219
        in account.
220
    :type end_day: datetime
221
    :param service: service in which acts are dealt with.
222
    :type service: calebasse.ressources.Service
223

  
224
    :returns: a list of dictionnaries where patients are the keys and values
225
        are lists of acts. The second element of this list in not a dict but
226
        a list of the days where are all days are not locked.
227
    :rtype: list
228
    """
229

  
230
    acts_not_locked, days_not_locked, acts_not_valide, \
231
        acts_not_billable, acts_billable = \
232
            list_acts_for_billing_first_round(end_day, service)
233
    acts_diagnostic = {}
234
    acts_treatment = {}
235
    acts_losts = {}
236
    for patient, acts in acts_billable.items():
237
        for act in acts:
238
            cared, hc = act.is_act_covered_by_diagnostic_healthcare()
239
            if cared:
240
                if act.patient in acts_diagnostic:
241
                    acts_diagnostic[act.patient]. \
242
                        append((act, hc))
243
                else:
244
                    acts_diagnostic[act.patient] = [(act, hc)]
245
            else:
246
                cared, hc = act.is_act_covered_by_treatment_healthcare()
247
                if cared:
248
                    if act.patient in acts_treatment:
249
                        acts_treatment[act.patient]. \
250
                            append((act, hc))
251
                    else:
252
                        acts_treatment[act.patient] = [(act, hc)]
253
                else:
254
                    if act.patient in acts_losts:
255
                        acts_losts[act.patient]. \
256
                            append(act)
257
                    else:
258
                        acts_losts[act.patient] = [act]
259
    return (acts_not_locked, days_not_locked, acts_not_valide,
260
        acts_not_billable, acts_diagnostic, acts_treatment,
261
        acts_losts)

Also available in: Unified diff