jordanreport 1.0.0
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 +7 -0
- data/jordanreport.rb +116 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8500d7f1c4245f6e4a6e00bd3960f29e7c1e1da1d9590976150ef0ec5a47361
|
4
|
+
data.tar.gz: 8a65679fb43c06b3aa40c751896dfc08c39e42f54f770d9771f67e4238a15e0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4f5c4b43eaa69a4b0a337efa8a09b30f3645af2fd72dd1ff50a2ea0d5ea01d1c9773e3efbce12643cdf92d75fa6bf0a24f966cae0fb775d8329930b2bfbc8a5
|
7
|
+
data.tar.gz: 584db97edaecee060db41cb52982adde9af9b3a9b2735b7a3bed6dbdae514ae081955a1244517f702b4f8e5a80c9354bb980b02919c4d4cddf38eed928cb43ed
|
data/jordanreport.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'prawn'
|
3
|
+
|
4
|
+
# In this class we consume the singleton pattern where we only deal
|
5
|
+
# we one instance of "Patient" per method invokation. This class takes
|
6
|
+
# a patient object and writes to a JSON file. The JSON file can then be used
|
7
|
+
# by the admin of the application so he/she can view analytics for the application
|
8
|
+
|
9
|
+
class Report_Logging_JM
|
10
|
+
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
PATH = "public/reports/"
|
14
|
+
# Ref : https://stackoverflow.com/questions/55207753/how-json-file-is-overwritten-for-every-invocation-of-my-ruby-method
|
15
|
+
def self.writes(patient)
|
16
|
+
events_json = []
|
17
|
+
File.open("public/events.json","a") do |f|
|
18
|
+
f.write(patient.to_json)
|
19
|
+
end
|
20
|
+
write_pdf_record(patient)
|
21
|
+
end
|
22
|
+
# Ref : https://github.com/prawnpdf/prawn
|
23
|
+
# Write to PDF using the Prawn Gem
|
24
|
+
def self.write_pdf_record(patient)
|
25
|
+
|
26
|
+
# If we don't have the reports directory then make one!
|
27
|
+
Dir.mkdir("#{PATH}") unless File.exists?("#{PATH}")
|
28
|
+
|
29
|
+
# Get details
|
30
|
+
patient_name = patient.Full_Name
|
31
|
+
patient_age = patient.Age.to_s
|
32
|
+
patient_sex = patient.Sex
|
33
|
+
patient_address = patient.Address
|
34
|
+
patient_pps = patient.PPS
|
35
|
+
patient_medical_card_status = patient.Medical_Card
|
36
|
+
|
37
|
+
# Generate PDF with the Patient's Name appended to the PDF name
|
38
|
+
Prawn::Document.generate("#{PATH}#{patient_name}.pdf", :margin => 100) do
|
39
|
+
|
40
|
+
# Put Main Logo on Front
|
41
|
+
image Rails.root.to_s + '/app/assets/images/logo.png', :width => 500, :height => 500, :position => :center
|
42
|
+
|
43
|
+
# Create Second Page
|
44
|
+
start_new_page
|
45
|
+
|
46
|
+
# define new grid
|
47
|
+
define_grid(:columns => 5, :rows => 8, :gutter => 10)
|
48
|
+
|
49
|
+
# define variables into their own box
|
50
|
+
|
51
|
+
# Define Name
|
52
|
+
grid([0,0], [0,1]).bounding_box do
|
53
|
+
text "Patient Full Name : "
|
54
|
+
end
|
55
|
+
grid([0,2], [0,3]).bounding_box do
|
56
|
+
text patient_name
|
57
|
+
end
|
58
|
+
|
59
|
+
# Define Age
|
60
|
+
grid([1,0], [1,1]).bounding_box do
|
61
|
+
text "Patient Age : "
|
62
|
+
end
|
63
|
+
grid([1,2], [1,3]).bounding_box do
|
64
|
+
text patient_age
|
65
|
+
end
|
66
|
+
|
67
|
+
# Define Sex
|
68
|
+
grid([2,0], [2,1]).bounding_box do
|
69
|
+
text "Patient Sex : "
|
70
|
+
end
|
71
|
+
grid([2,2], [2,3]).bounding_box do
|
72
|
+
text patient_sex
|
73
|
+
end
|
74
|
+
|
75
|
+
# Define Address
|
76
|
+
grid([3,0], [3,1]).bounding_box do
|
77
|
+
text "Patient'a Address : "
|
78
|
+
end
|
79
|
+
grid([3,2], [3,3]).bounding_box do
|
80
|
+
text patient_address
|
81
|
+
end
|
82
|
+
|
83
|
+
# Define pps
|
84
|
+
grid([4,0], [4,1]).bounding_box do
|
85
|
+
text "Patient's PPS Number : "
|
86
|
+
end
|
87
|
+
grid([4,2], [4,3]).bounding_box do
|
88
|
+
text patient_pps
|
89
|
+
end
|
90
|
+
|
91
|
+
# Define Medical Card Status
|
92
|
+
grid([5,0], [5,1]).bounding_box do
|
93
|
+
text "Medical Card Status : "
|
94
|
+
end
|
95
|
+
grid([5,2], [5,3]).bounding_box do
|
96
|
+
text patient_medical_card_status
|
97
|
+
end
|
98
|
+
|
99
|
+
# Stamp
|
100
|
+
create_stamp("approved") do
|
101
|
+
rotate(30, :origin => [-5, -5]) do
|
102
|
+
stroke_color "FF3333"
|
103
|
+
stroke_ellipse [0, 0], 29, 15
|
104
|
+
stroke_color "000000"
|
105
|
+
|
106
|
+
fill_color "993333"
|
107
|
+
font("Times-Roman") do
|
108
|
+
draw_text "Confidential", :at => [-23, -3]
|
109
|
+
end
|
110
|
+
fill_color "000000"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
stamp_at "approved", [200, 200]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jordanreport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JordanM
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem utilises the singleton pattern to construct a PDF for every
|
14
|
+
patient record inserted into the db.
|
15
|
+
email: noemail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- jordanreport.rb
|
21
|
+
homepage: https://rubygems.org/gems/jordanreport
|
22
|
+
licenses: []
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: PDF and JSON logger for Dental Application
|
44
|
+
test_files: []
|