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

    authenticateCaller();
    try {
      RecordManagerService entityInstanceService = Context.getRecordManagerService();
      EntityDefinitionManagerService entityDefService = Context.getEntityDefinitionManagerService();
      Entity entityDef = entityDefService.loadEntity(entityModel.getEntityVersionId());
      org.openhie.openempi.model.Record record =
          ModelTransformer.mapToRecord(entityDef, entity, Record.class);

      Record updatedRecord = entityInstanceService.updateRecord(entityDef, record);

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

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