bartcant / DAML-Covid19

DAML implementation for Covid-19 State Surveillance System
0 stars 2 forks source link

Python Bot for updating TestResult from "Pending" to "Negative" #63

Closed bartcant closed 3 years ago

bartcant commented 4 years ago

scenario

Precondition:

  1. Citizen (Alice) has requested CovidTest with HealthClinic

  2. Testing for Covid Appointment has been scheduled

  3. Novant Healthclinic logs in

  4. Go to Covid19Test

  5. Selects DAML contract for Alice

  6. Enter the information and submits "TestResult" is "Pending" Note : This will trigger a Verifiable Credential to Alice Mobile phone

New requirement

a Python Bot initiates an automatic Update to the Covid19Test Contract and updates the "TestResult" to "Negative" The phyton code triggers a new "DAML Choice" on the Covid19Test Contract

Something like this

nonconsuming UpdateCovid19Test : ContractId Covid19Test
        with
         newcovid19testdata : Covid19testdata

        do  
          archive self
          create this with covid19testdata = newcovid19testdata

Please note that all the Covid19Testdata stays the same, except testresult is updated to "Negative"

  testdate : Date      
  healthclinic: Party 
  citizen: Party
  statehealth: Party
  testtype: Text
  testnumber: Int
  testresult: Testresult
  locationstate: Locationstate
   deriving (Eq, Show)

After the DAML contract is updated, this should now trigger a second Verifiable Credential with the updated TestResult

bartcant commented 3 years ago

I am getting the following error

python python_bot/bot.py File "python_bot/bot.py", line 24 async def bot_ready(event): ^ SyntaxError: invalid syntax

bartcant commented 3 years ago

Previous item has been resolved by upgrading to Python 3.8

bartcant commented 3 years ago

Now I am seeing continuous activity on the output log which I killed after a few seconds

[ INFO] 2020-09-29 11:38:17,036 | root | [on_updated] [ INFO] 2020-09-29 11:38:17,037 | root | 00f9a7ae145cc94323ee7265d0f13dbe7888b25c00813422a385ab37c5dc469f61 [ INFO] 2020-09-29 11:38:17,037 | root | None [ INFO] 2020-09-29 11:38:17,037 | root | [on_message] [ INFO] 2020-09-29 11:38:17,037 | root | 003f39e2e1c8174d70cd09ec7fa050034441d65f50b84d1fb615df75665e45caf6 [ INFO] 2020-09-29 11:38:17,038 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:17,038 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:17,040 | dazl | cmd submit: party Operator, workflow_id '9715686', command_id '6174c20', 1 command: '[<exercise "Up...f75665e45caf6>]' [ INFO] 2020-09-29 11:38:17,557 | dazl | Processing transaction: 00000000000001060000000000000000, 9715686772734a71a30b4f66cfbee2ad, 6174c20c62074e59938c2077b2f9c120 [ INFO] 2020-09-29 11:38:17,557 | root | [on_updated] [ INFO] 2020-09-29 11:38:17,557 | root | 003f39e2e1c8174d70cd09ec7fa050034441d65f50b84d1fb615df75665e45caf6 [ INFO] 2020-09-29 11:38:17,557 | root | None [ INFO] 2020-09-29 11:38:17,557 | root | [on_message] [ INFO] 2020-09-29 11:38:17,557 | root | 00fa8331f72f0f93795b4d9e8728d87f0909014e428bca7479e930bc5167ce2b9f [ INFO] 2020-09-29 11:38:17,557 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:17,557 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:17,557 | dazl | cmd submit: party Operator, workflow_id '910a907', command_id 'a7d805a', 1 command: '[<exercise "Up...0bc5167ce2b9f>]' [ INFO] 2020-09-29 11:38:18,056 | dazl | Processing transaction: 00000000000001070000000000000000, 910a907ea1ea464b9b89f254fc1923c1, a7d805a20bce4ab89b21822154d31da0 [ INFO] 2020-09-29 11:38:18,056 | root | [on_updated] [ INFO] 2020-09-29 11:38:18,056 | root | 00fa8331f72f0f93795b4d9e8728d87f0909014e428bca7479e930bc5167ce2b9f [ INFO] 2020-09-29 11:38:18,056 | root | None [ INFO] 2020-09-29 11:38:18,056 | root | [on_message] [ INFO] 2020-09-29 11:38:18,056 | root | 00e9e04a6d675a3f24a8b46276b55840dc3ad63a3c4d918537cc53662a0e9ce50c [ INFO] 2020-09-29 11:38:18,056 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:18,056 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:18,071 | dazl | cmd submit: party Operator, workflow_id '18aa5a9', command_id 'c886250', 1 command: '[<exercise "Up...3662a0e9ce50c>]' [ INFO] 2020-09-29 11:38:18,577 | dazl | Processing transaction: 00000000000001080000000000000000, 18aa5a96c28b4edcb6d368935d455f08, c88625030c6d4b49a28a0f5e3845d891 [ INFO] 2020-09-29 11:38:18,579 | root | [on_updated] [ INFO] 2020-09-29 11:38:18,580 | root | 00e9e04a6d675a3f24a8b46276b55840dc3ad63a3c4d918537cc53662a0e9ce50c [ INFO] 2020-09-29 11:38:18,580 | root | None [ INFO] 2020-09-29 11:38:18,580 | root | [on_message] [ INFO] 2020-09-29 11:38:18,580 | root | 0031a0bc77ec56ebecb53cc28f21cc708911f758e0d6734d2a84a3acb191b6fa40 [ INFO] 2020-09-29 11:38:18,581 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:18,581 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:18,583 | dazl | cmd submit: party Operator, workflow_id '5548b6d', command_id 'e0eb8d8', 1 command: '[<exercise "Up...3acb191b6fa40>]' [ INFO] 2020-09-29 11:38:19,107 | dazl | Processing transaction: 00000000000001090000000000000000, 5548b6d90f514b55952f9534c9970805, e0eb8d80d71e453a88287a586092bf6a [ INFO] 2020-09-29 11:38:19,107 | root | [on_updated] [ INFO] 2020-09-29 11:38:19,108 | root | 0031a0bc77ec56ebecb53cc28f21cc708911f758e0d6734d2a84a3acb191b6fa40 [ INFO] 2020-09-29 11:38:19,108 | root | None [ INFO] 2020-09-29 11:38:19,108 | root | [on_message] [ INFO] 2020-09-29 11:38:19,109 | root | 0008ab5156911acc5d8a0e1e4d98d6d8484c3e42daf4b207587790ac9abe2fe6da [ INFO] 2020-09-29 11:38:19,109 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:19,109 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:19,112 | dazl | cmd submit: party Operator, workflow_id 'e043fd8', command_id '22662fc', 1 command: '[<exercise "Up...0ac9abe2fe6da>]' [ INFO] 2020-09-29 11:38:19,628 | dazl | Processing transaction: 000000000000010a0000000000000000, e043fd84adfc4833b817d22bc4d6525c, 22662fc519f64f0b94c1e472eba63d8d [ INFO] 2020-09-29 11:38:19,628 | root | [on_updated] [ INFO] 2020-09-29 11:38:19,628 | root | 0008ab5156911acc5d8a0e1e4d98d6d8484c3e42daf4b207587790ac9abe2fe6da [ INFO] 2020-09-29 11:38:19,628 | root | None [ INFO] 2020-09-29 11:38:19,628 | root | [on_message] [ INFO] 2020-09-29 11:38:19,628 | root | 008bc346d1afcaae3854a61d45dbca2e87063fbb1ea10690f7f8cbc4059afe42ba [ INFO] 2020-09-29 11:38:19,628 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:19,628 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:19,628 | dazl | cmd submit: party Operator, workflow_id 'a2b820a', command_id 'c2b2d4c', 1 command: '[<exercise "Up...bc4059afe42ba>]' [ INFO] 2020-09-29 11:38:20,160 | dazl | Processing transaction: 000000000000010b0000000000000000, a2b820a4008f4299806c2803c29ac730, c2b2d4c7e0d642b18907fdf924b79a6d [ INFO] 2020-09-29 11:38:20,160 | root | [on_updated] [ INFO] 2020-09-29 11:38:20,160 | root | 008bc346d1afcaae3854a61d45dbca2e87063fbb1ea10690f7f8cbc4059afe42ba [ INFO] 2020-09-29 11:38:20,160 | root | None [ INFO] 2020-09-29 11:38:20,160 | root | [on_message] [ INFO] 2020-09-29 11:38:20,160 | root | 0022c6868c22254e3199f626e509103186c479909a263b22aaa74edb86ce334847 [ INFO] 2020-09-29 11:38:20,160 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:20,160 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:20,160 | dazl | cmd submit: party Operator, workflow_id '73c983b', command_id 'a58a555', 1 command: '[<exercise "Up...edb86ce334847>]' [ INFO] 2020-09-29 11:38:20,695 | dazl | Processing transaction: 000000000000010c0000000000000000, 73c983b29e32449d85357d3360cdc0ba, a58a555b40c74beda0a59723c531d6df [ INFO] 2020-09-29 11:38:20,695 | root | [on_updated] [ INFO] 2020-09-29 11:38:20,695 | root | 0022c6868c22254e3199f626e509103186c479909a263b22aaa74edb86ce334847 [ INFO] 2020-09-29 11:38:20,695 | root | None [ INFO] 2020-09-29 11:38:20,695 | root | [on_message] [ INFO] 2020-09-29 11:38:20,695 | root | 00c9ee1517de14e0acbdd391082811eab02207f84746f2f962d44a7b0a7546d5cf [ INFO] 2020-09-29 11:38:20,695 | root | {'covid19testdata': {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'}, 'healthclinic': 'Novant', 'citizen': 'Alice', 'operator': 'Operator', 'statehealth': 'NCHealth'} [ INFO] 2020-09-29 11:38:20,695 | root | {'testdate': datetime.date(2020, 10, 1), 'healthclinic': 'Novant', 'citizen': 'Alice', 'statehealth': 'NCHealth', 'testtype': 'Covid', 'testnumber': 121, 'testresult': 'Negative', 'locationstate': 'NC'} [ INFO] 2020-09-29 11:38:20,695 | dazl | cmd submit: party Operator, workflow_id 'e2c1064', command_id '53911fa', 1 command: '[<exercise "Up...a7b0a7546d5cf>]' Traceback (most recent call last): File "python_bot/bot.py", line 52, in main() File "python_bot/bot.py", line 49, in main network.run_forever() File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\dazl\client\api.py", line 315, in run_forever self._impl.invoker.loop.run_until_complete(self.aio_run(*coroutines)) File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 603, in run_until_complete self.run_forever() File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\windows_events.py", line 316, in run_forever super().run_forever() File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 570, in run_forever self._run_once() File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 1823, in _run_once event_list = self._selector.select(timeout) File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\windows_events.py", line 434, in select self._poll(timeout) File "C:\Users\bartc\AppData\Local\Programs\Python\Python38-32\lib\asyncio\windows_events.py", line 783, in _poll status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms) KeyboardInterrupt

bartcant commented 3 years ago

Issue is working fine now