jp_vaccination 0.1.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/.github/workflows/main.yml +16 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +260 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/data/vaccinations.json +485 -0
- data/jp_vaccination.gemspec +39 -0
- data/lib/jp_vaccination/vaccination.rb +21 -0
- data/lib/jp_vaccination/version.rb +5 -0
- data/lib/jp_vaccination.rb +111 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b24ce38db45a0d195c2343c3c64366601e3a178f2225e335d60c0d613bf210a6
|
4
|
+
data.tar.gz: a63b2fa69cff42d13fc3ee2c21a351875ad08f27ee8939296f26137efd9ef39a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 261d6f73f91adf69ba637bf11a055da9887f43d45764ccdfaad30c97a2b1de2ca932b2ca748084660e6a34205c66171a1578a37951e0df15f6aa9ea3c3898f8b
|
7
|
+
data.tar.gz: fbef6b69d109ef7820e181b7287f00f98524d5fcd18e1ae152ee9c0020d6c61e68aadfe1ddfd0264831d03859aedce47f980dd7692c94951f5957ecee3de8a38
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 3.1.0
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at snwxxx29@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in jp_vaccination.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
|
10
|
+
gem 'minitest', '~> 5.0'
|
11
|
+
|
12
|
+
gem 'rubocop', '~> 1.7'
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem 'rubocop-fjord'
|
16
|
+
gem 'rubocop-minitest'
|
17
|
+
gem 'rubocop-rails'
|
18
|
+
gem 'rubocop-rake'
|
19
|
+
gem 'rubocop-rspec'
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jp_vaccination (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (7.0.2.2)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 1.6, < 2)
|
12
|
+
minitest (>= 5.1)
|
13
|
+
tzinfo (~> 2.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
concurrent-ruby (1.1.9)
|
16
|
+
i18n (1.10.0)
|
17
|
+
concurrent-ruby (~> 1.0)
|
18
|
+
minitest (5.15.0)
|
19
|
+
parallel (1.21.0)
|
20
|
+
parser (3.1.1.0)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
rack (2.2.3)
|
23
|
+
rainbow (3.1.1)
|
24
|
+
rake (13.0.6)
|
25
|
+
regexp_parser (2.2.1)
|
26
|
+
rexml (3.2.5)
|
27
|
+
rubocop (1.25.1)
|
28
|
+
parallel (~> 1.10)
|
29
|
+
parser (>= 3.1.0.0)
|
30
|
+
rainbow (>= 2.2.2, < 4.0)
|
31
|
+
regexp_parser (>= 1.8, < 3.0)
|
32
|
+
rexml
|
33
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
36
|
+
rubocop-ast (1.16.0)
|
37
|
+
parser (>= 3.1.1.0)
|
38
|
+
rubocop-fjord (0.2.0)
|
39
|
+
rubocop (>= 1.0)
|
40
|
+
rubocop-performance
|
41
|
+
rubocop-minitest (0.17.2)
|
42
|
+
rubocop (>= 0.90, < 2.0)
|
43
|
+
rubocop-performance (1.13.3)
|
44
|
+
rubocop (>= 1.7.0, < 2.0)
|
45
|
+
rubocop-ast (>= 0.4.0)
|
46
|
+
rubocop-rails (2.13.2)
|
47
|
+
activesupport (>= 4.2.0)
|
48
|
+
rack (>= 1.1)
|
49
|
+
rubocop (>= 1.7.0, < 2.0)
|
50
|
+
rubocop-rake (0.6.0)
|
51
|
+
rubocop (~> 1.0)
|
52
|
+
rubocop-rspec (2.9.0)
|
53
|
+
rubocop (~> 1.19)
|
54
|
+
ruby-progressbar (1.11.0)
|
55
|
+
tzinfo (2.0.4)
|
56
|
+
concurrent-ruby (~> 1.0)
|
57
|
+
unicode-display_width (2.1.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
x86_64-darwin-20
|
61
|
+
x86_64-linux
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
jp_vaccination!
|
65
|
+
minitest (~> 5.0)
|
66
|
+
rake (~> 13.0)
|
67
|
+
rubocop (~> 1.7)
|
68
|
+
rubocop-fjord
|
69
|
+
rubocop-minitest
|
70
|
+
rubocop-rails
|
71
|
+
rubocop-rake
|
72
|
+
rubocop-rspec
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
2.3.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 napple29
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
# JpVaccination
|
2
|
+
It provides data on infant vaccination in Japan. It also processes calculations of recommended and next available dates for vaccination.
|
3
|
+
|
4
|
+
These data are based on [the vaccination schedule of the National Institute of Infectious Diseases](https://www.niid.go.jp/niid/ja/schedule.html). Currently, only regular and some optional vaccinations in infancy are covered, but in the future all vaccinations will be covered.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'jp_vaccination'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install jp_vaccination
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'jp_vaccination'
|
26
|
+
```
|
27
|
+
### Check vaccination_keys.
|
28
|
+
You can check the list of [vaccination_keys](#about-vaccination_key) that can be passed as arguments.
|
29
|
+
|
30
|
+
`JpVaccination.vaccination_keys`
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
pp JpVaccination.vaccination_keys
|
34
|
+
|
35
|
+
=> [{ 'ヒブ 1回目' => 'hib_1' },
|
36
|
+
{ 'ヒブ 2回目' => 'hib_2' },
|
37
|
+
{ 'ヒブ 3回目' => 'hib_3' },
|
38
|
+
{ 'ヒブ 4回目' => 'hib_4' },
|
39
|
+
{ 'B型肝炎 1回目' => 'hepatitis_B_1' },
|
40
|
+
{ 'B型肝炎 2回目' => 'hepatitis_B_2' },
|
41
|
+
{ 'B型肝炎 3回目' => 'hepatitis_B_3' },
|
42
|
+
{ 'ロタウイルス 1回目' => 'rotavirus_1' },
|
43
|
+
{ 'ロタウイルス 2回目' => 'rotavirus_2' },
|
44
|
+
{ 'ロタウイルス 3回目' => 'rotavirus_3' },
|
45
|
+
{ '小児用肺炎球菌 1回目' => 'pneumococcus_1' },
|
46
|
+
{ '小児用肺炎球菌 2回目' => 'pneumococcus_2' },
|
47
|
+
{ '小児用肺炎球菌 3回目' => 'pneumococcus_3' },
|
48
|
+
{ '小児用肺炎球菌 4回目' => 'pneumococcus_4' },
|
49
|
+
{ '4種混合 第1期 1回目' => 'DPT_IPV_1' },
|
50
|
+
{ '4種混合 第1期 2回目' => 'DPT_IPV_2' },
|
51
|
+
{ '4種混合 第1期 3回目' => 'DPT_IPV_3' },
|
52
|
+
{ '4種混合 第1期 4回目' => 'DPT_IPV_4' },
|
53
|
+
{ '2種混合 第2期' => 'DT_1' },
|
54
|
+
{ 'BCG ' => 'BCG_1' },
|
55
|
+
{ '麻しん・風しん混合 第1期' => 'MR_1' },
|
56
|
+
{ '麻しん・風しん混合 第2期' => 'MR_2' },
|
57
|
+
{ '水痘 1回目' => 'chickenpox_1' },
|
58
|
+
{ '水痘 2回目' => 'chickenpox_2' },
|
59
|
+
{ 'おたふくかぜ 1回目' => 'mumps_1' },
|
60
|
+
{ 'おたふくかぜ 2回目' => 'mumps_2' },
|
61
|
+
{ '日本脳炎 第1期 1回目' => 'Japanese_encephalitis_1' },
|
62
|
+
{ '日本脳炎 第1期 2回目' => 'Japanese_encephalitis_2' },
|
63
|
+
{ '日本脳炎 第1期 3回目' => 'Japanese_encephalitis_3' },
|
64
|
+
{ '日本脳炎 第2期' => 'Japanese_encephalitis_4' }]
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
### Access to vaccination data.
|
69
|
+
Pass the argument as a string for the [vaccination_key](#about-vaccination_key).
|
70
|
+
|
71
|
+
`JpVaccination.find(vaccination_key)`
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
chickenpox_1st = JpVaccination.find('chickenpox_1')
|
75
|
+
|
76
|
+
chickenpox_1st.name # => "水痘"
|
77
|
+
chickenpox_1st.period # => "1回目"
|
78
|
+
chickenpox_1st.regular # => true
|
79
|
+
chickenpox_1st.type # => "生ワクチン"
|
80
|
+
chickenpox_1st.recommended # => {:month=>12}
|
81
|
+
chickenpox_1st.deadline # => {:date_type=>"month", :start=>12, :end=>15, :less_than=>true}
|
82
|
+
chickenpox_1st.interval # => nil
|
83
|
+
|
84
|
+
# name + period
|
85
|
+
chickenpox_1st.formal_name # => "水痘 1回目"
|
86
|
+
```
|
87
|
+
Example data.
|
88
|
+
|column|data|example|title|
|
89
|
+
|-|-|-|-|
|
90
|
+
name |String|"水痘"|予防接種名|
|
91
|
+
period|String|"2回目"|期間|
|
92
|
+
regular|true/false|true|定期/任意|
|
93
|
+
type[^1]|String|"生ワクチン"|種類|
|
94
|
+
recommended|Hash|{ month: 18 }| 推奨接種月齢
|
95
|
+
deadline[^2]|Hash|{<br> date_type: "month",<br>start: 15,<br> end: 36,<br> less_than: true<br>}|接種期日|
|
96
|
+
interval[^2]|Hash|{ <br>date_type: "month",<br> start: 3,<br> end: 12 <br>}|接種間隔|
|
97
|
+
|
98
|
+
[^1]:`nil except for live vaccines.`
|
99
|
+
[^2]:5~36 months:{date_type:"month",start:15,end:36},`less_than:true` is less than.
|
100
|
+
`less_than:false` is below.
|
101
|
+
|
102
|
+
### Calculate all recommended dates of vaccination
|
103
|
+
`JpVaccination.recommended_days(birthday, convert_to_strings)`
|
104
|
+
|
105
|
+
default convert_to_string: nil
|
106
|
+
|
107
|
+
```rb
|
108
|
+
birthday = '2022-03-01'
|
109
|
+
pp JpVaccination.recommended_days(birthday, convert_to_strings = true)
|
110
|
+
# default convert_to_string: nil
|
111
|
+
|
112
|
+
=> [{:name=>"ヒブ 1回目", :date=>"2022-05-01"},
|
113
|
+
{:name=>"ヒブ 2回目", :date=>"2022-06-01"},
|
114
|
+
{:name=>"ヒブ 3回目", :date=>"2022-07-01"},
|
115
|
+
{:name=>"ヒブ 4回目", :date=>"2023-03-01"},
|
116
|
+
{:name=>"B型肝炎 1回目", :date=>"2022-05-01"},
|
117
|
+
{:name=>"B型肝炎 2回目", :date=>"2022-06-01"},
|
118
|
+
{:name=>"B型肝炎 3回目", :date=>"2022-10-01"},
|
119
|
+
{:name=>"ロタウイルス 1回目", :date=>"2022-05-01"},
|
120
|
+
{:name=>"ロタウイルス 2回目", :date=>"2022-06-01"},
|
121
|
+
{:name=>"ロタウイルス 3回目", :date=>"2022-07-01"},
|
122
|
+
{:name=>"小児用肺炎球菌 1回目", :date=>"2022-05-01"},
|
123
|
+
{:name=>"小児用肺炎球菌 2回目", :date=>"2022-06-01"},
|
124
|
+
{:name=>"小児用肺炎球菌 3回目", :date=>"2022-07-01"},
|
125
|
+
{:name=>"小児用肺炎球菌 4回目", :date=>"2023-03-01"},
|
126
|
+
{:name=>"4種混合 第1期 1回目", :date=>"2022-06-01"},
|
127
|
+
{:name=>"4種混合 第1期 2回目", :date=>"2022-07-01"},
|
128
|
+
{:name=>"4種混合 第1期 3回目", :date=>"2022-08-01"},
|
129
|
+
{:name=>"4種混合 第1期 4回目", :date=>"2023-03-01"},
|
130
|
+
{:name=>"2種混合 第2期", :date=>"2033-03-01"},
|
131
|
+
{:name=>"BCG ", :date=>"2022-08-01"},
|
132
|
+
{:name=>"麻しん・風しん混合 第1期", :date=>"2023-03-01"},
|
133
|
+
{:name=>"麻しん・風しん混合 第2期", :date=>"2027-04-01〜2028-04-01"},
|
134
|
+
{:name=>"水痘 1回目", :date=>"2023-03-01"},
|
135
|
+
{:name=>"水痘 2回目", :date=>"2023-09-01"},
|
136
|
+
{:name=>"おたふくかぜ 1回目", :date=>"2023-03-01"},
|
137
|
+
{:name=>"おたふくかぜ 2回目", :date=>"2027-04-01〜2028-04-01"},
|
138
|
+
{:name=>"日本脳炎 第1期 1回目", :date=>"2025-03-01"},
|
139
|
+
{:name=>"日本脳炎 第1期 2回目", :date=>"2025-04-01"},
|
140
|
+
{:name=>"日本脳炎 第1期 3回目", :date=>"2026-03-01"},
|
141
|
+
{:name=>"日本脳炎 第2期", :date=>"2031-03-01"}]
|
142
|
+
```
|
143
|
+
### Sort recommended vaccination dates in ascending order
|
144
|
+
`JpVaccination.recommended_schedules(birthday, convert_to_strings = nil)`
|
145
|
+
|
146
|
+
You can turn Date into String by setting `convert_to_strings` to true
|
147
|
+
|
148
|
+
```rb
|
149
|
+
birthday = '2022-03-01'
|
150
|
+
pp JpVaccination.recommended_schedules(birthday, convert_to_strings = true)
|
151
|
+
# default convert_to_string: nil
|
152
|
+
|
153
|
+
=> {"2022-05-01"=>["ヒブ 1回目", "ロタウイルス 1回目", "小児用肺炎球菌 1回目", "B型肝炎 1回目"],
|
154
|
+
"2022-06-01"=>["ヒブ 2回目", "ロタウイルス 2回目", "小児用肺炎球菌 2回目", "4種混合 第1期 1回目", "B型肝炎 2回目"],
|
155
|
+
"2022-07-01"=>["ヒブ 3回目", "ロタウイルス 3回目", "小児用肺炎球菌 3回目", "4種混合 第1期 2回目"],
|
156
|
+
"2022-08-01"=>["4種混合 第1期 3回目", "BCG "],
|
157
|
+
"2022-10-01"=>["B型肝炎 3回目"],
|
158
|
+
"2023-03-01"=>["おたふくかぜ 1回目", "ヒブ 4回目", "小児用肺炎球菌 4回目", "水痘 1回目", "麻しん・風しん混合 第1期", "4種混合 第1期 4回目"],
|
159
|
+
"2023-09-01"=>["水痘 2回目"],
|
160
|
+
"2025-03-01"=>["日本脳炎 第1期 1回目"],
|
161
|
+
"2025-04-01"=>["日本脳炎 第1期 2回目"],
|
162
|
+
"2026-03-01"=>["日本脳炎 第1期 3回目"],
|
163
|
+
"2027-04-01〜2028-03-31"=>["おたふくかぜ 2回目", "麻しん・風しん混合 第2期"],
|
164
|
+
"2031-03-01"=>["日本脳炎 第2期"],
|
165
|
+
"2033-03-01"=>["2種混合 第2期"]}
|
166
|
+
```
|
167
|
+
|
168
|
+
|
169
|
+
`JpVaccination.recommended_schedules(birthday, nil)` or
|
170
|
+
`JpVaccination.recommended_schedules(birthday)`
|
171
|
+
```ruby
|
172
|
+
pp JpVaccination.recommended_schedules('2022-03-01')
|
173
|
+
=> {#<Date: 2022-05-01 ((2459701j,0s,0n),+0s,2299161j)>=>["小児用肺炎球菌 1回目", "ヒブ 1回目", "ロタウイルス 1回目", "B型肝炎 1回目"],…
|
174
|
+
```
|
175
|
+
|
176
|
+
### Calculate the next available vaccination date from the date of the previous vaccination.
|
177
|
+
`JpVaccination.next_day(vaccination_key, last_time)`
|
178
|
+
|
179
|
+
```rb
|
180
|
+
pp JpVaccination.next_day('hepatitis_B_2', '2020-04-01')
|
181
|
+
|
182
|
+
=> {:name=>"B型肝炎 2回目", :date=>#<Date: 2020-04-28 ((2458968j,0s,0n),+0s,2299161j)>}
|
183
|
+
```
|
184
|
+
|
185
|
+
If you want to find the date of the first vaccination, in short, the last character of the vaccination_key is 1, enter the date of birth in last_time.
|
186
|
+
|
187
|
+
`JpVaccination.next_day(vaccination_1, birthday)`
|
188
|
+
```ruby
|
189
|
+
birthday = '2022-02-01'
|
190
|
+
pp JpVaccination.next_day('hepatitis_B_1', birthday)
|
191
|
+
|
192
|
+
=> {:name=>"B型肝炎 1回目", :date=>#<Date: 2022-04-01 ((2458968j,0s,0n),+0s,2299161j)>}
|
193
|
+
```
|
194
|
+
|
195
|
+
### Argument Error
|
196
|
+
If the [vaccination_key](#about-vaccination_key) is incorrect, the following error occurs.
|
197
|
+
```
|
198
|
+
# hepatitis_B_4 is incorrect.
|
199
|
+
|
200
|
+
puts JpVaccination.next_day(vaccination_key: 'hepatitis_B_4', last_time: '2020-04-01')
|
201
|
+
|
202
|
+
# error
|
203
|
+
jp_vaccination/lib/jp_vaccination.rb:99:in `output_argument_error': The vaccination_key 'hepatitis_B_4' doesn't exist. (ArgumentError)
|
204
|
+
```
|
205
|
+
|
206
|
+
## About vaccination_key
|
207
|
+
The key formation is `(vaccination's English translation)_(period-number)`.
|
208
|
+
|
209
|
+
Each vaccination and corresponding key is as follows.
|
210
|
+
|
211
|
+
|vaccination_key|name|period|
|
212
|
+
|---|-----|------|
|
213
|
+
|hib_1|ヒブ|1回目|
|
214
|
+
|hib_2|ヒブ|2回目|
|
215
|
+
|hib_3|ヒブ|3回目|
|
216
|
+
|hib_4|ヒブ|4回目|
|
217
|
+
|hepatitis_B_1|B型肝炎|1回目|
|
218
|
+
|hepatitis_B_2|B型肝炎|2回目|
|
219
|
+
|hepatitis_B_3|B型肝炎|3回目|
|
220
|
+
|rotavirus_1|ロタウイルス|1回目|
|
221
|
+
|rotavirus_2|ロタウイルス|2回目|
|
222
|
+
|rotavirus_3|ロタウイルス|3回目|
|
223
|
+
|pneumococcus_1|小児用肺炎球菌|1回目|
|
224
|
+
|pneumococcus_2|小児用肺炎球菌|2回目|
|
225
|
+
|pneumococcus_3|小児用肺炎球菌|3回目|
|
226
|
+
|pneumococcus_4|小児用肺炎球菌|4回目|
|
227
|
+
|DPT_IPV_1|4種混合|第1期 1回目|
|
228
|
+
|DPT_IPV_2|4種混合|第1期 2回目|
|
229
|
+
|DPT_IPV_3|4種混合|第1期 3回目|
|
230
|
+
|DPT_IPV_4|4種混合|第2期|
|
231
|
+
|DT_1|2種混合|第2期|
|
232
|
+
|BCG_1|BCG|-|
|
233
|
+
|MR_1|麻しん・風しん混合|第1期|
|
234
|
+
|MR_2|麻しん・風しん混合|第2期|
|
235
|
+
|chickenpox_1|水痘|1回目|
|
236
|
+
|chickenpox_2|水痘|2回目|
|
237
|
+
|mumps_1|おたふくかぜ|1回目|
|
238
|
+
|mumps_2|おたふくかぜ|2回目|
|
239
|
+
|Japanese_encephalitis_1|日本脳炎|第1期 1回目|
|
240
|
+
|Japanese_encephalitis_2|日本脳炎|第1期 2回目|
|
241
|
+
|Japanese_encephalitis_3|日本脳炎|第1期 3回目|
|
242
|
+
|Japanese_encephalitis_4|日本脳炎|第2期|
|
243
|
+
|
244
|
+
## Development
|
245
|
+
|
246
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
247
|
+
|
248
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
249
|
+
|
250
|
+
## Contributing
|
251
|
+
|
252
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/napple29/jp_vaccination. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/napple29/jp_vaccination/blob/master/CODE_OF_CONDUCT.md).
|
253
|
+
|
254
|
+
## License
|
255
|
+
|
256
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
257
|
+
|
258
|
+
## Code of Conduct
|
259
|
+
|
260
|
+
Everyone interacting in the JpVaccination project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/napple29/jp_vaccination/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubocop/rake_task'
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'jp_vaccination'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,485 @@
|
|
1
|
+
{
|
2
|
+
"vaccinations": {
|
3
|
+
"hib_1": {
|
4
|
+
"name": "ヒブ",
|
5
|
+
"period": "1回目",
|
6
|
+
"regular": true,
|
7
|
+
"recommended": {
|
8
|
+
"month": 2
|
9
|
+
},
|
10
|
+
"deadline": {
|
11
|
+
"date_type": "month",
|
12
|
+
"start": 2,
|
13
|
+
"end": 7,
|
14
|
+
"less_than": true
|
15
|
+
}
|
16
|
+
},
|
17
|
+
"hib_2": {
|
18
|
+
"name": "ヒブ",
|
19
|
+
"period": "2回目",
|
20
|
+
"regular": true,
|
21
|
+
"recommended": {
|
22
|
+
"month": 3
|
23
|
+
},
|
24
|
+
"deadline": {
|
25
|
+
"date_type": "month",
|
26
|
+
"start": null,
|
27
|
+
"end": 12,
|
28
|
+
"less_than": true
|
29
|
+
},
|
30
|
+
"interval": {
|
31
|
+
"date_type": "day",
|
32
|
+
"start": 27,
|
33
|
+
"end": 56
|
34
|
+
}
|
35
|
+
},
|
36
|
+
"hib_3": {
|
37
|
+
"name": "ヒブ",
|
38
|
+
"period": "3回目",
|
39
|
+
"regular": true,
|
40
|
+
"recommended": {
|
41
|
+
"month": 4
|
42
|
+
},
|
43
|
+
"deadline": {
|
44
|
+
"date_type": "month",
|
45
|
+
"start": null,
|
46
|
+
"end": 12,
|
47
|
+
"less_than": true
|
48
|
+
},
|
49
|
+
"interval": {
|
50
|
+
"date_type": "day",
|
51
|
+
"start": 27,
|
52
|
+
"end": 56
|
53
|
+
}
|
54
|
+
},
|
55
|
+
"hib_4": {
|
56
|
+
"name": "ヒブ",
|
57
|
+
"period": "4回目",
|
58
|
+
"regular": true,
|
59
|
+
"recommended": {
|
60
|
+
"month": 12
|
61
|
+
},
|
62
|
+
"deadline": {
|
63
|
+
"date_type": "month",
|
64
|
+
"start": null,
|
65
|
+
"end": 60,
|
66
|
+
"less_than": true
|
67
|
+
},
|
68
|
+
"interval": {
|
69
|
+
"date_type": "month",
|
70
|
+
"start": 7,
|
71
|
+
"end": 13,
|
72
|
+
"less_than": true
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"hepatitis_B_1": {
|
76
|
+
"name": "B型肝炎",
|
77
|
+
"period": "1回目",
|
78
|
+
"regular": true,
|
79
|
+
"recommended": {
|
80
|
+
"month": 2
|
81
|
+
},
|
82
|
+
"deadline": {
|
83
|
+
"date_type": "month",
|
84
|
+
"start": 2,
|
85
|
+
"end": null,
|
86
|
+
"less_than": true
|
87
|
+
}
|
88
|
+
},
|
89
|
+
"hepatitis_B_2": {
|
90
|
+
"name": "B型肝炎",
|
91
|
+
"period": "2回目",
|
92
|
+
"regular": true,
|
93
|
+
"recommended": {
|
94
|
+
"month": 3
|
95
|
+
},
|
96
|
+
"interval": {
|
97
|
+
"date_type": "day",
|
98
|
+
"start": 27,
|
99
|
+
"end": null
|
100
|
+
},
|
101
|
+
"description": "①生後2か月②生後3か月③生後7-8か月 ①-②は27日(4週)以上、①-③は139日(20週)以上あける"
|
102
|
+
},
|
103
|
+
"hepatitis_B_3": {
|
104
|
+
"name": "B型肝炎",
|
105
|
+
"period": "3回目",
|
106
|
+
"regular": true,
|
107
|
+
"recommended": {
|
108
|
+
"month": 7
|
109
|
+
},
|
110
|
+
"deadline": {
|
111
|
+
"date_type": "year",
|
112
|
+
"start": null,
|
113
|
+
"end": 1,
|
114
|
+
"less_than": true
|
115
|
+
},
|
116
|
+
"interval": {
|
117
|
+
"date_type": "week",
|
118
|
+
"start": 16,
|
119
|
+
"end": 20,
|
120
|
+
"less_than": true
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"rotavirus_1": {
|
124
|
+
"name": "ロタウイルス",
|
125
|
+
"period": "1回目",
|
126
|
+
"regular": true,
|
127
|
+
"recommended": {
|
128
|
+
"month": 2
|
129
|
+
},
|
130
|
+
"deadline": {
|
131
|
+
"date_type": "day",
|
132
|
+
"start": null,
|
133
|
+
"end": 104,
|
134
|
+
"less_than": true
|
135
|
+
}
|
136
|
+
},
|
137
|
+
"rotavirus_2": {
|
138
|
+
"name": "ロタウイルス",
|
139
|
+
"period": "2回目",
|
140
|
+
"regular": true,
|
141
|
+
"recommended": {
|
142
|
+
"month": 3
|
143
|
+
},
|
144
|
+
"deadline": {
|
145
|
+
"date_type": "day",
|
146
|
+
"start": null,
|
147
|
+
"end": 168,
|
148
|
+
"less_than": true
|
149
|
+
},
|
150
|
+
"interval": {
|
151
|
+
"date_type": "week",
|
152
|
+
"start": 4,
|
153
|
+
"end": null,
|
154
|
+
"less_than": true
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"rotavirus_3": {
|
158
|
+
"name": "ロタウイルス",
|
159
|
+
"period": "3回目",
|
160
|
+
"regular": true,
|
161
|
+
"recommended": {
|
162
|
+
"month": 4
|
163
|
+
},
|
164
|
+
"deadline": {
|
165
|
+
"date_type": "day",
|
166
|
+
"start": null,
|
167
|
+
"end": 224
|
168
|
+
},
|
169
|
+
"interval": {
|
170
|
+
"date_type": "week",
|
171
|
+
"start": 4,
|
172
|
+
"end": null,
|
173
|
+
"less_than": true
|
174
|
+
}
|
175
|
+
},
|
176
|
+
"pneumococcus_1": {
|
177
|
+
"name": "小児用肺炎球菌",
|
178
|
+
"period": "1回目",
|
179
|
+
"regular": true,
|
180
|
+
"recommended": {
|
181
|
+
"month": 2
|
182
|
+
},
|
183
|
+
"deadline": {
|
184
|
+
"date_type": "month",
|
185
|
+
"start": 2,
|
186
|
+
"end": 7,
|
187
|
+
"less_than": true
|
188
|
+
}
|
189
|
+
},
|
190
|
+
"pneumococcus_2": {
|
191
|
+
"name": "小児用肺炎球菌",
|
192
|
+
"period": "2回目",
|
193
|
+
"regular": true,
|
194
|
+
"recommended": {
|
195
|
+
"month": 3
|
196
|
+
},
|
197
|
+
"deadline": {
|
198
|
+
"date_type": "month",
|
199
|
+
"start": null,
|
200
|
+
"end": 12,
|
201
|
+
"less_than": true
|
202
|
+
},
|
203
|
+
"interval": {
|
204
|
+
"date_type": "day",
|
205
|
+
"start": 27,
|
206
|
+
"end": 56,
|
207
|
+
"less_than": true
|
208
|
+
}
|
209
|
+
},
|
210
|
+
"pneumococcus_3": {
|
211
|
+
"name": "小児用肺炎球菌",
|
212
|
+
"period": "3回目",
|
213
|
+
"regular": true,
|
214
|
+
"recommended": {
|
215
|
+
"month": 4
|
216
|
+
},
|
217
|
+
"deadline": {
|
218
|
+
"date_type": "month",
|
219
|
+
"start": null,
|
220
|
+
"end": 12,
|
221
|
+
"less_than": true
|
222
|
+
},
|
223
|
+
"interval": {
|
224
|
+
"date_type": "day",
|
225
|
+
"start": 27,
|
226
|
+
"end": 56,
|
227
|
+
"less_than": true
|
228
|
+
}
|
229
|
+
},
|
230
|
+
"pneumococcus_4": {
|
231
|
+
"name": "小児用肺炎球菌",
|
232
|
+
"period": "4回目",
|
233
|
+
"regular": true,
|
234
|
+
"recommended": {
|
235
|
+
"month": 12
|
236
|
+
},
|
237
|
+
"deadline": {
|
238
|
+
"date_type": "month",
|
239
|
+
"start": 12,
|
240
|
+
"end": 15,
|
241
|
+
"less_than": true
|
242
|
+
},
|
243
|
+
"interval": {
|
244
|
+
"date_type": "day",
|
245
|
+
"start": 60,
|
246
|
+
"end": null,
|
247
|
+
"less_than": true
|
248
|
+
}
|
249
|
+
},
|
250
|
+
"DPT_IPV_1": {
|
251
|
+
"name": "4種混合",
|
252
|
+
"period": "第1期 1回目",
|
253
|
+
"regular": true,
|
254
|
+
"recommended": {
|
255
|
+
"month": 3
|
256
|
+
},
|
257
|
+
"deadline": {
|
258
|
+
"date_type": "month",
|
259
|
+
"start": 3,
|
260
|
+
"end": 12,
|
261
|
+
"less_than": true
|
262
|
+
}
|
263
|
+
},
|
264
|
+
"DPT_IPV_2": {
|
265
|
+
"name": "4種混合",
|
266
|
+
"period": "第1期 2回目",
|
267
|
+
"regular": true,
|
268
|
+
"recommended": {
|
269
|
+
"month": 4
|
270
|
+
},
|
271
|
+
"deadline": null,
|
272
|
+
"interval": {
|
273
|
+
"date_type": "day",
|
274
|
+
"start": 20,
|
275
|
+
"end": 56
|
276
|
+
}
|
277
|
+
},
|
278
|
+
"DPT_IPV_3": {
|
279
|
+
"name": "4種混合",
|
280
|
+
"period": "第1期 3回目",
|
281
|
+
"regular": true,
|
282
|
+
"recommended": {
|
283
|
+
"month": 5
|
284
|
+
},
|
285
|
+
"deadline": null,
|
286
|
+
"interval": {
|
287
|
+
"date_type": "day",
|
288
|
+
"start": 20,
|
289
|
+
"end": 56
|
290
|
+
}
|
291
|
+
},
|
292
|
+
"DPT_IPV_4": {
|
293
|
+
"name": "4種混合",
|
294
|
+
"period": "第1期 4回目",
|
295
|
+
"regular": true,
|
296
|
+
"recommended": {
|
297
|
+
"month": 12
|
298
|
+
},
|
299
|
+
"deadline": null,
|
300
|
+
"interval": {
|
301
|
+
"date_type": "month",
|
302
|
+
"start": 12,
|
303
|
+
"end": 18
|
304
|
+
}
|
305
|
+
},
|
306
|
+
"DT_1": {
|
307
|
+
"name": "2種混合",
|
308
|
+
"period": "第2期",
|
309
|
+
"regular": true,
|
310
|
+
"recommended": {
|
311
|
+
"year": 11
|
312
|
+
},
|
313
|
+
"deadline": {
|
314
|
+
"date_type": "year",
|
315
|
+
"start": 11,
|
316
|
+
"end": 13,
|
317
|
+
"less_than": true
|
318
|
+
}
|
319
|
+
},
|
320
|
+
"BCG_1": {
|
321
|
+
"name": "BCG",
|
322
|
+
"period": "",
|
323
|
+
"regular": true,
|
324
|
+
"type": "生ワクチン",
|
325
|
+
"recommended": {
|
326
|
+
"month": 5
|
327
|
+
},
|
328
|
+
"deadline": {
|
329
|
+
"date_type": "month",
|
330
|
+
"start": 5,
|
331
|
+
"end": 8,
|
332
|
+
"less_than": true
|
333
|
+
}
|
334
|
+
},
|
335
|
+
"MR_1": {
|
336
|
+
"name": "麻しん・風しん混合",
|
337
|
+
"period": "第1期",
|
338
|
+
"regular": true,
|
339
|
+
"type": "生ワクチン",
|
340
|
+
"recommended": {
|
341
|
+
"month": 12
|
342
|
+
},
|
343
|
+
"deadline": {
|
344
|
+
"date_type": "year",
|
345
|
+
"start": 1,
|
346
|
+
"end": 2,
|
347
|
+
"less_than": true
|
348
|
+
},
|
349
|
+
"description": "①1歳以上2歳未満 ②5歳以上7歳未満(小学校入学前の1年間)"
|
350
|
+
},
|
351
|
+
"MR_2": {
|
352
|
+
"name": "麻しん・風しん混合",
|
353
|
+
"period": "第2期",
|
354
|
+
"type": "生ワクチン",
|
355
|
+
"regular": true,
|
356
|
+
"recommended": "小学校入学前1年間",
|
357
|
+
"deadline": {
|
358
|
+
"date_type": "小学校入学前1年間"
|
359
|
+
}
|
360
|
+
},
|
361
|
+
"chickenpox_1": {
|
362
|
+
"name": "水痘",
|
363
|
+
"period": "1回目",
|
364
|
+
"regular": true,
|
365
|
+
"type": "生ワクチン",
|
366
|
+
"recommended": {
|
367
|
+
"month": 12
|
368
|
+
},
|
369
|
+
"deadline": {
|
370
|
+
"date_type": "month",
|
371
|
+
"start": 12,
|
372
|
+
"end": 15,
|
373
|
+
"less_than": true
|
374
|
+
}
|
375
|
+
},
|
376
|
+
"chickenpox_2": {
|
377
|
+
"name": "水痘",
|
378
|
+
"period": "2回目",
|
379
|
+
"regular": true,
|
380
|
+
"type": "生ワクチン",
|
381
|
+
"recommended": {
|
382
|
+
"month": 18
|
383
|
+
},
|
384
|
+
"deadline": {
|
385
|
+
"date_type": "month",
|
386
|
+
"start": 15,
|
387
|
+
"end": 36,
|
388
|
+
"less_than": true
|
389
|
+
},
|
390
|
+
"interval": {
|
391
|
+
"date_type": "month",
|
392
|
+
"start": 3,
|
393
|
+
"end": 12
|
394
|
+
}
|
395
|
+
},
|
396
|
+
"mumps_1": {
|
397
|
+
"name": "おたふくかぜ",
|
398
|
+
"period": "1回目",
|
399
|
+
"regular": false,
|
400
|
+
"type": "生ワクチン",
|
401
|
+
"recommended": {
|
402
|
+
"month": 12
|
403
|
+
},
|
404
|
+
"deadline": {
|
405
|
+
"date_type": "month",
|
406
|
+
"start": 12,
|
407
|
+
"end": 16
|
408
|
+
}
|
409
|
+
},
|
410
|
+
"mumps_2": {
|
411
|
+
"name": "おたふくかぜ",
|
412
|
+
"period": "2回目",
|
413
|
+
"regular": false,
|
414
|
+
"type": "生ワクチン",
|
415
|
+
"recommended": "小学校入学前1年間",
|
416
|
+
"deadline": null
|
417
|
+
},
|
418
|
+
"Japanese_encephalitis_1": {
|
419
|
+
"name": "日本脳炎",
|
420
|
+
"period": "第1期 1回目",
|
421
|
+
"regular": true,
|
422
|
+
"recommended": {
|
423
|
+
"year": 3
|
424
|
+
},
|
425
|
+
"deadline": {
|
426
|
+
"date_type": "year",
|
427
|
+
"start": 3,
|
428
|
+
"end": 4,
|
429
|
+
"less_than": true
|
430
|
+
}
|
431
|
+
},
|
432
|
+
"Japanese_encephalitis_2": {
|
433
|
+
"name": "日本脳炎",
|
434
|
+
"period": "第1期 2回目",
|
435
|
+
"regular": true,
|
436
|
+
"recommended": {
|
437
|
+
"month": 37
|
438
|
+
},
|
439
|
+
"deadline": {
|
440
|
+
"date_type": "year",
|
441
|
+
"start": 3,
|
442
|
+
"end": 4,
|
443
|
+
"less_than": true
|
444
|
+
},
|
445
|
+
"interval": {
|
446
|
+
"date_type": "day",
|
447
|
+
"start": 6,
|
448
|
+
"end": 28
|
449
|
+
}
|
450
|
+
},
|
451
|
+
"Japanese_encephalitis_3": {
|
452
|
+
"name": "日本脳炎",
|
453
|
+
"period": "第1期 3回目",
|
454
|
+
"regular": true,
|
455
|
+
"recommended": {
|
456
|
+
"year": 4
|
457
|
+
},
|
458
|
+
"deadline": {
|
459
|
+
"date_type": "year",
|
460
|
+
"start": 4,
|
461
|
+
"end": 5,
|
462
|
+
"less_than": true
|
463
|
+
},
|
464
|
+
"interval": {
|
465
|
+
"date_type": "month",
|
466
|
+
"start": 6,
|
467
|
+
"end": 12
|
468
|
+
}
|
469
|
+
},
|
470
|
+
"Japanese_encephalitis_4": {
|
471
|
+
"name": "日本脳炎",
|
472
|
+
"period": "第2期",
|
473
|
+
"regular": true,
|
474
|
+
"recommended": {
|
475
|
+
"year": 9
|
476
|
+
},
|
477
|
+
"deadline": {
|
478
|
+
"date_type": "year",
|
479
|
+
"start": 9,
|
480
|
+
"end": 13,
|
481
|
+
"less_than": true
|
482
|
+
}
|
483
|
+
}
|
484
|
+
}
|
485
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/jp_vaccination/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'jp_vaccination'
|
7
|
+
spec.version = JpVaccination::VERSION
|
8
|
+
spec.authors = ['napple29']
|
9
|
+
spec.email = ['snwxxx29@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = "It provides immunization data for minors in Japan \
|
12
|
+
and calculates the expected date of immunization."
|
13
|
+
spec.description = "We provide data extracted from \
|
14
|
+
the National Institute of Infectious Diseases' immunization schedule \
|
15
|
+
for people under 20 years of age. Based on those data, \
|
16
|
+
we have created a function that automatically calculates the vaccination date."
|
17
|
+
spec.homepage = 'https://github.com/napple29/jp_vaccination'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
spec.required_ruby_version = '>= 2.7.0'
|
20
|
+
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/napple29/jp_vaccination'
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/napple29/jp_vaccination/blob/main/CHANGELOG.md'
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, checkout our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JpVaccination
|
4
|
+
class Vaccination
|
5
|
+
attr_reader :name, :period, :deadline, :regular, :interval, :recommended, :type
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@name = data[:name]
|
9
|
+
@period = data[:period]
|
10
|
+
@regular = data[:regular]
|
11
|
+
@type = data[:type]
|
12
|
+
@recommended = data[:recommended]
|
13
|
+
@deadline = data[:deadline]
|
14
|
+
@interval = data[:interval]
|
15
|
+
end
|
16
|
+
|
17
|
+
def formal_name
|
18
|
+
"#{@name} #{@period}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
require_relative './jp_vaccination/vaccination'
|
6
|
+
require_relative './jp_vaccination/version'
|
7
|
+
|
8
|
+
module JpVaccination
|
9
|
+
class << self
|
10
|
+
def vaccination_keys
|
11
|
+
vaccinations_json.map do |key, _value|
|
12
|
+
{ find(key).formal_name => key.to_s }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def find(vaccination_key)
|
17
|
+
data = vaccinations_json[vaccination_key.to_sym]
|
18
|
+
output_argument_error(vaccination_key) if data.nil?
|
19
|
+
JpVaccination::Vaccination.new(data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def recommended_days(birthday, convert_to_strings = nil)
|
23
|
+
vaccinations_json.map do |_key, vaccination|
|
24
|
+
name = "#{vaccination[:name]} #{vaccination[:period]}"
|
25
|
+
|
26
|
+
if vaccination[:recommended].class != Hash
|
27
|
+
recommended_day = pre_school_year(birthday, convert_to_strings)
|
28
|
+
elsif vaccination[:recommended][:month]
|
29
|
+
recommended_day = Date.parse(birthday) >> vaccination[:recommended][:month].to_i
|
30
|
+
elsif vaccination[:recommended][:year]
|
31
|
+
recommended_day = Date.parse(birthday) >> vaccination[:recommended][:year].to_i * 12
|
32
|
+
end
|
33
|
+
if convert_to_strings && recommended_day.instance_of?(Date)
|
34
|
+
recommended_day = recommended_day.strftime('%Y-%m-%d')
|
35
|
+
end
|
36
|
+
{ name: name, date: recommended_day }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def recommended_schedules(birthday, convert_to_strings = nil)
|
41
|
+
sort_by_date_vaccination_days =
|
42
|
+
recommended_days(birthday, convert_to_strings).sort_by do |day|
|
43
|
+
[Date, String].include?(day[:date].class) ? day[:date] : day[:date].first
|
44
|
+
end
|
45
|
+
combined_name_and_date = sort_by_date_vaccination_days.each_with_object({}) do |day, ret|
|
46
|
+
ret[day[:name]] = day[:date]
|
47
|
+
end
|
48
|
+
combined_name_and_date.each_key.group_by { |date| combined_name_and_date[date] }.each_value(&:sort!)
|
49
|
+
end
|
50
|
+
|
51
|
+
def next_day(vaccination_key, last_time)
|
52
|
+
next_day = {}
|
53
|
+
vaccinations_json.each do |key, vaccination|
|
54
|
+
next unless key == vaccination_key.to_sym
|
55
|
+
|
56
|
+
name = "#{vaccination[:name]} #{vaccination[:period]}"
|
57
|
+
|
58
|
+
date = case vaccination[:interval]
|
59
|
+
when nil
|
60
|
+
calc_date(period: vaccination[:deadline], start_or_end: :start, date: last_time)
|
61
|
+
else
|
62
|
+
calc_date(period: vaccination[:interval], start_or_end: :start, date: last_time)
|
63
|
+
end
|
64
|
+
next_day[:name] = name
|
65
|
+
next_day[:date] = date
|
66
|
+
end
|
67
|
+
output_argument_error(vaccination_key) if next_day[:name].nil?
|
68
|
+
next_day
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def vaccinations_json
|
74
|
+
json_file = File.expand_path('../data/vaccinations.json', __dir__)
|
75
|
+
JSON.parse(File.read(json_file), symbolize_names: true)[:vaccinations]
|
76
|
+
end
|
77
|
+
|
78
|
+
def calc_date(period:, start_or_end:, date:)
|
79
|
+
date = case period[:date_type]
|
80
|
+
when 'day'
|
81
|
+
Date.parse(date) + period[start_or_end].to_i
|
82
|
+
when 'week'
|
83
|
+
Date.parse(date) + (period[start_or_end].to_i * 7)
|
84
|
+
when 'month'
|
85
|
+
Date.parse(date) >> period[start_or_end].to_i
|
86
|
+
when 'year'
|
87
|
+
Date.parse(date) >> (period[start_or_end].to_i * 12)
|
88
|
+
end
|
89
|
+
return date if start_or_end != :end
|
90
|
+
|
91
|
+
period[:less_than] ? date - 1 : date
|
92
|
+
end
|
93
|
+
|
94
|
+
def pre_school_year(birthday, convert_to_strings = nil)
|
95
|
+
fifth_birthday = Date.parse(birthday) >> 12 * 5
|
96
|
+
year = case fifth_birthday.month
|
97
|
+
when 1..3
|
98
|
+
fifth_birthday.year
|
99
|
+
when 4
|
100
|
+
fifth_birthday.day == 1 ? fifth_birthday.year : fifth_birthday.year.next
|
101
|
+
when 5..12
|
102
|
+
fifth_birthday.year.next
|
103
|
+
end
|
104
|
+
convert_to_strings ? "#{year}-04-01〜#{year.next}-03-31" : Date.new(year, 4, 1)..Date.new(year.next, 3, 31)
|
105
|
+
end
|
106
|
+
|
107
|
+
def output_argument_error(vaccination_key)
|
108
|
+
raise ArgumentError, "The vaccination_key '#{vaccination_key}' doesn\'t exist."
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jp_vaccination
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- napple29
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: We provide data extracted from the National Institute
|
14
|
+
of Infectious Diseases' immunization schedule for people
|
15
|
+
under 20 years of age. Based on those data, we have created
|
16
|
+
a function that automatically calculates the vaccination date.
|
17
|
+
email:
|
18
|
+
- snwxxx29@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- ".github/workflows/main.yml"
|
24
|
+
- ".gitignore"
|
25
|
+
- ".rubocop.yml"
|
26
|
+
- CHANGELOG.md
|
27
|
+
- CODE_OF_CONDUCT.md
|
28
|
+
- Gemfile
|
29
|
+
- Gemfile.lock
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- bin/console
|
34
|
+
- bin/setup
|
35
|
+
- data/vaccinations.json
|
36
|
+
- jp_vaccination.gemspec
|
37
|
+
- lib/jp_vaccination.rb
|
38
|
+
- lib/jp_vaccination/vaccination.rb
|
39
|
+
- lib/jp_vaccination/version.rb
|
40
|
+
homepage: https://github.com/napple29/jp_vaccination
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
homepage_uri: https://github.com/napple29/jp_vaccination
|
45
|
+
source_code_uri: https://github.com/napple29/jp_vaccination
|
46
|
+
changelog_uri: https://github.com/napple29/jp_vaccination/blob/main/CHANGELOG.md
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.7.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.3.3
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: It provides immunization data for minors in Japan and
|
66
|
+
calculates the expected date of immunization.
|
67
|
+
test_files: []
|