forked from segfault/ruby-hl7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from mymedlab/dg1_segment
Add DG1 segment, and ignore rspec configs
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ doc | |
pkg | ||
.rspec | ||
.DS_Store | ||
.rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module HL7 | ||
class Message::Segment::DG1 < HL7::Message::Segment | ||
weight 92 | ||
add_field :set_id | ||
add_field :diagnosis_coding_method | ||
add_field :diagnosis_code | ||
add_field :diagnosis_date_time do |value| | ||
convert_to_ts(value) | ||
end | ||
add_field :diagnosis_type | ||
add_field :major_diagnostic_category | ||
add_field :diagnosis_related_group | ||
add_field :drg_approval_indicator | ||
add_field :drg_grouper_review_code | ||
add_field :outlier_type | ||
add_field :outlier_days | ||
add_field :outlier_cost | ||
add_field :grouper_version_and_type | ||
add_field :diagnosis_priority | ||
add_field :diagnosis_clinician | ||
add_field :diagnosis_classification | ||
add_field :confidential_indicator | ||
add_field :attestation_date_time do |value| | ||
convert_to_ts(value) | ||
end | ||
|
||
private | ||
|
||
def self.convert_to_ts(value) #:nodoc: | ||
if value.is_a?(Time) || value.is_a?(Date) | ||
value.to_hl7 | ||
else | ||
value | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# encoding: UTF-8 | ||
require "spec_helper" | ||
|
||
describe HL7::Message::Segment::DG1 do | ||
context "reading" do | ||
let(:base_string) do | ||
"DG1|1|I9|71596^OSTEOARTHROS NOS-L/LEG ^I9|OSTEOARTHROS NOS-L/LEG ||A|" | ||
end | ||
let(:segment){ segment = HL7::Message::Segment::DG1.new(base_string) } | ||
|
||
it "allows access to an DG1 segment" do | ||
expect(segment.set_id).to eq("1") | ||
expect(segment.diagnosis_coding_method).to eq("I9") | ||
expect(segment.diagnosis_code).to eq("71596^OSTEOARTHROS NOS-L/LEG ^I9") | ||
expect(segment.diagnosis_date_time).to eq("OSTEOARTHROS NOS-L/LEG ") | ||
expect(segment.diagnosis_type).to eq("") | ||
expect(segment.major_diagnostic_category).to eq("A") | ||
expect(segment.diagnosis_related_group).to eq("") | ||
expect(segment.drg_approval_indicator).to eq(nil) | ||
expect(segment.drg_grouper_review_code).to eq(nil) | ||
expect(segment.outlier_type).to eq(nil) | ||
expect(segment.outlier_days).to eq(nil) | ||
expect(segment.outlier_cost).to eq(nil) | ||
expect(segment.grouper_version_and_type).to eq(nil) | ||
expect(segment.diagnosis_priority).to eq(nil) | ||
expect(segment.diagnosis_clinician).to eq(nil) | ||
expect(segment.diagnosis_classification).to eq(nil) | ||
expect(segment.confidential_indicator).to eq(nil) | ||
expect(segment.attestation_date_time).to eq(nil) | ||
end | ||
end | ||
|
||
context "creating" do | ||
let(:segment){ segment = HL7::Message::Segment::DG1.new } | ||
|
||
it "allows creation of an DGH segment" do | ||
segment.set_id = "2" | ||
expect(segment.set_id).to eq("2") | ||
end | ||
end | ||
end |