Exemple #1
0
 def _get_all_medications(self):
     url = 'https://drchrono.com/api/medications'
     while url:
         data = requests.get(url, headers=self.headers).json()
         for item in data['results']:
             Medication().save_from_dict(item)
         url = data['next']
Exemple #2
0
 def create_medications(token):
     body = request.get_json()
     new_medicationName = body.get("medicationName", None)
     new_price = body.get("price", None)
     try:
         medication = Medication(medicationName=new_medicationName,
                                 price=new_price)
         medication.insert()
     except:
         abort(422)
     medications = Medication.query.all()
     formatted_medications = [
         medication.format() for medication in medications
     ]
     return jsonify({
         'success': True,
         'medications': formatted_medications,
         'total_medications': len(medications)
     })
Exemple #3
0
def add_medication():
    if request.method == 'POST':
        if not match_hours(request.form['hours']):
            return redirect(url_for('drug_chart.medication'))

        hours = request.form['hours'].replace(' ', '').split(',')
        medication = Medication(name=request.form['name'],
                                indications=request.form['indications'],
                                given_hours=convert_binary(hours))

        db.session.add(medication)
        db.session.commit()
        return redirect(url_for('drug_chart.medication'))

    return render_template('drug_chart/create.html')
Exemple #4
0
    def test_medication(self):
        """Test Patient Medication"""
        self.assertEqual(len(self.p1.medications), 0)

        m1 = Medication(name="Plaquenil",
                        doctors_id=1,
                        patients_id=1,
                        description="U07.1 - COVID-19")

        db.session.add(m1)
        db.session.commit()

        self.assertEqual(len(self.p1.medications), 1)
        self.assertEqual(len(self.p2.medications), 0)

        self.assertEqual(self.p1.medications[0].id, m1.id)
Exemple #5
0
def add_med(request):
	generic_name = request.POST.get('generic_name')
	units = request.POST.get('units')
	user = request.user.pk
	new_med_entry = Medication()	#.objects.create(generic_name=generic_name, units, user)
	new_med_entry.generic_name = generic_name
	new_med_entry.units = units
	new_med_entry.user = request.user
	new_med_entry.save()
	# use redirect here
	return HttpResponseRedirect(reverse('med_tracker_app:user_dash'))
Exemple #6
0
 def test_medication_given(self):
     m1 = Medication(name="Plaquenil",
                     doctors_id=1,
                     patients_id=1,
                     description="U07.1 - COVID-19")
     db.session.add(m1)
     db.session.commit()
     mg = Medication_Given(nurses_id=1,
                           doctors_id=1,
                           patients_id=1,
                           medications_id=1)
     db.session.add(mg)
     db.session.commit()
     self.assertEqual(len(self.p1.medications_given), 1)
     self.assertEqual(len(self.p2.medications_given), 0)
     self.assertEqual(len(self.d1.medications_given), 1)
     self.assertEqual(len(self.d2.medications_given), 0)
     self.assertEqual(len(self.n1.medications_given), 1)
     self.assertEqual(len(self.n2.medications_given), 0)
Exemple #7
0
def add_to_db_list_medications():
    """Will create a form  medications with patients in side bar menu"""

    form = NewMedicationPatientForm()
    patients = Patient.query.all()
    pl = [(patient.id, patient.first_name + " " + patient.last_name + " " +
           patient.date_of_birth.strftime('%Y-%m-%d')) for patient in patients]
    form.patient.choices = pl
    d = Doctor.query.all()
    dl = [(doctor.id, doctor.last_name + " " + doctor.first_name)
          for doctor in d]
    form.doctor.choices = dl
    if form.validate_on_submit():
        patient = form.patient.data
        doctor = form.doctor.data
        m = Medication(name=request.args.get('rxterms', 'None'),
                       description=request.args.get('diagnosis', 'None'),
                       patients_id=patient,
                       doctors_id=doctor)
        db.session.add(m)
        db.session.commit()
        return redirect("/medications")

    return render_template("medication/create.html", form=form)
Exemple #8
0
def add_medication(medication: MedicationDto) -> None:
    new_medication = Medication(name=medication.name)
    session.add(new_medication)
    session.commit()
db.session.add(p3)
db.session.add(p4)
db.session.add(p5)
db.session.add(p6)
db.session.add(p7)
db.session.add(p8)
db.session.add(p9)
db.session.add(p10)
db.session.add(p11)
db.session.add(p12)
db.session.add(p13)
db.session.add(p14)
db.session.add(p15)

m1 = Medication(name="tylenol 325mg",
                description="for pain",
                doctors_id=1,
                patients_id=1)
m2 = Medication(name="turmeric 500mg",
                description="anti-oxidant",
                doctors_id=1,
                patients_id=2)
m3 = Medication(name="caffeine tablets",
                description="for focus",
                doctors_id=1,
                patients_id=2)
m4 = Medication(name="vitamin c",
                description="immune support",
                doctors_id=1,
                patients_id=2)
m5 = Medication(name="hydralazine 50mg",
                description="blood pressure",
Exemple #10
0
def refreshDBwithFHIR(request):
    #get json from dir
    with open("hit_server/FHIRJsonResponse.json") as data_file:
        data = json.load(data_file)

    for p in data.keys():
        print p, data[p]["Contact Info"]["first_name"], data[p][
            "Contact Info"]["last_name"]
        patientobj = PatientInfo()  # create a patient object.
        patientobj.pid = p
        patientobj.first_name = data[p]["Contact Info"]["first_name"]
        patientobj.last_name = data[p]["Contact Info"]["last_name"]
        patientobj.save()

        #first add all conditions to patient?

        all_conditions = data[p]["Conditions"].keys()
        for con in all_conditions:
            conditionobj = Condition()
            conditionobj.condition_name = data[p]["Conditions"][con]["name"]
            conditionobj.onset_date = data[p]["Conditions"][con]["onset_date"]
            conditionobj.condition_code = data[p]["Conditions"][con]["code"]
            conditionobj.condition_desc = data[p]["Conditions"][con]["text"]
            conditionobj.condition_for_patients = patientobj  # how to use related object

            conditionobj.save()

        all_medications = data[p]["Medications"].keys()

        if len(all_medications) == 0:
            pass

        else:
            for meds in all_medications:
                medicationobj = Medication()
                medicationobj.med_status = data[p]["Medications"][meds][
                    "status"]
                medicationobj.med_name = data[p]["Medications"][meds]["name"]
                medicationobj.med_code = data[p]["Medications"][meds]["code"]
                medicationobj.med_dosage_value = data[p]["Medications"][meds][
                    "dosage_value"]
                medicationobj.med_dosage_text = data[p]["Medications"][meds][
                    "dosage_text"]
                medicationobj.med_dosage_units = data[p]["Medications"][meds][
                    "dosage_units"]
                medicationobj.med_date_written = data[p]["Medications"][meds][
                    "date_written"]
                medicationobj.med_code_system = data[p]["Medications"][meds][
                    "code_system"]

                medicationobj.medications_for_patients = patientobj  # how to use related object

                medicationobj.save()

        all_observations = data[p]["Observations"].keys()
        for obs in all_observations:
            observationobj = Observation()
            observationobj.obs_name = data[p]["Observations"][obs]["name"]
            observationobj.obs_code = data[p]["Observations"][obs]["code"]
            observationobj.obs_desc = data[p]["Observations"][obs]["text"]

            check_existance_of_value = data[p]["Observations"][obs].keys()
            if "value" in check_existance_of_value:
                observationobj.obs_value = data[p]["Observations"][obs][
                    "value"]
            else:
                observationobj.obs_value = 0.0

            if "units" in check_existance_of_value:
                observationobj.obs_units = data[p]["Observations"][obs][
                    "units"]
            else:
                observationobj.obs_units = "NULL"

            observationobj.obs_date = data[p]["Observations"][obs]["date_time"]

            observationobj.obs_for_patients = patientobj  # how to use related object

            observationobj.save()

    return HttpResponse()
    '''
Exemple #11
0
def refreshDBwithFHIR(request):
	#get json from dir
	with open("hit_server/FHIRJsonResponse.json") as data_file:
		data = json.load(data_file)

	for p in data.keys():
		print p, data[p]["Contact Info"]["first_name"], data[p]["Contact Info"]["last_name"]
		patientobj = PatientInfo()  			# create a patient object.
		patientobj.pid = p
		patientobj.first_name = data[p]["Contact Info"]["first_name"]
		patientobj.last_name = data[p]["Contact Info"]["last_name"]
		patientobj.save()

		#first add all conditions to patient?

		all_conditions = data[p]["Conditions"].keys()
		for con in all_conditions:
			conditionobj = Condition()
			conditionobj.condition_name = data[p]["Conditions"][con]["name"]
			conditionobj.onset_date = data[p]["Conditions"][con]["onset_date"]
			conditionobj.condition_code = data[p]["Conditions"][con]["code"]
			conditionobj.condition_desc = data[p]["Conditions"][con]["text"]
			conditionobj.condition_for_patients = patientobj   # how to use related object

			conditionobj.save()

		all_medications = data[p]["Medications"].keys()

		if len(all_medications) == 0:
			pass

		else:
			for meds in all_medications:
				medicationobj = Medication()
				medicationobj.med_status = data[p]["Medications"][meds]["status"]
				medicationobj.med_name = data[p]["Medications"][meds]["name"]
				medicationobj.med_code = data[p]["Medications"][meds]["code"]
				medicationobj.med_dosage_value = data[p]["Medications"][meds]["dosage_value"]
				medicationobj.med_dosage_text = data[p]["Medications"][meds]["dosage_text"]
				medicationobj.med_dosage_units = data[p]["Medications"][meds]["dosage_units"]
				medicationobj.med_date_written = data[p]["Medications"][meds]["date_written"]
				medicationobj.med_code_system = data[p]["Medications"][meds]["code_system"]


				medicationobj.medications_for_patients = patientobj   # how to use related object

				medicationobj.save()


		all_observations = data[p]["Observations"].keys()
		for obs in all_observations:
			observationobj = Observation()
			observationobj.obs_name = data[p]["Observations"][obs]["name"]
			observationobj.obs_code = data[p]["Observations"][obs]["code"]
			observationobj.obs_desc = data[p]["Observations"][obs]["text"]

			check_existance_of_value = data[p]["Observations"][obs].keys()
			if "value" in check_existance_of_value:
				observationobj.obs_value = data[p]["Observations"][obs]["value"]
			else:
				observationobj.obs_value = 0.0

			if "units" in check_existance_of_value:
				observationobj.obs_units = data[p]["Observations"][obs]["units"]
			else:
				observationobj.obs_units = "NULL"


			observationobj.obs_date = data[p]["Observations"][obs]["date_time"]

			observationobj.obs_for_patients = patientobj   # how to use related object

			observationobj.save()

	return HttpResponse()

	'''