isdrugallergic 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isdrugallergic.rb +42 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6d2367362b2ff209b5aff069fb9ead527fb1635c6afb1eab613686d37ee910
|
4
|
+
data.tar.gz: c9b450897a4c2079f88626c82a2c3ca3e90ddb8134af32beafe0b3a7686d0323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d4c2b18991942c466c6162340442ad94b217ef2350d0e3ef9403288ab846d71d797bef1f7e412f899a962bf66f7e7f03d7dc894ca041d120db7f945494457f
|
7
|
+
data.tar.gz: 971cf2d8898c7bbc85990d2630a116138f4155f1b2cf5ef376b28a6a9deba3d12ba7cae51b816cc51af370cf77767ce8e3c6adcd19a46dc9b8f9f1cd5e502f48
|
data/lib/isdrugallergic.rb
CHANGED
@@ -2,31 +2,50 @@ class Checkallergy
|
|
2
2
|
|
3
3
|
def self.check_allergy(presc_drug, allergies)
|
4
4
|
|
5
|
+
#initialize variables
|
6
|
+
@presc_drug = presc_drug
|
7
|
+
@allergies allergies
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
@allergies = allergies
|
9
|
-
|
10
|
-
|
11
|
-
#loop through each patient allergy
|
12
|
-
@allergies.each do |allergy|
|
13
|
-
|
14
|
-
# puts("\n\n\n"+allergy.allergy_name.downcase+" <==> "+@presc_drug.downcase+"\n\n\n")
|
15
|
-
if allergy.allergy_name.downcase.eql? @presc_drug.downcase
|
16
|
-
# puts("Allergic Conflict Found")
|
17
|
-
@status_code = 0
|
18
|
-
@status_message = "There was an allergy conflict with the proposed drug:"+@presc_drug
|
19
|
-
break
|
20
|
-
else
|
21
|
-
# puts("Allergic conflict not found")
|
22
|
-
@status_code = 1
|
23
|
-
@status_message = "No allergy conflicts found with drug:"+@presc_drug
|
24
|
-
end
|
9
|
+
#if patient allergies are nil return false
|
10
|
+
if allergies.nil?
|
25
11
|
|
26
|
-
|
12
|
+
status_code = 0
|
13
|
+
status_message = "No allergy conflicts found with drug:"+@presc_drug
|
14
|
+
|
15
|
+
#if patient has allergies
|
16
|
+
else
|
27
17
|
|
28
|
-
#
|
29
|
-
|
18
|
+
#if allergy_match? method returns true: return with conflict error
|
19
|
+
if allergy_match?
|
20
|
+
status_code = 1
|
21
|
+
status_message = "There was an allergy conflict with the proposed drug:"+@presc_drug
|
22
|
+
|
23
|
+
#if allergy_match? method returns flase: return no conflict
|
24
|
+
else
|
25
|
+
status_code = 0
|
26
|
+
status_message = "No allergy conflicts found with drug:"+@presc_drug
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#return response to the caller with the allergy conflict status
|
31
|
+
return({"status_code":status_code, "status_message":status_message})
|
30
32
|
|
31
33
|
end
|
32
|
-
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def allergy_match?
|
38
|
+
#iterate through each patient allergy and compare to prescription drug
|
39
|
+
@allergies.each do |allergy|
|
40
|
+
|
41
|
+
# puts("\n\n\n"+allergy.downcase+" <==> "+@presc_drug.downcase+"\n\n\n")
|
42
|
+
if allergy.allergy_name.downcase.eql? @presc_drug.downcase
|
43
|
+
return true
|
44
|
+
break
|
45
|
+
else
|
46
|
+
# puts("Allergic conflict not found")
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|