Пример #1
0
def process_formulary(pricetable_persist_path, formulary_md_path, output_filename_list, screen_output, verbose_debug=False):
    # Load updated pricetable
    pricetable = read_pricetable(pricetable_persist_path)

    # Processing formulary
    print('\nProcessing Formulary Markdown...')
    formularylist = fh.read_md(str(formulary_md_path))
    formularyparsed = fh.parse_mddata(formularylist)

    print('Number of EHHapp formulary medications: {}'.format(len(formularyparsed)))
    screen_output.append(['Number of EHHapp formulary medications',len(formularyparsed)])

    if verbose_debug:
        print('Extracted Formulary Entries:')
        print(formularyparsed[0])
        for i in range(0,4):
            print('from Formulary: NAME:{} DOSECOST:{}'.format(fh.FormularyRecord(formularyparsed[i]).NAME,
                                                               fh.FormularyRecord(formularyparsed[i]).DOSECOST))

    formulary = fh.store_formulary(formularyparsed)

    # Updating Formulary Against Invoice
    print('\nFinding Matches...')
    mcount, pricechanges, updatedformulary, updatedpricetable, softmatch, pricetable_unmatched_meds, fuzzymatches =\
        formulary_update_from_pricetable(formulary, pricetable)

    print('Number of partial medication matches: {}'.format(softmatch))
    screen_output.append(['Number of partial medication matches',softmatch])

    print('Number of medication matches: {}'.format(mcount))
    screen_output.append(['Number of medication matches',mcount])

    print('Number of EHHapp formulary price changes: {}'.format(pricechanges))
    screen_output.append(['Number of EHHapp formulary price changes',pricechanges])

    print('Number of invoice medications without match: {}'.format(len(pricetable_unmatched_meds)))
    screen_output.append(['Number of invoice medications without match',len(pricetable_unmatched_meds)])

    if verbose_debug:
        print('Number of invoice medications without match')
        for med in pricetable_unmatched_meds:
            print(med)

        for i in range(0,4):
            print('updated Formulary markdown: {}'.format(updatedformulary[i]._to_markdown()))

    # Test BLACKLISTED attribute
    blacklisted = [d for d in updatedformulary if d.BLACKLISTED]

    print('Number of blacklisted drugs: {}'.format(len(blacklisted)))
    screen_output.append(['Number of blacklisted drugs',len(blacklisted)])

    # Save updated pricetable
    write_pricetable(updatedpricetable, pricetable_persist_path)
    write_pricetable

    return pricetable_unmatched_meds, output_filename_list, screen_output, fuzzymatches
Пример #2
0
def process_formulary(pricetable_persist_path, formulary_md_path, output_filename_list, screen_output, verbose_debug=False):
    # Load updated pricetable
    pricetable = read_pricetable(pricetable_persist_path)

    # Processing formulary
    print('\nProcessing Formulary Markdown...')
    formularylist = fh.read_md(str(formulary_md_path))
    formularyparsed = fh.parse_mddata(formularylist)

    print('Number of EHHapp formulary medications: {}'.format(len(formularyparsed)))
    screen_output.append(['Number of EHHapp formulary medications',len(formularyparsed)])

    if verbose_debug:
        print('Extracted Formulary Entries:')
        print(formularyparsed[0])
        for i in range(0,4):
            print('from Formulary: NAME:{} DOSECOST:{}'.format(fh.FormularyRecord(formularyparsed[i]).NAME,
                                                               fh.FormularyRecord(formularyparsed[i]).DOSECOST))

    formulary = fh.store_formulary(formularyparsed)

    # Updating Formulary Against Invoice
    print('\nFinding Matches...')
    mcount, pricechanges, updatedformulary, updatedpricetable, softmatch, pricetable_unmatched_meds, fuzzymatches =\
        formulary_update_from_pricetable(formulary, pricetable)

    print('Number of partial medication matches: {}'.format(softmatch))
    screen_output.append(['Number of partial medication matches',softmatch])

    print('Number of medication matches: {}'.format(mcount))
    screen_output.append(['Number of medication matches',mcount])

    print('Number of EHHapp formulary price changes: {}'.format(pricechanges))
    screen_output.append(['Number of EHHapp formulary price changes',pricechanges])

    print('Number of invoice medications without match: {}'.format(len(pricetable_unmatched_meds)))
    screen_output.append(['Number of invoice medications without match',len(pricetable_unmatched_meds)])

    if verbose_debug:
        print('Number of invoice medications without match')
        for med in pricetable_unmatched_meds:
            print(med)

        for i in range(0,4):
            print('updated Formulary markdown: {}'.format(updatedformulary[i]._to_markdown()))

    # Test BLACKLISTED attribute
    blacklisted = [d for d in updatedformulary if d.BLACKLISTED]

    print('Number of blacklisted drugs: {}'.format(len(blacklisted)))
    screen_output.append(['Number of blacklisted drugs',len(blacklisted)])

    # Save updated pricetable
    write_pricetable(updatedpricetable, pricetable_persist_path)
    write_pricetable

    return pricetable_unmatched_meds, output_filename_list, screen_output, fuzzymatches
Пример #3
0
def process_usermatches(usermatches, formulary_md_path, pricetable_unmatched_meds, pricetable_persist_path,
                        pricetable_output_path, output_filename_list, screen_output):
    # Load updated pricetable
    pricetable = read_pricetable(pricetable_persist_path)

    # Process FileIO
    formulary_md_filename = formulary_md_path.split('/')[-1]  # Remove directory from filename
    formulary_md_filename_no_extension = formulary_md_filename.split('.', 1)[0]

    current_script_path = os.path.realpath(__file__)[:-len('/rxparse.py')]

    formulary_update_rm_path = current_script_path+'/output/'+formulary_md_filename_no_extension+'_UPDATED.markdown'
    output_filename_list.append(formulary_md_filename_no_extension+'_UPDATED.markdown')
    formulary_update_tsv_path = current_script_path+'/output/'+formulary_md_filename_no_extension+'_UPDATED.tsv'
    output_filename_list.append(formulary_md_filename_no_extension+'_UPDATED.tsv')

    # Processing formulary
    print('\nProcessing Formulary Markdown...')
    formularylist = fh.read_md(str(formulary_md_path))
    formularyparsed = fh.parse_mddata(formularylist)
    formulary = fh.store_formulary(formularyparsed)

    updatedpricetable, updatedformulary, newmcount, newpricechanges, pricetable_unmatched_meds= formulary_update_from_usermatches(formulary, pricetable, pricetable_unmatched_meds, usermatches)

    # Save updated formulary as markdown and tsv
    formulary_to_markdown(updatedformulary, formulary_update_rm_path)
    formulary_to_tsv(updatedformulary, formulary_update_tsv_path)

    print(updatedpricetable)
    # Save updated pricetable
    write_pricetable(updatedpricetable, pricetable_persist_path)
    write_pricetable(updatedpricetable, pricetable_output_path)

    # Update screen outputs
    screen_output[4][1] = screen_output[4][1] + newmcount  # Number of matches
    screen_output[5][1] = screen_output[5][1] + newpricechanges  # Number of price changes
    screen_output[6][1] = screen_output[6][1] - newmcount  # Number of unmatched invoice entries

    return pricetable_unmatched_meds, screen_output
Пример #4
0
def process_usermatches(usermatches, formulary_md_path, pricetable_unmatched_meds, pricetable_persist_path,
                        pricetable_output_path, output_filename_list, screen_output):
    # Load updated pricetable
    pricetable = read_pricetable(pricetable_persist_path)

    # Process FileIO
    formulary_md_filename = formulary_md_path.split('/')[-1]  # Remove directory from filename
    formulary_md_filename_no_extension = formulary_md_filename.split('.', 1)[0]

    current_script_path = os.path.realpath(__file__)[:-len('/rxparse.py')]

    formulary_update_rm_path = current_script_path+'/output/'+formulary_md_filename_no_extension+'_UPDATED.markdown'
    output_filename_list.append(formulary_md_filename_no_extension+'_UPDATED.markdown')
    formulary_update_tsv_path = current_script_path+'/output/'+formulary_md_filename_no_extension+'_UPDATED.tsv'
    output_filename_list.append(formulary_md_filename_no_extension+'_UPDATED.tsv')

    # Processing formulary
    print('\nProcessing Formulary Markdown...')
    formularylist = fh.read_md(str(formulary_md_path))
    formularyparsed = fh.parse_mddata(formularylist)
    formulary = fh.store_formulary(formularyparsed)

    updatedpricetable, updatedformulary, newmcount, newpricechanges, pricetable_unmatched_meds= formulary_update_from_usermatches(formulary, pricetable, pricetable_unmatched_meds, usermatches)

    # Save updated formulary as markdown and tsv
    formulary_to_markdown(updatedformulary, formulary_update_rm_path)
    formulary_to_tsv(updatedformulary, formulary_update_tsv_path)

    print(updatedpricetable)
    # Save updated pricetable
    write_pricetable(updatedpricetable, pricetable_persist_path)
    write_pricetable(updatedpricetable, pricetable_output_path)

    # Update screen outputs
    screen_output[4][1] = screen_output[4][1] + newmcount  # Number of matches
    screen_output[5][1] = screen_output[5][1] + newpricechanges  # Number of price changes
    screen_output[6][1] = screen_output[6][1] - newmcount  # Number of unmatched invoice entries

    return pricetable_unmatched_meds, screen_output