def getConsultationByCoursByYearForGraph(session, ID_COURS, year='%'): #LOG.info("----- getConsultationByCoursByYearForGraph -----") COC = aliased(tables.ConsultationCoursMySQL) nbConsultations = session.query(func.MONTH( COC.DATE_CONS), func.count(COC.DATE_CONS), COC.PUBLIC_CONS).filter( and_(COC.ID_COURS == ID_COURS, COC.TYPE_CONS == "Cours", func.YEAR(COC.DATE_CONS) == year)).group_by( func.MONTH(COC.DATE_CONS), COC.PUBLIC_CONS) return nbConsultations
def getConsultationByCoursByUniversityYearForGraph(session, ID_COURS, year): LOG.info("----- getConsultationByCoursByUniversityYearForGraph -----") COC = aliased(tables.ConsultationCoursMySQL) nbConsultations = session.query(func.MONTH( COC.DATE_CONS), func.count(COC.DATE_CONS), COC.PUBLIC_CONS).filter( and_( COC.ID_COURS == ID_COURS, COC.TYPE_CONS == "Cours", COC.DATE_CONS.between("%s/09/01" % str(year - 1), "%s/08/31" % str(year)))).group_by( func.MONTH(COC.DATE_CONS), COC.PUBLIC_CONS) return nbConsultations
def statistik_monthly(): pasien = Pasien.query rawat_jalan = RawatJalan.query rawat_inap = RawatInap.query rujukan = PasienRujukan.query.join(RawatInap) rujukan_mount = [] rj_mount = [] ri_mount = [] pasien_mount = [] for a in range(1,13): rujukan_mount.append(len(rujukan.filter(func.MONTH(RawatInap.tanggal_masuk)==a).all())) rj_mount.append(len(rawat_jalan.filter(func.MONTH(RawatJalan.tanggal)==a).all())) ri_mount.append(len(rawat_inap.filter(func.MONTH(RawatInap.tanggal_masuk)==a).all())) pasien_mount.append(len(pasien.filter(func.MONTH(Pasien.create_at)==a).all())) return jsonify({"pasien":pasien_mount, "rujukan":rujukan_mount, "rawat_inap":ri_mount, "rawat_jalan":rj_mount})
def getConnexionELPByMonth(session, COD_ELP, month, year, listeInds): CI = aliased(tables.ConnexionINDMySQL) nbConnexion = session.query(CI.SESAME_ETU).filter( and_(CI.SESAME_ETU.in_(listeInds), func.MONTH(CI.DATE_CONN) == month, func.YEAR(CI.DATE_CONN) == year)) return nbConnexion.count()
def getConsultationCoursByMonth(session, month, year='%', listeIdCours=[], SESAME_ETU=None): COC = aliased(tables.ConsultationCoursMySQL) if SESAME_ETU: nbConsultations = session.query(COC.ID_COURS, func.count( COC.DATE_CONS)).filter( and_(COC.SESAME_ETU == SESAME_ETU, COC.ID_COURS.in_(listeIdCours), func.MONTH(COC.DATE_CONS) == month, func.YEAR(COC.DATE_CONS) == year)).group_by(COC.ID_COURS) else: nbConsultations = session.query(COC.ID_COURS, func.count( COC.DATE_CONS)).filter( and_(COC.ID_COURS.in_(listeIdCours), func.MONTH(COC.DATE_CONS) == month, func.YEAR(COC.DATE_CONS) == year)).group_by(COC.ID_COURS) return nbConsultations
def getConsultationByElementByCoursByMonth(session, ID_COURS, ID_CONS, month, year='%'): #LOG.info("----- getConsultationByElementsByCoursByMonth -----") COC = aliased(tables.ConsultationCoursMySQL) nbConsultations = session.query(COC.PUBLIC_CONS, func.count( COC.DATE_CONS)).filter( and_(COC.ID_COURS == ID_COURS, COC.ID_CONS == ID_CONS, func.MONTH(COC.DATE_CONS) == month, func.YEAR(COC.DATE_CONS) == year)).group_by(COC.PUBLIC_CONS) return nbConsultations