コード例 #1
0
    def next_visit(self, txn_key, claim_id, doctor_pkey):
        clinic_pkey = txn_key.get_public_key().as_hex()
        clinic_hex = helper.make_clinic_address(clinic_pkey=clinic_pkey)
        claim_hex = helper.make_claim_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey,
                                              event_time=current_times_str)

        next_visit = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=clinic_pkey,
            description="Doctor: {}, completed next visit for claim: {}".
            format(doctor_pkey, claim_hex),
            event_time=current_times_str)

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

        batch, signature = self._create_txn_and_batch(
            txn_key, BATCH_KEY, [claim_hex, event_hex, clinic_hex],
            [event_hex], payload)

        batch_list = batch_pb2.BatchList(batches=[batch])

        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=80)
コード例 #2
0
    def assign_doctor(self, txn_key, claim_id, doctor_pkey):
        clinic_pkey = txn_key.get_public_key().as_hex()
        clinic_hex = helper.make_clinic_address(clinic_pkey=clinic_pkey)
        claim_hex = helper.make_claim_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey,
                                              event_time=current_times_str)

        assign = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=clinic_pkey,
            description="Doctor: {}, 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)

        batch, signature = self._create_txn_and_batch(
            txn_key, BATCH_KEY, [claim_hex, event_hex, clinic_hex],
            [event_hex], payload)

        batch_list = batch_pb2.BatchList(batches=[batch])

        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=80)
コード例 #3
0
    def eat_pills(self, txn_key, claim_id):
        clinic_pkey = txn_key.get_public_key().as_hex()
        clinic_hex = helper.make_clinic_address(clinic_pkey=clinic_pkey)
        claim_hex = helper.make_claim_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey)
        current_times_str = str(time.time())
        event_hex = helper.make_event_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey,
                                              event_time=current_times_str)

        pills = payload_pb2.ActionOnClaim(
            claim_id=claim_id,
            clinic_pkey=clinic_pkey,
            description="Eat pills in scope of claim: {}".format(claim_hex),
            event_time=current_times_str)

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

        batch, signature = self._create_txn_and_batch(
            txn_key, BATCH_KEY, [claim_hex, event_hex, clinic_hex],
            [event_hex], payload)

        batch_list = batch_pb2.BatchList(batches=[batch])

        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=80)
コード例 #4
0
    def create_claim(self, txn_key, claim_id, patient_pkey):
        clinic_pkey = txn_key.get_public_key().as_hex()
        clinic_hex = helper.make_clinic_address(clinic_pkey=clinic_pkey)
        claim_hex = helper.make_claim_address(claim_id=claim_id,
                                              clinic_pkey=clinic_pkey)

        claim = payload_pb2.CreateClaim(claim_id=claim_id,
                                        clinic_pkey=clinic_pkey,
                                        patient_pkey=patient_pkey)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.CREATE_CLAIM,
            create_claim=claim)

        batch, signature = self._create_txn_and_batch(txn_key, BATCH_KEY,
                                                      [claim_hex, clinic_hex],
                                                      [claim_hex], payload)

        batch_list = batch_pb2.BatchList(batches=[batch])

        self._client.send_batches(batch_list)
        return self._client.get_statuses([signature], wait=40)