Exemple #1
0
 def write_to_schedule(self, schedule_record):
     database = CloudantDatabase(
         self.client,
         self.app.config['CLOUDANT_NOSQL_DB_SCHEDULE_DATABASE_NAME'])
     append_info = {
         "status": 'active',
         "failure_counts": "0",
         "submit time": time.ctime()
     }
     new_document = schedule_record.copy()
     new_document.update(append_info)
     if database.exists():
         database.create_document(new_document)
     else:
         database = self.client.create_database(
             self.app.config['CLOUDANT_NOSQL_DB_SCHEDULE_DATABASE_NAME'])
         database.create_document(new_document)
Exemple #2
0
 def write_to_request(self, document, user=None, status=None):
     database = CloudantDatabase(
         self.client,
         self.app.config['CLOUDANT_NOSQL_DB_REQUEST_DATABASE_NAME'])
     append_info = {
         "user": user,
         "status": status,
         "failure_counts": "0",
         "submit time": time.ctime()
     }
     new_document = document.copy()
     new_document.update(append_info)
     if database.exists():
         database.create_document(new_document)
     else:
         database = self.client.create_database(
             self.app.config['CLOUDANT_NOSQL_DB_REQUEST_DATABASE_NAME'])
         database.create_document(new_document)
Exemple #3
0
 def write_to_mail(self, to, sender, subject, confirm_link, requester):
     database = CloudantDatabase(
         self.client,
         self.app.config['CLOUDANT_NOSQL_DB_MAIL_DATABASE_NAME'])
     doc = {
         "to": to,
         "sender": sender,
         "subject": subject,
         "confirm_link": confirm_link,
         "requester": requester,
         "status": 'submitted',
         "submit time": time.ctime()
     }
     if database.exists():
         database.create_document(doc)
     else:
         database = self.client.create_database(
             self.app.config['CLOUDANT_NOSQL_DB_MAIL_DATABASE_NAME'])
         database.create_document(doc)
def patient_details():
    if (request.method == "POST"):
        allergies = request.form["allergies"]
        immunizations = request.form["immunizations"]
        observations = request.form["observations"]
        procedures = request.form["procedures"]
        careplans = request.form["careplans"]
        medications = request.form["medications"]
        current = request.form["current"]
        #flash("Patient Details Successfully Updated !!!",category="success")

        ## code to store this info in the database
        username = "******"
        apikey = "HAltxJaD5Sr4VsbAVB4-rYLfWdrWOkW0fWuqzQFP_Ra_"
        client = Cloudant.iam(username, apikey, connect=True)

        db_name = "patient_details"
        p_details = CloudantDatabase(client, db_name)

        date_v = str(date.today())
        encounter_id = str(session["user_id"]) + '_' + date_v
        if p_details.exists():

            patient_document = {
                "allergies": allergies,
                "immunizations": immunizations,
                "observations": observations,
                "procedures": procedures,
                "careplans": careplans,
                "medications": medications,
                "current": current,
                "encounter_id": encounter_id,
                "date": date_v
            }
            p_details.create_document(patient_document)
        #flash("Data Added Successfully !")
        client.disconnect()
        flash("Patient Details Successfully Updated !!!", category="success")

        return redirect(url_for("patient_details"))

    return render_template("p_details.html")
Exemple #5
0
    def init_user(self, userinfo, status='active'):

        database = CloudantDatabase(
            self.client,
            self.app.config['CLOUDANT_NOSQL_DB_USER_DATABASE_NAME'])
        doc = {
            "emailAddress": userinfo.get('emailAddress'),
            "firstName": userinfo.get('firstName'),
            "lastName": userinfo.get('lastName'),
            "uid": userinfo.get('uid'),
            "approved_country_accesses": None,
            "approved_company_accesses": None,
            "pending_country_accesses": None,
            "pending_company_accesses": None,
            "status": status,
            "init time": time.ctime()
        }
        if database.exists():
            database.create_document(doc)
        else:
            return False