Revision 0b364f95
Added by Mikaël Ates over 12 years ago
scripts/import_pcs.py | ||
---|---|---|
453 | 453 |
#CmppHealthCareDiagnostic.objects.bulk_create(HcDiags) |
454 | 454 |
#CmppHealthCareTreatment.objects.bulk_create(HcTraits) |
455 | 455 |
# Association des actes au healthcare |
456 |
i = 0 |
|
456 | 457 |
for patient_id, pcs in histo.items(): |
457 | 458 |
patient = None |
458 | 459 |
try: |
... | ... | |
468 | 469 |
a = Act.objects.get(old_id=act['id']) |
469 | 470 |
except: |
470 | 471 |
print "Acte non trouve %s" % act['id'] |
472 |
i += 1 |
|
471 | 473 |
continue |
472 | 474 |
if not a.is_billed: |
473 | 475 |
print "Acte deja pris en charge mais non facture %s" %a |
474 | 476 |
a.is_billed = True |
475 | 477 |
a.healthcare = hc |
476 | 478 |
a.save() |
479 |
print "Acte non trouve %d" % i |
|
477 | 480 |
# Historique des dossiers, Automatic switch state ? Automated hc creation ? |
478 | 481 |
print "--> Lecture table des dossiers..." |
479 | 482 |
csvfile = open(os.path.join(db_path, db, 'dossiers.csv'), 'rb') |
... | ... | |
491 | 494 |
date_inscription = None |
492 | 495 |
date_clos = None |
493 | 496 |
date_retour = None |
494 |
fss = [] |
|
495 | 497 |
|
496 | 498 |
pdb.set_trace() |
497 | 499 |
FileState.objects.filter(patient__service=service).delete() |
498 | 500 |
for dossier in tables_data['dossiers']: |
501 |
fss = [] |
|
499 | 502 |
patient = None |
500 | 503 |
try: |
501 | 504 |
patient = PatientRecord.objects.get(old_id=dossier['id'], service=service) |
... | ... | |
599 | 602 |
patient.last_state = fs |
600 | 603 |
patient.save() |
601 | 604 |
if len(fss) > 1: |
602 |
for status, date, comment in fss[1:]: |
|
603 |
patient.set_state(status=status, author=creator, date_selected=date, comment=comment) |
|
605 |
for status, date_selected, comment in fss[1:]: |
|
606 |
try: |
|
607 |
patient.set_state(status=status, author=creator, date_selected=date_selected, comment=comment) |
|
608 |
except Exception, e: |
|
609 |
print "Pour patient %s, exception %s" % (patient, str(e)) |
|
604 | 610 |
|
605 | 611 |
# Si reouverture apres date de cloture, passer à cette date en d ou en t |
606 | 612 |
# Combinaisons possibles |
Also available in: Unified diff
scripts: update import pcs scripts.