docs: public  <T extends Resource>  byte[] getResourceAsByteArray(T resource, boolean pretty, boolean isJson) {
      ByteArrayOutputStream baos = null;
      byte[] byteArray = null;
      try {
        baos = new ByteArrayOutputStream();
        IParser parser = null;
        if(isJson) {
          parser = new JsonParser();
        } else {
          parser = new XmlParser();
        }
        parser.setOutputStyle(pretty ? OutputStyle.PRETTY : OutputStyle.NORMAL);
        parser.compose(baos, resource);
        baos.close();
        byteArray =  baos.toByteArray();
        baos.close();
      } catch (Exception e) {
        try{
          baos.close();
        }catch(Exception ex) {
          throw new EFhirClientException("Error closing output stream", ex);
        }
        throw new EFhirClientException("Error converting output stream to byte array", e);
      }
      return byteArray;
    }