Ejemplo n.º 1
0
def upgrade(tool):
    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        # The currently installed version is more recent than the target
        # version of this upgradestep
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Required because of a mismatch between the view and workflow states
    # selector in Analysis Services view. See @93109be
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    # Remove indexes no longer used as per @daf57e3 and PR#307
    ut.delIndexAndColumn('bika_setup_catalog', 'getSortKey')
    ut.delIndexAndColumn('bika_setup_catalog', 'sortKey')

    # Add sortable_title index in analyses catalog, so analyses get sorted
    # automatically based on the same rules as Analysis Services do (PR#307):
    #   sortkey + title ascending
    ut.addIndex(CATALOG_ANALYSIS_LISTING, 'sortable_title', 'FieldIndex')
    ut.refreshCatalogs()

    # Do nothing, we just only want the profile version to be 1.0.0
    logger.info("{0} upgraded to version {1}".format(product, version))
    return True
Ejemplo n.º 2
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # -------- ADD YOUR STUFF HERE --------
    ut.delIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatient')
    ut.delIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctor')

    ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientID')
    ut.addIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientTitle',
                         'FieldIndex')

    # In case if upgrade was already run after PR #72 got accepted
    ut.delColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientURL')
    ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getPatientURL')
    ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getClientPatientID')
    ut.addIndexAndColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorTitle',
                         'FieldIndex')

    # In case if upgrade was already run after PR #72 got accepted
    ut.delColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorURL')
    ut.addColumn(CATALOG_ANALYSIS_REQUEST_LISTING, 'getDoctorURL')
    ut.addIndex(CATALOG_PATIENTS, 'listing_searchable_text', 'TextIndexNG3')
    ut.refreshCatalogs()
    logger.info("{0} upgraded to version {1}".format(product, version))

    return True
Ejemplo n.º 3
0
def upgrade(tool):
    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        # The currently installed version is more recent than the target
        # version of this upgradestep
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Required because of a mismatch between the view and workflow states
    # selector in Analysis Services view. See @93109be
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    # Remove indexes no longer used as per @daf57e3 and PR#307
    ut.delIndexAndColumn('bika_setup_catalog', 'getSortKey')
    ut.delIndexAndColumn('bika_setup_catalog', 'sortKey')

    # Add sortable_title index in analyses catalog, so analyses get sorted
    # automatically based on the same rules as Analysis Services do (PR#307):
    #   sortkey + title ascending
    ut.addIndex(CATALOG_ANALYSIS_LISTING, 'sortable_title', 'FieldIndex')
    ut.refreshCatalogs()

    # Do nothing, we just only want the profile version to be 1.0.0
    logger.info("{0} upgraded to version {1}".format(product, version))
    return True
Ejemplo n.º 4
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Required to make filtering by department in worksheets work
    ut.addIndex(CATALOG_WORKSHEET_LISTING, 'getDepartmentUIDs', 'KeywordIndex')
    # Required by https://github.com/senaite/senaite.core/issues/683
    ut.addIndexAndColumn('bika_catalog', 'getBatchUIDs', 'KeywordIndex')
    # Required by https://github.com/senaite/senaite.core/pulls/752
    ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getDateAnalysisPublished')

    ut.refreshCatalogs()

    # % Error subfield is meaningless in result ranges. Also, the system was
    # calculating the %Error based on the result (not based on the range), so
    # the shoulder from the left was always smaller than the shoulder from the
    # right. One could argue that this could be fixed easily by using the length
    # of the valid range to compute the shoulders by using the %error. Again,
    # this is a weak solution, cause in some cases the scale of the range might
    # be exponential, logaritmic (e.g. pH). Also, the sensitivity of the test
    # may differ when the result falls in one end or another. Thus, is for the
    # best interest of the labmanger to be able to set the shoulders (and
    # therefore, when the warnings must show up) manually.
    # See PR#694
    remove_error_subfield_from_analysis_specs(portal, ut)

    # Reindex ReferenceAnalysis because of Calculation and Interims fields have
    # been added to Controls and Blanks. Until now, only routine analyses allowed
    # Calculations and Interim fields
    # Required by https://github.com/senaite/senaite.core/issues/735
    reindex_reference_analysis(portal, ut)

    # reload type profiles so that the fix for
    # https://github.com/senaite/senaite.core/issues/590
    # becomes effective
    setup = portal.portal_setup
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    logger.info("{0} upgraded to version {1}".format(product, version))

    return True
Ejemplo n.º 5
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    ut.addIndex(CATALOG_PATIENTS, 'getClientPatientID', 'FieldIndex')
    ut.refreshCatalogs()

    logger.info("{0} upgraded to version {1}".format(product, version))

    return True
Ejemplo n.º 6
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    ut.addIndex(CATALOG_PATIENTS, 'getClientPatientID', 'FieldIndex')
    ut.refreshCatalogs()

    logger.info("{0} upgraded to version {1}".format(product, version))

    return True
Ejemplo n.º 7
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    setup = portal.portal_setup
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        # The currently installed version is more recent than the target
        # version of this upgradestep
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Convert ReferenceField's values into UIDReferenceFields.
    UpgradeReferenceFields()

    # Calculations not triggered in manage results view
    # https://github.com/senaite/bika.lims/issues/355
    # Since we've already migrated the ReferenceField DependentServices from
    # Calculation (with relation name 'CalculationAnalysisService' above, this
    # wouldn't be strictly necessary, but who knows... maybe we've lost the
    # at_references too, so just do it.
    fix_broken_calculations()

    # Backward compatibility with < 1.0.0
    RemoveARPriorities(portal)
    RemoveVersionableTypes()
    handle_AS_wo_category(portal)
    migrateFileFields(portal)

    # Indexes and colums were changed as per
    # https://github.com/senaite/bika.lims/pull/353
    ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestUID')
    ut.addIndex(CATALOG_ANALYSIS_LISTING, 'getRequestUID', 'FieldIndex')
    ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestURL')
    ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestTitle')
    ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestURL')
    ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestTitle')
    ut.reindexIndex(CATALOG_ANALYSIS_LISTING, 'getPrioritySortkey')
    ut.refreshCatalogs()

    return True
Ejemplo n.º 8
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    setup = portal.portal_setup
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        # The currently installed version is more recent than the target
        # version of this upgradestep
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Convert ReferenceField's values into UIDReferenceFields.
    UpgradeReferenceFields()

    # Calculations not triggered in manage results view
    # https://github.com/senaite/bika.lims/issues/355
    # Since we've already migrated the ReferenceField DependentServices from
    # Calculation (with relation name 'CalculationAnalysisService' above, this
    # wouldn't be strictly necessary, but who knows... maybe we've lost the
    # at_references too, so just do it.
    fix_broken_calculations()

    # Backward compatibility with < 1.0.0
    RemoveARPriorities(portal)
    RemoveVersionableTypes()
    handle_AS_wo_category(portal)
    migrateFileFields(portal)

    # Indexes and colums were changed as per
    # https://github.com/senaite/bika.lims/pull/353
    ut.delIndex(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestUID')
    ut.addIndex(CATALOG_ANALYSIS_LISTING, 'getRequestUID', 'FieldIndex')
    ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestURL')
    ut.delColumn(CATALOG_ANALYSIS_LISTING, 'getAnalysisRequestTitle')
    ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestURL')
    ut.addColumn(CATALOG_ANALYSIS_LISTING, 'getRequestTitle')
    ut.reindexIndex(CATALOG_ANALYSIS_LISTING, 'getPrioritySortkey')
    ut.refreshCatalogs()

    return True
Ejemplo n.º 9
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # Required to make filtering by department in worksheets work
    ut.addIndex(CATALOG_WORKSHEET_LISTING, 'getDepartmentUIDs', 'KeywordIndex')
    ut.refreshCatalogs()

    logger.info("{0} upgraded to version {1}".format(product, version))

    return True
Ejemplo n.º 10
0
def upgrade(tool):
    portal = aq_parent(aq_inner(tool))
    ut = UpgradeUtils(portal)
    ufrom = ut.getInstalledVersion(product)
    if ut.isOlderVersion(product, version):
        logger.info('Skipping upgrade of {0}: {1} > {2}'.format(
            product, ufrom, version))
        # The currently installed version is more recent than the target
        # version of this upgradestep
        return True

    logger.info('Upgrading {0}: {1} -> {2}'.format(product, ufrom, version))

    # Add index for LIMS-2082 to allow analyses to be correctly filtered by
    # instrument in worksheet/add_analyses
    ut.addIndex('bika_analysis_catalog', 'getAllowedInstrumentUIDs',
                'KeywordIndex')

    # Refresh affected catalogs
    ut.refreshCatalogs()

    logger.info("{0} upgraded to version {1}".format(product, version))
    return True
Ejemplo n.º 11
0
def upgrade(tool):
    portal = tool.aq_inner.aq_parent
    ut = UpgradeUtils(portal)
    ver_from = ut.getInstalledVersion(product)

    if ut.isOlderVersion(product, version):
        logger.info("Skipping upgrade of {0}: {1} > {2}".format(
            product, ver_from, version))
        return True

    logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version))

    # -------- ADD YOUR STUFF HERE --------

    # Lab Managers can not remove Analyses in "Manage Analyses" form
    fix_permission_on_analysisrequests()

    # Traceback when submitting duplicate when Duplicate Variation is not set
    # Walkthrough all analyses and analyses services and set 0.00 value for
    # DuplicateVariation if returns None
    # https://github.com/senaite/senaite.core/issues/768
    fix_duplicate_variation_nonfloatable_values()

    # Analyses submission in Worksheets is slow
    # Remove "_LatestReferenceAnalyses" ReferenceField. Is not used anymore,
    # https://github.com/senaite/senaite.core/pull/776
    del_at_refs('InstrumentLatestReferenceAnalyses')

    # Make searches in Analysis Request listings faster
    # https://github.com/senaite/senaite.core/pull/771
    ut.addIndex(CATALOG_ANALYSIS_REQUEST_LISTING, "listing_searchable_text",
                "TextIndexNG3")

    ut.refreshCatalogs()
    logger.info("{0} upgraded to version {1}".format(product, version))

    return True