Skip to content
Snippets Groups Projects
test.ipynb 4.39 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "code",
   "metadata": {},
   "outputs": [],
   "source": [
    "from memory_db import InMemoryDatabase\n",
    "from utils import populate_tables\n",
    "import csv\n",
    "import constants\n",
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "outputs": [],
   "source": [
    "db = InMemoryDatabase()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor = db.connection.cursor()\n",
    "query = 'SELECT * FROM test_results;'\n",
    "cursor.execute(query)\n",
    "cursor.fetchall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "conn.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor = db.connection.cursor()\n",
    "query = 'SELECT * FROM test_results;'\n",
    "cursor.execute(query)\n",
    "cursor.fetchall()"
   "metadata": {},
   "outputs": [],
   "source": [
    "db.insert_patient('822825', 29, 'f')\n",
    "db.insert_patient('16318', 42, 'm')\n",
    "db.insert_patient('440673', 67, 'f')"
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('822825', 29, 'f', '2024-01-01 06:12:00', 68.58),\n",
       " ('822825', 29, 'f', '2024-01-09 10:48:00', 70.58),\n",
       " ('822825', 29, 'f', '2024-01-09 14:20:00', 64.15),\n",
       " ('822825', 29, 'f', '2024-01-10 17:29:00', 48.39),\n",
       " ('822825', 29, 'f', '2024-01-17 06:27:00', 58.01),\n",
       " ('822825', 29, 'f', '2024-01-23 17:55:00', 85.93)]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db.get_patient_history('822825')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('16318', 42, 'm', '16318', '2024-01-01 09:47:00', 64.44),\n",
       " ('16318', 42, 'm', '16318', '2024-01-04 16:35:00', 1070423.72)]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db.get_patient_history('16318')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('440673', 67, 'f', '440673', '2024-01-01 10:47:00', 69.18),\n",
       " ('440673', 67, 'f', '440673', '2024-01-01 12:43:00', 83.32),\n",
       " ('440673', 67, 'f', '440673', '2024-01-05 13:04:00', 84.87),\n",
       " ('440673', 67, 'f', '440673', '2024-01-05 15:47:00', 76.07)]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db.get_patient_history('440673')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "db.discharge_patient('16318')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# db.persist_db()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "db.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}