onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
1 stars 1 forks source link

Fix NoSuchMethodError in Fhir validation #138

Open Wambere opened 4 months ago

Wambere commented 4 months ago

Fix the error below source

EFSITY: :: INFO  :: ecbis_liberia/structure_map/json/child/child_immunization_record_all_follow_up.json
Error: Exception in thread "main" java.lang.NoSuchMethodError: 'org.hl7.fhir.utilities.xhtml.XhtmlParser org.hl7.fhir.utilities.xhtml.XhtmlParser.setValidatorMode(boolean)'
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildPrimitiveInstance(JsonParser.java:[35](https://github.com/onaio/fhir-resources/actions/runs/7897731649/job/21556230354?pr=3002#step:6:36)0)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildPrimitive(JsonParser.java:317)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildItem(JsonParser.java:220)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildren(JsonParser.java:194)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildComplexInstance(JsonParser.java:271)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildComplex(JsonParser.java:245)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildItem(JsonParser.java:222)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parseChildren(JsonParser.java:194)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parse(JsonParser.java:164)
    at org.hl7.fhir.r5.elementmodel.JsonParser.parse(JsonParser.java:126)
    at org.hl7.fhir.validation.instance.InstanceValidator.validate(InstanceValidator.java:628)
    at org.hl7.fhir.common.hapi.validation.validator.ValidatorWrapper.validate(ValidatorWrapper.java:193)
    at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validate(FhirInstanceValidator.java:238)
    at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.doValidate(BaseValidatorBridge.java:22)
    at org.hl7.fhir.common.hapi.validation.validator.BaseValidatorBridge.validateResource(BaseValidatorBridge.java:48)
    at org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator.validateResource(FhirInstanceValidator.java:26)
    at ca.uhn.fhir.validation.FhirValidator.validateResource(FhirValidator.java:343)
    at ca.uhn.fhir.validation.FhirValidator.doValidate(FhirValidator.java:264)
    at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:252)
    at ca.uhn.fhir.validation.FhirValidator.validateWithResult(FhirValidator.java:211)
    at org.smartregister.command.ValidateFhirResourcesCommand.validateResource(ValidateFhirResourcesCommand.java:122)
    at org.smartregister.command.ValidateFhirResourcesCommand.validateFhirResources(ValidateFhirResourcesCommand.java:86)
    at org.smartregister.command.ValidateFhirResourcesCommand.run(ValidateFhirResourcesCommand.java:49)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at org.smartregister.Main.main(Main.java:29)
Error: Process completed with exit code 1.
##[debug]Finishing: Run validation
Wambere commented 4 months ago

@dubdabasoduba it seems the validator is having an issue validating resources that have the text field with a div html value.

According to https://www.hl7.org/fhir/domainresource-definitions.html#DomainResource.text alternative names are narrative; html; xhtml; display.

If I replace text in the failing resources with any of the alternatives above, the validation works.

Can we work with this modification on the resources or must we use text ?

dubdabasoduba commented 4 months ago

@Wambere when you say replace does this mean altering the resource itself?

Wambere commented 4 months ago

@dubdabasoduba instead of

{
  "resourceType": "StructureMap",
  "text": {
    "status": "additional",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">...</div>"
  },
  "name": "ImmunizationCarePlan",
  ....
}

I switched it to

{
  "resourceType": "StructureMap",
  "narrative": {
    "status": "additional",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">...</div>"
  },
  "name": "ImmunizationCarePlan",
  ....
}
dubdabasoduba commented 4 months ago

@Wambere as we discussed earlier we can update the validator to replace text with narrative during validation

Wambere commented 4 months ago

@dubdabasoduba after thinking about how to go about this, I now think it makes more sense for the validator to "notify" the user that they need to make that change instead of itself trying to make that change, since this would involve making changes to a PR. It could just print it as one of the other errors that the user needs to fix

dubdabasoduba commented 4 months ago

@Wambere I was thinking of an inconsequential update, where the validator just changes it before validating and does not persist it in memory. Since the servers will most of the time return the resources with this property added.

If the data was copied from the server then it will have this data updated by the server or the resource generator on the tooling repo