FHIR Chat · Validate mcode cancer patient · implementers

Stream: implementers

Topic: Validate mcode cancer patient


view this post on Zulip Roman Rodnin (Apr 01 2020 at 15:43):

Hi! I am building an application that would work with mcode profiles.
Right now i have a problem with validating it using hapi-fhir library:

I use canonicals to load structure definitions:

    String mcodeCancerPatient = "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-patient";
    String usCoreRaceExtension = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race";
    String usCoreEthnicityExtension = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity";
    String usCoreBithsexExtension = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex";
    String ombRaceCategory = "http://hl7.org/fhir/us/core/ValueSet/omb-race-category";

    ResponseEntity<String> cancerPatient = restTemplate.getForEntity(mcodeCancerPatient, String.class);
    ResponseEntity<String> raceExtension = restTemplate.getForEntity(usCoreRaceExtension, String.class);
    ResponseEntity<String> ethnicityExtension = restTemplate.getForEntity(usCoreEthnicityExtension, String.class);
    ResponseEntity<String> birthsexExtension = restTemplate.getForEntity(usCoreBithsexExtension, String.class);
    ResponseEntity<String> ombRaceCategoryResp = restTemplate.getForEntity(ombRaceCategory, String.class);

    StructureDefinition cancerPatientDefinition = (StructureDefinition) parser.parseResource(cancerPatient.getBody());
    StructureDefinition raceExtensionDefinition = (StructureDefinition) parser.parseResource(raceExtension.getBody());
    StructureDefinition ethnicityExtensionDefinition = (StructureDefinition) parser.parseResource(ethnicityExtension.getBody());
    StructureDefinition birthsexExtensionDefinition = (StructureDefinition) parser.parseResource(birthsexExtension.getBody());

then i create FhirValidator and passing structure definitions to it:

    Resource resource = resourceLoader.getResource("classpath:codesystem/CodeSystem-cdcrec.json");
    CodeSystem raceAndEthnicityCodeSystem = (CodeSystem) parser.parseResource(resource.getInputStream());
    ValueSet ombRaceValueSet = (ValueSet) parser.parseResource(ombRaceCategoryResp.getBody());

    PrePopulatedValidationSupport prePopulatedValidationSupport = new PrePopulatedValidationSupport();
    prePopulatedValidationSupport.addStructureDefinition(cancerPatientDefinition);
    prePopulatedValidationSupport.addStructureDefinition(raceExtensionDefinition);
    prePopulatedValidationSupport.addStructureDefinition(ethnicityExtensionDefinition);
    prePopulatedValidationSupport.addStructureDefinition(birthsexExtensionDefinition);

    prePopulatedValidationSupport.addValueSet(ombRaceValueSet);
    prePopulatedValidationSupport.addCodeSystem(raceAndEthnicityCodeSystem);
    FhirValidator fhirValidator = FhirVersion.R4.getFhirContext().newValidator();
    ValidationSupportChain validationSupportChain = new ValidationSupportChain(
      new DefaultProfileValidationSupport(),
      prePopulatedValidationSupport
    );
    FhirInstanceValidator instanceValidator = new FhirInstanceValidator(validationSupportChain);
    fhirValidator.registerValidatorModule(instanceValidator);

Then i am validating resource:

{
  "resourceType": "Patient",
  "id": "1",
  "meta": {
    "versionId": "1",
    "profile": [
      "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-patient"
    ]
  },
  "extension": [
    {
      "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
      "extension": [
        {
          "url": "ombCategory",
          "valueCoding": {
            "system": "urn:oid:2.16.840.1.113883.6.238",
            "code": "2076-8",
            "display": "Native Hawaiian or Other Pacific Islander"
          }
        },
        {
          "url": "text",
          "valueString": "Native Hawaiian Or Other Pacific Islander"
        }
      ]
    },
    {
      "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
      "extension": [
        {
          "url": "ombCategory",
          "valueCoding": {
            "system": "urn:oid:2.16.840.1.113883.6.238",
            "code": "2186-5",
            "display": "Not Hispanic or Latino"
          }
        },
        {
          "url": "text",
          "valueString": "Black Or African American"
        }
      ]
    }
  ],
  "identifier": [
    {
      "use": "usual",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
            "code": "MR"
          }
        ]
      },
      "system": "urn:oid:1.2.36.146.595.217.0.1",
      "value": "12345",
      "period": {
        "start": "2001-05-06"
      },
      "assigner": {
        "display": "Acme Healthcare"
      }
    }
  ],
  "active": true,
  "name": [
    {
      "use": "official",
      "family": "Chalmers",
      "given": [
        "Peter",
        "James"
      ]
    },
    {
      "use": "usual",
      "given": [
        "Jim"
      ]
    },
    {
      "use": "maiden",
      "family": "Windsor",
      "given": [
        "Peter",
        "James"
      ],
      "period": {
        "end": "2002"
      }
    }
  ],
  "gender": "female",
  "birthDate": "1990-02-12",
  "deceasedDateTime": "2020-03-20T00:00:00+03:00",
}

But ValidationResult gives me next message:
Unknown code: urn:oid:2.16.840.1.113883.6.238 / 2076-8

I've lost a lot of time debugging this problem and it seems to me like validator can't validate complex extensions (like us core race) and doesn't properly handle bindings on elements.

I will be glad to any help, thanks!

view this post on Zulip Lloyd McKenzie (Apr 01 2020 at 16:53):

You can't use an OID as the system id of something that has a defined URL

view this post on Zulip Lloyd McKenzie (Apr 01 2020 at 16:55):

There's an official URL for the race & ethnicity code system used by US core - and that's the only URI permitted. If you're converting between v3 (e.g. CDA) and FHIR, you must transform your code and identifier systems wherever an official URL has been defined. (And in general you're encouraged to convert from OIDs to URLs everywhere - using OIDs is harder on implementers, can't resolve, etc.

view this post on Zulip Roman Rodnin (Apr 01 2020 at 17:01):

I've download the codesystem here: https://www.hl7.org/fhir/us/core/CodeSystem-cdcrec.html
and there is no defined URL

view this post on Zulip Lloyd McKenzie (Apr 01 2020 at 17:21):

It's unfortunate that US Core chose to stick with an OID (@Brett Marquard @Eric Haas - any insight on why?) From a validation perspective if you pass in the id of the US Core IG as part of the validation, it should load the definition for that code system and validate correctly.

view this post on Zulip Roman Rodnin (Apr 01 2020 at 17:34):

But i have already load this codesystem from file to a ValidationModule, and all other required StructureDefinitions as well. Is there any example of validating us core patient using hapi-fhir library? I didn't find one

view this post on Zulip Lloyd McKenzie (Apr 01 2020 at 17:56):

@James Agnew

view this post on Zulip Eric Haas (Apr 01 2020 at 17:57):

that OID is available and used by the other HL7 standards and a URL is not.

view this post on Zulip Grahame Grieve (Apr 01 2020 at 18:57):

@Roman Rodnin the current validator validates this jut fine. What versions of hapi-fhir and fhir-core are you using?

view this post on Zulip Roman Rodnin (Apr 01 2020 at 19:04):

@Grahame Grieve i am using the latest (4.2.0)

view this post on Zulip Grahame Grieve (Apr 01 2020 at 19:07):

then the problem is probably to do with the way HAPI hosts the validator. Thats getting a lot of work in 5.x of HAPI

view this post on Zulip Roman Rodnin (Apr 01 2020 at 19:18):

So, is this a bug in 4.2.0 version and i should wait for it being fixed or my code contains some errors?

view this post on Zulip Grahame Grieve (Apr 01 2020 at 19:30):

I don't know. you should ask on the #hapi stream or the HAPI support forum (after trying with v5 first)

view this post on Zulip Lloyd McKenzie (Apr 01 2020 at 20:48):

@Eric Haas There are OIDs available for lots of code systems - we still define URLs for most because OIDs suck and it's better to suffer the pain of mapping between OIDs and URLs than to suffer the pain of OIDs ongoing. (All implementers will have to support mapping regardless because of the number of terminology and identifiers that do have URLs that are mandated.)

view this post on Zulip Roman Rodnin (Apr 02 2020 at 14:58):

@Grahame Grieve Thank you! Moving to snapshot version of library helped me a lot.
Now i stuck with validating snomed ct codes. As i understand i should have ValueSet resource and CodeSystem as well provided to the PrePopulatedValidationSupport, but i can't find snomedct CodeSystem resource to download. I found that there is ITerminologyServices interface authored by you, but without any implementations or usage examples. Could you please help me with this?
(Probably i should have created a new topic in #hapi stream, but i don't want to spam everywhere)

view this post on Zulip Grahame Grieve (Apr 02 2020 at 19:50):

you won't find a CodeSystem resource for the big public terminologies; they have their own custom perfectly honed distribution formats already, and trying to reproduce them in a generic format like CodeSystem results in resources that are GB large.

view this post on Zulip Grahame Grieve (Apr 02 2020 at 19:50):

so HAPI has it's own Snomed provider


Last updated: Apr 12 2022 at 19:14 UTC