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)
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)
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)
def create_clinic(self, txn_key, name): clinic = payload_pb2.CreateClinic( public_key=txn_key.get_public_key().as_hex(), name=name) payload = payload_pb2.TransactionPayload( payload_type=payload_pb2.TransactionPayload.CREATE_CLINIC, create_clinic=clinic) clinic_hex = helper.make_clinic_address( clinic_pkey=txn_key.get_public_key().as_hex()) batch, signature = self._create_txn_and_batch(txn_key, BATCH_KEY, [clinic_hex], [clinic_hex], payload) batch_list = batch_pb2.BatchList(batches=[batch]) self._client.send_batches(batch_list) return self._client.get_statuses([signature], wait=40)
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)