Exemplo n.º 1
0
    def _store_event(self, claim_id, clinic_pkey, description, event_time,
                     event):
        address = helper.make_event_address(claim_id, clinic_pkey, event_time)
        ev = payload_pb2.ActionOnClaim()
        ev.claim_id = claim_id
        ev.clinic_pkey = clinic_pkey
        ev.description = description
        ev.event_time = event_time
        ev.event = event

        state_data = ev.SerializeToString()
        self._context.set_state({address: state_data}, timeout=self.TIMEOUT)
    def next_visit(self, claim_id, description, doctor_pkey, wait=None, auth_user=None,
                   auth_password=None):
        batch_key = txn_key = self._signer.get_public_key().as_hex()

        clinic_hex = helper.make_clinic_address(clinic_pkey=txn_key)
        claim_hex = helper.make_claim_address(claim_id=claim_id, clinic_pkey=txn_key)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id, clinic_pkey=txn_key, event_time=current_times_str)

        next_visit = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=txn_key,
            description="Doctor pkey: {}, claim hex: {}, description: {}".format(doctor_pkey, claim_hex, description),
            event_time=current_times_str)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.NEXT_VISIT,
            next_visit=next_visit)

        return self._send_healthcare_txn(txn_key, batch_key, [claim_hex, event_hex, clinic_hex], [event_hex], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)
    def attend_procedures(self, claim_id, description, wait=None, auth_user=None,
                          auth_password=None):
        batch_key = txn_key = self._signer.get_public_key().as_hex()

        clinic_hex = helper.make_clinic_address(clinic_pkey=txn_key)
        claim_hex = helper.make_claim_address(claim_id=claim_id, clinic_pkey=txn_key)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id, clinic_pkey=txn_key, event_time=current_times_str)

        attend_procedures = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=txn_key,
            description=description,
            event_time=current_times_str)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.ATTEND_PROCEDURES,
            attend_procedures=attend_procedures)

        return self._send_healthcare_txn(txn_key, batch_key, [claim_hex, event_hex, clinic_hex], [event_hex], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)
    def eat_pills(self, claim_id, description, wait=None, auth_user=None,
                  auth_password=None):
        batch_key = txn_key = self._signer.get_public_key().as_hex()

        clinic_hex = helper.make_clinic_address(clinic_pkey=txn_key)
        address = helper.make_claim_address(claim_id=claim_id, clinic_pkey=txn_key)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id, clinic_pkey=txn_key, event_time=current_times_str)

        eat_pills = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=txn_key,
            description=description,
            event_time=current_times_str)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.EAT_PILLS,
            eat_pills=eat_pills)

        return self._send_healthcare_txn(txn_key, batch_key, [address, event_hex, clinic_hex], [event_hex], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)
    def assign_doctor(self, claim_id, doctor_pkey, wait=None, auth_user=None,
                      auth_password=None):
        batch_key = txn_key = self._signer.get_public_key().as_hex()

        clinic_hex = helper.make_clinic_address(clinic_pkey=txn_key)
        claim_hex = helper.make_claim_address(claim_id=claim_id, clinic_pkey=txn_key)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id, clinic_pkey=txn_key, event_time=current_times_str)

        assign = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=txn_key,
            description="Doctor pkey: {}, assigned to claim: {}".format(doctor_pkey, claim_hex),
            event_time=current_times_str)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.ASSIGN_DOCTOR,
            assign_doctor=assign)

        return self._send_healthcare_txn(txn_key, batch_key, [claim_hex, event_hex, clinic_hex], [event_hex], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)