Пример #1
0
    def setUpClass(cls):

        if not os.path.isfile('Pipeline.db'):
            createTransferDB('Pipeline.db', '.', 'enilepiP')
        if os.path.isfile('who_cod.R'):
            os.remove('who_cod.R')
        # if os.path.isfile('tariff_cod.py'):
        #     os.remove('tariff_cod.py')

        pipelineRunDate = datetime.datetime(2018, 9, 1, 9, 0,
                                            0).strftime('%Y_%m_%d_%H:%M:%S')
        xferDB = TransferDB(dbFileName='Pipeline.db',
                            dbDirectory='.',
                            dbKey='enilepiP',
                            plRunDate=pipelineRunDate)
        conn = xferDB.connectDB()
        cls.cod_who = xferDB.configDHIS(conn, 'InSilicoVA')
        cls.cod_tariff = xferDB.configDHIS(conn, 'SmartVA')

        with open("who_cod.R", "w", newline="") as f:
            f.write("data(causetextV5, package='InterVA5')\n")
            f.write(
                "write.csv(causetextV5, file='who_cod.csv', row.names=FALSE)\n"
            )
        rArgs = ["R", "CMD", "BATCH", "--vanilla", "who_cod.R"]
        subprocess.run(args=rArgs,
                       stdin=subprocess.PIPE,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE,
                       check=True)
        who = read_csv("who_cod.csv", index_col=0)
        index_who_causes = [i for i in who.index if "b_" in i]
        cls.who_causes = who.loc[index_who_causes, who.columns[0]].tolist()
Пример #2
0
    def setUpClass(cls):

        shutil.rmtree('DHIS/blobs/', ignore_errors = True)
        shutil.copy('OpenVAFiles/sampleEAV.csv',
                    'OpenVAFiles/entityAttributeValue.csv')
        shutil.copy('OpenVAFiles/sample_recordStorage.csv',
                    'OpenVAFiles/recordStorage.csv')
        # Define valid parameters for SwissTPH DHIS2 Server.
        dirOpenVA = 'OpenVAFiles'
        dhisURL = 'https://va30se.swisstph-mis.ch'
        # dhisURL = 'https://va25.swisstph-mis.ch'
        dhisUser = '******'
        dhisPassword = '******'
        dhisOrgUnit = 'SCVeBskgiK6'

        # parameters for connecting to DB (assuming DB is in tests folder)
        dbFileName = 'Pipeline.db'
        dbKey = 'enilepiP'
        wrong_dbKey = 'wrongKey'
        # dbDirectory = os.path.abspath(os.path.dirname(__file__))
        dbDirectory = '.'
        if not os.path.isfile('Pipeline.db'):
            createTransferDB(dbFileName, dbDirectory, dbKey)
        pipelineRunDate = datetime.datetime.now()

        xferDB = TransferDB(dbFileName = dbFileName,
                            dbDirectory = dbDirectory,
                            dbKey = dbKey,
                            plRunDate = pipelineRunDate)
        conn = xferDB.connectDB()
        settingsDHIS = xferDB.configDHIS(conn, 'InSilicoVA')

        cls.pipelineDHIS = dhis.DHIS(settingsDHIS, '.')
        apiDHIS = cls.pipelineDHIS.connect()
        cls.postLog = cls.pipelineDHIS.postVA(apiDHIS)
        cls.pipelineDHIS.verifyPost(cls.postLog, apiDHIS)