コード例 #1
0
class PaymentDetail(core_models.VersionedModel):
    id = models.BigAutoField(db_column='PaymentDetailsID', primary_key=True)

    payment = models.ForeignKey(Payment,
                                models.DO_NOTHING,
                                db_column='PaymentID',
                                related_name="payment_details")
    # beware putting FKs: product code (,...): need to check if we can/must adapt payment info if code (,...) change
    # i.e. normally, FK is pointing to PK, not to a field
    product_code = models.CharField(db_column='ProductCode',
                                    max_length=8,
                                    blank=True,
                                    null=True)
    insurance_number = models.CharField(db_column='InsuranceNumber',
                                        max_length=12,
                                        blank=True,
                                        null=True)  # CHF_ID

    policy_stage = models.CharField(db_column='PolicyStage',
                                    max_length=1,
                                    blank=True,
                                    null=True)
    amount = models.DecimalField(db_column='Amount',
                                 max_digits=18,
                                 decimal_places=2,
                                 blank=True,
                                 null=True)

    premium = models.ForeignKey(Premium,
                                models.SET_NULL,
                                db_column='PremiumID',
                                related_name="payment_details",
                                blank=True,
                                null=True)

    enrollment_date = fields.DateField(db_column='enrollmentDate',
                                       blank=True,
                                       null=True)
    expected_amount = models.DecimalField(db_column='ExpectedAmount',
                                          max_digits=18,
                                          decimal_places=2,
                                          blank=True,
                                          null=True)

    # rowid = models.TextField(db_column='RowID', blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    # ! auditED in field name
    audit_user_id = models.IntegerField(db_column='AuditedUserId',
                                        blank=True,
                                        null=True)

    class Meta:
        managed = False
        db_table = 'tblPaymentDetails'

    def __str__(self):
        return f"id:{self.id}, payment:{self.payment_id}, ins_nb:{self.insurance_number}, amount:{self.amount}, " \
               f"premium:{self.premium_id}"
コード例 #2
0
class Policy(models.Model):
    id = models.AutoField(db_column='PolicyID', primary_key=True)
    legacy_id = models.IntegerField(db_column='LegacyID',
                                    blank=True,
                                    null=True)

    stage = models.CharField(db_column='PolicyStage',
                             max_length=1,
                             blank=True,
                             null=True)
    status = models.SmallIntegerField(db_column='PolicyStatus',
                                      blank=True,
                                      null=True)
    value = models.DecimalField(db_column='PolicyValue',
                                max_digits=18,
                                decimal_places=2,
                                blank=True,
                                null=True)

    # familyid = models.ForeignKey(Tblfamilies, models.DO_NOTHING, db_column='FamilyID')
    enroll_date = fields.DateField(db_column='EnrollDate')
    start_date = fields.DateField(db_column='StartDate')
    effective_date = fields.DateField(db_column='EffectiveDate',
                                      blank=True,
                                      null=True)
    expiry_date = fields.DateField(db_column='ExpiryDate',
                                   blank=True,
                                   null=True)

    # prodid = models.ForeignKey('Tblproduct', models.DO_NOTHING, db_column='ProdID')
    # officerid = models.ForeignKey(Tblofficer, models.DO_NOTHING, db_column='OfficerID', blank=True, null=True)

    validity_from = fields.DateTimeField(db_column='ValidityFrom')
    validity_to = fields.DateTimeField(db_column='ValidityTo',
                                       blank=True,
                                       null=True)

    offline = models.BooleanField(db_column='isOffline', blank=True, null=True)
    audit_user_id = models.IntegerField(db_column='AuditUserID')
    row_id = models.BinaryField(db_column='RowID', blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tblPolicy'
コード例 #3
0
class ClaimAttachment(core_models.UUIDModel, core_models.UUIDVersionedModel):
    claim = models.ForeignKey(
        Claim, models.DO_NOTHING, related_name='attachments')
    type = models.TextField(blank=True, null=True)
    title = models.TextField(blank=True, null=True)
    date = fields.DateField(blank=True, null=True)
    filename = models.TextField(blank=True, null=True)
    mime = models.TextField(blank=True, null=True)
    # frontend contributions may lead to externalized (nas) storage for documents
    url = models.TextField(blank=True, null=True)
    # Support of BinaryField is database-related: prefer to stick to b64-encoded
    document = models.TextField(blank=True, null=True)

    class Meta:
        managed = True
        db_table = "claim_ClaimAttachment"
コード例 #4
0
class ServicesPricelist(VersionedModel):
    id = models.AutoField(db_column='PLServiceID', primary_key=True)
    uuid = models.CharField(db_column='PLServiceUUID',
                            max_length=36,
                            default=uuid.uuid4,
                            unique=True)
    name = models.CharField(db_column='PLServName', max_length=100)
    pricelist_date = fields.DateField(db_column='DatePL')
    location = models.ForeignKey("location.Location",
                                 db_column="LocationId",
                                 blank=True,
                                 null=True,
                                 on_delete=models.DO_NOTHING)
    audit_user_id = models.IntegerField(db_column='AuditUserID')

    # row_id = models.BinaryField(db_column='RowID', blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tblPLServices'
コード例 #5
0
class Claim(core_models.VersionedModel):
    id = models.AutoField(db_column='ClaimID', primary_key=True)
    uuid = models.CharField(db_column='ClaimUUID',
                            max_length=36,
                            default=uuid.uuid4,
                            unique=True)
    category = models.CharField(db_column='ClaimCategory',
                                max_length=1,
                                blank=True,
                                null=True)
    insuree = models.ForeignKey(insuree_models.Insuree,
                                models.DO_NOTHING,
                                db_column='InsureeID')
    code = models.CharField(db_column='ClaimCode', max_length=8, unique=True)
    date_from = fields.DateField(db_column='DateFrom')
    date_to = fields.DateField(db_column='DateTo', blank=True, null=True)
    status = models.SmallIntegerField(db_column='ClaimStatus')
    adjuster = models.ForeignKey(core_models.InteractiveUser,
                                 models.DO_NOTHING,
                                 db_column='Adjuster',
                                 blank=True,
                                 null=True)
    adjustment = models.TextField(db_column='Adjustment',
                                  blank=True,
                                  null=True)
    claimed = models.DecimalField(db_column='Claimed',
                                  max_digits=18,
                                  decimal_places=2,
                                  blank=True,
                                  null=True)
    approved = models.DecimalField(db_column='Approved',
                                   max_digits=18,
                                   decimal_places=2,
                                   blank=True,
                                   null=True)
    reinsured = models.DecimalField(db_column='Reinsured',
                                    max_digits=18,
                                    decimal_places=2,
                                    blank=True,
                                    null=True)
    valuated = models.DecimalField(db_column='Valuated',
                                   max_digits=18,
                                   decimal_places=2,
                                   blank=True,
                                   null=True)
    date_claimed = fields.DateField(db_column='DateClaimed')
    date_processed = fields.DateField(db_column='DateProcessed',
                                      blank=True,
                                      null=True)
    # Django uses the feedback_id column to create the feedback column, which conflicts with the boolean field
    feedback_available = models.BooleanField(db_column='Feedback',
                                             default=False)
    feedback = models.OneToOneField(Feedback,
                                    models.DO_NOTHING,
                                    db_column='FeedbackID',
                                    blank=True,
                                    null=True,
                                    related_name="+")
    explanation = models.TextField(db_column='Explanation',
                                   blank=True,
                                   null=True)
    feedback_status = models.SmallIntegerField(db_column='FeedbackStatus',
                                               blank=True,
                                               null=True)
    review_status = models.SmallIntegerField(db_column='ReviewStatus',
                                             blank=True,
                                             null=True)
    approval_status = models.SmallIntegerField(db_column='ApprovalStatus',
                                               blank=True,
                                               null=True)
    rejection_reason = models.SmallIntegerField(db_column='RejectionReason',
                                                blank=True,
                                                null=True)

    batch_run = models.ForeignKey(claim_batch_models.BatchRun,
                                  models.DO_NOTHING,
                                  db_column='RunID',
                                  blank=True,
                                  null=True)
    audit_user_id = models.IntegerField(db_column='AuditUserID')
    validity_from_review = fields.DateTimeField(db_column='ValidityFromReview',
                                                blank=True,
                                                null=True)
    validity_to_review = fields.DateTimeField(db_column='ValidityToReview',
                                              blank=True,
                                              null=True)

    health_facility = models.ForeignKey(location_models.HealthFacility,
                                        models.DO_NOTHING,
                                        db_column='HFID')

    submit_stamp = fields.DateTimeField(db_column='SubmitStamp',
                                        blank=True,
                                        null=True)
    process_stamp = fields.DateTimeField(db_column='ProcessStamp',
                                         blank=True,
                                         null=True)
    remunerated = models.DecimalField(db_column='Remunerated',
                                      max_digits=18,
                                      decimal_places=2,
                                      blank=True,
                                      null=True)
    guarantee_id = models.CharField(db_column='GuaranteeId',
                                    max_length=50,
                                    blank=True,
                                    null=True)
    admin = models.ForeignKey(ClaimAdmin,
                              models.DO_NOTHING,
                              db_column='ClaimAdminId',
                              blank=True,
                              null=True)
    icd = models.ForeignKey(medical_models.Diagnosis,
                            models.DO_NOTHING,
                            db_column='ICDID',
                            related_name="claim_icds")
    icd_1 = models.ForeignKey(medical_models.Diagnosis,
                              models.DO_NOTHING,
                              db_column='ICDID1',
                              related_name="claim_icd1s",
                              blank=True,
                              null=True)
    icd_2 = models.ForeignKey(medical_models.Diagnosis,
                              models.DO_NOTHING,
                              db_column='ICDID2',
                              related_name="claim_icd2s",
                              blank=True,
                              null=True)
    icd_3 = models.ForeignKey(medical_models.Diagnosis,
                              models.DO_NOTHING,
                              db_column='ICDID3',
                              related_name="claim_icd3s",
                              blank=True,
                              null=True)
    icd_4 = models.ForeignKey(medical_models.Diagnosis,
                              models.DO_NOTHING,
                              db_column='ICDID4',
                              related_name="claim_icd4s",
                              blank=True,
                              null=True)

    visit_type = models.CharField(db_column='VisitType',
                                  max_length=1,
                                  blank=True,
                                  null=True)
    audit_user_id_review = models.IntegerField(db_column='AuditUserIDReview',
                                               blank=True,
                                               null=True)
    audit_user_id_submit = models.IntegerField(db_column='AuditUserIDSubmit',
                                               blank=True,
                                               null=True)
    audit_user_id_process = models.IntegerField(db_column='AuditUserIDProcess',
                                                blank=True,
                                                null=True)
    scheme_type = models.IntegerField(db_column='SchemeType',
                                      blank=True,
                                      null=True)
    subProduct_id = models.IntegerField(db_column='subProduct_id',
                                        blank=True,
                                        null=True)

    # row_id = models.BinaryField(db_column='RowID', blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tblClaim'

    STATUS_REJECTED = 1
    STATUS_ENTERED = 2
    STATUS_CHECKED = 4
    STATUS_PROCESSED = 8
    STATUS_VALUATED = 16

    FEEDBACK_IDLE = 1
    FEEDBACK_NOT_SELECTED = 2
    FEEDBACK_SELECTED = 4
    FEEDBACK_DELIVERED = 8
    FEEDBACK_BYPASSED = 16

    REVIEW_IDLE = 1
    REVIEW_NOT_SELECTED = 2
    REVIEW_SELECTED = 4
    REVIEW_DELIVERED = 8
    REVIEW_BYPASSED = 16

    def reject(self, rejection_code):
        updated_items = self.items.filter(validity_to__isnull=True).update(
            rejection_reason=rejection_code)
        updated_services = self.services.filter(
            validity_to__isnull=True).update(rejection_reason=rejection_code)
        signal_claim_rejection.send(sender=self.__class__, claim=self)
        return updated_items + updated_services

    def save_history(self, **kwargs):
        prev_id = super(Claim, self).save_history()
        if prev_id:
            prev_items = []
            for item in self.items.all():
                prev_items.append(item.save_history())
            ClaimItem.objects.filter(id__in=prev_items).update(
                claim_id=prev_id)
            prev_services = []
            for service in self.services.all():
                prev_services.append(service.save_history())
            ClaimService.objects.filter(id__in=prev_services).update(
                claim_id=prev_id)
        return prev_id

    @classmethod
    def get_queryset(cls, queryset, user):
        queryset = Claim.filter_queryset(queryset)
        # GraphQL calls with an info object while Rest calls with the user itself
        if isinstance(user, ResolveInfo):
            user = user.context.user
        if settings.ROW_SECURITY and user.is_anonymous:
            return queryset.filter(id=-1)
        if settings.ROW_SECURITY:
            # TechnicalUsers don't have health_facility_id attribute
            if hasattr(user._u,
                       'health_facility_id') and user._u.health_facility_id:
                return queryset.filter(
                    health_facility_id=user._u.health_facility_id)
            else:
                dist = UserDistrict.get_user_districts(user._u)
                return queryset.filter(health_facility__location_id__in=[
                    l.location_id for l in dist
                ])
        return queryset
コード例 #6
0
class Payment(core_models.VersionedModel):
    id = models.BigAutoField(db_column='PaymentID', primary_key=True)
    uuid = models.CharField(db_column='PaymentUUID', max_length=36)

    expected_amount = models.DecimalField(db_column='ExpectedAmount',
                                          max_digits=18,
                                          decimal_places=2,
                                          blank=True,
                                          null=True)
    received_amount = models.DecimalField(db_column='ReceivedAmount',
                                          max_digits=18,
                                          decimal_places=2,
                                          blank=True,
                                          null=True)
    officer_code = models.CharField(db_column='OfficerCode',
                                    max_length=50,
                                    blank=True,
                                    null=True)
    phone_number = models.CharField(db_column='PhoneNumber',
                                    max_length=12,
                                    blank=True,
                                    null=True)
    request_date = fields.DateField(db_column='RequestDate',
                                    blank=True,
                                    null=True)
    received_date = fields.DateField(db_column='ReceivedDate',
                                     blank=True,
                                     null=True)
    status = models.IntegerField(db_column='PaymentStatus',
                                 blank=True,
                                 null=True)

    transaction_no = models.CharField(db_column='TransactionNo',
                                      max_length=50,
                                      blank=True,
                                      null=True)
    origin = models.CharField(db_column='PaymentOrigin',
                              max_length=50,
                              blank=True,
                              null=True)
    matched_date = fields.DateField(db_column='MatchedDate',
                                    blank=True,
                                    null=True)
    receipt_no = models.CharField(db_column='ReceiptNo',
                                  max_length=100,
                                  blank=True,
                                  null=True)
    payment_date = fields.DateField(db_column='PaymentDate',
                                    blank=True,
                                    null=True)
    rejected_reason = models.CharField(db_column='RejectedReason',
                                       max_length=255,
                                       blank=True,
                                       null=True)
    date_last_sms = fields.DateField(db_column='DateLastSMS',
                                     blank=True,
                                     null=True)
    language_name = models.CharField(db_column='LanguageName',
                                     max_length=10,
                                     blank=True,
                                     null=True)
    type_of_payment = models.CharField(db_column='TypeOfPayment',
                                       max_length=50,
                                       blank=True,
                                       null=True)
    transfer_fee = models.DecimalField(db_column='TransferFee',
                                       max_digits=18,
                                       decimal_places=2,
                                       blank=True,
                                       null=True)

    # rowid = models.TextField(db_column='RowID')
    # auditED, not audit ???
    # auditeduser_id = models.IntegerField(db_column='AuditedUSerID', blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tblPayment'
コード例 #7
0
class Contract(core_models.HistoryBusinessModel):
    code = models.CharField(db_column='Code', max_length=64, null=False)
    policy_holder = models.ForeignKey(PolicyHolder,
                                      db_column="PolicyHolderUUID",
                                      on_delete=models.deletion.DO_NOTHING,
                                      blank=True,
                                      null=True)
    amount_notified = models.FloatField(db_column='AmountNotified',
                                        blank=True,
                                        null=True)
    amount_rectified = models.FloatField(db_column='AmountRectified',
                                         blank=True,
                                         null=True)
    amount_due = models.FloatField(db_column='AmountDue',
                                   blank=True,
                                   null=True)
    date_approved = fields.DateTimeField(db_column='DateApproved',
                                         blank=True,
                                         null=True)
    date_payment_due = fields.DateField(db_column='DatePaymentDue',
                                        blank=True,
                                        null=True)
    state = models.SmallIntegerField(db_column='State', blank=True, null=True)
    payment_reference = models.CharField(db_column='PaymentReference',
                                         max_length=255,
                                         blank=True,
                                         null=True)
    amendment = models.IntegerField(db_column='Amendment',
                                    blank=False,
                                    null=False,
                                    default=0)

    objects = ContractManager()

    @property
    def amount(self):
        amount = 0
        if self.state in [1, 2]:
            amount = self.amount_notified
        elif self.state in [4, 11, 3]:
            amount = self.amount_rectified
        elif self.state in [5, 6, 7, 8, 9, 10]:
            amount = self.amount_due
        else:
            amount = self.amount_due
        return amount

    @classmethod
    def get_queryset(cls, queryset, user):
        queryset = cls.filter_queryset(queryset)
        if isinstance(user, ResolveInfo):
            user = user.context.user
        if settings.ROW_SECURITY and user.is_anonymous:
            return queryset.filter(id=-1)
        if settings.ROW_SECURITY:
            pass
        return queryset

    class Meta:
        db_table = 'tblContract'

    STATE_REQUEST_FOR_INFORMATION = 1
    STATE_DRAFT = 2
    STATE_OFFER = 3
    STATE_NEGOTIABLE = 4
    STATE_EXECUTABLE = 5
    STATE_ADDENDUM = 6
    STATE_EFFECTIVE = 7
    STATE_EXECUTED = 8
    STATE_DISPUTED = 9
    STATE_TERMINATED = 10
    STATE_COUNTER = 11
コード例 #8
0
class Payment(core_models.VersionedModel):
    STATUS_REJECTEDPOSTED_3 = -3
    STATUS_REJECTEDPOSTED_2 = -2
    STATUS_REJECTEDPOSTED_1 = -1
    STATUS_NOTYETCONFIRMED = 1
    STATUS_POSTED = 2
    STATUS_ASSIGNED = 3
    STATUS_UNMATCHED = 4
    STATUS_PAYMENTMATCHED = 5
    STATUS_CHOICES = (
        (STATUS_REJECTEDPOSTED_3, _("REJECTEDPOSTED_3")),
        (STATUS_REJECTEDPOSTED_2, _("REJECTEDPOSTED_2")),
        (STATUS_REJECTEDPOSTED_1, _("REJECTEDPOSTED_1")),
        (STATUS_NOTYETCONFIRMED, _("NOTYETCONFIRMED")),
        (STATUS_POSTED, _("POSTED")),
        (STATUS_ASSIGNED, _("ASSIGNED")),
        (STATUS_UNMATCHED, _("UNMATCHED")),
        (STATUS_PAYMENTMATCHED, _("PAYMENTMATCHED")),
    )

    id = models.BigAutoField(db_column='PaymentID', primary_key=True)
    uuid = models.CharField(db_column='PaymentUUID',
                            max_length=36,
                            default=uuid.uuid4,
                            unique=True)

    expected_amount = models.DecimalField(db_column='ExpectedAmount',
                                          max_digits=18,
                                          decimal_places=2,
                                          blank=True,
                                          null=True)
    received_amount = models.DecimalField(db_column='ReceivedAmount',
                                          max_digits=18,
                                          decimal_places=2,
                                          blank=True,
                                          null=True)
    officer_code = models.CharField(db_column='OfficerCode',
                                    max_length=50,
                                    blank=True,
                                    null=True)
    phone_number = models.CharField(db_column='PhoneNumber',
                                    max_length=12,
                                    blank=True,
                                    null=True)
    request_date = fields.DateField(db_column='RequestDate',
                                    blank=True,
                                    null=True)
    received_date = fields.DateField(db_column='ReceivedDate',
                                     blank=True,
                                     null=True)
    status = models.IntegerField(db_column='PaymentStatus',
                                 blank=True,
                                 null=True)

    transaction_no = models.CharField(db_column='TransactionNo',
                                      max_length=50,
                                      blank=True,
                                      null=True)
    origin = models.CharField(db_column='PaymentOrigin',
                              max_length=50,
                              blank=True,
                              null=True)
    matched_date = fields.DateField(db_column='MatchedDate',
                                    blank=True,
                                    null=True)
    receipt_no = models.CharField(db_column='ReceiptNo',
                                  max_length=100,
                                  blank=True,
                                  null=True)
    payment_date = fields.DateField(db_column='PaymentDate',
                                    blank=True,
                                    null=True)
    rejected_reason = models.CharField(db_column='RejectedReason',
                                       max_length=255,
                                       blank=True,
                                       null=True)
    date_last_sms = fields.DateField(db_column='DateLastSMS',
                                     blank=True,
                                     null=True)
    language_name = models.CharField(db_column='LanguageName',
                                     max_length=10,
                                     blank=True,
                                     null=True)
    type_of_payment = models.CharField(db_column='TypeOfPayment',
                                       max_length=50,
                                       blank=True,
                                       null=True)
    transfer_fee = models.DecimalField(db_column='TransferFee',
                                       max_digits=18,
                                       decimal_places=2,
                                       blank=True,
                                       null=True)

    # rowid = models.TextField(db_column='RowID')
    # auditED, not audit ???
    # auditeduser_id = models.IntegerField(db_column='AuditedUSerID', blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tblPayment'

    def __str__(self):
        return f"id:{self.id}, expected_amount: {self.expected_amount}, status:{self.status}, " \
               f"type:{self.type_of_payment}, uuid:{self.uuid}"