class TestRequiredAutocompleteMedicine(TestCase): def setUp(self): self.client = Client() self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.recipe_name = "Manipulated Medicine" self.manipulated_medicine.physical_form = "Physical Form" self.manipulated_medicine.quantity = 10 self.manipulated_medicine.measurement = 'kg' self.manipulated_medicine.composition = ( "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition.") self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() def test_prescription_request_autocomplete_medicine_fail(self): request = self.factory.get( '/prescription/ajax/autocomplete_medicine/?term=Med') request.user = self.health_professional response = AutoCompleteMedicine.as_view()(request) self.assertNotEquals(response, HttpResponse) def test_prescription_request_autocomplete_medicine_return_no_medicine( self): request = self.factory.get( '/prescription/ajax/autocomplete_medicine/?term=testan', HTTP_X_REQUESTED_WITH='XMLHttpRequest') request.user = self.health_professional response = AutoCompleteMedicine.as_view()(request) self.assertEquals(response.status_code, 200) def test_prescription_request_autocomplete_medicine_return_one_medicine( self): request = self.factory.get( '/prescription/ajax/autocomplete_medicine/?term=Med', HTTP_X_REQUESTED_WITH='XMLHttpRequest') request.user = self.health_professional response = AutoCompleteMedicine.as_view()(request) self.assertEquals(response.status_code, 200) def test_prescription_request_autocomplete_medicine_return_one_manipulatede_medicine( self): request = self.factory.get( '/prescription/ajax/autocomplete_medicine/?term=Man', HTTP_X_REQUESTED_WITH='XMLHttpRequest') request.user = self.health_professional response = AutoCompleteMedicine.as_view()(request) self.assertEquals(response.status_code, 200)
def setUp(self): self.client = Client() self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.recipe_name = "Manipulated Medicine" self.manipulated_medicine.physical_form = "Physical Form" self.manipulated_medicine.quantity = 10 self.manipulated_medicine.measurement = 'kg' self.manipulated_medicine.composition = ( "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition." + "Manipulated Medicine Composition.") self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save()
class TestShowDetailPrescriptionView(TestCase): def setUp(self): self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.posology = "Medicamento de Teste" self.quantity = 1 self.via = constants.VIA_CHOICES[0][0] self.patient = "Carlos Nogueira" self.prescription = NoPatientPrescription() self.prescription.patient = self.patient self.prescription.cid = None self.prescription.health_professional = self.health_professional self.prescription.pk = 1 self.prescription.save() self.has_manipulated_medicine = PrescriptionHasMedicine() self.has_manipulated_medicine.prescription_medicine = self.prescription self.has_manipulated_medicine.medicine = self.medicine self.has_manipulated_medicine.posology = self.posology self.has_manipulated_medicine.via = self.via self.has_manipulated_medicine.quantity = self.quantity self.has_manipulated_medicine.save() self.has_medicine = PrescriptionHasManipulatedMedicine() self.has_medicine.prescription_medicine = self.prescription self.has_medicine.manipulated_medicine = self.manipulated_medicine self.has_medicine.posology = self.posology self.has_medicine.via = self.via self.has_medicine.quantity = self.quantity self.has_medicine.save() def test_prescription_get_with_health_professional(self): request = self.factory.get('/prescription/show_prescription/1') request.user = self.health_professional # Get the response response = ShowDetailPrescriptionView.as_view()(request, pk=1) self.assertEqual(response.status_code, 200)
def setUp(self): # Making a HealthProfessional self.view = ListAllMedicines # Making medicati self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.listing = Medicine.objects.all()
def setUp(self): self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.posology = "Medicamento de Teste" self.quantity = 1 self.via = constants.VIA_CHOICES[0][0] self.patient = "Carlos Nogueira" self.prescription = NoPatientPrescription() self.prescription.patient = self.patient self.prescription.cid = None self.prescription.health_professional = self.health_professional self.prescription.pk = 1 self.prescription.save() self.has_manipulated_medicine = PrescriptionHasMedicine() self.has_manipulated_medicine.prescription_medicine = self.prescription self.has_manipulated_medicine.medicine = self.medicine self.has_manipulated_medicine.posology = self.posology self.has_manipulated_medicine.via = self.via self.has_manipulated_medicine.quantity = self.quantity self.has_manipulated_medicine.save() self.has_medicine = PrescriptionHasManipulatedMedicine() self.has_medicine.prescription_medicine = self.prescription self.has_medicine.manipulated_medicine = self.manipulated_medicine self.has_medicine.posology = self.posology self.has_medicine.via = self.via self.has_medicine.quantity = self.quantity self.has_medicine.save()
class TestListAllMedicines(TestCase): def setUp(self): # Making a HealthProfessional self.view = ListAllMedicines # Making medicati self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.listing = Medicine.objects.all() def test_medicine_is_show(self): instance = self.view() self.assertEqual(instance.get_queryset()[0], self.listing[0])
def setUp(self): self.factory = RequestFactory() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.disease = Disease() self.disease.pk = 1 self.disease.id_cid_10 = "A01" self.disease.description = "A random disease" self.disease.save() self.prescription = Prescription() self.prescription.pk = 1 self.prescription.health_professional = self.health_professional self.prescription.cid = self.disease self.prescription.save() self.prescription_2 = Prescription() self.prescription_2.pk = 2 self.prescription_2.health_professional = self.health_professional self.prescription_2.cid = self.disease self.prescription_2.save() self.prescription_3 = Prescription() self.prescription_3.pk = 3 self.prescription_3.health_professional = self.health_professional self.prescription_3.cid = self.disease self.prescription_3.save() self.prescription_4 = Prescription() self.prescription_4.pk = 4 self.prescription_4.health_professional = self.health_professional self.prescription_4.cid = self.disease self.prescription_4.save() self.prescription_5 = Prescription() self.prescription_5.pk = 5 self.prescription_5.health_professional = self.health_professional self.prescription_5.cid = self.disease self.prescription_5.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.manipulated_medicine_2 = ManipulatedMedicine() self.manipulated_medicine_2.pk = 2 self.manipulated_medicine_2.recipe_name = "teste" self.manipulated_medicine_2.physical_form = "asdadsafdf" self.manipulated_medicine_2.quantity = 12 self.manipulated_medicine_2.measurement = "kg" self.manipulated_medicine_2.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine_2.health_professional = self.health_professional self.manipulated_medicine_2.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 2 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine_2 self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 12 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 4 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription_2 self.hasmanipulated_medicine.save() self.recommendation = NewRecommendation() self.recommendation.recommendation_description = "recomendacao de teste" self.recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription_3 self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.medicine = Medicine() self.medicine.name = "asdoajsdoiasj" self.medicine.active_ingredient = "dsofaksdofk" self.medicine.laboratory = "dofijasoifjjf" self.medicine.description = "oiajdoaisjddj" self.medicine.save() self.medicine_2 = Medicine() self.medicine_2.name = "asdoajsdoiasj" self.medicine_2.active_ingredient = "dsofaksdofk" self.medicine_2.laboratory = "dofijasoifjjf" self.medicine_2.description = "oiajdoaisjddj" self.medicine_2.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 2 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine_2 self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 21 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.default_exam = DefaultExam() self.default_exam.id_tuss = 'oiafj' self.default_exam.save() self.custom_exam = CustomExam() self.custom_exam.health_professional_FK = self.health_professional self.custom_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription self.prescription_default_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription_4 self.prescription_default_exam.save() self.prescription_custom_exam = PrescriptionCustomExam() self.prescription_custom_exam.exam = self.custom_exam self.prescription_custom_exam.prescription = self.prescription self.prescription_custom_exam.save()
def setUp(self): self.client = Client() self.factory = RequestFactory() self.patient = Patient() self.patient.pk = 1 self.patient.name = "Paciente de teste" self.patient.date_of_birth = "1991-10-21" self.patient.phone = "06199999999" self.patient.email = "*****@*****.**" self.patient.sex = "M" self.patient.id_document = "1000331" self.patient.CEP = "72850735" self.patient.UF = "DF" self.patient.city = "Brasília" self.patient.neighborhood = "Asa sul" self.patient.complement = "Bloco 2 QD 701" self.patient.save() self.health_professional = HealthProfessional() self.health_professional.pk = 1 self.health_professional.crm = '12345' self.health_professional.crm_state = 'US' self.health_professional.specialty_first = 'Nutricao' self.health_professional.specialty_second = 'Pediatria' self.health_professional.save() self.health_professional = HealthProfessional.objects.create_user( email='*****@*****.**', password='******') self.health_professional_no_specialty_second = HealthProfessional() self.health_professional_no_specialty_second.pk = 2 self.health_professional_no_specialty_second.crm = '11111' self.health_professional_no_specialty_second.crm_state = 'US' self.health_professional_no_specialty_second.specialty_first = 'Nutricao' self.health_professional_no_specialty_second.specialty_second = 'Nao Possui' self.health_professional_no_specialty_second.email = '*****@*****.**' self.health_professional_no_specialty_second.password = '******' self.health_professional_no_specialty_second.save() self.disease = Disease() self.disease.pk = 1 self.disease.id_cid_10 = "A01" self.disease.description = "A random disease" self.disease.save() self.prescription = NoPatientPrescription() self.prescription.pk = 1 self.prescription.health_professional = self.health_professional self.prescription.cid = self.disease self.prescription.patient = "Algum nome" self.prescription.save() self.prescription_2 = NoPatientPrescription() self.prescription_2.pk = 2 self.prescription_2.health_professional = self.health_professional self.prescription_2.cid = self.disease self.prescription_2.patient = "Algum nome" self.prescription_2.save() self.prescription_3 = PatientPrescription() self.prescription_3.pk = 3 self.prescription_3.health_professional = self.health_professional self.prescription_3.cid = self.disease self.prescription_3.patient = self.patient self.prescription_3.save() self.prescription_4 = PatientPrescription() self.prescription_4.pk = 4 self.prescription_4.health_professional = self.health_professional self.prescription_4.cid = self.disease self.prescription_4.patient = self.patient self.prescription_4.save() self.prescription_5 = PatientPrescription() self.prescription_5.pk = 5 self.prescription_5.health_professional = self.health_professional self.prescription_5.cid = self.disease self.prescription_5.patient = self.patient self.prescription_5.save() self.prescription_6 = PatientPrescription() self.prescription_6.pk = 6 self.prescription_6.health_professional = self.health_professional_no_specialty_second self.prescription_6.cid = self.disease self.prescription_6.patient = self.patient self.prescription_6.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.manipulated_medicine_2 = ManipulatedMedicine() self.manipulated_medicine_2.pk = 2 self.manipulated_medicine_2.recipe_name = "teste" self.manipulated_medicine_2.physical_form = "asdadsafdf" self.manipulated_medicine_2.quantity = 12 self.manipulated_medicine_2.measurement = "kg" self.manipulated_medicine_2.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine_2.health_professional = self.health_professional self.manipulated_medicine_2.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 2 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine_2 self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 12 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 4 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription_2 self.hasmanipulated_medicine.save() self.recommendation = NewRecommendation() self.recommendation.recommendation_description = "recomendacao de teste" self.recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription_3 self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.medicine = Medicine() self.medicine.name = "asdoajsdoiasj" self.medicine.active_ingredient = "dsofaksdofk" self.medicine.laboratory = "dofijasoifjjf" self.medicine.description = "oiajdoaisjddj" self.medicine.save() self.medicine_2 = Medicine() self.medicine_2.name = "asdoajsdoiasj" self.medicine_2.active_ingredient = "dsofaksdofk" self.medicine_2.laboratory = "dofijasoifjjf" self.medicine_2.description = "oiajdoaisjddj" self.medicine_2.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 2 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine_2 self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 21 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.default_exam = DefaultExam() self.default_exam.id_tuss = 'oiafj' self.default_exam.save() self.custom_exam = CustomExam() self.custom_exam.health_professional_FK = self.health_professional self.custom_exam.save() self.new_exam = NewExam() self.new_exam.exam_description = 'Test String' self.new_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription self.prescription_default_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription_4 self.prescription_default_exam.save() self.prescription_custom_exam = PrescriptionCustomExam() self.prescription_custom_exam.exam = self.custom_exam self.prescription_custom_exam.prescription = self.prescription self.prescription_custom_exam.save() self.prescription_new_exam = PrescriptionNewExam() self.prescription_new_exam.exam = self.new_exam self.prescription_new_exam.prescription = self.prescription self.prescription_new_exam.save() self.pattern = Pattern() self.pattern.name = "Pattern de teste" self.pattern.user_creator = self.health_professional self.pattern.clinic = "clinica de teste" self.pattern.header = "header de teste" self.pattern.font = 'Helvetica' self.pattern.font_size = '12' self.pattern.footer = "footer de teste" self.pattern.pagesize = "letter" self.pattern.pk = 1 self.pattern.logo = None self.pattern.save() self.pattern = Pattern() self.pattern.name = "Pattern de teste" self.pattern.user_creator = self.health_professional self.pattern.clinic = "clinica de teste" self.pattern.header = "header de teste" self.pattern.font = 'Helvetica' self.pattern.font_size = '12' self.pattern.footer = "footer de teste" self.pattern.pagesize = "A4" self.pattern.pk = 2 self.pattern.logo = None self.pattern.save() self.pattern = Pattern() self.pattern.name = "Pattern de teste" self.pattern.user_creator = self.health_professional self.pattern.clinic = "clinica de teste" self.pattern.header = "header de teste" self.pattern.font = 'Helvetica' self.pattern.font_size = '12' self.pattern.footer = "footer de teste" self.pattern.pagesize = "A5" self.pattern.pk = 3 self.pattern.logo = None self.pattern.save()
def collect_medicine_info_from_medex(base_url='https://medex.com.bd/brands', limit=1): page_url_list = get_page_urls(base_url, limit) for idx, page_url in enumerate(page_url_list): res = requests.get(page_url) soup = BeautifulSoup(res.content, 'html.parser') print(f"For Page {idx + 1}\n") for atr in soup.find_all(href=re.compile("/brands/"))[:]: medicine_url = atr['href'] print(f"Details of {medicine_url.split('/')[-1]}") res2 = requests.get(medicine_url) soup2 = BeautifulSoup(res2.content, 'html.parser') full = soup2.find("h1", "page-heading-1-l").find_all("span")[1].text dosage = soup2.find( "h1", "page-heading-1-l").find_all("span")[1].small.text brand_name = full.replace(dosage, "").strip() generic_name = soup2.find(attrs={ "title": "Generic Name" }).a.text.strip() strength = soup2.find(attrs={"title": "Strength"}).text.strip() manufactured_by = soup2.find(attrs={ "title": "Manufactured by" }).a.text.strip() package_container = "".join( soup2.find(attrs={ "class": "package-container" }).text.strip().split()) indications = find_content(soup=soup2, content_id='indications') therapheutic_class = find_content(soup=soup2, content_id='drug_classes') description = find_content(soup=soup2, content_id='description') pharmacology = find_content(soup=soup2, content_id='mode_of_action') doasge_and_administration = find_content(soup=soup2, content_id='dosage') interaction = find_content(soup=soup2, content_id='interaction') contraindications = find_content(soup=soup2, content_id='contraindications') side_effects = find_content(soup=soup2, content_id='side_effects') pregnancy_and_lactation = find_content(soup=soup2, content_id='pregnancy_cat') precautions = find_content(soup=soup2, content_id='precautions') storage_conditions = find_content(soup=soup2, content_id='storage_conditions') overdose_effects = find_content(soup=soup2, content_id='overdose_effects') administration = find_content(soup=soup2, content_id='administration') medicine = Medicine( dosage=dosage, brand_name=brand_name, generic_name=generic_name, strength=re.findall(r"[-+]?\d*\.\d+|\d+", strength)[0], manufactured_by=manufactured_by, unit_price=re.findall(r"[-+]?\d*\.\d+|\d+", package_container)[0], indications=indications, therapheutic_class=therapheutic_class, description=description, pharmacology=pharmacology, doasge_and_administration=doasge_and_administration, interaction=interaction, contraindications=contraindications, side_effects=side_effects, pregnancy_and_lactation=pregnancy_and_lactation, precautions=precautions, storage_conditions=storage_conditions, overdose_effects=overdose_effects, administration=administration, ) m = medicine.save() print(m) print( f"Brand: {brand_name}\nDosage form: {dosage}\nGeneric Name: {generic_name}\nStrength: {strength}\n" f"Manufactured By: {manufactured_by}\nPackage: {package_container}\nIndications: {indications}\n" f"Therapheutic Class: {therapheutic_class}\nDescription: {description}\nPharmacology: {pharmacology}\n" f"Dosage&Administration: {doasge_and_administration}\nInteraction: {interaction}\nContraindications: {contraindications}\n" f"Side Effects: {side_effects}\nPregnancy and Lactation: {pregnancy_and_lactation}\nPrecautions: {precautions}\n" f"Storage Conditions: {storage_conditions}\nOverdose_effects: {overdose_effects}\nAdministration: {administration}" ) print('\n\n\n') print('\n\n\n')
def take(request): obj = Medicine() obj.save() return redirect("medicine:index")
def add_medicine(request): context = {"page": "add_medicine"} if request.session.get('is_login', None): username = request.session.get('username') context['username'] = username else: return login(request) drugstore = request.session.get('storeid') if request.method == "POST": name = request.POST.get("name") price = request.POST.get("price") desc = request.POST.get("desc") status = request.POST.get("status") stock = request.POST.get("stock") medicinecode = request.POST.get("medicinecode") unite = request.POST.get("unite") type = request.POST.get("type") # image=request.FILES.get("medicineimg") if not all( [name, price, desc, status, stock, medicinecode, unite, type]): context['errmsg'] = '数据不完整' return render(request, "medicine/add_medicine.html", context=context) medicine = Medicine() medicine.name = name medicine.price = price medicine.status = status medicine.desc = desc medicine.stock = stock medicine.medicinecode = medicinecode medicine.unite = unite medicine.type = type medicine.drugstore_id = drugstore medicine.save() return render(request, "medicine/add_medicine.html", context=context)
def setUp(self): self.factory = RequestFactory() self.client = Client() self.view = CreateCopyPrescription() self.patient = Patient() self.patient.pk = 1 self.patient.name = "Paciente de teste" self.patient.date_of_birth = "1991-10-21" self.patient.phone = "06199999999" self.patient.email = "*****@*****.**" self.patient.sex = "M" self.patient.id_document = "1000331" self.patient.CEP = "72850735" self.patient.UF = "DF" self.patient.city = "Brasília" self.patient.neighborhood = "Asa sul" self.patient.complement = "Bloco 2 QD 701" self.patient.save() self.health_professional = HealthProfessional() self.health_professional.pk = 1 self.health_professional.crm = '12345' self.health_professional.crm_state = 'US' self.health_professional.save() self.medicine = Medicine() self.medicine.name = "Medicamento Teste" self.medicine.active_ingredient = "Teste Lab" self.medicine.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.disease = Disease() self.disease.pk = 1 self.disease.id_cid_10 = "A01" self.disease.description = "A random disease" self.disease.save() self.health_professional_2 = HealthProfessional.objects.create_user(email='*****@*****.**', password='******') self.nopatientprescription = NoPatientPrescription() self.nopatientprescription.patient = self.patient self.nopatientprescription.cid = self.disease self.nopatientprescription.health_professional = self.health_professional_2 self.nopatientprescription.patient = "Junior Marques" self.nopatientprescription.save() self.patientprescription = PatientPrescription() self.patientprescription.patient = self.patient self.patientprescription.cid = self.disease self.patientprescription.health_professional = self.health_professional_2 self.patientprescription.patient = self.patient self.patientprescription.save() self.posology = "Medicamento de Teste" self.quantity = 1 self.via = constants.VIA_CHOICES[0][0] self.has_medicine = PrescriptionHasMedicine() self.has_medicine.prescription_medicine = self.nopatientprescription.prescription_ptr self.has_medicine.medicine = self.medicine self.has_medicine.posology = self.posology self.has_medicine.via = self.via self.has_medicine.quantity = self.quantity self.has_medicine.save() self.has_manipulated = PrescriptionHasManipulatedMedicine() self.has_manipulated.prescription_medicine = self.nopatientprescription.prescription_ptr self.has_manipulated.manipulated_medicine = self.manipulated_medicine self.has_manipulated.posology = self.posology self.has_manipulated.via = self.via self.has_manipulated.quantity = self.quantity self.has_manipulated.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 2 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.nopatientprescription.prescription_ptr self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 12 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.nopatientprescription.prescription_ptr self.hasmanipulated_medicine.save() self.recommendation = NewRecommendation() self.recommendation.recommendation_description = "recomendacao de teste" self.recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.nopatientprescription.prescription_ptr self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.nopatientprescription.prescription_ptr self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.medicine = Medicine() self.medicine.name = "asdoajsdoiasj" self.medicine.active_ingredient = "dsofaksdofk" self.medicine.laboratory = "dofijasoifjjf" self.medicine.description = "oiajdoaisjddj" self.medicine.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 2 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.nopatientprescription.prescription_ptr self.prescription_has_medicine.save() self.default_exam = DefaultExam() self.default_exam.id_tuss = 'oiafj' self.default_exam.save() self.custom_exam = CustomExam() self.custom_exam.health_professional_FK = self.health_professional self.custom_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.nopatientprescription.prescription_ptr self.prescription_default_exam.save() self.prescription_custom_exam = PrescriptionCustomExam() self.prescription_custom_exam.exam = self.custom_exam self.prescription_custom_exam.prescription = self.nopatientprescription.prescription_ptr self.prescription_custom_exam.save()
class TestPrintPrescriptionPatient(TestCase): def setUp(self): self.factory = RequestFactory() self.client = Client() self.view = PrintPrescriptionPatient.generate_pdf self.patient = Patient() self.patient.pk = 1 self.patient.name = "Paciente de teste" self.patient.date_of_birth = "1991-10-21" self.patient.phone = "06199999999" self.patient.email = "*****@*****.**" self.patient.sex = "M" self.patient.id_document = "1000331" self.patient.CEP = "72850735" self.patient.UF = "DF" self.patient.city = "Brasília" self.patient.neighborhood = "Asa sul" self.patient.complement = "Bloco 2 QD 701" self.patient.save() self.health_professional = HealthProfessional() self.health_professional.pk = 1 self.health_professional.crm = '12345' self.health_professional.crm_state = 'US' self.health_professional.specialty_first = 'Nutricao' self.health_professional.specialty_second = 'Pediatria' self.health_professional.email = '*****@*****.**' self.health_professional.password = '******' self.health_professional.save() self.health_professional_no_specialty_second = HealthProfessional() self.health_professional_no_specialty_second.pk = 2 self.health_professional_no_specialty_second.crm = '11111' self.health_professional_no_specialty_second.crm_state = 'US' self.health_professional_no_specialty_second.specialty_first = 'Nutricao' self.health_professional_no_specialty_second.specialty_second = 'Nao Possui' self.health_professional_no_specialty_second.email = '*****@*****.**' self.health_professional_no_specialty_second.password = '******' self.health_professional_no_specialty_second.save() self.disease = Disease() self.disease.pk = 1 self.disease.id_cid_10 = "A01" self.disease.description = "A random disease" self.disease.save() self.prescription = NoPatientPrescription() self.prescription.pk = 1 self.prescription.health_professional = self.health_professional self.prescription.cid = self.disease self.prescription.patient = "Algum nome" self.prescription.save() self.prescription_2 = NoPatientPrescription() self.prescription_2.pk = 2 self.prescription_2.health_professional = self.health_professional self.prescription_2.cid = self.disease self.prescription_2.patient = "Algum nome" self.prescription_2.save() self.prescription_3 = PatientPrescription() self.prescription_3.pk = 3 self.prescription_3.health_professional = self.health_professional self.prescription_3.cid = self.disease self.prescription_3.patient = self.patient self.prescription_3.save() self.prescription_4 = PatientPrescription() self.prescription_4.pk = 4 self.prescription_4.health_professional = self.health_professional self.prescription_4.cid = self.disease self.prescription_4.patient = self.patient self.prescription_4.save() self.prescription_5 = PatientPrescription() self.prescription_5.pk = 5 self.prescription_5.health_professional = self.health_professional self.prescription_5.cid = self.disease self.prescription_5.patient = self.patient self.prescription_5.save() self.prescription_6 = PatientPrescription() self.prescription_6.pk = 6 self.prescription_6.health_professional = self.health_professional_no_specialty_second self.prescription_6.cid = self.disease self.prescription_6.patient = self.patient self.prescription_6.save() self.manipulated_medicine = ManipulatedMedicine() self.manipulated_medicine.pk = 1 self.manipulated_medicine.recipe_name = "teste" self.manipulated_medicine.physical_form = "asdadsafdf" self.manipulated_medicine.quantity = 12 self.manipulated_medicine.measurement = "kg" self.manipulated_medicine.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine.health_professional = self.health_professional self.manipulated_medicine.save() self.manipulated_medicine_2 = ManipulatedMedicine() self.manipulated_medicine_2.pk = 2 self.manipulated_medicine_2.recipe_name = "teste" self.manipulated_medicine_2.physical_form = "asdadsafdf" self.manipulated_medicine_2.quantity = 12 self.manipulated_medicine_2.measurement = "kg" self.manipulated_medicine_2.composition = "aosdjoaisjdoiajsdoij" self.manipulated_medicine_2.health_professional = self.health_professional self.manipulated_medicine_2.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 2 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine_2 self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 12 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription self.hasmanipulated_medicine.save() self.hasmanipulated_medicine = PrescriptionHasManipulatedMedicine() self.hasmanipulated_medicine.manipulated_medicine = self.manipulated_medicine self.hasmanipulated_medicine.posology = "asd" self.hasmanipulated_medicine.quantity = 1 self.hasmanipulated_medicine.pk = 4 self.hasmanipulated_medicine.via = 'Via Intravenosa' self.hasmanipulated_medicine.prescription_medicine = self.prescription_2 self.hasmanipulated_medicine.save() self.recommendation = NewRecommendation() self.recommendation.recommendation_description = "recomendacao de teste" self.recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.prescription_has_recommendation = PrescriptionNewRecommendation() self.prescription_has_recommendation.prescription = self.prescription_3 self.prescription_has_recommendation.recommendation = self.recommendation self.prescription_has_recommendation.save() self.medicine = Medicine() self.medicine.name = "asdoajsdoiasj" self.medicine.active_ingredient = "dsofaksdofk" self.medicine.laboratory = "dofijasoifjjf" self.medicine.description = "oiajdoaisjddj" self.medicine.save() self.medicine_2 = Medicine() self.medicine_2.name = "asdoajsdoiasj" self.medicine_2.active_ingredient = "dsofaksdofk" self.medicine_2.laboratory = "dofijasoifjjf" self.medicine_2.description = "oiajdoaisjddj" self.medicine_2.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 2 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.prescription_has_medicine = PrescriptionHasMedicine() self.prescription_has_medicine.medicine = self.medicine_2 self.prescription_has_medicine.posology = "asd" self.prescription_has_medicine.quantity = 1 self.prescription_has_medicine.pk = 21 self.prescription_has_medicine.via = 'Via Intravenosa' self.prescription_has_medicine.prescription_medicine = self.prescription self.prescription_has_medicine.save() self.default_exam = DefaultExam() self.default_exam.id_tuss = 'oiafj' self.default_exam.save() self.custom_exam = CustomExam() self.custom_exam.health_professional_FK = self.health_professional self.custom_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription self.prescription_default_exam.save() self.prescription_default_exam = PrescriptionDefaultExam() self.prescription_default_exam.exam = self.default_exam self.prescription_default_exam.prescription = self.prescription_4 self.prescription_default_exam.save() self.prescription_custom_exam = PrescriptionCustomExam() self.prescription_custom_exam.exam = self.custom_exam self.prescription_custom_exam.prescription = self.prescription self.prescription_custom_exam.save() def test_print_prescription_get_no_second_speciality(self): request = self.factory.get('/prescription/print_prescription/1/3') response = self.view(request, pk=6) self.assertEqual(response.status_code, 200) def test_print_prescription(self): request = self.factory.get('/prescription/print_prescription/1/3') response = self.view(request, pk=1) self.assertEqual(response.status_code, 200) def test_print_prescription_get_invalid_medicine(self): request = self.factory.get('/prescription/print_prescription/2') response = self.view(request, pk=2) self.assertEqual(response.status_code, 200) def test_print_prescription_get_invalid_recommendation(self): request = self.factory.get('/prescription/print_prescription/3') response = self.view(request, pk=3) self.assertEqual(response.status_code, 200) def test_print_prescription_get_invalid_exam(self): request = self.factory.get('/prescription/print_prescription/4') response = self.view(request, pk=4) self.assertEqual(response.status_code, 200) def test_print_prescription_get_invalid(self): request = self.factory.get('/prescription/print_prescription/3') response = self.view(request, pk=3) self.assertEqual(response.status_code, 200)