material-identity / CoA-schemas

A JSON data structure for Digital Certificates of Analysis of plastics and other materials
https://materialidentity.org
GNU Affero General Public License v3.0
3 stars 1 forks source link

[EP] Value ranges for inspection results #40

Open stiebitzhofer opened 2 years ago

stiebitzhofer commented 2 years ago

Describe the problem

For some inspections the results is a value range. One example is

Range of bulk density 99.0 .. 100.0

Specify the details

  1. Add a value type range to attribute ValueType
"ValueType": {
    "description": "The data type of the measured value.",
    "enum": [
         "string",
         "number",
         "date",
         "date-time",
         "boolean",
         "range"
    ],
    "default": "number"
},
  1. Specify a pattern for range values for example

<value_1>;<value_2>

  1. Specify a rendering for example

<value_1> .. <value_2>

Tasks

Explain the benefits

Value ranges for inspection results can be added to CoA in a proper data structure.

stiebitzhofer commented 1 year ago

@BALA-KASI Does the problem https://github.com/thematerials-network/CoA-schemas/issues/57 apply to ranges as well? Or generalized to all numeric measurement results and specification values?

stiebitzhofer commented 1 year ago

@getlarge Can you please review the requirement and my proposed solution? Thank you!

getlarge commented 1 year ago

Since the purpose of our schemas is to allow automated read/write, i’m a bit concerned by the separator that would be used in a range value, should it be declared in another property ? Should there be a unique default ? then how to validate the value (using a JSON schema validator or in code )? I didn’t take too much time to think about it, but i would rather modify the type of Inspection.Value to be a union of string and array of string with exactly 2 items. Something like :

{
   …  
   "Inspection": {
      "title": "Inspection",
      "description": "A structure to specify any kind of measurements. It follows the structure as defined by CAMPUS (https://www.campusplastics.com)",
      "type": "object",
      "properties": {
        …
        "Value": {
          "description": "A measured or calculated Value (e.g. mean of individual measurements).",
          "oneOf": [
               {  "type": "string" },
               {   
                  "type": "array",  
                  "items": {
                       "type": "string"
                   },
                   "minItems": 2,
                   "maxItems": 2
               }
           ]
        },
        ….
    },
    …
}

Or eventually by using the more recent prefixItems

stiebitzhofer commented 1 year ago

@getlarge I agree, that's how it should be done.

stiebitzhofer commented 1 year ago

Will create an issue in the CoA and schema repositories.

getlarge commented 1 year ago

do you want to go on with the PR, or should i do it ?

stiebitzhofer commented 1 year ago

I would be happy if you take over. Thanks!