コード例 #1
0
    def _store_clinic(self, public_key, name):
        address = helper.make_clinic_address(public_key)

        clinic = payload_pb2.CreateClinic()
        clinic.public_key = public_key
        clinic.name = name

        state_data = clinic.SerializeToString()
        self._context.set_state({address: state_data}, timeout=self.TIMEOUT)
コード例 #2
0
 def _load_clinic(self, public_key=None):
     clinic = None
     clinic_hex = [] if public_key is None else [
         helper.make_clinic_address(public_key)
     ]
     state_entries = self._context.get_state(clinic_hex,
                                             timeout=self.TIMEOUT)
     if state_entries:
         clinic = payload_pb2.CreateClinic()
         clinic.ParseFromString(state_entries[0].data)
     return clinic
コード例 #3
0
    def create_clinic(self, name, wait=None, auth_user=None, auth_password=None):
        batch_key = txn_key = self._signer.get_public_key().as_hex()

        address = helper.make_clinic_address(clinic_pkey=txn_key)

        clinic = payload_pb2.CreateClinic(
            public_key=txn_key,
            name=name)

        payload = payload_pb2.TransactionPayload(
            payload_type=payload_pb2.TransactionPayload.CREATE_CLINIC,
            create_clinic=clinic)

        return self._send_healthcare_txn(txn_key, batch_key, [address], [address], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)
コード例 #4
0
    def add_claim(self, claim_id, patient_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)

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

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

        return self._send_healthcare_txn(txn_key, batch_key, [claim_hex, clinic_hex], [claim_hex], payload,
                                         wait=wait,
                                         auth_user=auth_user,
                                         auth_password=auth_password)
コード例 #5
0
    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)
コード例 #6
0
    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)
コード例 #7
0
    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)
コード例 #8
0
    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)