Ejemplo n.º 1
0
 def healthServiceAvailability(code, priority, hospital, ssn, start_date=None):
     if start_date == None:
         start_date = DateConverter.fromDateToString(DateConverter.today())
     url = UrlProvider.raws['healthServiceAvailability']
     url = url.replace("[code]", code)
     url = url.replace("[priority]", priority)
     url = url.replace("[start_date]", start_date)
     url = url.replace("[hospital]", hospital)
     url = url.replace("[ssn]", ssn)
     url = url.replace("[hospital_description]", '-')
     return url
Ejemplo n.º 2
0
class Visit(db.Model):
    __tablename__ = 'Visit'
    user_id = db.Column(db.Integer, db.ForeignKey('User.id'), primary_key=True, onupdate='CASCADE')
    country_id = db.Column(db.String(2), db.ForeignKey('Country.id'), primary_key=True, onupdate='CASCADE')
    year = db.Column(db.String(4), server_default=DateConverter.get_current_day_string())
    month = db.Column(db.String(2), server_default=DateConverter.get_current_month_string())
    day = db.Column(db.String(2), server_default=DateConverter.get_current_day_string())

    user = db.relationship('User', back_populates='countries')
    country = db.relationship('Country', back_populates='users')

    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day
Ejemplo n.º 3
0
    def date_changed(self, index):
        day_from = self.cbx['from']['day'].currentIndex() + 1
        month_from = self.cbx['from']['month'].currentIndex() + 1
        year_from = self.cbx['from']['year'].currentText()

        day_to = self.cbx['to']['day'].currentIndex() + 1
        month_to = self.cbx['to']['month'].currentIndex() + 1
        year_to = self.cbx['to']['year'].currentText()

        dates = {
            'from': DateConverter().format_raw_dmy(day_from, month_from,
                                                   year_from),
            'to': DateConverter().format_raw_dmy(day_to, month_to, year_to)
        }

        self.send_event('filter-widget', 'change_dates', dates)
Ejemplo n.º 4
0
    def get(self, code, priority, hospital, ssn, start_date):
        if isinstance(code, HospitalServiceCode):
            code = code.code
        
        if isinstance(hospital, Hospital):
            hospital = hospital.id_hospital

        self.setUrl(UrlProvider.healthServiceAvailability(code, priority, hospital, ssn, start_date))

        jsonservices = self.load()

        if self.areThereErrors():
            print("CRITICAL: server side error:", self.rawdata)
            return []

        services = []

        #generating a single service for every possible combination
        for jsonservice in jsonservices:
            for date in jsonservice['date']:
                for orari in date['orari']:
                    s = HospitalService()
                    s.code = code
                    s.hospital = hospital
                    s.date = DateConverter.fromStringToDate(date['data'], orari)
                    s.hospital = jsonservice['sede']['descrizione']
                    s.id_hospital = jsonservice['sede']['idStruttura']
                    s.unit = jsonservice['unitaOfferente']['descrizione']
                    s.id_unit = jsonservice['unitaOfferente']['idStruttura']

                    services.append(s)

        return services
    def build_response_message(self, response, orig_data):
        subject = 'Your Akamai content removal request (%s)' % response.get('purgeId')

        if orig_data.get('type').upper() == 'CPCODE':
            objects = '\n'.join(x + ' (' + JsonObject.transform_cpcode(x) + ')' for x in orig_data.get('objects'))
        else:
            objects = '\n'.join(orig_data.get('objects'))

        msg = 'This message confirms that your Akamai content removal request has been processed by all active servers on our network. Here are the details.\n\n'
        msg += 'ID:                %s\n' % response.get('purgeId')
        msg += 'Domain:            %s\n' % orig_data.get('domain')
        msg += 'Requestor:         %s\n' % response.get('submittedBy')
        msg += 'Submission time:   %s\n' % DateConverter.convert_date(response.get('submissionTime'))
        msg += 'Completion time:   %s\n' % DateConverter.convert_date(response.get('completionTime'))
        msg += '\n'
        msg += 'Content purged:\n\n'
        msg += '%s %s(s)\n\n%s' % (orig_data.get('action'), orig_data.get('type'), objects)

        return subject, msg
Ejemplo n.º 6
0
 def __str__(self):
     out = "---Hospital Service---" + "\n"
     out += "code:\t\t" + self.code + "\n"
     out += "hospital:\t" + self.hospital + "\n"
     out += "date:\t\t" + DateConverter.fromDateToPrint(self.date) + "\n"
     out += "id_hospital:\t" + str(self.id_hospital) + "\n"
     out += "unit:\t\t" + self.unit + "\n"
     out += "id_unit:\t" + str(self.id_unit) + "\n"
     out += "----------------------"
     return out
Ejemplo n.º 7
0
def qdatetimeToStr(utc, date, time):
    (D, M, Y) = DateConverter.JDNtoGD(date)
    date_format = "%i-%i-%i %i:%02i:%06.3f"
    milliseconds = time
    hours, milliseconds = divmod(milliseconds, 3600000)
    minutes, milliseconds = divmod(milliseconds, 60000)
    seconds = float(milliseconds) / 1000
    if utc:
        date_format += " UTC"
    return date_format % (D, M, Y, hours, minutes, seconds)
 def get_response(self):
     r = requests.request(self.method, self.uri, auth=self.auth, headers=self.headers, data=self.data)
     message = self.uri + '\n\n'
     try:
         for x, y in r.json().iteritems():
             if 'Time' in str(x) and y is not None:
                 message += str(x) + ': ' + DateConverter.convert_date(y) + '\n'
             else:
                 message += str(x) + ': ' + str(y) + '\n'
     except ValueError:
         message += r.text
     return message, r
Ejemplo n.º 9
0
    def csv_to_expense(self, csv_line, formatter):
        fields = formatter['fields']

        return {
            'date':
            DateConverter().format_raw(csv_line['field_' +
                                                str(fields['date'])]),
            'concept':
            csv_line['field_' + str(fields['concept'])],
            'value':
            csv_line['field_' + str(fields['value'])].replace(',', '')
        }
Ejemplo n.º 10
0
    def build_response_message(self, response, orig_data):
        subject = 'Your Akamai content removal request (%s)' % response.get(
            'purgeId')

        if orig_data.get('type').upper() == 'CPCODE':
            objects = '\n'.join(x + ' (' + JsonObject.transform_cpcode(x) + ')'
                                for x in orig_data.get('objects'))
        else:
            objects = '\n'.join(orig_data.get('objects'))

        msg = 'This message confirms that your Akamai content removal request has been processed by all active servers on our network. Here are the details.\n\n'
        msg += 'ID:                %s\n' % response.get('purgeId')
        msg += 'Domain:            %s\n' % orig_data.get('domain')
        msg += 'Requestor:         %s\n' % response.get('submittedBy')
        msg += 'Submission time:   %s\n' % DateConverter.convert_date(
            response.get('submissionTime'))
        msg += 'Completion time:   %s\n' % DateConverter.convert_date(
            response.get('completionTime'))
        msg += '\n'
        msg += 'Content purged:\n\n'
        msg += '%s %s(s)\n\n%s' % (orig_data.get('action'),
                                   orig_data.get('type'), objects)

        return subject, msg
Ejemplo n.º 11
0
 def get_response(self):
     r = requests.request(self.method,
                          self.uri,
                          auth=self.auth,
                          headers=self.headers,
                          data=self.data)
     message = self.uri + '\n\n'
     try:
         for x, y in r.json().iteritems():
             if 'Time' in str(x) and y is not None:
                 message += str(x) + ': ' + DateConverter.convert_date(
                     y) + '\n'
             else:
                 message += str(x) + ': ' + str(y) + '\n'
     except ValueError:
         message += r.text
     return message, r
Ejemplo n.º 12
0
    def format_expense(self, expense):
        expense['date'] = DateConverter().format_pretty(expense['date'])

        return expense
Ejemplo n.º 13
0
if args.hospital:
    c = CUP()
    hospitals = c.getHospitals(args.servicecode, args.priority)

    for hospital in hospitals:
        print(hospital)

#python fastcup.py --book --servicecode P3039 --priority D --hospitalcode 30063 --ssn <AAABBB12X34Y567Z>
if args.book:
    c = CUP()
    services = c.getHospitalServices(args.servicecode, args.priority,
                                     args.hospitalcode, args.ssn)

    fl = FilterList(services)
    f = DateFilter()
    f.setGreaterThan(DateConverter.today())
    f.setSmallerThan(DateConverter.today() + DateConverter.delta(7))
    fl.addFilter(f)
    results = fl.getFiltered()

    for result in results:
        print(result)

#python fastcup.py --notify --servicecode P3039 --priority D --hospitalcode 30063 --ssn <AAABBB12X34Y567Z>
if args.notify:
    notify = Notify()
    qr = notify.register()

    secs = 120
    if args.seconds:
        secs = args.seconds
Ejemplo n.º 14
0
from DateConverter import DateConverter

app = Flask(__name__)

FILE_PATH = os.getcwd() + "/file.db"

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + FILE_PATH
app.config['UPLOAD_FOLDER'] = uploadFile.UPLOAD_FOLDER
app.config[
    'SECRET_KEY'] = "siasdjasiodjldsj(S*u293719312.,12391u37912739723901/.,';][;][2209526510"

#initialize database
db = SQLAlchemy(app)

#dateConvertor
converter = DateConverter()


@app.route("/searchFile", methods=['GET', 'POST'])
def search():
    return render_template("Search.html")


@app.route("/addFile", methods=['GET', 'POST'])
def add():

    if request.method == "POST":

        # filename = request.form.get('filename')
        # category  = request.form.get('category')
        # category = change_into_string(category)
Ejemplo n.º 15
0
 def csv_to_expense(self, csv_line):
     return {
         'date': DateConverter().format_raw(csv_line['field_0']),
         'concept': csv_line['field_3'],
         'value': csv_line['field_5'].replace(',', '')
     }