-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Json format 2.0 #6
Changes from 6 commits
004f016
adfbb84
d2a388e
669ef1f
34e4d49
c215bf1
ec304e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,12 @@ import { | |
CHARGE_BILLING_CLASSES, | ||
CHARGE_SETTINGS, | ||
DRUG_UNITS, | ||
CONTRACTING_METHODS, | ||
STANDARD_CHARGE_METHODOLOGY, | ||
} from "./types.js" | ||
import { errorObjectToValidationError, parseJson } from "../common/json.js" | ||
|
||
const STANDARD_CHARGE_DEFINITIONS = { | ||
billing_code_information: { | ||
code_information: { | ||
type: "object", | ||
properties: { | ||
code: { type: "string" }, | ||
|
@@ -37,6 +37,7 @@ const STANDARD_CHARGE_DEFINITIONS = { | |
}, | ||
required: ["unit", "type"], | ||
}, | ||
|
||
standard_charges: { | ||
type: "object", | ||
properties: { | ||
|
@@ -48,11 +49,6 @@ const STANDARD_CHARGE_DEFINITIONS = { | |
enum: CHARGE_SETTINGS, | ||
type: "string", | ||
}, | ||
modifiers: { | ||
type: "array", | ||
items: { type: "string" }, | ||
uniqueItems: true, | ||
}, | ||
payers_information: { | ||
type: "array", | ||
items: { $ref: "#/definitions/payers_information" }, | ||
|
@@ -71,9 +67,9 @@ const STANDARD_CHARGE_DEFINITIONS = { | |
properties: { | ||
description: { type: "string" }, | ||
drug_information: { $ref: "#/definitions/drug_information" }, | ||
billing_code_information: { | ||
code_information: { | ||
type: "array", | ||
items: { $ref: "#/definitions/billing_code_information" }, | ||
items: { $ref: "#/definitions/code_information" }, | ||
minItems: 1, | ||
}, | ||
standard_charges: { | ||
|
@@ -82,29 +78,24 @@ const STANDARD_CHARGE_DEFINITIONS = { | |
minItems: 1, | ||
}, | ||
}, | ||
required: ["description", "billing_code_information", "standard_charges"], | ||
required: ["description", "code_information", "standard_charges"], | ||
}, | ||
payers_information: { | ||
type: "object", | ||
properties: { | ||
payer_name: { type: "string" }, | ||
plan_name: { type: "string" }, | ||
additional_payer_notes: { type: "string" }, | ||
standard_charge: { type: "number", exclusiveMinimum: 0 }, | ||
standard_charge_percent: { type: "number", exclusiveMinimum: 0 }, | ||
contracting_method: { | ||
enum: CONTRACTING_METHODS, | ||
standard_charge_dollar: { type: "number", exclusiveMinimum: 0 }, | ||
standard_charge_algorithm: { type: "string" }, | ||
standard_charge_percentage: { type: "number", exclusiveMinimum: 0 }, | ||
estimated_amount: { type: "number", exclusiveMinimum: 0 }, | ||
methodology: { | ||
enum: STANDARD_CHARGE_METHODOLOGY, | ||
type: "string", | ||
}, | ||
}, | ||
required: ["payer_name", "plan_name", "contracting_method"], | ||
if: { | ||
properties: { | ||
contracting_method: { const: "percent of total billed charges" }, | ||
}, | ||
}, | ||
then: { required: ["standard_charge_percent"] }, | ||
else: { required: ["standard_charge"] }, | ||
required: ["payer_name", "plan_name", "methodology"], | ||
}, | ||
} | ||
|
||
|
@@ -113,9 +104,9 @@ const STANDARD_CHARGE_PROPERTIES = { | |
properties: { | ||
description: { type: "string" }, | ||
drug_information: { $ref: "#/definitions/drug_information" }, | ||
billing_code_information: { | ||
code_information: { | ||
type: "array", | ||
items: { $ref: "#/definitions/billing_code_information" }, | ||
items: { $ref: "#/definitions/code_information" }, | ||
minItems: 1, | ||
}, | ||
standard_charges: { | ||
|
@@ -124,7 +115,7 @@ const STANDARD_CHARGE_PROPERTIES = { | |
minItems: 1, | ||
}, | ||
}, | ||
required: ["description", "billing_code_information", "standard_charges"], | ||
required: ["description", "code_information", "standard_charges"], | ||
} | ||
|
||
export const STANDARD_CHARGE_SCHEMA = { | ||
|
@@ -145,22 +136,92 @@ export const METADATA_DEFINITIONS = { | |
}, | ||
required: ["license_number", "state"], | ||
}, | ||
affirmation: { | ||
type: "object", | ||
properties: { | ||
affirmation: { | ||
const: | ||
"To the best of its knowledge and belief, the hospital has included all applicable standard charge information in accordance with the requirements of 45 CFR 180.50, and the information encoded is true, accurate, and complete as of the date indicated.", | ||
}, | ||
confirm_affirmation: { | ||
type: "boolean", | ||
}, | ||
shaselton-usds marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
required: ["affirmation", "confirm_affirmation"], | ||
}, | ||
modifier_information: { | ||
type: "object", | ||
properties: { | ||
description: { | ||
type: "string", | ||
}, | ||
code: { | ||
type: "string", | ||
}, | ||
shaselton-usds marked this conversation as resolved.
Show resolved
Hide resolved
|
||
modifier_payer_information: { | ||
type: "array", | ||
items: { | ||
$ref: "#/definitions/modifier_payer_information", | ||
}, | ||
minItems: 1, | ||
}, | ||
}, | ||
required: ["description", "modifier_payer_information", "code"], | ||
}, | ||
modifier_payer_information: { | ||
type: "object", | ||
properties: { | ||
payer_name: { | ||
type: "string", | ||
}, | ||
plan_name: { | ||
type: "string", | ||
}, | ||
description: { | ||
type: "string", | ||
}, | ||
}, | ||
required: ["payer_name", "plan_name", "description"], | ||
}, | ||
} | ||
|
||
export const METADATA_PROPERTIES = { | ||
hospital_name: { type: "string" }, | ||
last_updated_on: { type: "string", format: "date" }, | ||
license_information: { | ||
type: "array", | ||
items: { $ref: "#/definitions/license_information" }, | ||
minItems: 1, | ||
$ref: "#/definitions/license_information", | ||
}, | ||
version: { type: "string" }, | ||
hospital_location: { type: "string" }, | ||
financial_aid_policy: { type: "string" }, | ||
hospital_address: { | ||
type: "array", | ||
items: { type: "string" }, | ||
}, | ||
hospital_location: { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
}, | ||
}, | ||
affirmation: { | ||
$ref: "#/definitions/affirmation", | ||
}, | ||
modifier_information: { | ||
type: "array", | ||
items: { | ||
$ref: "#/definitions/modifier_information", | ||
}, | ||
}, | ||
} | ||
|
||
export const METADATA_REQUIRED = ["hospital_name", "last_updated_on", "version"] | ||
export const METADATA_REQUIRED = [ | ||
"hospital_name", | ||
"last_updated_on", | ||
"hospital_location", | ||
"hospital_address", | ||
"license_information", | ||
"version", | ||
"affirmation", | ||
] | ||
|
||
export const METADATA_SCHEMA = { | ||
$schema: "http://json-schema.org/draft-07/schema#", | ||
|
@@ -213,6 +274,7 @@ export async function validateJson( | |
if (typeof key === "string") { | ||
metadata[key] = value | ||
} else { | ||
// is this where I need to put another check for the modifier information? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the right spot for that. These checks that collect values into the local |
||
hasCharges = true | ||
if (!validator.validate(STANDARD_CHARGE_SCHEMA, value)) { | ||
valid = false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import test from "ava" | ||
import { loadFixtureStream } from "../utils.js" | ||
import { validateJson } from "../../src/json.js" | ||
|
||
test("validateJson", async (t) => { | ||
const result = await validateJson( | ||
loadFixtureStream("/2.0/sample-valid.json"), | ||
"v2.0" | ||
) | ||
t.is(result.valid, true) | ||
t.deepEqual(result.errors.length, 0) | ||
}) | ||
|
||
test("validateJson empty", async (t) => { | ||
const result = await validateJson( | ||
loadFixtureStream("/2.0/sample-empty.json"), | ||
"v2.0" | ||
) | ||
t.is(result.valid, false) | ||
t.deepEqual(result.errors.length, 8) | ||
}) | ||
|
||
test("validateJson maxErrors", async (t) => { | ||
const result = await validateJson( | ||
loadFixtureStream("/2.0/sample-empty.json"), | ||
"v2.0", | ||
{ | ||
maxErrors: 1, | ||
} | ||
) | ||
t.is(result.valid, false) | ||
t.deepEqual(result.errors.length, 1) | ||
}) | ||
|
||
test("validateJson errorFile", async (t) => { | ||
const result = await validateJson( | ||
loadFixtureStream("/2.0/sample-errors.json"), | ||
"v2.0" | ||
) | ||
t.is(result.valid, false) | ||
t.deepEqual(result.errors.length, 3) | ||
t.deepEqual(result.errors, [ | ||
{ | ||
path: "/standard_charges/0/payers_information/0/standard_charge_dollar", | ||
field: "standard_charge_dollar", | ||
message: "must be number", | ||
}, | ||
{ | ||
path: "/standard_charges/3/payers_information/2", | ||
field: "2", | ||
message: "must have required property 'methodology'", | ||
}, | ||
{ | ||
path: "/affirmation/affirmation", | ||
field: "affirmation", | ||
message: "must be equal to constant", | ||
}, | ||
]) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mint-thompson I'm thinking that we'll probably want to update this to support major, minor, and patch versioning, but keeping it consistent with the previous implementation for now.