Unknown Element '' found while Parsing (HAPI version : 3.2.0)

688 views
Skip to first unread message

Annie

unread,
Jun 22, 2018, 1:27:23 PM6/22/18
to HAPI FHIR
Hi,

Appreciate your help in any way. Could it be due to library version issue?

I am seeing this error for the below elements after parsing using HAPI library:

11:26:49,135 INFO  [ca.uhn.fhir.util.VersionUtil] (http-localhost/127.0.0.1:8443-2) HAPI FHIR version is: 3.2.0

11:26:49,160 INFO  [ca.uhn.fhir.context.FhirContext] (http-localhost/127.0.0.1:8443-2) Creating new FHIR context for FHIR version [DSTU2]

11:26:59,912 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'deviceIdentifier' found while parsing

11:26:59,914 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'name' found while parsing

11:26:59,917 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'expirationDate' found while parsing

11:26:59,921 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'subject' found while parsing

11:26:59,922 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'taken' found while parsing

11:26:59,923 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'text' found while parsing

11:26:59,927 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'sequence' found while parsing

11:26:59,928 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'patientInstruction' found while parsing

11:26:59,930 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'doseQuantity' found while parsing

11:26:59,933 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'basedOn' found while parsing

11:26:59,940 WARN  [ca.uhn.fhir.parser.LenientErrorHandler] (http-localhost/127.0.0.1:8443-2) Unknown element 'interpretation' found while parsing


I am running the below code for parsing:



FhirContext fhCtxt = FhirContext.forDstu2();

IParser jsonParser = fhCtxt.newJsonParser();

DiagnosticReport report = jsonParser.parseResource(DiagnosticReport.class, decryptedRequest);

String resourceType = report.getResourceName();

if (DIAGNOSTIC_REPORT.equalsIgnoreCase(resourceType)) {

String decodedString = jsonParser.encodeResourceToString(report);

JSONObject decodedJSON = new JSONObject(decodedString);


But after String decodedString = jsonParser.encodeResourceToString(report); line I am seeing the errors for unknown elements found while parsing.


The JSON fhir input string is:


{\"resourceType\":\"Observation\",\"id\":\"as123\",\"text\":{\"status\":\"generated\"},\"contained\":[{\"resourceType\":\"Patient\",\"id\":\"12357899\",\"active\":true,\"gender\":\"male\",\"birthDate\":\"2006-10-12\"},{\"resourceType\":\"Device\",\"id\":\"f001\",\"identifier\":[{\"value\":\"12345\"}],\"type\":{\"coding\":[{\"code\":\"25062003\",\"display\":\"xyz, device\"}]},\"status\":\"active\",\"manufactureDate\":\"2015-08-08\"},{\"resourceType\":\"MedicationStatement\",\"id\":\"med006\",\"dateAsserted\":\"2014-02-22\",\"status\":\"Active\",\"effectiveDateTime\":\"2014-02-01\",\"dosage\":[{\"text\":\"5ml three times daily\",\"asNeededBoolean\":false,\"route\":{\"coding\":[{\"system\":\"http:snomed.infosct\",\"code\":\"260548002\",\"display\":\"Oral\"}]},\"maxDosePerPeriod\":{\"numerator\":{\"value\":3},\"denominator\":{\"value\":1,\"system\":\"http:unitsofmeasure.org\",\"code\":\"d\"}}}]}],\"status\":\"final\",\"category\":{\"coding\":[{\"code\":\"survey\",\"display\":\"Survey\"}],\"text\":\"Survey\"},\"code\":{\"coding\":[{\"code\":\"9272-6\",\"display\":\"1 minute Apgar Score\"},{\"code\":\"169895004\",\"display\":\"Apgar at 1 minute\"}],\"text\":\"1 minute Apgar Score\"},\"subject\":{\"reference\":\"#12357899\"},\"effectiveDateTime\":\"2016-05-18T22:33:22Z\",\"performer\":[{\"reference\":\"Practitionerexample\"}],\"valueQuantity\":{\"value\":0,\"code\":\"{score}\"},\"device\":{\"reference\":\"#f001\"},\"related\":[{\"type\":\"has-member\",\"target\":{\"reference\":\"#med006\"}}],\"component\":[{\"code\":{\"coding\":[{\"code\":\"32406-1\",\"display\":\"1 minute Apgar Color\"},{\"code\":\"249227004\",\"display\":\"Apgar color score\"}],\"text\":\"Apgar color score\"},\"valueCodeableConcept\":{\"coding\":[{\"extension\":[{\"url\":\"\",\"valueDecimal\":0}],\"code\":\"LA6722-8\",\"display\":\"The baby's whole body is completely bluish-gray or pale\"},{\"code\":\"0\"}],\"text\":\"0. The baby's whole body is completely bluish-gray or pale\"}},{\"code\":{\"coding\":[{\"code\":\"32407-9\",\"display\":\"1 minute Apgar Heart Rate\"},{\"code\":\"249223000\",\"display\":\"Apgar heart rate score\"}],\"text\":\"Apgar respiratory effort score\"},\"valueCodeableConcept\":{\"coding\":[{\"extension\":[{\"url\":\"\",\"valueDecimal\":0}],\"code\":\"LA6716-0\",\"display\":\"No heart rate\"},{\"code\":\"0\"}],\"text\":\"0. No heart rate\"}},{\"code\":{\"coding\":[{\"system\":\"g\",\"code\":\"32409-5\",\"display\":\"1 minute Apgar Reflex Irritability\"},{\"code\":\"249226008\",\"display\":\"Apgar response to stimulus score\"}],\"text\":\"Apgar response to stimulus score\"},\"valueCodeableConcept\":{\"coding\":[{\"extension\":[{\"url\":\"\",\"valueDecimal\":0}],\"code\":\"LA6719-4\",\"display\":\"No response to airways being suctioned\"},{\"code\":\"0\"}],\"text\":\"0. No response to airways being suctioned\"}},{\"code\":{\"coding\":[{\"code\":\"32408-7\",\"display\":\"1 minute Apgar Muscle Tone\"},{\"code\":\"249225007\",\"display\":\"Apgar muscle tone score\"}],\"text\":\"Apgar muscle tone score\"},\"valueCodeableConcept\":{\"coding\":[{\"extension\":[{\"url\":\"\",\"valueDecimal\":0}],\"code\":\"LA6713-7\",\"display\":\"Limp; no movement\"},{\"code\":\"0\"}],\"text\":\"0. Limp; no movement\"}},{\"code\":{\"coding\":[{\"code\":\"32410-3\",\"display\":\"1 minute Apgar Respiratory effort\"},{\"code\":\"249224006\",\"display\":\"Apgar respiratory effort score\"}],\"text\":\"Apgar respiratory effort score\"},\"valueCodeableConcept\":{\"coding\":[{\"extension\":[{\"url\":\"\",\"valueDecimal\":0}],\"code\":\"LA6725-1\",\"display\":\"Not breathing\"},{\"code\":\"0\"}],\"text\":\"0. Not breathing\"}}]}


Thanks!


James Agnew

unread,
Jun 22, 2018, 1:51:55 PM6/22/18
to anita kumari, HAPI FHIR
The message "Unknown element 'deviceIdentifier' found while parsing" means that the input has an element called "deviceIdentifier" in it, and that element is not valid for the resource type being parsed. I don't see that string anywhere in the snippet you posted, so I'm guessing there may be other content being parsed.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/295a7484-2407-4955-b166-b129f6200dde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Annie

unread,
Jun 22, 2018, 5:54:59 PM6/22/18
to HAPI FHIR
Thanks for your response!
My bad, I had copied the response json after parsing in my previous email.

Below is the correct input string which has deviceIdentifier in it. Per fhir protocol for Device resource type, this deviceIdentifier element is present (https://www.hl7.org/fhir/device-example-udi2.json.html). I copied the same example as provided in fhir website but still getting the same error. Likewise, I am seeing the issue for other elements.

  1. Can it be an issue with the fhir library version that I am using (3.2.0) ? 
  2. Is Dstu2 compatible with 3.2.0 library?

Input string:

{\r\n  \"resourceType\": \"Observation\",\r\n  \"id\": \"xyz123\",\r\n  \"text\": {\r\n    \"status\": \"generated\"\r\n\t},\r\n\"contained\":[\r\n{\r\n  \"resourceType\": \"Patient\",\r\n  \"id\": \"12357899\",\r\n  \"birthDate\": \"2006-10-12\",\r\n  \"gender\": \"male\",\r\n  \"active\": true\r\n},\r\n{\r\n  \"resourceType\": \"Device\",\r\n  \"id\": \"device001\",\r\n  \"udi\": {\r\n    \"deviceIdentifier\": \"A9999XYZ100T0474\",\r\n    \"name\": \"xyz MDI\"\r\n  },\r\n  \"status\": \"active\",\r\n  \"type\": {\r\n  \"coding\": [\r\n      {\r\n        \"system\": \"https:www.xyz.com\",\r\n        \"code\": \"86184003\",\r\n        \"display\": \"xyzHealth\"\r\n      }\r\n    ],\r\n    \"text\": \"xyz\"\r\n  },\r\n  \"manufacturer\": \"xyzHealth\",\r\n  \"model\": \"AB 45-J\",\r\n  \"manufactureDate\": \"2013-02-01\",\r\n  \"expirationDate\": \"2014-02-01\",\r\n  \"patient\": {\r\n    \"reference\": \"#12357899\"\r\n  },\r\n  \"note\": [\r\n    {\r\n      \"authorReference\": {\r\n        \"reference\": \"Practitionerxcda-author\"\r\n      },\r\n      \"time\": \"2015-06-28T14:03:32+10:00\",\r\n      \"text\": \"QA Checked\"\r\n    }\r\n  ]\r\n},\r\n{\r\n  \"resourceType\": \"MedicationStatement\",\r\n  \"id\": \"medstmt001\",\r\n  \"status\": \"Active\",\r\n  \"medicationCodeableConcept\": {\r\n    \"coding\": [\r\n      {\r\n        \"system\": \"http:snomed.infosct\",\r\n        \"code\": \"27658006\",\r\n        \"display\": \"Rescue Medication(Metaproterenol)\"\r\n      }\r\n    ]\r\n  },\r\n  \"effectiveDateTime\": \"2014-02-01\",\r\n  \"dateAsserted\": \"2014-02-22\",\r\n  \"subject\": {\t \r\n    \"reference\": \"#12357899\",\r\n    \"display\": \"Tom Holden\"\r\n  },\r\n  \"taken\": \"n\",\r\n  \"note\": [\r\n    {\r\n      \"text\": \"Patient indicates he missed the occasional dose\"\r\n    }\r\n  ],\r\n  \"dosage\": [\r\n    {\r\n      \"sequence\": 1,\r\n      \"text\": \"5ml three times daily\",\r\n\t  \"patientInstruction\": \"Regimen:Take one to two tablets every four to six hours as needed for rib pain\",\r\n      \"asNeededBoolean\": false,\r\n      \"route\": {\r\n        \"coding\": [\r\n          {\r\n            \"system\": \"http:snomed.infosct\",\r\n            \"code\": \"260548002\",\r\n            \"display\": \"Oral\"\r\n          }\r\n        ]\r\n      },\r\n      \"doseQuantity\": {\r\n        \"value\": 5,\r\n        \"unit\": \"mL\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n\r\n],\r\n  \"identifier\": [\r\n    {\r\n\t\"use\":\"official\",\r\n      \"system\": \"http:hl7.orgfhiridentifier-type\",\r\n      \"value\": \"urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281\"\r\n    },\r\n\t{\r\n      \"type\": {\r\n        \"coding\": [\r\n          {\r\n            \"system\": \"http:hl7.orgfhiridentifier-type\",\r\n            \"code\": \"SNO\"\r\n          }\r\n        ],\r\n        \"text\": \"Serial Number\"\r\n      },\r\n      \"value\": \"AMID-342135-8464\"\r\n    }\r\n  \r\n  ],\r\n  \"basedOn\": [\r\n    {\r\n      \"identifier\": {\r\n        \"system\": \"https:acme.orgidentifiers\",\r\n        \"value\": \"1234\"\r\n      }\r\n    }\r\n  ],\r\n  \"status\": \"final\",\r\n  \"category\": [\r\n    {\r\n      \"coding\": [\r\n        {\r\n          \"system\": \"http:hl7.orgfhirobservation-category\",\r\n          \"code\": \"Propeller Readings\",\r\n          \"display\": \"Propeller Readings\"\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"code\": {\r\n    \"coding\": [\r\n      {\r\n        \"system\": \"http:loinc.org\",\r\n        \"code\": \"85354-9\",\r\n        \"display\": \" Propeller \"\r\n      }\r\n    ],\r\n    \"text\": \" Propeller\"\r\n  },\r\n  \"subject\": {\r\n    \"reference\": \"#12357899\"\r\n  },\r\n  \"effectiveDateTime\": \"2012-09-17\",\r\n  \"performer\": [\r\n    {\r\n      \"reference\": \"Practitionerxyz\"\r\n    }\r\n  ],\r\n  \"interpretation\": {\r\n    \"coding\": [\r\n      {\r\n        \"system\": \"https:www.xyz.com\",\r\n        \"code\": \"86184003\",\r\n        \"display\": \"In Control\"\r\n      }\r\n    ],\r\n    \"text\": \"In Control\"\r\n  },\r\n  \"device\": {\r\n    \"reference\": \"#device001\"\r\n  },\r\n  \"related\": [\r\n    {\r\n      \"type\": \"has-member\",\r\n      \"target\": {\r\n        \"reference\": \"#medstmt001\"\r\n      }\r\n    }\r\n  ],\r\n  \"component\": [\r\n    {\r\n      \"code\": {\r\n        \"coding\": [\r\n          {\r\n            \"system\": \"https:www.xyz.com\",\r\n            \"code\": \"8480-6\",\r\n            \"display\": \"Rescue Med\"\r\n          }\r\n        ]\r\n      },\r\n      \"valueQuantity\": {\r\n        \"value\": 107,\r\n        \"unit\": \"mmHg\",\r\n        \"system\": \"http:unitsofmeasure.org\",\r\n        \"code\": \"mm[Hg]\"\r\n      },\r\n      \"interpretation\": {\r\n        \"coding\": [\r\n          {\r\n            \"system\": \"http:hl7.orgfhirv20078\",\r\n            \"code\": \"N\",\r\n            \"display\": \"In Control\"\r\n          }\r\n        ],\r\n        \"text\": \"In Control\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n

Annie

unread,
Jun 26, 2018, 3:48:27 PM6/26/18
to HAPI FHIR
Could you please advice on the below?

Patrick Werner

unread,
Jun 26, 2018, 4:22:26 PM6/26/18
to HAPI FHIR
you are parsing a Observation as a Diagnostic Report.

Annie

unread,
Jul 2, 2018, 11:51:54 AM7/2/18
to HAPI FHIR

Per Fhir Protocol, The contained structure can be included within the Observation resource type as well. 
Based on which I created a customized Json structure for my application. After Json parsing, getting everything back in the response except for doseQuantity (which is inside component) and few other elements for which it shows unknown elements.

{
  • "resourceType":"Observation",
  • "id":"xyz123",
  • "text":{},
  • "contained":[
    1. {Patient},
    2. {Device},
    3. {MedicationStatement}
    ]
    ,
  • "identifier":[],
  • "status":"final",
  • "category":[],
  • "code":{},
  • "subject":{},
  • "effectiveDateTime":"2012-09-17",
  • "performer":[],
  • "interpretation":{},
  • "device":{
    • "reference":"#device001"
    },
  • "related":[],
  • "component":[]
} 

Please review this structure and advice if my understanding is wrong.

Thanks!

James Agnew

unread,
Jul 2, 2018, 6:09:40 PM7/2/18
to anita kumari, HAPI FHIR
The following isn't valid JSON, let alone valid FHIR:

"contained":[
  1. {Patient},
  2. {Device},
  3. {MedicationStatement}

I'd recommend reviewing the fhir specification's section on contained resources for examples.

Cheers,
James

sent from my phone.


Reply all
Reply to author
Forward
0 new messages