The FhirUtil Utility Class
There is also a FhirUtil class accessible in JavaScript contexts. This contains methods to convert to and from XML/JSON, create special resource types like OperationOutcome, or generating resource narratives. Here are some of the most useful methods available:
- toXML(resource, fhirVersion)
- fromXML(resourceXML, fhirVersion)
- toJSON(resource, fhirVersion)
- fromJSON(resourceJSON, fhirVersion)
- xmlToJSON(resourceXML, fhirVersion)
- jsonToXML(resourceJSON, fhirVersion)
- createOperationOutcome(severity, code, details, fhirVersion)
- createBinaryResource(byteArray, mimeType, fhirVersion)
- createBinaryResource(base64String, mimeType, fhirVersion)
- generateNarrative(resource, fhirVersion)
Note that we deprecated the versions of these methods that do not take a fhirVersion, and we recommend you modify your existing code to use these new methods. There are other methods that are not listed here; as mentioned before you can look at the Reference list, the auto-completion dialog, or the Javadoc for more information.