- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STUPatientsRecords/PatientsRecords.py

Go to the documentation of this file.

    00001 """
    00002 * Copyright (c) 2009 Stanford University, School of Medicine All rights reserved.
    00003 *
    00004 * STANFORD ACADEMIC SOFTWARE LICENSE AGREEMENT
    00005 * FOR AngioLocalize SOURCE CODE:
    00006 *
    00007 * 1.    This is a legal agreement between you, RECIPIENT, and STANFORD UNIVERSITY.
    00008 *       By accepting, receiving, and using AngioLocalize.including any accompanying information, materials or
    00009 *       manuals (Program), you are agreeing to be bound by the terms of this Agreement.
    00010 *       If you do not agree to the terms of this Agreement, promptly return the Program to the STANFORD.
    00011
    00012 * 2.    STANFORD grants to RECIPIENT a royalty-free, nonexclusive, and nontransferable license to use the Program
    00013 *       and accompanying source code furnished hereunder, upon the terms and conditions set out below.
    00014 *       documentation and/or other materials provided with the distribution.
    00015 * 3.    RECIPIENT acknowledges that the Program is a research tool still in the development stage and that
    00016 *       it is being supplied as is, without any accompanying services, support or improvements from STANFORD.
    00017 * 4.    RECIPIENT agrees to use the Program solely for internal non-commercial purposes.
    00018 * 5.    RECIPIENT may create derivatives and further transfer the Program under the following terms and conditions:
    00019 *        A) Recipient agrees to not commercially exploit the Program and agrees all uses will be for non-commercial purposes; and,
    00020 *        B) Recipient may not mark any derivatives with the title of Program and may not to use iPad mark for any derivatives; and,
    00021 *        C) Recipient agrees to mark and acknowledge all derivatives as follows: "This is a derivative work based on AngioLocalize:
    00022 *           Frameless AVM localization with 2D Digital Subtraction Angiography (DSA) and 3D Rotational Angiography (DRA) Images developed
    00023 *           by Dimitre Hristov, Lina Liu.
    00024 *        D) Recipient agrees to make all improvements, enhancements and derivatives available under
    00025 *           similar terms and conditions to the research community.
    00026 * 6.    RECIPIENT warrants that RECIPIENT will not remove or export any part of the software or Program from the United
    00027 *       States except in full compliance with all United States and other applicable laws and regulations.
    00028 * 7.    RECIPIENT will use the Program in compliance with all applicable laws, policies and regulations including, but not
    00029 *       limited to, any approvals, informed consent and patient confidentiality principles.
    00030 * 8.    RECIPIENT will indemnify, hold harmless, and defend Stanford against any claim of any kind arising out of or
    00031 *       related to the exercise of any rights granted under this Agreement or the breach of this Agreement by RECIPIENT.
    00032 * 9.    Title and copyright to the Program and any associated documentation shall at all times remain with STANFORD,
    00033 *       and RECIPIENT agrees to preserve same.
    00034 """
    00035 #----------------------------------------------------------------------------------
    00036 ## @Macro module PatientsRecords
    00037 #
    00038 # \file    PatientsRecords.py
    00039 # \author  lina
    00040 # \date    2008-12-08
    00041 #
    00042 # User can create, delete patient records or view existing records
    00043 #
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047 from PythonQt import *
    00048
    00049
    00050 ## send a query to the Database and return the result set
    00051 def sendQuery(query):
    00052   ctx.field("DBConn.Statement").setValue(query);
    00053   dbModule = ctx.module("DBConn");
    00054   result = dbModule.call("sendQuery");
    00055   if (result == -1):
    00056     MLAB.logError("The following query to database failed. \n" + query + "\n.");
    00057   dbModule.call("close");
    00058   return result;
    00059
    00060 ## initDB is used to retrieve the data from patient records and show it
    00061 ## in a table.
    00062 def initDB():
    00063     myList = ctx.control("list");
    00064     myList.clearItems();
    00065     ##init DB
    00066     queryString = "select lastName, firstName, dateofBirth, sex, MRO from Patients;";
    00067     result = sendQuery(queryString);
    00068     if result == -1:
    00069       return;
    00070
    00071     for item in result:
    00072       lastName = item["lastname"];
    00073       firstName = item["firstname"];
    00074       DOB = item["dateofbirth"];
    00075       sex = "M";
    00076       if (item["sex"] == 1):
    00077         sex = "F";
    00078       MRO = item["mro"];
    00079       myList.insertItem([""+lastName, ""+firstName, ""+str(MRO), ""+str(DOB), ""+sex]);
    00080     if myList.currentItem() != None:
    00081       selectChanged();
    00082     MLAB.log("retrieve and display Patient Records.");
    00083
    00084 ## this function is called when the user change the selection on the patients'
    00085 ## record list
    00086 def selectChanged():
    00087   myList = ctx.control("list");
    00088   item = myList.selectedItem();
    00089   if item != None:
    00090     ctx.field("itemSelected").setValue(True);
    00091     ctx.field("itemSelected").touch();
    00092     currentPatient = item;
    00093     ctx.field("PatientsName").setValue(item.text(1) + " " + item.text(0));
    00094     ctx.field("PatientID").setValue(item.text(2));
    00095     ctx.field("PatientsBirthDate").setValue(item.text(3));
    00096     ctx.field("PatientsSex").setValue(item.text(4));
    00097
    00098     parentM = context.parent();
    00099     parentM.field("PatientsName").setValue(item.text(0) + "^" + item.text(1));
    00100     parentM.field("PatientID").setValue(item.text(2));
    00101     parentM.field("PatientsBirthDate").setValue(item.text(3));
    00102     parentM.field("PatientsSex").setValue(item.text(4));
    00103
    00104     title = "Patient: " + item.text(0) + "^" + item.text(1) + "   with MRO: " + item.text(2) + " DOB: " + item.text(3) + " " + item.text(4);
    00105     ctx.window().setTitle(title);
    00106     ctx.field("patientSelected").touch();
    00107     return;
    00108   else:
    00109    ctx.field("itemSelected").setValue(False);
    00110    ctx.field("patientSelected").touch();
    00111   resetValues();
    00112
    00113 ## reset the patient information
    00114 def resetValues():
    00115   ctx.field("PatientsName").setValue("");
    00116   ctx.field("PatientID").setValue("");
    00117   ctx.field("PatientsBirthDate").setValue("");
    00118   ctx.field("PatientsSex").setValue("");
    00119
    00120   parentM = context.parent();
    00121   parentM.field("PatientsName").setValue("");
    00122   parentM.field("PatientID").setValue("");
    00123   parentM.field("PatientsBirthDate").setValue("");
    00124   parentM.field("PatientsSex").setValue("");
    00125   ctx.window().setTitle("Angio-Localize angioLocalize");
    00126
    00127 ## this function sets the values in gender combo Box: Male or Female
    00128 def setItems():
    00129     ctx.control("genderBox").setItems(["M","F"]);
    00130
    00131 ## add the item to the listbox and Close dialog
    00132 def closeOk():
    00133     myList = ctx.control("list");
    00134     firstName = ctx.field("FirstName").value;
    00135     lastName = ctx.field("LastName").value;
    00136     MRO = ctx.field("MRO").value;
    00137     DOB = ctx.field("DOB").value;
    00138     if (DOB.isdigit() == False):
    00139       MLAB.showInformation("Make sure DOB's format is correct.", "", "MevisLab");
    00140       return;
    00141     gender = ctx.control("genderBox").currentText();
    00142     sex = 0;
    00143     if (gender == "F"):
    00144       sex = 1;
    00145     queryString = "INSERT INTO PATIENTS (PATIENTID, LASTNAME, FIRSTNAME, DATEOFBIRTH, SEX, MRO) VALUES(DEFAULT,";
    00146     queryString = queryString + "'" + lastName + "'" + "," + "'" + firstName + "'" + ",";
    00147     queryString = queryString + str(DOB) + "," + str(sex) + "," + "'" + str(MRO) + "'" + ");"
    00148     result = sendQuery(queryString);
    00149     if (result == -1):
    00150       MLAB.showInformation("The record cannot be saved. make sure MRO does not exist in database.", "", "MevisLab");
    00151       return;
    00152     showGender = "M";
    00153     if (gender == "F"):
    00154       showGender = "F";
    00155     myList.insertItem([""+lastName, ""+firstName, ""+MRO, ""+DOB, ""+showGender]);
    00156     closeCancel();
    00157
    00158 ## clear the patient record entry
    00159 def closeCancel():
    00160     ctx.field("FirstName").setValue("");
    00161     ctx.field("LastName").setValue("");
    00162     ctx.field("MRO").setValue("");
    00163     ctx.field("DOB").setValue("");
    00164     ctx.control("genderBox").setCurrentItem(0);
    00165
    00166 ## delete a patient in the database
    00167 def delete():
    00168     MRO = ctx.control("list").currentItem().text(2);
    00169     queryString = "DELETE FROM PATIENTS WHERE mro = '" + MRO + "'";
    00170     result = sendQuery(queryString);
    00171     if (result != -1):
    00172       ctx.control("list").removeItem(ctx.control("list").currentItem());
    00173     else:
    00174       MLAB.showInformation("The database operation deleting patient with MRO:" + ctx.control("list").currentItem().text(2) + " failed.", "", "MLAB");
    00175     deletePatientInFile(MRO);
    00176     selectChanged();
    00177
    00178 ## show Help
    00179 def helpOnCreate():
    00180     # Here is the framework for entering help information
    00181     ctx.showHtmlHelp();
    00182 #//# MeVis signature v1
    00183 #//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
    00184 #//# owner: MeVis
    00185 #//# date: 2009-06-10T04:12:25
    00186 #//# hash: vHSfj+Qt8xrIkDVP4W0Rep0YH6a3+MySa0+Cs+AoqEK/IbB+f5szwmyVTENOjzz/JEgm2t31FtHmUUMFcQg5VQ==
    00187 #//# MeVis end
    00188

All Classes Namespaces Files Functions Variables Enumerator Friends