public RecordWeb addEntity(EntityWeb entityModel, RecordWeb entity) throws Exception {
    log.debug("Received request to add entity instance record.");

    authenticateCaller();
    try {
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());
      RecordManagerService entityInstanceService = Context.getRecordManagerService();

      org.openhie.openempi.model.Record record =
          ModelTransformer.mapToRecord(entityDef, entity, Record.class);

      Record addedRecord = entityInstanceService.addRecord(entityDef, record);

      return ModelTransformer.mapToRecord(addedRecord, RecordWeb.class);

    } catch (Throwable t) {
      log.error("Failed to execute: " + t.getMessage(), t);
      throw new RuntimeException(t);
    }
  }