Пример #1
0
class PatientDocument(models.Model):
    """
    Implements a document to be attached to a patient file
    """
    patient = models.ForeignKey(Patient,
                                verbose_name=_('patient'),
                                on_delete=models.CASCADE)
    document = models.OneToOneField(Document,
                                    verbose_name=_('document'),
                                    on_delete=models.CASCADE,
                                    primary_key=True)
    attachment_type = models.SmallIntegerField(_('attachmentType'))

    AttachmentType = enum('AttachmentType', 'SURGICAL', 'MEDICAL', 'FAMILIAL',
                          'TRAUMA', 'MEDICAL_REPORTS')

    def delete(self, *args, **kwargs):
        super(PatientDocument, self).delete(*args, **kwargs)
        self.document.delete()
Пример #2
0
    def _get_last_invoice(self):
        if self.invoices.all().count() == 0:
            return None
        invoices = self.invoices.all().order_by('-date')
        if invoices.first().canceled_by is not None:
            return self._resolve_invoice(invoices.first())
        return self.invoices.latest('date')

    last_invoice = property(_get_last_invoice)


ExaminationType = enum(
    'ExaminationType',
    'EMPTY',
    'NORMAL',
    'CONTINUING',
    'RETURN',
    'EMERGENCY',
)

ExaminationStatus = enum(
    'ExaminationStatus',
    'IN_PROGRESS',
    'WAITING_FOR_PAIEMENT',
    'INVOICED_PAID',
    'NOT_INVOICED',
)

InvoiceStatus = enum('InvoiceStatus', 'DRAFT', 'WAITING_FOR_PAIEMENT',
                     'INVOICED_PAID', 'CANCELED')