{ "cells": [ { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using: /home/studen/.labkey/astuden/astuden.crt\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3/dist-packages/urllib3/connection.py:391: SubjectAltNameWarning: Certificate for merlin.fmf.uni-lj.si has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "User: andrej studen CSRF: 52cd68383b7a832e93e7d9b5801002e5\n" ] } ], "source": [ "import sys\n", "import os\n", "import SimpleITK\n", "import numpy\n", "import matplotlib.pyplot\n", "import chardet\n", "import json\n", "sys.path.append(os.path.join(os.path.expanduser('~'),'software','src','nixSuite','wrapper'))\n", "import nixWrapper\n", "nixWrapper.loadLibrary('labkeyInterface')\n", "import labkeyInterface\n", "net=labkeyInterface.labkeyInterface()\n", "fconfig=os.path.join(os.path.expanduser('~'),'.labkey','network.json')\n", "net.init(fconfig)\n", "print('Using: {}'.format(net.connectionConfig['SSL']['user']))\n", "net.getCSRF()\n", "import labkeyFileBrowser\n", "sys.path.append(os.getcwd())\n", "fb=labkeyFileBrowser.labkeyFileBrowser(net)\n", "project='iPNUMMretro/Study'\n", "import labkeyDatabaseBrowser\n", "db=labkeyDatabaseBrowser.labkeyDB(net)\n", "ds=db.selectRows(project,'study','ClinicalData',[])\n", "patients=[row['PatientId'] for row in ds['rows']]\n" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3/dist-packages/urllib3/connection.py:391: SubjectAltNameWarning: Certificate for merlin.fmf.uni-lj.si has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "User: andrej studen CSRF: da3766ebe339095e3a6098173e1021be\n", "User: andrej studen CSRF: f6a2f89d2f85bab544539a2a6369623f\n", "User: andrej studen CSRF: 9f326c3dcb4b44d6a7e5ab4f8a7ad8e5\n", "NIX-LJU-D2002-IRAE-A002: Row 1 Could not convert 'Brez simptomov' for field pneumonitisDate, should be of type Timestamp\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3/dist-packages/urllib3/connection.py:391: SubjectAltNameWarning: Certificate for merlin.fmf.uni-lj.si has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "User: andrej studen CSRF: 23dc8fd59e280d53b02bbe070154ddfd\n", "User: andrej studen CSRF: a5262b1412a1eee7c4b89b1125cae433\n", "User: andrej studen CSRF: 43860ad987c603df25731d108a6f8001\n", "User: andrej studen CSRF: af866c8085460ff91530b735e3c736dd\n", "User: andrej studen CSRF: 24f34a00e4376366740efe2e187fa4e2\n", "User: andrej studen CSRF: 933ce18a272115a2183d751a91dba4e3\n", "User: andrej studen CSRF: cf62df2f5e93ae8f4585e1180edd81d2\n", "User: andrej studen CSRF: 35fbfe403566416581defd2efb709fba\n", "User: andrej studen CSRF: f73fbbe1e541cd5ede1ff09b7f5807be\n", "User: andrej studen CSRF: 882aac6ea404860faab770ae320df827\n", "User: andrej studen CSRF: bfdb52f52cae66c27d88d93dc2dbe2bf\n", "User: andrej studen CSRF: 3c48c8bec64e886deb27ee07d7f100c7\n", "NIX-LJU-D2002-IRAE-A014: Row 1 Could not convert '2 (bolj gradus 1)' for field colitisGrade, should be of type Integer\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3/dist-packages/urllib3/connection.py:391: SubjectAltNameWarning: Certificate for merlin.fmf.uni-lj.si has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "User: andrej studen CSRF: 753d6094324a2cf7b0c2183a58efc7f5\n", "User: andrej studen CSRF: f062199d4b6f0ae27c79ae8419d14d78\n", "User: andrej studen CSRF: 008a3f6d93aa90095b3583f755820351\n", "User: andrej studen CSRF: afdb1f8aaf40d60beaba5b3bdb7a1e5e\n", "User: andrej studen CSRF: eaf924935c314c9e900ee44e4cfbc01f\n", "User: andrej studen CSRF: a4bbb057b0b857b171f1d64df73f4ece\n", "User: andrej studen CSRF: 762f91b1c9d5660a47e9db009c5ef3dd\n", "User: andrej studen CSRF: b4bf09d3c6253cf1778cf469ae44e835\n", "User: andrej studen CSRF: efb18145b40fc1f1bd11eb1453d29eef\n", "User: andrej studen CSRF: 850ae1edf1e364273f7a61a115e3a6b1\n", "User: andrej studen CSRF: b776dca81c5e8a4229c1cfaf9271e14a\n", "User: andrej studen CSRF: 8beff4a7833d3ab9038e39b03e10a6ce\n", "User: andrej studen CSRF: 9ff9519885f76f6915d9882745416f3c\n", "User: andrej studen CSRF: 6d04cf5aa9301790c5f88f358f016954\n", "User: andrej studen CSRF: e6340e8bded2d34150a4c897288477af\n", "User: andrej studen CSRF: 351d0f95a8414060f042fd76a6668417\n" ] } ], "source": [ "rows=ds['rows']\n", "for row in rows:\n", " idFilter={'variable':'PatientId','value':row['PatientId'],'oper':'eq'}\n", " dsQ=db.selectRows(project,'study','ClinicalDataInternational',[idFilter])\n", " \n", " if len(dsQ['rows'])==0:\n", " fields=['PatientId','SequenceNum']\n", " qrow={f:row[f] for f in fields}\n", " mode='insert' \n", " else:\n", " qrow=dsQ['rows'][0]\n", " mode='update'\n", " \n", " copyFields=['itStartAge']\n", " for f in copyFields:\n", " qrow[f]=row[f]\n", " \n", " if row['sex']==0:\n", " qrow['gender']=1\n", " if row['sex']==1:\n", " qrow['gender']=2\n", " qrow['aeStartDate']=row['aeIdentificationDate']\n", " \n", " if row['origoCode']==0:\n", " qrow['melanomaPrimaryAnatomicSite']=3\n", " if row['origoCode']==1:\n", " qrow['melanomaPrimaryAnatomicSite']=1\n", " if row['origoCode']==2:\n", " qrow['melanomaPrimaryAnatomicSite']=2\n", " if row['origoCode']==3:\n", " qrow['melanomaPrimaryAnatomicSite']=4\n", " \n", " qrow['psECOGStartIT']=row['psAtITIntroduction']\n", " if row['mutations']==0:\n", " qrow ['actionableMutation']=1\n", " if row['mutations']==1:\n", " qrow ['actionableMutation']=2\n", " if row['mutations']==2:\n", " qrow ['actionableMutation']=3\n", " if row['mutations']==3:\n", " qrow ['actionableMutation']=4\n", " if row['mutations']==9:\n", " qrow ['actionableMutation']=5\n", " \n", " qrow['itTreatmentSetting']=2\n", " qrow['itStartDate']=row['itStart']\n", " qrow['firstITStartDate']=row['itStart']\n", " \n", " if row['bora']==0:#CR\n", " qrow ['bestResponse']=4\n", " if row['bora']==1:#PR\n", " qrow ['bestResponse']=2 #radiographic response\n", " if row['bora']==2:#SD\n", " qrow ['bestResponse']=3 #mixed radiographic response\n", " if row['bora']==9:#PD\n", " qrow ['bestResponse']=1\n", " \n", " if row['pneumonitis']==0:\n", " qrow['pneumonitisGrade']=7\n", " else:\n", " qrow['pneumonitisGrade']=row['pneumonitis']\n", " qrow['pneumonitisDate']=row['aeIdentificationDate']\n", " \n", " \n", " if row['diarrhea']==\"0\":\n", " qrow['colitisGrade']=7\n", " else:\n", " qrow['colitisGrade']=row['diarrhea']\n", " qrow['colitisDate']=row['aeIdentificationDate']\n", " \n", " \n", " if row['hypotirosis']==0:\n", " qrow['thyroiditisGrade']=7\n", " else:\n", " qrow['thyroiditisGrade']=row['hypotirosis']\n", " qrow['thyroiditisDate']=row['aeIdentificationDate']\n", " \n", " \n", " if row['sistemicKS']==0:\n", " qrow['immunosupressionFlag']=2\n", " if row['sistemicKS']==1:\n", " qrow['immunosupressionFlag']=1\n", " \n", " qrow['firstITInfusionDate']=row['itStart']\n", " qrow['itLine']=2\n", " #qrow['durationOfCurrentIT']=\n", " \n", " statusResponse=db.modifyRows(mode,project,'study','ClinicalDataInternational',[qrow])\n", " encoding=chardet.detect(statusResponse)['encoding']\n", " status=json.loads(statusResponse.decode(encoding))\n", " try:\n", " print('{}: {}'.format(row['PatientId'],status['exception']))\n", " except KeyError:\n", " pass\n", " #qrow['itType']=\n", "\n", " " ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{}:{} NIX-LJU-D2002-IRAE-A014 True\n", "User: andrej studen CSRF: 14eef5230ef9055ca662e626545b47a3\n" ] } ], "source": [ "dset='ClinicalDataInternational'\n", "#dset='Imaging1'\n", "idFilter={'variable':'PatientId','value':'NIX-LJU-D2002-IRAE-A014','oper':'eq'}\n", "ds=db.selectRows(project,'study',dset,[idFilter])\n", "\n", "rows=ds['rows']\n", "for row in rows:\n", " print('{}:{}',row['PatientId'],row['valid'])\n", " row['valid']=0\n", " db.modifyRows('update',project,'study',dset,[row]) \n", " " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3/dist-packages/urllib3/connection.py:391: SubjectAltNameWarning: Certificate for merlin.fmf.uni-lj.si has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A000\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: e6ddccd420b2c45a98f4448be951ccef\n", "DA\n", "NE\n", "N/A\n", "ID: NIX-LJU-D2002-IRAE-A001\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 9e7dbdb1cdac31d0864826f400101393\n", "DA\n", "DA\n", "DA\n", "ID: NIX-LJU-D2002-IRAE-A002\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 1\n", "User: andrej studen CSRF: c0bbc36da5070408e01f64bab3080f1b\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A003\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: e7ca4b3cd6c8d27d543fff197b90a032\n", "DA\n", "DA\n", "DA\n", "ID: NIX-LJU-D2002-IRAE-A004\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 1\n", "User: andrej studen CSRF: fa458a4c0e96331402bdd87f8a7f710a\n", "NE?\n", "?\n", "N/A\n", "ID: NIX-LJU-D2002-IRAE-A005\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 59fb9bedb5feef9f13b413f6c8c5df38\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A006\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 58159ae265b106dd58482a3712cc4d7a\n", "DA\n", "NE\n", "N/A\n", "ID: NIX-LJU-D2002-IRAE-A007\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: d183cf6807cc174b9938c50af7e02cf4\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A008\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: f0c31176678928d65da70372149b6526\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A009\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 88dac5d71b7c07b8d81a24a63ce42988\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A010\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 5681d301d8ae4f91211f0a809d161dc4\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A011\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: d55c8dc31a662a73ecf05f8e5db480d9\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A012\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: dc01e50e6657c46e98953eefca1ebf45\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A013\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: c7436d74e009397cbde3617e504dbbb4\n", "DA\n", "NE\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A014\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 8dad9e03f6e363ca3203d1e6fa331a6a\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A015\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 13d60528591a5ee6bf769e5377a75a40\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A016\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 08f475ab641d385e7d41627fd0009aba\n", "DA\n", "DA\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A017\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: b97cdd281b69c27093080fe96fe5dfb3\n", "DA\n", "NE\n", "N/A\n", "ID: NIX-LJU-D2002-IRAE-A018\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 681751b836021ac4b9823468b0d567b4\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A019\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 46bdbb07c59514955ef84ccd34fc9349\n", "DA\n", "DA\n", "DA\n", "ID: NIX-LJU-D2002-IRAE-A020\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 1\n", "User: andrej studen CSRF: 1bb520ede2c623366a00e51d0c716cbd\n", "DA\n", "DA\n", "DA\n", "ID: NIX-LJU-D2002-IRAE-A021\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 1\n", "User: andrej studen CSRF: b218a6de9bbf877d662dc97a0e8aad7c\n", "NE?\n", "NE\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A021\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 6057ac8cf59a41bb4363ec935884a95b\n", "DA\n", "DA\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A022\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: c388fa864554c83d0fd3774f14a7a76d\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A023\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 0dd3c771579e964cc9f30d36e2c76be9\n", "NE?\n", "?\n", "N/A\n", "ID: NIX-LJU-D2002-IRAE-A024\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 675b2897a02eb1e4aa400d4cfd362605\n", "?\n", "NE\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A025\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: eccd25fec46ab30e9c663469cfdc5dae\n", "DA\n", "DA\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A026\n", "petDetectedAE: 1\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: cc46e5322f1a0118a140756345ca26f8\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A027\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: afdb95dcf8e9a7ebf37890d082bf18d7\n", "DA- hepatalna fleksura?\n", "DA\n", "NE\n", "ID: NIX-LJU-D2002-IRAE-A028\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 1\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 10fc4b1aa9f13aea658b41faede0b857\n", "None\n", "None\n", "None\n", "ID: NIX-LJU-D2002-IRAE-A029\n", "petDetectedAE: 2\n", "earlyPETAEDetection: 2\n", "petRelatedAction: 2\n", "User: andrej studen CSRF: 1b70124a2a0ca3e3f36bd084b4da0033\n" ] } ], "source": [ "rows=ds['rows']\n", "for row in rows:\n", " idFilter={'variable':'PatientId','value':row['PatientId'],'oper':'eq'}\n", " dsQ=db.selectRows(project,'study','ClinicalDataInternational',[idFilter])\n", " \n", " vals={'petDetectedAE':2,'earlyPETAEDetection':2,'petRelatedAction':2}#No\n", " for v in vals:\n", " print(row[v])\n", " if row[v]=='DA':\n", " vals[v]=1 #Yes\n", " for qrow in dsQ['rows']:\n", " print('ID: {}'.format(qrow['PatientId']))\n", " for v in vals:\n", " qrow[v]=vals[v]\n", " print('{}: {}'.format(v,qrow[v]))\n", " db.modifyRows('update',project,'study','ClinicalDataInternational',[qrow]) \n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }