Exemplo n.º 1
0
def main():
    # ########additional Input GUI parameters and GUI call#########
    title = "COPATH.NLS PARSER"
    msg_fileopenbox = "Choose a *.txt file"
    file_type = "*.txt"
    file_extension = ".txt"
    msg_enterbox = "Enter the name for the project search\nDefault: ~\COPATHNLS_OUTPUT_"
    msg = "Select the Copath from were the NLIIa extracted"
    sites = ["JSON_CASES", "JSON_MRN"]
    choice_site = choicebox(msg, title, sites)
    if choice_site == "JSON_CASES":
        type_file = "cases"
    else:
        type_file = "mrn"
    openfile, out_dir = inputgui.inputstuff(title, msg_fileopenbox, file_type,
                                            file_extension, msg_enterbox)
    with open(openfile, "r+") as insect:
        total_json = insect.read()
    full_json = json.loads(total_json)
    if type_file == "cases":
        get_cases = copathhack_output_parsers.get_data_cases(full_json)
    else:
        get_cases = copathhack_output_parsers.get_data_cases(full_json)
    get_stuff.get_tabdelimited()
    long_ass_string_allcases = excel_crap(t)
    print(len(t))  #tabulator(new_dict)

    arr = [["/JSON_CASES_OUT.txt", t], ["/MRNs.txt", mrns],
           ["/TABDELIM_CASES_OUT.txt", long_ass_string_allcases]]
    for e in arr:
        outtext = out_dir + str(e[0])
        os.open(outtext, os.O_RDWR | os.O_CREAT)
        with open(outtext, "w+") as out:
            out.write(str(e[1]))
Exemplo n.º 2
0
def input_gui():
    msg = """
    This program will parse text files created from PDF dumps obtained from CoPath Natural Language Search IIa (no race).\n\n
    ________INSTRUCTIONS________\n
    1. When prompted, select a text file (*.txt) containing the dumped NLS\n
    2. Select directory were output will be saved\n
    2. Select the CoPath version (JMH or UM) used to obtain the original PDF\n
    3. Select the case types (letter of accessioning numbers) you want to parse\n
    4. Hold for a bit... results will be out in a few seconds.\n\n
    ___________OUTPUT___________\n
    1. Tab-delimited text file (/TABDELIM_CASES_OUT_(x=time serial).txt)\n
        a. STRUCTURE: SURG_NUM -> ACCESS_DATE -> SIGN_DATE -> SEX -> AGE -> NAME -> MRN -> DIAGNOSIS\n
    2. JSON formated file with SURG_NUMs as keys (/JSON_CASES_(x=time serial).txt)\n
        a.STRUCTURE: {SURG_NUM : [ACCESS_DATE, SIGN_DATE, SEX, AGE, NAME, MRN, DIAGNOSIS],...]],...}\n
    3. JSON formated file with MRNs as keys (/JSON_MRN_(x=time serial).txt)\n
        a.STRUCTURE: {MRN : [NAME, [[SURG_NUM, ACCESS_DATE, SIGN_DATE, SEX, AGE, DIAGNOSIS],...]],...}\n\n
    __________ABOUT_____________\n
    Source: https://github.com/gcampuzano14
    This free and open-source software\n\n
            """
    title = "COPATH.NLS!"
    btnchoices = ["Lets do it!", "Cancel"]
    intro = buttonbox(msg=msg, title=title, choices=btnchoices, image=None)
    if intro == "Lets do it!":
        pass
    else:
        quit()

    # ########additional Input GUI parameters and GUI call#########
    msg_fileopenbox = "Choose a *.txt file"
    file_type = "*.txt"
    file_extension = ".txt"
    msg_enterbox = "Enter the name for the project search\nDefault: ~\COPATHNLS_OUTPUT_"
    openfile, out_dir = inputgui.inputstuff(title, msg_fileopenbox, file_type,
                                            file_extension, msg_enterbox)

    msg = "Select the Copath from were the NLIIa extracted"
    sites = ["JMH Copath NLSIIa", "UM Copath NLSIIa"]

    choice_site = choicebox(msg, title, sites)
    if choice_site == "JMH Copath NLSIIa":
        specs = ["S", "US", "T", "C", "H", "M", "F", "A", "SS", "NS"]
    else:
        specs = ["US", "UT", "UB", "M", "UC"]

    msg = "Select all the specimen class letters that apply"
    choice_spec = multchoicebox(msg, title, specs)

    encryption = boolbox(msg='Do you want to encrypt output',
                         title=title,
                         choices=('Yes', 'No'),
                         image=None)

    return openfile, out_dir, choice_site, choice_spec, encryption
Exemplo n.º 3
0
def main():
    # ########additional Input GUI parameters and GUI call#########
    title = "COPATH.NLS PARSER"
    msg_fileopenbox = "Choose a *.txt file"
    file_type = "*.txt"
    file_extension = ".txt"
    msg_enterbox = "Enter the name for the project search\nDefault: ~\COPATHNLS_OUTPUT_"
    openfile, out_dir, savedir, filepath = inputgui.inputstuff(
        title, msg_fileopenbox, file_type, file_extension, msg_enterbox)
    output_file = os.path.join(out_dir, "casesout.txt")
    kwlist = ["acute", "leukemia"]
    mrnlist = os.path.join(filepath, "mrns.txt")
    with open(mrnlist, "r+") as mathclist:
        matchlist = mathclist.read().split(",")
    temp_list, remainder = parser(openfile, kwlist, matchlist)
    print "TOTAL CASES: " + str(len(temp_list))  # tabulator(new_dict)
    findstuff(temp_list, output_file, remainder)
Exemplo n.º 4
0
def main():
    # ########additional Input GUI parameters and GUI call#########
    title = "COPATH.NLS.HACK PARSER"
    msg_fileopenbox = "Choose a *.txt file"
    file_type = "*.txt"
    file_extension = ".txt"
    msg_enterbox = "Enter the name for the project search\nDefault: ~\COPATHNLS_OUTPUT_"
    openfile, out_dir = inputgui.inputstuff(title, msg_fileopenbox, file_type, file_extension, msg_enterbox)
    with open(openfile, "r+") as insect:
        total_mrn = insect.read()
    full_mrn = json.loads(total_mrn)
    patient_list, mrns = parser(full_mrn)
    long_ass_string_allcases = tabdelim_mrn(patient_list)
    print(len(patient_list))  # tabulator(new_dict)
    arr = [["/JSON_CASES_OUT.txt", patient_list], ["/MRNs.txt", mrns], ["/TABDELIM_CASES_OUT.txt", long_ass_string_allcases]]
    for e in arr:
        outtext = out_dir + str(e[0])
        os.open(outtext, os.O_RDWR | os.O_CREAT)
        with open(outtext, "w+") as out:
            out.write(str(e[1]))
Exemplo n.º 5
0
import re
import rsa
from rsa.bigfile import decrypt_bigfile
import inputgui
from easygui import enterbox

# compile executable: python -O D:\path_to\pyinstaller-2.0\pyinstaller.py --onefile COPATHNLSHACK_DECRYPTOR_v1.PY
# ########additional Input GUI parameters and GUI call#########
title = "COPATH.NLS DECRYPTOR"
msg_fileopenbox = "Choose an encrypted *.txt file\nRemember to grab private-key"
file_type = "*.txt"
file_extension = ".txt"
msg_enterbox = "Enter the name for the folder to save decrypted file\nDefault: ~\COPATHNLS_OUTPUT_"
inputfile, outdir = inputgui.inputstuff(title, msg_fileopenbox, file_type,
                                        file_extension, msg_enterbox)

pk = enterbox(msg='Enter Private Key.',
              title=' ',
              default='',
              strip=True,
              image=None,
              root=None)
pkelements = pk.split(",")
privkey = rsa.PrivateKey(int(pkelements[0]), int(pkelements[1]),
                         int(pkelements[2]), int(pkelements[3]),
                         int(pkelements[4]))

fileid = re.compile(".*CRYPTO_(.*)\.txt")

outfileex = fileid.match(inputfile)
output = outfileex.group(1)