Esempio n. 1
0
 def Import(self):
     print "EOOO"
     s_t = ''
     c_t = 'lab'
     bucket = {}
     pc = getToolByName(self.context, 'portal_catalog')
     bsc = getToolByName(self.context, 'bika_setup_catalog')
     # collect up all values into the bucket
     for row in self.get_rows(3):
         c_t = row['Client_title'] if row['Client_title'] else 'lab'
         if c_t not in bucket:
             bucket[c_t] = {}
         s_t = row['SampleType_title'] if row['SampleType_title'] else s_t
         if s_t not in bucket[c_t]:
             bucket[c_t][s_t] = []
         service = bsc(portal_type='AnalysisService', title=row['service'])
         if not service:
             service = bsc(portal_type='AnalysisService',
                           getKeyword=row['service'])
         try:
             service = service[0].getObject()
             bucket[c_t][s_t].append({
             'keyword': service.getKeyword(),
             'min': row.get('min','0'),
             'max': row.get('max','0'),
             'minpanic': row.get('minpanic','0'),
             'maxpanic': row.get('maxpanic','0'),
             'error': row.get('error','0'),
             })
         except IndexError:
             warning = "Error with service name %s on sheet %s. Service not uploaded."
             logger.warning(warning, row.get('service', ''), self.sheetname)
     # write objects.
     for c_t in bucket:
         if c_t == 'lab':
             folder = self.context.bika_setup.bika_analysisspecs
         else:
             folder = pc(portal_type='Client', title=c_t)
             if (not folder or len(folder) != 1):
                 logger.warn("Client %s not found. Omiting client specifications." % c_t)
                 continue
             folder = folder[0].getObject()
         for s_t in bucket[c_t]:
             resultsrange = bucket[c_t][s_t]
             sampletype = bsc(portal_type='SampleType', title=s_t)[0]
             _id = folder.invokeFactory('AnalysisSpec', id=tmpID())
             obj = folder[_id]
             obj.edit(
                 title=sampletype.Title,
                 ResultsRange=resultsrange)
             obj.setSampleType(sampletype.UID)
             obj.unmarkCreationFlag()
             renameAfterCreation(obj)
Esempio n. 2
0
def setup_health_catalogs(portal):
    # an item should belong to only one catalog.
    # that way looking it up means first looking up *the* catalog
    # in which it is indexed, as well as making it cheaper to index.
    def addIndex(cat, *args):
        try:
            cat.addIndex(*args)
        except:
            pass

    def addColumn(cat, col):
        try:
            cat.addColumn(col)
        except:
            pass

    logger.info("Setup catalogs ...")

    # bika_catalog
    bc = getToolByName(portal, 'bika_catalog', None)
    if not bc:
        logger.warning('Could not find the bika_catalog tool.')
        return
    addIndex(bc, 'getClientTitle', 'FieldIndex')
    addIndex(bc, 'getPatientID', 'FieldIndex')
    addIndex(bc, 'getPatientUID', 'FieldIndex')
    addIndex(bc, 'getPatientTitle', 'FieldIndex')
    addIndex(bc, 'getDoctorID', 'FieldIndex')
    addIndex(bc, 'getDoctorUID', 'FieldIndex')
    addIndex(bc, 'getDoctorTitle', 'FieldIndex')
    addIndex(bc, 'getClientPatientID', 'FieldIndex')
    addColumn(bc, 'getClientTitle')
    addColumn(bc, 'getPatientID')
    addColumn(bc, 'getPatientUID')
    addColumn(bc, 'getPatientTitle')
    addColumn(bc, 'getDoctorID')
    addColumn(bc, 'getDoctorUID')
    addColumn(bc, 'getDoctorTitle')
    addColumn(bc, 'getClientPatientID')

    # portal_catalog
    pc = getToolByName(portal, 'portal_catalog', None)
    if not pc:
        logger.warning('Could not find the portal_catalog tool.')
        return
    addIndex(pc, 'getDoctorID', 'FieldIndex')
    addIndex(pc, 'getDoctorUID', 'FieldIndex')
    addIndex(pc, 'getPrimaryReferrerUID', 'FieldIndex')
    addColumn(pc, 'getDoctorID')
    addColumn(pc, 'getDoctorUID')

    # bika_setup_catalog
    bsc = getToolByName(portal, 'bika_setup_catalog', None)
    if not bsc:
        logger.warning('Could not find the bika_setup_catalog tool.')
        return
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Disease', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('AetiologicAgent', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Treatment', ['bika_setup_catalog'])
    at.setCatalogsByType('Symptom', ['bika_setup_catalog'])
    at.setCatalogsByType('Drug', ['bika_setup_catalog'])
    at.setCatalogsByType('DrugProhibition', ['bika_setup_catalog'])
    at.setCatalogsByType('VaccinationCenter', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('InsuranceCompany', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Immunization', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseStatus', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseOutcome', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('IdentifierType', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseSyndromicClassification', ['bika_setup_catalog'])
    at.setCatalogsByType('Ethnicity', [
        'bika_setup_catalog',
    ])

    addIndex(bsc, 'getGender', 'FieldIndex')
    addColumn(bsc, 'getGender')

    catalog_definitions_lims_health = getCatalogDefinitionsLIMS()
    catalog_definitions_lims_health.update(getCatalogDefinitionsHealth())
    # Updating health catalogs if there is any change in them
    setup_catalogs(portal,
                   catalog_definitions_lims_health,
                   catalogs_extension=getCatalogExtensions())

    logger.info("Setup catalogs [DONE]")
Esempio n. 3
0
def setupHealthCatalogs(context):
    # an item should belong to only one catalog.
    # that way looking it up means first looking up *the* catalog
    # in which it is indexed, as well as making it cheaper to index.

    if context.readDataFile('bika.health.txt') is None:
        return
    portal = context.getSite()

    def addIndex(cat, *args):
        try:
            cat.addIndex(*args)
        except:
            pass

    def addColumn(cat, col):
        try:
            cat.addColumn(col)
        except:
            pass

    # create lexicon
    wordSplitter = Empty()
    wordSplitter.group = 'Word Splitter'
    wordSplitter.name = 'Unicode Whitespace splitter'
    caseNormalizer = Empty()
    caseNormalizer.group = 'Case Normalizer'
    caseNormalizer.name = 'Unicode Case Normalizer'
    stopWords = Empty()
    stopWords.group = 'Stop Words'
    stopWords.name = 'Remove listed and single char words'
    elem = [wordSplitter, caseNormalizer, stopWords]
    zc_extras = Empty()
    zc_extras.index_type = 'Okapi BM25 Rank'
    zc_extras.lexicon_id = 'Lexicon'

    # bika_catalog
    bc = getToolByName(portal, 'bika_catalog', None)
    if bc == None:
        logger.warning('Could not find the bika_catalog tool.')
        return
    addIndex(bc, 'getClientTitle', 'FieldIndex')
    addIndex(bc, 'getPatientID', 'FieldIndex')
    addIndex(bc, 'getPatientUID', 'FieldIndex')
    addIndex(bc, 'getPatientTitle', 'FieldIndex')
    addIndex(bc, 'getDoctorID', 'FieldIndex')
    addIndex(bc, 'getDoctorUID', 'FieldIndex')
    addIndex(bc, 'getDoctorTitle', 'FieldIndex')
    addIndex(bc, 'getClientPatientID', 'FieldIndex')
    addColumn(bc, 'getClientTitle')
    addColumn(bc, 'getPatientID')
    addColumn(bc, 'getPatientUID')
    addColumn(bc, 'getPatientTitle')
    addColumn(bc, 'getDoctorID')
    addColumn(bc, 'getDoctorUID')
    addColumn(bc, 'getDoctorTitle')
    addColumn(bc, 'getClientPatientID')

    # portal_catalog
    pc = getToolByName(portal, 'portal_catalog', None)
    if pc == None:
        logger.warning('Could not find the portal_catalog tool.')
        return
    addIndex(pc, 'getDoctorID', 'FieldIndex')
    addIndex(pc, 'getDoctorUID', 'FieldIndex')
    addColumn(pc, 'getDoctorID')
    addColumn(pc, 'getDoctorUID')

    # bika_setup_catalog
    bsc = getToolByName(portal, 'bika_setup_catalog', None)
    if bsc == None:
        logger.warning('Could not find the bika_setup_catalog tool.')
        return
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Disease', ['bika_setup_catalog', ])
    at.setCatalogsByType('AetiologicAgent', ['bika_setup_catalog', ])
    at.setCatalogsByType('Treatment', ['bika_setup_catalog'])
    at.setCatalogsByType('Symptom', ['bika_setup_catalog'])
    at.setCatalogsByType('Drug', ['bika_setup_catalog'])
    at.setCatalogsByType('DrugProhibition', ['bika_setup_catalog'])
    at.setCatalogsByType('VaccinationCenter', ['bika_setup_catalog', ])
    at.setCatalogsByType('InsuranceCompany', ['bika_setup_catalog', ])
    at.setCatalogsByType('Immunization', ['bika_setup_catalog', ])
    at.setCatalogsByType('CaseStatus', ['bika_setup_catalog', ])
    at.setCatalogsByType('CaseOutcome', ['bika_setup_catalog', ])
    at.setCatalogsByType('EpidemiologicalYear', ['bika_setup_catalog', ])
    at.setCatalogsByType('IdentifierType', ['bika_setup_catalog', ])
    at.setCatalogsByType('CaseSyndromicClassification', ['bika_setup_catalog', ])
    at.setCatalogsByType('Ethnicity', ['bika_setup_catalog', ])

    addIndex(bsc,'getGender', 'FieldIndex')
    addColumn(bsc,'getGender')

    # bika_patient_catalog
    bpc = getToolByName(portal, 'bika_patient_catalog', None)
    if bpc == None:
        logger.warning('Could not find the bika_patient_catalog tool.')
        return
    bpc.manage_addProduct['ZCTextIndex'].manage_addLexicon('Lexicon', 'Lexicon', elem)
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Patient', ['bika_patient_catalog'])
    addIndex(bpc, 'path', 'ExtendedPathIndex', ('getPhysicalPath'))
    addIndex(bpc, 'allowedRolesAndUsers', 'KeywordIndex')
    addIndex(bpc, 'UID', 'FieldIndex')
    addIndex(bpc, 'Title', 'ZCTextIndex', zc_extras)
    addIndex(bpc, 'Description', 'ZCTextIndex', zc_extras)
    addIndex(bpc, 'id', 'FieldIndex')
    addIndex(bpc, 'getId', 'FieldIndex')
    addIndex(bpc, 'Type', 'FieldIndex')
    addIndex(bpc, 'portal_type', 'FieldIndex')
    addIndex(bpc, 'created', 'DateIndex')
    addIndex(bpc, 'Creator', 'FieldIndex')
    addIndex(bpc, 'getObjPositionInParent', 'GopipIndex')
    addIndex(bpc, 'sortable_title', 'FieldIndex')
    addIndex(bpc, 'review_state', 'FieldIndex')
    addIndex(bpc, 'getPatientID', 'FieldIndex')
    addIndex(bpc, 'getClientPatientID', 'FieldIndex')
    addIndex(bpc, 'getPrimaryReferrerUID', 'FieldIndex')
    addIndex(bpc, 'getGender', 'FieldIndex')
    addIndex(bpc, 'getAgeSplittedStr', 'FieldIndex')
    addIndex(bpc, 'getPrimaryReferrerTitle', 'FieldIndex')
    addIndex(bpc, 'getCitizenship', 'FieldIndex')
    addIndex(bpc, 'getBirthDate', 'DateIndex')
    addIndex(bpc, 'inactive_state', 'FieldIndex')
    addColumn(bpc, 'id')
    addColumn(bpc, 'UID')
    addColumn(bpc, 'Title')
    addColumn(bpc, 'Type')
    addColumn(bpc, 'portal_type')
    addColumn(bpc, 'sortable_title')
    addColumn(bpc, 'Description')
    addColumn(bpc, 'getPatientID')
    addColumn(bpc, 'getClientPatientID')
    addColumn(bpc, 'getPrimaryReferrerUID')
    addColumn(bpc, 'review_state')
    addColumn(bpc, 'inactive_state')
Esempio n. 4
0
def setupHealthCatalogs(context):
    # an item should belong to only one catalog.
    # that way looking it up means first looking up *the* catalog
    # in which it is indexed, as well as making it cheaper to index.

    if context.readDataFile('bika.health.txt') is None:
        return
    portal = context.getSite()

    def addIndex(cat, *args):
        try:
            cat.addIndex(*args)
        except:
            pass

    def addColumn(cat, col):
        try:
            cat.addColumn(col)
        except:
            pass

    # create lexicon
    wordSplitter = Empty()
    wordSplitter.group = 'Word Splitter'
    wordSplitter.name = 'Unicode Whitespace splitter'
    caseNormalizer = Empty()
    caseNormalizer.group = 'Case Normalizer'
    caseNormalizer.name = 'Unicode Case Normalizer'
    stopWords = Empty()
    stopWords.group = 'Stop Words'
    stopWords.name = 'Remove listed and single char words'
    elem = [wordSplitter, caseNormalizer, stopWords]
    zc_extras = Empty()
    zc_extras.index_type = 'Okapi BM25 Rank'
    zc_extras.lexicon_id = 'Lexicon'

    # bika_catalog
    bc = getToolByName(portal, 'bika_catalog', None)
    if bc == None:
        logger.warning('Could not find the bika_catalog tool.')
        return
    addIndex(bc, 'getClientTitle', 'FieldIndex')
    addIndex(bc, 'getPatientID', 'FieldIndex')
    addIndex(bc, 'getPatientUID', 'FieldIndex')
    addIndex(bc, 'getPatientTitle', 'FieldIndex')
    addIndex(bc, 'getDoctorID', 'FieldIndex')
    addIndex(bc, 'getDoctorUID', 'FieldIndex')
    addIndex(bc, 'getDoctorTitle', 'FieldIndex')
    addIndex(bc, 'getClientPatientID', 'FieldIndex')
    addColumn(bc, 'getClientTitle')
    addColumn(bc, 'getPatientID')
    addColumn(bc, 'getPatientUID')
    addColumn(bc, 'getPatientTitle')
    addColumn(bc, 'getDoctorID')
    addColumn(bc, 'getDoctorUID')
    addColumn(bc, 'getDoctorTitle')
    addColumn(bc, 'getClientPatientID')

    # portal_catalog
    pc = getToolByName(portal, 'portal_catalog', None)
    if pc == None:
        logger.warning('Could not find the portal_catalog tool.')
        return
    addIndex(pc, 'getDoctorID', 'FieldIndex')
    addIndex(pc, 'getDoctorUID', 'FieldIndex')
    addColumn(pc, 'getDoctorID')
    addColumn(pc, 'getDoctorUID')

    # bika_setup_catalog
    bsc = getToolByName(portal, 'bika_setup_catalog', None)
    if bsc == None:
        logger.warning('Could not find the bika_setup_catalog tool.')
        return
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Disease', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('AetiologicAgent', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Treatment', ['bika_setup_catalog'])
    at.setCatalogsByType('Symptom', ['bika_setup_catalog'])
    at.setCatalogsByType('Drug', ['bika_setup_catalog'])
    at.setCatalogsByType('DrugProhibition', ['bika_setup_catalog'])
    at.setCatalogsByType('VaccinationCenter', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('InsuranceCompany', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Immunization', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseStatus', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseOutcome', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('EpidemiologicalYear', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('IdentifierType', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseSyndromicClassification', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Ethnicity', [
        'bika_setup_catalog',
    ])

    addIndex(bsc, 'getGender', 'FieldIndex')
    addColumn(bsc, 'getGender')

    catalog_definitions_lims_health = getCatalogDefinitionsLIMS()
    catalog_definitions_lims_health.update(getCatalogDefinitionsHealth())
    # Updating health catalogs if there is any change in them
    setup_catalogs(portal,
                   catalog_definitions_lims_health,
                   catalogs_extension=getCatalogExtensions())
Esempio n. 5
0
def setupHealthCatalogs(context):
    # an item should belong to only one catalog.
    # that way looking it up means first looking up *the* catalog
    # in which it is indexed, as well as making it cheaper to index.

    if context.readDataFile('bika.health.txt') is None:
        return
    portal = context.getSite()

    def addIndex(cat, *args):
        try:
            cat.addIndex(*args)
        except:
            pass

    def addColumn(cat, col):
        try:
            cat.addColumn(col)
        except:
            pass

    # create lexicon
    wordSplitter = Empty()
    wordSplitter.group = 'Word Splitter'
    wordSplitter.name = 'Unicode Whitespace splitter'
    caseNormalizer = Empty()
    caseNormalizer.group = 'Case Normalizer'
    caseNormalizer.name = 'Unicode Case Normalizer'
    stopWords = Empty()
    stopWords.group = 'Stop Words'
    stopWords.name = 'Remove listed and single char words'
    elem = [wordSplitter, caseNormalizer, stopWords]
    zc_extras = Empty()
    zc_extras.index_type = 'Okapi BM25 Rank'
    zc_extras.lexicon_id = 'Lexicon'

    # bika_catalog
    bc = getToolByName(portal, 'bika_catalog', None)
    if bc == None:
        logger.warning('Could not find the bika_catalog tool.')
        return
    addIndex(bc, 'getClientTitle', 'FieldIndex')
    addIndex(bc, 'getPatientID', 'FieldIndex')
    addIndex(bc, 'getPatientUID', 'FieldIndex')
    addIndex(bc, 'getPatientTitle', 'FieldIndex')
    addIndex(bc, 'getDoctorID', 'FieldIndex')
    addIndex(bc, 'getDoctorUID', 'FieldIndex')
    addIndex(bc, 'getDoctorTitle', 'FieldIndex')
    addIndex(bc, 'getClientPatientID', 'FieldIndex')
    addColumn(bc, 'getClientTitle')
    addColumn(bc, 'getPatientID')
    addColumn(bc, 'getPatientUID')
    addColumn(bc, 'getPatientTitle')
    addColumn(bc, 'getDoctorID')
    addColumn(bc, 'getDoctorUID')
    addColumn(bc, 'getDoctorTitle')
    addColumn(bc, 'getClientPatientID')

    # portal_catalog
    pc = getToolByName(portal, 'portal_catalog', None)
    if pc == None:
        logger.warning('Could not find the portal_catalog tool.')
        return
    addIndex(pc, 'getDoctorID', 'FieldIndex')
    addIndex(pc, 'getDoctorUID', 'FieldIndex')
    addColumn(pc, 'getDoctorID')
    addColumn(pc, 'getDoctorUID')

    # bika_setup_catalog
    bsc = getToolByName(portal, 'bika_setup_catalog', None)
    if bsc == None:
        logger.warning('Could not find the bika_setup_catalog tool.')
        return
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Disease', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('AetiologicAgent', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Treatment', ['bika_setup_catalog'])
    at.setCatalogsByType('Symptom', ['bika_setup_catalog'])
    at.setCatalogsByType('Drug', ['bika_setup_catalog'])
    at.setCatalogsByType('DrugProhibition', ['bika_setup_catalog'])
    at.setCatalogsByType('VaccinationCenter', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('InsuranceCompany', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Immunization', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseStatus', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseOutcome', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('EpidemiologicalYear', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('IdentifierType', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('CaseSyndromicClassification', [
        'bika_setup_catalog',
    ])
    at.setCatalogsByType('Ethnicity', [
        'bika_setup_catalog',
    ])

    addIndex(bsc, 'getGender', 'FieldIndex')
    addColumn(bsc, 'getGender')

    # bika_patient_catalog
    bpc = getToolByName(portal, 'bika_patient_catalog', None)
    if bpc == None:
        logger.warning('Could not find the bika_patient_catalog tool.')
        return
    bpc.manage_addProduct['ZCTextIndex'].manage_addLexicon(
        'Lexicon', 'Lexicon', elem)
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('Patient', ['bika_patient_catalog'])
    addIndex(bpc, 'path', 'ExtendedPathIndex', ('getPhysicalPath'))
    addIndex(bpc, 'allowedRolesAndUsers', 'KeywordIndex')
    addIndex(bpc, 'UID', 'FieldIndex')
    addIndex(bpc, 'Title', 'ZCTextIndex', zc_extras)
    addIndex(bpc, 'Description', 'ZCTextIndex', zc_extras)
    addIndex(bpc, 'id', 'FieldIndex')
    addIndex(bpc, 'getId', 'FieldIndex')
    addIndex(bpc, 'Type', 'FieldIndex')
    addIndex(bpc, 'portal_type', 'FieldIndex')
    addIndex(bpc, 'created', 'DateIndex')
    addIndex(bpc, 'Creator', 'FieldIndex')
    addIndex(bpc, 'getObjPositionInParent', 'GopipIndex')
    addIndex(bpc, 'sortable_title', 'FieldIndex')
    addIndex(bpc, 'review_state', 'FieldIndex')
    addIndex(bpc, 'getPatientID', 'FieldIndex')
    addIndex(bpc, 'getClientPatientID', 'FieldIndex')
    addIndex(bpc, 'getPrimaryReferrerUID', 'FieldIndex')
    addIndex(bpc, 'getGender', 'FieldIndex')
    addIndex(bpc, 'getAgeSplittedStr', 'FieldIndex')
    addIndex(bpc, 'getPrimaryReferrerTitle', 'FieldIndex')
    addIndex(bpc, 'getCitizenship', 'FieldIndex')
    addIndex(bpc, 'getBirthDate', 'DateIndex')
    addIndex(bpc, 'inactive_state', 'FieldIndex')
    addColumn(bpc, 'id')
    addColumn(bpc, 'UID')
    addColumn(bpc, 'Title')
    addColumn(bpc, 'Type')
    addColumn(bpc, 'portal_type')
    addColumn(bpc, 'sortable_title')
    addColumn(bpc, 'Description')
    addColumn(bpc, 'getPatientID')
    addColumn(bpc, 'getClientPatientID')
    addColumn(bpc, 'getPrimaryReferrerUID')
    addColumn(bpc, 'review_state')
    addColumn(bpc, 'inactive_state')